Compare commits
1 Commits
master
...
ompstream-
Author | SHA1 | Date |
---|---|---|
Thomas Preud'homme | af43b01b92 |
183
gcc/cp/parser.c
183
gcc/cp/parser.c
|
@ -21259,6 +21259,10 @@ cp_parser_omp_clause_name (cp_parser *parser)
|
||||||
if (!strcmp ("firstprivate", p))
|
if (!strcmp ("firstprivate", p))
|
||||||
result = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE;
|
result = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE;
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
if (!strcmp ("input", p))
|
||||||
|
result = PRAGMA_OMP_CLAUSE_INPUT;
|
||||||
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (!strcmp ("lastprivate", p))
|
if (!strcmp ("lastprivate", p))
|
||||||
result = PRAGMA_OMP_CLAUSE_LASTPRIVATE;
|
result = PRAGMA_OMP_CLAUSE_LASTPRIVATE;
|
||||||
|
@ -21272,6 +21276,8 @@ cp_parser_omp_clause_name (cp_parser *parser)
|
||||||
case 'o':
|
case 'o':
|
||||||
if (!strcmp ("ordered", p))
|
if (!strcmp ("ordered", p))
|
||||||
result = PRAGMA_OMP_CLAUSE_ORDERED;
|
result = PRAGMA_OMP_CLAUSE_ORDERED;
|
||||||
|
else if (!strcmp ("output", p))
|
||||||
|
result = PRAGMA_OMP_CLAUSE_OUTPUT;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!strcmp ("reduction", p))
|
if (!strcmp ("reduction", p))
|
||||||
|
@ -21392,6 +21398,152 @@ cp_parser_omp_var_list (cp_parser *parser, enum omp_clause_code kind, tree list)
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* OpenMP X.X:
|
||||||
|
stream-list:
|
||||||
|
identifier ************************
|
||||||
|
variable-list , identifier
|
||||||
|
|
||||||
|
KIND must be OMP_CLAUSE_INPUT or OMP_CLAUSE_OUTPUT. */
|
||||||
|
static bool
|
||||||
|
cp_parser_omp_stream_identifier (cp_parser *parser, location_t loc,
|
||||||
|
tree *id, tree *sub)
|
||||||
|
{
|
||||||
|
if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME))
|
||||||
|
cp_parser_error (parser, "expected stream or view identifier");
|
||||||
|
|
||||||
|
*id = lookup_name (cp_lexer_peek_token (parser->lexer)->u.value);
|
||||||
|
if (*id == NULL_TREE)
|
||||||
|
{
|
||||||
|
inform (loc, "OpenMP stream and view identifiers must"
|
||||||
|
" be declared before use in streaming clauses.");
|
||||||
|
cp_parser_name_lookup_error(
|
||||||
|
parser, cp_lexer_peek_token (parser->lexer)->u.value, *id, NULL,
|
||||||
|
cp_lexer_peek_token (parser->lexer)->location);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*id == error_mark_node)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
cp_lexer_consume_token (parser->lexer);
|
||||||
|
|
||||||
|
/* If this is an array reference. */
|
||||||
|
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
|
||||||
|
{
|
||||||
|
cp_lexer_consume_token (parser->lexer);
|
||||||
|
*sub = cp_parser_expression (parser, false, NULL);
|
||||||
|
cp_parser_require (parser, CPP_CLOSE_SQUARE, "expected %<]%>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*sub = NULL_TREE;
|
||||||
|
|
||||||
|
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
|
||||||
|
{
|
||||||
|
cp_parser_error (parser, "single dimension arrays"
|
||||||
|
" supported only in streaming clauses");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Next, we must either connect a view or have another stream use
|
||||||
|
separated by a comma, or the closing parenthesis. This test
|
||||||
|
prevents all other syntaxes that will be supported later (like
|
||||||
|
dot or deref ...) */
|
||||||
|
if (cp_lexer_next_token_is_not (parser->lexer, CPP_LSHIFT)
|
||||||
|
&& cp_lexer_next_token_is_not (parser->lexer, CPP_RSHIFT)
|
||||||
|
&& cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)
|
||||||
|
&& cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA))
|
||||||
|
{
|
||||||
|
cp_parser_error (parser, "wrong syntax on streaming clause");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static tree
|
||||||
|
cp_parser_omp_stream_clause (cp_parser *parser,
|
||||||
|
enum omp_clause_code kind,
|
||||||
|
tree list, location_t location)
|
||||||
|
{
|
||||||
|
gcc_assert (kind == OMP_CLAUSE_INPUT || kind == OMP_CLAUSE_OUTPUT);
|
||||||
|
|
||||||
|
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
|
||||||
|
return list;
|
||||||
|
|
||||||
|
/* Every stream clause must start with either a stream identifier or
|
||||||
|
a view identifier. */
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
tree stream_id, stream_idx, view_id, view_idx;
|
||||||
|
tree omp_clause;
|
||||||
|
|
||||||
|
if (!cp_parser_omp_stream_identifier (parser, location,
|
||||||
|
&stream_id, &stream_idx))
|
||||||
|
break;
|
||||||
|
|
||||||
|
omp_clause = build_omp_clause (location, kind);
|
||||||
|
OMP_CLAUSE_STREAM_ID (omp_clause) = stream_id;
|
||||||
|
OMP_CLAUSE_STREAM_SUB (omp_clause) = stream_idx;
|
||||||
|
|
||||||
|
if (cp_lexer_next_token_is (parser->lexer, CPP_LSHIFT)
|
||||||
|
|| cp_lexer_next_token_is (parser->lexer, CPP_RSHIFT))
|
||||||
|
{
|
||||||
|
bool lshift_stream_operator_p =
|
||||||
|
cp_lexer_next_token_is (parser->lexer, CPP_LSHIFT);
|
||||||
|
|
||||||
|
cp_lexer_consume_token (parser->lexer);
|
||||||
|
|
||||||
|
if (!cp_parser_omp_stream_identifier (parser, location,
|
||||||
|
&view_id, &view_idx))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* If the clause is reversed ("view << >> stream" instead of
|
||||||
|
"stream << >> view"), swap the roles. */
|
||||||
|
if ((kind == OMP_CLAUSE_INPUT && lshift_stream_operator_p)
|
||||||
|
|| (kind == OMP_CLAUSE_OUTPUT && !lshift_stream_operator_p))
|
||||||
|
{
|
||||||
|
OMP_CLAUSE_STREAM_ID (omp_clause) = view_id;
|
||||||
|
view_id = stream_id;
|
||||||
|
OMP_CLAUSE_STREAM_SUB (omp_clause) = view_idx;
|
||||||
|
view_idx = stream_idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
OMP_CLAUSE_VIEW_ID (omp_clause) = view_id;
|
||||||
|
OMP_CLAUSE_BURST_SIZE (omp_clause) = view_idx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OMP_CLAUSE_VIEW_ID (omp_clause) = NULL_TREE;
|
||||||
|
OMP_CLAUSE_BURST_SIZE (omp_clause) = NULL_TREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
OMP_CLAUSE_CHAIN (omp_clause) = list;
|
||||||
|
list = omp_clause;
|
||||||
|
|
||||||
|
/* TODO: TINO Check this */
|
||||||
|
/*if(OMP_CLAUSE_VIEW_ID (omp_clause) != NULL_TREE)
|
||||||
|
{
|
||||||
|
tree new_omp_clause = build_omp_clause (location, OMP_CLAUSE_PRIVATE);
|
||||||
|
OMP_CLAUSE_DECL (new_omp_clause) = OMP_CLAUSE_VIEW_ID (omp_clause);
|
||||||
|
OMP_CLAUSE_CHAIN (new_omp_clause) = list;
|
||||||
|
list = new_omp_clause;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
|
||||||
|
cp_lexer_consume_token (parser->lexer);
|
||||||
|
else if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_PAREN))
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cp_parser_error (parser, "expected %<,%> or %<)%>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cp_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/* OpenMP 3.0:
|
/* OpenMP 3.0:
|
||||||
collapse ( constant-expression ) */
|
collapse ( constant-expression ) */
|
||||||
|
|
||||||
|
@ -21519,6 +21671,15 @@ cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* OpenMP X.X:
|
||||||
|
input ( expression ) */
|
||||||
|
|
||||||
|
static tree
|
||||||
|
cp_parser_omp_clause_input (cp_parser *parser, tree list, location_t location)
|
||||||
|
{
|
||||||
|
return cp_parser_omp_stream_clause (parser, OMP_CLAUSE_INPUT, list, location);
|
||||||
|
}
|
||||||
|
|
||||||
/* OpenMP 2.5:
|
/* OpenMP 2.5:
|
||||||
nowait */
|
nowait */
|
||||||
|
|
||||||
|
@ -21582,6 +21743,16 @@ cp_parser_omp_clause_ordered (cp_parser *parser ATTRIBUTE_UNUSED,
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* OpenMP X.X:
|
||||||
|
output ( expression ) */
|
||||||
|
|
||||||
|
static tree
|
||||||
|
cp_parser_omp_clause_output (cp_parser *parser, tree list, location_t location)
|
||||||
|
{
|
||||||
|
return cp_parser_omp_stream_clause (parser, OMP_CLAUSE_OUTPUT, list,
|
||||||
|
location);
|
||||||
|
}
|
||||||
|
|
||||||
/* OpenMP 2.5:
|
/* OpenMP 2.5:
|
||||||
reduction ( reduction-operator : variable-list )
|
reduction ( reduction-operator : variable-list )
|
||||||
|
|
||||||
|
@ -21807,6 +21978,11 @@ cp_parser_omp_all_clauses (cp_parser *parser, unsigned int mask,
|
||||||
clauses = cp_parser_omp_clause_if (parser, clauses, token->location);
|
clauses = cp_parser_omp_clause_if (parser, clauses, token->location);
|
||||||
c_name = "if";
|
c_name = "if";
|
||||||
break;
|
break;
|
||||||
|
case PRAGMA_OMP_CLAUSE_INPUT:
|
||||||
|
clauses = cp_parser_omp_clause_input (parser, clauses,
|
||||||
|
token->location);
|
||||||
|
c_name = "input";
|
||||||
|
break;
|
||||||
case PRAGMA_OMP_CLAUSE_LASTPRIVATE:
|
case PRAGMA_OMP_CLAUSE_LASTPRIVATE:
|
||||||
clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_LASTPRIVATE,
|
clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_LASTPRIVATE,
|
||||||
clauses);
|
clauses);
|
||||||
|
@ -21826,6 +22002,11 @@ cp_parser_omp_all_clauses (cp_parser *parser, unsigned int mask,
|
||||||
token->location);
|
token->location);
|
||||||
c_name = "ordered";
|
c_name = "ordered";
|
||||||
break;
|
break;
|
||||||
|
case PRAGMA_OMP_CLAUSE_OUTPUT:
|
||||||
|
clauses = cp_parser_omp_clause_output (parser, clauses,
|
||||||
|
token->location);
|
||||||
|
c_name = "output";
|
||||||
|
break;
|
||||||
case PRAGMA_OMP_CLAUSE_PRIVATE:
|
case PRAGMA_OMP_CLAUSE_PRIVATE:
|
||||||
clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_PRIVATE,
|
clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_PRIVATE,
|
||||||
clauses);
|
clauses);
|
||||||
|
@ -22861,8 +23042,10 @@ cp_parser_omp_single (cp_parser *parser, cp_token *pragma_tok)
|
||||||
|
|
||||||
#define OMP_TASK_CLAUSE_MASK \
|
#define OMP_TASK_CLAUSE_MASK \
|
||||||
( (1u << PRAGMA_OMP_CLAUSE_IF) \
|
( (1u << PRAGMA_OMP_CLAUSE_IF) \
|
||||||
|
| (1u << PRAGMA_OMP_CLAUSE_INPUT) \
|
||||||
| (1u << PRAGMA_OMP_CLAUSE_UNTIED) \
|
| (1u << PRAGMA_OMP_CLAUSE_UNTIED) \
|
||||||
| (1u << PRAGMA_OMP_CLAUSE_DEFAULT) \
|
| (1u << PRAGMA_OMP_CLAUSE_DEFAULT) \
|
||||||
|
| (1u << PRAGMA_OMP_CLAUSE_OUTPUT) \
|
||||||
| (1u << PRAGMA_OMP_CLAUSE_PRIVATE) \
|
| (1u << PRAGMA_OMP_CLAUSE_PRIVATE) \
|
||||||
| (1u << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \
|
| (1u << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \
|
||||||
| (1u << PRAGMA_OMP_CLAUSE_SHARED))
|
| (1u << PRAGMA_OMP_CLAUSE_SHARED))
|
||||||
|
|
|
@ -3787,8 +3787,10 @@ finish_omp_clauses (tree clauses)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OMP_CLAUSE_INPUT:
|
||||||
case OMP_CLAUSE_NOWAIT:
|
case OMP_CLAUSE_NOWAIT:
|
||||||
case OMP_CLAUSE_ORDERED:
|
case OMP_CLAUSE_ORDERED:
|
||||||
|
case OMP_CLAUSE_OUTPUT:
|
||||||
case OMP_CLAUSE_DEFAULT:
|
case OMP_CLAUSE_DEFAULT:
|
||||||
case OMP_CLAUSE_UNTIED:
|
case OMP_CLAUSE_UNTIED:
|
||||||
case OMP_CLAUSE_COLLAPSE:
|
case OMP_CLAUSE_COLLAPSE:
|
||||||
|
@ -3839,6 +3841,18 @@ finish_omp_clauses (tree clauses)
|
||||||
need_copy_assignment = true;
|
need_copy_assignment = true;
|
||||||
need_implicitly_determined = true;
|
need_implicitly_determined = true;
|
||||||
break;
|
break;
|
||||||
|
case OMP_CLAUSE_INPUT:
|
||||||
|
name = "input";
|
||||||
|
need_complete_non_reference = true;
|
||||||
|
need_copy_ctor = true;
|
||||||
|
need_implicitly_determined = true;
|
||||||
|
break;
|
||||||
|
case OMP_CLAUSE_OUTPUT:
|
||||||
|
name = "output";
|
||||||
|
need_complete_non_reference = true;
|
||||||
|
need_copy_assignment = true;
|
||||||
|
need_implicitly_determined = true;
|
||||||
|
break;
|
||||||
case OMP_CLAUSE_REDUCTION:
|
case OMP_CLAUSE_REDUCTION:
|
||||||
name = "reduction";
|
name = "reduction";
|
||||||
need_implicitly_determined = true;
|
need_implicitly_determined = true;
|
||||||
|
|
|
@ -210,21 +210,12 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_SINGLE_COPY_END, "GOMP_single_copy_end",
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CREATE_STREAM,
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CREATE_STREAM,
|
||||||
"GOMP_stream_create_stream",
|
"GOMP_stream_create_stream",
|
||||||
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_CREATE_STREAM,
|
|
||||||
"GOMP_batchQ_create_stream",
|
|
||||||
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CREATE_READ_VIEW,
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CREATE_READ_VIEW,
|
||||||
"GOMP_stream_create_read_view",
|
"GOMP_stream_create_read_view",
|
||||||
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_CREATE_READ_VIEW,
|
|
||||||
"GOMP_batchQ_create_read_view",
|
|
||||||
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CREATE_WRITE_VIEW,
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CREATE_WRITE_VIEW,
|
||||||
"GOMP_stream_create_write_view",
|
"GOMP_stream_create_write_view",
|
||||||
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_CREATE_WRITE_VIEW,
|
|
||||||
"GOMP_batchQ_create_write_view",
|
|
||||||
BT_FN_PTR_SIZE_SIZE, ATTR_NOTHROW_LIST)
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CREATE_TASK,
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CREATE_TASK,
|
||||||
"GOMP_stream_create_task",
|
"GOMP_stream_create_task",
|
||||||
BT_FN_PTR, ATTR_NOTHROW_LIST)
|
BT_FN_PTR, ATTR_NOTHROW_LIST)
|
||||||
|
@ -243,9 +234,6 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS,
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CONNECT_VIEW,
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_CONNECT_VIEW,
|
||||||
"GOMP_stream_connect_view",
|
"GOMP_stream_connect_view",
|
||||||
BT_FN_VOID_PTR_PTR_PTR, ATTR_NOTHROW_LIST)
|
BT_FN_VOID_PTR_PTR_PTR, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_CONNECT_VIEW,
|
|
||||||
"GOMP_batchQ_connect_view",
|
|
||||||
BT_FN_VOID_PTR_PTR_PTR, ATTR_NOTHROW_LIST)
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_WAIT_UNTIL_CONNECTED,
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_WAIT_UNTIL_CONNECTED,
|
||||||
"GOMP_stream_wait_until_connected",
|
"GOMP_stream_wait_until_connected",
|
||||||
BT_FN_VOID_PTR, ATTR_NOTHROW_LIST)
|
BT_FN_VOID_PTR, ATTR_NOTHROW_LIST)
|
||||||
|
@ -254,20 +242,12 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_GET_AVAILABLE_WORK,
|
||||||
BT_FN_ULL_PTR_ULL, ATTR_NOTHROW_LIST)
|
BT_FN_ULL_PTR_ULL, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_UPDATE, "GOMP_stream_update",
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_UPDATE, "GOMP_stream_update",
|
||||||
BT_FN_PTR_PTR_ULL_ULL, ATTR_NOTHROW_LIST)
|
BT_FN_PTR_PTR_ULL_ULL, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_UPDATE, "GOMP_batchQ_update",
|
|
||||||
BT_FN_PTR_PTR_ULL_ULL, ATTR_NOTHROW_LIST)
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_STALL, "GOMP_stream_stall",
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_STALL, "GOMP_stream_stall",
|
||||||
BT_FN_PTR_PTR_ULL_ULL, ATTR_NOTHROW_LIST)
|
BT_FN_PTR_PTR_ULL_ULL, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_STALL, "GOMP_batchQ_stall",
|
|
||||||
BT_FN_PTR_PTR_ULL_ULL, ATTR_NOTHROW_LIST)
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_RELEASE, "GOMP_stream_release",
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_RELEASE, "GOMP_stream_release",
|
||||||
BT_FN_VOID_PTR_ULL, ATTR_NOTHROW_LIST)
|
BT_FN_VOID_PTR_ULL, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_RELEASE, "GOMP_batchQ_release",
|
|
||||||
BT_FN_VOID_PTR_ULL, ATTR_NOTHROW_LIST)
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_COMMIT, "GOMP_stream_commit",
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_COMMIT, "GOMP_stream_commit",
|
||||||
BT_FN_VOID_PTR_ULL, ATTR_NOTHROW_LIST)
|
BT_FN_VOID_PTR_ULL, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_COMMIT, "GOMP_batchQ_commit",
|
|
||||||
BT_FN_VOID_PTR_ULL, ATTR_NOTHROW_LIST)
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_TASK_EXIT, "GOMP_stream_task_exit",
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_TASK_EXIT, "GOMP_stream_task_exit",
|
||||||
BT_FN_VOID_PTR, ATTR_NOTHROW_LIST)
|
BT_FN_VOID_PTR, ATTR_NOTHROW_LIST)
|
||||||
|
|
||||||
|
@ -295,8 +275,6 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_EXIT, "GOMP_stream_exit",
|
||||||
BT_FN_VOID, ATTR_NOTHROW_LIST)
|
BT_FN_VOID, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_PRE, "GOMP_stream_pre",
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_PRE, "GOMP_stream_pre",
|
||||||
BT_FN_PTR_PTR_ULL, ATTR_NOTHROW_LIST)
|
BT_FN_PTR_PTR_ULL, ATTR_NOTHROW_LIST)
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_BATCHQ_PRE, "GOMP_batchQ_pre",
|
|
||||||
BT_FN_PTR_PTR_ULL, ATTR_NOTHROW_LIST)
|
|
||||||
|
|
||||||
|
|
||||||
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_PUSH_STUB, "GOMP_stream_push_stub",
|
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_STREAM_PUSH_STUB, "GOMP_stream_push_stub",
|
||||||
|
|
380
gcc/omp-low.c
380
gcc/omp-low.c
|
@ -78,8 +78,6 @@ Supported types are currently:
|
||||||
#include "optabs.h"
|
#include "optabs.h"
|
||||||
#include "cfgloop.h"
|
#include "cfgloop.h"
|
||||||
|
|
||||||
#define BATCHQ_ENABLED
|
|
||||||
|
|
||||||
/* Return the entry edge of a conditional block (true branch). */
|
/* Return the entry edge of a conditional block (true branch). */
|
||||||
|
|
||||||
static edge
|
static edge
|
||||||
|
@ -141,7 +139,7 @@ DEF_VEC_ALLOC_P(task_p,heap);
|
||||||
pass pointers to generated shared data between the enclosing
|
pass pointers to generated shared data between the enclosing
|
||||||
context to the tasks. This hashtab keeps the mapping between the
|
context to the tasks. This hashtab keeps the mapping between the
|
||||||
OMP directive and the decls of the variables. */
|
OMP directive and the decls of the variables. */
|
||||||
htab_t htab_omp_stmt;
|
htab_t htab_omp_stmt = NULL;
|
||||||
|
|
||||||
typedef struct omp_stmt
|
typedef struct omp_stmt
|
||||||
{
|
{
|
||||||
|
@ -190,8 +188,8 @@ lookup_omp_stmt (gimple stmt)
|
||||||
omp_stmt_t **slot, tmp;
|
omp_stmt_t **slot, tmp;
|
||||||
|
|
||||||
if (!htab_omp_stmt)
|
if (!htab_omp_stmt)
|
||||||
htab_omp_stmt = htab_create_ggc (10, hash_omp_stmt,
|
/* htab_omp_stmt = htab_create_ggc (10, hash_omp_stmt, eq_omp_stmt, NULL); */
|
||||||
eq_omp_stmt, NULL);
|
htab_omp_stmt = htab_create_alloc (10, hash_omp_stmt, eq_omp_stmt, NULL, xcalloc, free); /* Allow memory leak to avoid GC */
|
||||||
tmp.stmt = stmt;
|
tmp.stmt = stmt;
|
||||||
slot = (omp_stmt_p *) htab_find_slot (htab_omp_stmt, &tmp, INSERT);
|
slot = (omp_stmt_p *) htab_find_slot (htab_omp_stmt, &tmp, INSERT);
|
||||||
|
|
||||||
|
@ -436,11 +434,6 @@ typedef struct stream
|
||||||
/* Used for traversals */
|
/* Used for traversals */
|
||||||
bool visit;
|
bool visit;
|
||||||
|
|
||||||
#ifdef BATCHQ_ENABLED
|
|
||||||
/* Used for BatchQ */
|
|
||||||
bool use_batchQ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} stream_t;
|
} stream_t;
|
||||||
|
|
||||||
#define TYPE_SIZE_HAS_INT(TYPE) \
|
#define TYPE_SIZE_HAS_INT(TYPE) \
|
||||||
|
@ -480,8 +473,8 @@ lookup_stream (tree var/*, omp_region_p region*/)
|
||||||
get_outermost_parallel_streamization_info (region);*/
|
get_outermost_parallel_streamization_info (region);*/
|
||||||
|
|
||||||
if (!htab_stream)
|
if (!htab_stream)
|
||||||
htab_stream = htab_create_ggc (10, hash_stream,
|
/* htab_stream = htab_create_ggc (10, hash_stream, eq_stream, NULL); */
|
||||||
eq_stream, NULL);
|
htab_stream = htab_create_alloc(10, hash_stream, eq_stream, NULL, xcalloc, free); /* Allow memory leak to avoid GC */
|
||||||
tmp.var = var;
|
tmp.var = var;
|
||||||
slot = (stream_p *) htab_find_slot (htab_stream, &tmp, INSERT);
|
slot = (stream_p *) htab_find_slot (htab_stream, &tmp, INSERT);
|
||||||
|
|
||||||
|
@ -983,8 +976,8 @@ lookup_var_for_clause (tree clause)
|
||||||
tmp.clause = clause;
|
tmp.clause = clause;
|
||||||
|
|
||||||
if (!htab_clause_to_var)
|
if (!htab_clause_to_var)
|
||||||
htab_clause_to_var = htab_create_ggc (10, hash_clause_to_var,
|
/* htab_clause_to_var = htab_create_ggc (10, hash_clause_to_var, eq_clause_to_var, NULL); */
|
||||||
eq_clause_to_var, NULL);
|
htab_clause_to_var = htab_create_alloc (10, hash_clause_to_var, eq_clause_to_var, NULL, xcalloc, free); /* Allow memory leak to avoid GC */
|
||||||
|
|
||||||
slot = (clause_to_var *) htab_find_slot (htab_clause_to_var, &tmp, INSERT);
|
slot = (clause_to_var *) htab_find_slot (htab_clause_to_var, &tmp, INSERT);
|
||||||
|
|
||||||
|
@ -4799,38 +4792,7 @@ expand_steaming_taskreg_in_outer_context (omp_region_p region,
|
||||||
/* Create firstprivate views and pass the pointers as well. */
|
/* Create firstprivate views and pass the pointers as well. */
|
||||||
for (i = 0; VEC_iterate (view_p, sinfo->fpviews, i, view); ++i)
|
for (i = 0; VEC_iterate (view_p, sinfo->fpviews, i, view); ++i)
|
||||||
{
|
{
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CREATE_WRITE_VIEW];
|
||||||
int j, nb_associated_views = 0;
|
|
||||||
view_p aview;
|
|
||||||
|
|
||||||
for (j = 0; VEC_iterate (view_p, view->stream->rviews, j, aview); ++j)
|
|
||||||
{
|
|
||||||
if (INTEGER_CST_CHECK(aview->sinfo->num_instances))
|
|
||||||
nb_associated_views += TREE_INT_CST_LOW(aview->sinfo->num_instances);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Ensure we use generic functions */
|
|
||||||
nb_associated_views ++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Pretty sure this for loop is useless */
|
|
||||||
for (j = 0; VEC_iterate (view_p, view->stream->wviews, j, aview); ++j)
|
|
||||||
{
|
|
||||||
if (INTEGER_CST_CHECK(aview->sinfo->num_instances))
|
|
||||||
nb_associated_views += TREE_INT_CST_LOW(aview->sinfo->num_instances);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Ensure we use generic functions */
|
|
||||||
nb_associated_views ++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nb_associated_views == 1)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_CREATE_WRITE_VIEW];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CREATE_WRITE_VIEW];
|
|
||||||
stmt = gimple_build_call (fn, 2, view->view_size, get_view_burst_size (view, &gsi));
|
stmt = gimple_build_call (fn, 2, view->view_size, get_view_burst_size (view, &gsi));
|
||||||
gimple_call_set_lhs (stmt, view->view);
|
gimple_call_set_lhs (stmt, view->view);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
@ -4964,22 +4926,12 @@ expand_steaming_taskreg_in_outer_context (omp_region_p region,
|
||||||
|
|
||||||
/* COMMIT */
|
/* COMMIT */
|
||||||
gsi = gsi_last_bb (commit_bb);
|
gsi = gsi_last_bb (commit_bb);
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_COMMIT];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_COMMIT];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_COMMIT];
|
|
||||||
stmt = gimple_build_call (fn, 2, view_decl, task->local_activation_index);
|
stmt = gimple_build_call (fn, 2, view_decl, task->local_activation_index);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
|
||||||
/* STALL */
|
/* STALL */
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_STALL];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_STALL];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_STALL];
|
|
||||||
stmt = gimple_build_call (fn, 3, view_decl, task->local_activation_index,
|
stmt = gimple_build_call (fn, 3, view_decl, task->local_activation_index,
|
||||||
task->local_activation_index_next);
|
task->local_activation_index_next);
|
||||||
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
||||||
|
@ -5105,12 +5057,7 @@ handle_nested_streaming_tasks (omp_region_p region,
|
||||||
|
|
||||||
/* STALL */
|
/* STALL */
|
||||||
gsi = gsi_last_bb (initialization_bb);
|
gsi = gsi_last_bb (initialization_bb);
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_STALL];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_STALL];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_STALL];
|
|
||||||
stmt = gimple_build_call (fn, 3, view_decl, task->local_activation_index,
|
stmt = gimple_build_call (fn, 3, view_decl, task->local_activation_index,
|
||||||
task->local_activation_index_next);
|
task->local_activation_index_next);
|
||||||
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
||||||
|
@ -5118,12 +5065,7 @@ handle_nested_streaming_tasks (omp_region_p region,
|
||||||
|
|
||||||
/* COMMIT */
|
/* COMMIT */
|
||||||
gsi = gsi_last_bb (finalization_bb);
|
gsi = gsi_last_bb (finalization_bb);
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_COMMIT];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_COMMIT];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_COMMIT];
|
|
||||||
stmt = gimple_build_call (fn, 2, view_decl, task->local_activation_index);
|
stmt = gimple_build_call (fn, 2, view_decl, task->local_activation_index);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
}
|
}
|
||||||
|
@ -7691,46 +7633,26 @@ build_task_control_loop (streamization_info_p task)
|
||||||
for (i = 0; VEC_iterate (view_p, task->rviews, i, view); ++i)
|
for (i = 0; VEC_iterate (view_p, task->rviews, i, view); ++i)
|
||||||
{
|
{
|
||||||
gsi = gsi_last_bb (loop_acquire_bb);
|
gsi = gsi_last_bb (loop_acquire_bb);
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_UPDATE];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_UPDATE];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_UPDATE];
|
|
||||||
stmt = gimple_build_call (fn, 3, view->view, act_idx_start_reg, act_idx_end_reg);
|
stmt = gimple_build_call (fn, 3, view->view, act_idx_start_reg, act_idx_end_reg);
|
||||||
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
|
||||||
gsi = gsi_last_bb (loop_release_bb);
|
gsi = gsi_last_bb (loop_release_bb);
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_RELEASE];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_RELEASE];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_RELEASE];
|
|
||||||
stmt = gimple_build_call (fn, 2, view->view, act_idx_end_reg);
|
stmt = gimple_build_call (fn, 2, view->view, act_idx_end_reg);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
}
|
}
|
||||||
for (i = 0; VEC_iterate (view_p, task->wviews, i, view); ++i)
|
for (i = 0; VEC_iterate (view_p, task->wviews, i, view); ++i)
|
||||||
{
|
{
|
||||||
gsi = gsi_last_bb (loop_acquire_bb);
|
gsi = gsi_last_bb (loop_acquire_bb);
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_STALL];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_STALL];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_STALL];
|
|
||||||
stmt = gimple_build_call (fn, 3, view->view, act_idx_start_reg, act_idx_end_reg);
|
stmt = gimple_build_call (fn, 3, view->view, act_idx_start_reg, act_idx_end_reg);
|
||||||
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
|
||||||
gsi = gsi_last_bb (loop_release_bb);
|
gsi = gsi_last_bb (loop_release_bb);
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_COMMIT];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_COMMIT];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_COMMIT];
|
|
||||||
stmt = gimple_build_call (fn, 2, view->view, act_idx_end_reg);
|
stmt = gimple_build_call (fn, 2, view->view, act_idx_end_reg);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
}
|
}
|
||||||
|
@ -7867,205 +7789,72 @@ prepare_streaming_context (omp_region_p region)
|
||||||
parallel region. */
|
parallel region. */
|
||||||
for (i = 0; VEC_iterate (stream_p, sinfo->streams, i, stream); ++i)
|
for (i = 0; VEC_iterate (stream_p, sinfo->streams, i, stream); ++i)
|
||||||
{
|
{
|
||||||
int nb_views = 0, nb_rviews = 0, nb_wviews = 0;
|
|
||||||
|
|
||||||
#ifdef BATCHQ_ENABLED
|
|
||||||
stream->use_batchQ = 0;
|
|
||||||
#endif
|
|
||||||
for (j = 0; VEC_iterate (view_p, stream->rviews, j, view); ++j)
|
|
||||||
{
|
|
||||||
if (INTEGER_CST_CHECK(view->sinfo->num_instances))
|
|
||||||
{
|
|
||||||
nb_views += TREE_INT_CST_LOW(view->sinfo->num_instances);
|
|
||||||
nb_rviews += TREE_INT_CST_LOW(view->sinfo->num_instances);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Ensure we use generic functions */
|
|
||||||
nb_views += 2;
|
|
||||||
nb_rviews += 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j = 0; VEC_iterate (view_p, stream->wviews, j, view); ++j)
|
|
||||||
{
|
|
||||||
if (INTEGER_CST_CHECK(view->sinfo->num_instances))
|
|
||||||
{
|
|
||||||
nb_views += TREE_INT_CST_LOW(view->sinfo->num_instances);
|
|
||||||
nb_wviews += TREE_INT_CST_LOW(view->sinfo->num_instances);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Ensure we use generic functions */
|
|
||||||
nb_views += 2;
|
|
||||||
nb_wviews += 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Connect any firstprivate write views on this
|
|
||||||
stream. As these are the master views, they only
|
|
||||||
get one instance. */
|
|
||||||
for (j = 0; VEC_iterate (view_p, stream->fpviews, j, view); ++j)
|
|
||||||
{
|
|
||||||
/* Only one firstprivate view per stream possible. */
|
|
||||||
gcc_assert (j == 0);
|
|
||||||
/* If there are firstprivate views, there should be no write views. */
|
|
||||||
gcc_assert (VEC_empty (view_p, stream->wviews));
|
|
||||||
nb_views ++;
|
|
||||||
nb_wviews ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef BATCHQ_ENABLED
|
|
||||||
if (nb_views == 2)
|
|
||||||
stream->use_batchQ = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tree type_size = TYPE_SIZE_UNIT (stream->element_type);
|
tree type_size = TYPE_SIZE_UNIT (stream->element_type);
|
||||||
tree horizon_size;
|
tree horizon_size = build_int_cst (size_type_node,
|
||||||
tree read_burst_size, write_burst_size, burst_size;
|
HORIZON);
|
||||||
view_p rview, wview;
|
|
||||||
|
|
||||||
gsi = gsi_last_bb (sinfo->initialization_bb);
|
gsi = gsi_last_bb (sinfo->initialization_bb);
|
||||||
horizon_size = create_tmp_var (size_type_node,
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CREATE_STREAM];
|
||||||
"horizon_size");
|
stmt = gimple_build_call (fn, 2, type_size, horizon_size);
|
||||||
burst_size = create_tmp_var (size_type_node,
|
gimple_call_set_lhs (stmt, stream->stream);
|
||||||
"burst_size");
|
|
||||||
rview = VEC_index(view_p, stream->rviews, 0);
|
|
||||||
read_burst_size = get_view_burst_size (rview, &gsi);
|
|
||||||
if (VEC_empty (view_p, stream->wviews))
|
|
||||||
wview = VEC_index(view_p, stream->fpviews, 0);
|
|
||||||
else
|
|
||||||
wview = VEC_index(view_p, stream->wviews, 0);
|
|
||||||
write_burst_size = get_view_burst_size (wview, &gsi);
|
|
||||||
stmt = gimple_build_assign_with_ops (MAX_EXPR,
|
|
||||||
burst_size,
|
|
||||||
read_burst_size,
|
|
||||||
write_burst_size);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
/* MAX(read_burst_size, write_burst_size) / type_size */
|
|
||||||
stmt = gimple_build_assign_with_ops (CEIL_DIV_EXPR,
|
|
||||||
horizon_size,
|
|
||||||
burst_size,
|
|
||||||
type_size);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
#ifdef BATCHQ_ENABLED
|
|
||||||
if (stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_CREATE_STREAM];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
tree aggregation_factor, nbwviewscst, nbrviewscst;
|
|
||||||
tree max_nbviews;
|
|
||||||
|
|
||||||
aggregation_factor = build_int_cst (size_type_node,
|
|
||||||
AGGREGATION_FACTOR);
|
|
||||||
nbwviewscst = build_int_cst (size_type_node, nb_wviews);
|
|
||||||
nbrviewscst = build_int_cst (size_type_node, nb_rviews);
|
|
||||||
max_nbviews = create_tmp_var (size_type_node,
|
|
||||||
"max_nbviews");
|
|
||||||
stmt = gimple_build_assign_with_ops (MAX_EXPR,
|
|
||||||
max_nbviews,
|
|
||||||
nbrviewscst,
|
|
||||||
nbrviewscst);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
stmt = gimple_build_assign_with_ops (MULT_EXPR,
|
|
||||||
horizon_size,
|
|
||||||
horizon_size,
|
|
||||||
max_nbviews);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
stmt = gimple_build_assign_with_ops (MULT_EXPR,
|
|
||||||
horizon_size,
|
|
||||||
horizon_size,
|
|
||||||
aggregation_factor);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CREATE_STREAM];
|
|
||||||
#ifdef BATCHQ_ENABLED
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
stmt = gimple_build_call (fn, 2, type_size, horizon_size);
|
|
||||||
gimple_call_set_lhs (stmt, stream->stream);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
|
|
||||||
/* FIXME: this needs to take into account
|
/* FIXME: this needs to take into account
|
||||||
replication as well ... we may want to move this
|
replication as well ... we may want to move this
|
||||||
in the task call itself if we want dynamic values
|
in the task call itself if we want dynamic values
|
||||||
as well. */
|
as well. */
|
||||||
#ifdef BATCHQ_ENABLED
|
for (j = 0; VEC_iterate (view_p, stream->rviews, j, view); ++j)
|
||||||
if (stream->use_batchQ)
|
|
||||||
{
|
{
|
||||||
/* Connect any firstprivate write views on this
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS];
|
||||||
stream. As these are the master views, they only
|
stmt = gimple_build_call (fn, 4, stream->stream,
|
||||||
get one instance. */
|
view->sinfo->num_instances,
|
||||||
for (j = 0; VEC_iterate (view_p, stream->fpviews, j, view); ++j)
|
integer_zero_node,
|
||||||
{
|
boolean_false_node);
|
||||||
tree view_decl = lookup_var (view->view, sinfo->stmt);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
|
||||||
/* Only one firstprivate view per stream possible. */
|
|
||||||
gcc_assert (j == 0);
|
|
||||||
/* If there are firstprivate views, there should be no write views. */
|
|
||||||
gcc_assert (VEC_empty (view_p, stream->wviews));
|
|
||||||
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_CONNECT_VIEW];
|
|
||||||
stmt = gimple_build_call (fn, 3, task_decl, stream->stream, view_decl);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
for (j = 0; VEC_iterate (view_p, stream->wviews, j, view); ++j)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
for (j = 0; VEC_iterate (view_p, stream->rviews, j, view); ++j)
|
|
||||||
{
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS];
|
|
||||||
stmt = gimple_build_call (fn, 4, stream->stream,
|
|
||||||
view->sinfo->num_instances,
|
|
||||||
integer_zero_node,
|
|
||||||
boolean_false_node);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
}
|
|
||||||
for (j = 0; VEC_iterate (view_p, stream->wviews, j, view); ++j)
|
|
||||||
{
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS];
|
|
||||||
stmt = gimple_build_call (fn, 4, stream->stream,
|
|
||||||
integer_zero_node,
|
|
||||||
view->sinfo->num_instances,
|
|
||||||
boolean_false_node);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Connect any firstprivate write views on this
|
|
||||||
stream. As these are the master views, they only
|
|
||||||
get one instance. */
|
|
||||||
for (j = 0; VEC_iterate (view_p, stream->fpviews, j, view); ++j)
|
|
||||||
{
|
|
||||||
tree view_decl = lookup_var (view->view, sinfo->stmt);
|
|
||||||
|
|
||||||
/* Only one firstprivate view per stream possible. */
|
|
||||||
gcc_assert (j == 0);
|
|
||||||
/* If there are firstprivate views, there should be no write views. */
|
|
||||||
gcc_assert (VEC_empty (view_p, stream->wviews));
|
|
||||||
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS];
|
|
||||||
stmt = gimple_build_call (fn, 4, stream->stream,
|
|
||||||
integer_zero_node,
|
|
||||||
integer_one_node,
|
|
||||||
boolean_false_node);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CONNECT_VIEW];
|
|
||||||
stmt = gimple_build_call (fn, 3, task_decl, stream->stream, view_decl);
|
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the final count flag for the number of
|
|
||||||
expected views. */
|
|
||||||
gsi = gsi_last_bb (sinfo->post_initialization_bb);
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS];
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS];
|
||||||
stmt = gimple_build_call (fn, 4, stream->stream,
|
stmt = gimple_build_call (fn, 4, stream->stream,
|
||||||
integer_zero_node,
|
integer_zero_node,
|
||||||
integer_zero_node,
|
view->sinfo->num_instances,
|
||||||
boolean_true_node);
|
boolean_false_node);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Connect any firstprivate write views on this
|
||||||
|
stream. As these are the master views, they only
|
||||||
|
get one instance. */
|
||||||
|
for (j = 0; VEC_iterate (view_p, stream->fpviews, j, view); ++j)
|
||||||
|
{
|
||||||
|
tree view_decl = lookup_var (view->view, sinfo->stmt);
|
||||||
|
|
||||||
|
/* Only one firstprivate view per stream possible. */
|
||||||
|
gcc_assert (j == 0);
|
||||||
|
/* If there are firstprivate views, there should be no write views. */
|
||||||
|
gcc_assert (VEC_empty (view_p, stream->wviews));
|
||||||
|
|
||||||
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS];
|
||||||
|
stmt = gimple_build_call (fn, 4, stream->stream,
|
||||||
|
integer_zero_node,
|
||||||
|
integer_one_node,
|
||||||
|
boolean_false_node);
|
||||||
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
|
||||||
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CONNECT_VIEW];
|
||||||
|
stmt = gimple_build_call (fn, 3, task_decl, stream->stream, view_decl);
|
||||||
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the final count flag for the number of
|
||||||
|
expected views. */
|
||||||
|
gsi = gsi_last_bb (sinfo->post_initialization_bb);
|
||||||
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_ADD_EXPECTED_VIEWS];
|
||||||
|
stmt = gimple_build_call (fn, 4, stream->stream,
|
||||||
|
integer_zero_node,
|
||||||
|
integer_zero_node,
|
||||||
|
boolean_true_node);
|
||||||
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Issue wait until connected call in the parallel
|
/* Issue wait until connected call in the parallel
|
||||||
|
@ -8183,12 +7972,7 @@ prepare_streaming_context (omp_region_p region)
|
||||||
single threaded code before the other producer or any
|
single threaded code before the other producer or any
|
||||||
consumer can start. */
|
consumer can start. */
|
||||||
gsi = gsi_last_bb (task->initialization_bb);
|
gsi = gsi_last_bb (task->initialization_bb);
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_PRE];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_PRE];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_PRE];
|
|
||||||
stmt = gimple_build_call (fn, 2, view->stream->stream, get_view_burst_size (view, &gsi));
|
stmt = gimple_build_call (fn, 2, view->stream->stream, get_view_burst_size (view, &gsi));
|
||||||
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
gimple_call_set_lhs (stmt, view->buffer_pointer);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
@ -8294,22 +8078,12 @@ prepare_streaming_context (omp_region_p region)
|
||||||
gsi = gsi_last_bb (task->initialization_bb);
|
gsi = gsi_last_bb (task->initialization_bb);
|
||||||
for (i = 0; VEC_iterate (view_p, task->rviews, i, view); ++i)
|
for (i = 0; VEC_iterate (view_p, task->rviews, i, view); ++i)
|
||||||
{
|
{
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CREATE_READ_VIEW];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_CREATE_READ_VIEW];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CREATE_READ_VIEW];
|
|
||||||
stmt = gimple_build_call (fn, 2, view->view_size, get_view_burst_size (view, &gsi));
|
stmt = gimple_build_call (fn, 2, view->view_size, get_view_burst_size (view, &gsi));
|
||||||
gimple_call_set_lhs (stmt, view->view);
|
gimple_call_set_lhs (stmt, view->view);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CONNECT_VIEW];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_CONNECT_VIEW];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CONNECT_VIEW];
|
|
||||||
stmt = gimple_build_call (fn, 3, task_decl, view->stream->stream, view->view);
|
stmt = gimple_build_call (fn, 3, task_decl, view->stream->stream, view->view);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
|
||||||
|
@ -8317,22 +8091,12 @@ prepare_streaming_context (omp_region_p region)
|
||||||
|
|
||||||
for (i = 0; VEC_iterate (view_p, task->wviews, i, view); ++i)
|
for (i = 0; VEC_iterate (view_p, task->wviews, i, view); ++i)
|
||||||
{
|
{
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CREATE_WRITE_VIEW];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_CREATE_WRITE_VIEW];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CREATE_WRITE_VIEW];
|
|
||||||
stmt = gimple_build_call (fn, 2, view->view_size, get_view_burst_size (view, &gsi));
|
stmt = gimple_build_call (fn, 2, view->view_size, get_view_burst_size (view, &gsi));
|
||||||
gimple_call_set_lhs (stmt, view->view);
|
gimple_call_set_lhs (stmt, view->view);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
|
|
||||||
#ifdef BATCHQ_ENABLED
|
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CONNECT_VIEW];
|
||||||
if (view->stream->use_batchQ)
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_BATCHQ_CONNECT_VIEW];
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
fn = built_in_decls[BUILT_IN_GOMP_STREAM_CONNECT_VIEW];
|
|
||||||
stmt = gimple_build_call (fn, 3, task_decl, view->stream->stream, view->view);
|
stmt = gimple_build_call (fn, 3, task_decl, view->stream->stream, view->view);
|
||||||
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
|
||||||
}
|
}
|
||||||
|
@ -9829,8 +9593,8 @@ execute_lower_omp (void)
|
||||||
delete_omp_context);
|
delete_omp_context);
|
||||||
|
|
||||||
if (!htab_stmt_loc)
|
if (!htab_stmt_loc)
|
||||||
htab_stmt_loc = htab_create_ggc (10, hash_stmt_loc,
|
/* htab_stmt_loc = htab_create_ggc (10, hash_stmt_loc, eq_stmt_loc, NULL); */
|
||||||
eq_stmt_loc, NULL);
|
htab_stmt_loc = htab_create_ggc (10, hash_stmt_loc, eq_stmt_loc, NULL); /* Allow memory leak to avoid GC */
|
||||||
|
|
||||||
body = gimple_body (current_function_decl);
|
body = gimple_body (current_function_decl);
|
||||||
scan_omp (body, NULL);
|
scan_omp (body, NULL);
|
||||||
|
|
|
@ -168,28 +168,20 @@ GOMP_2.0 {
|
||||||
GOMP_loop_ull_static_next;
|
GOMP_loop_ull_static_next;
|
||||||
GOMP_loop_ull_static_start;
|
GOMP_loop_ull_static_start;
|
||||||
GOMP_stream_create_stream;
|
GOMP_stream_create_stream;
|
||||||
GOMP_batchQ_create_stream;
|
|
||||||
GOMP_stream_create_read_view;
|
GOMP_stream_create_read_view;
|
||||||
GOMP_batchQ_create_read_view;
|
|
||||||
GOMP_stream_create_write_view;
|
GOMP_stream_create_write_view;
|
||||||
GOMP_batchQ_create_write_view;
|
|
||||||
GOMP_stream_create_task;
|
GOMP_stream_create_task;
|
||||||
GOMP_stream_get_task_activation_counter;
|
GOMP_stream_get_task_activation_counter;
|
||||||
GOMP_stream_set_task_termination_flag;
|
GOMP_stream_set_task_termination_flag;
|
||||||
GOMP_stream_task_add_instance;
|
GOMP_stream_task_add_instance;
|
||||||
GOMP_stream_add_expected_views;
|
GOMP_stream_add_expected_views;
|
||||||
GOMP_stream_connect_view;
|
GOMP_stream_connect_view;
|
||||||
GOMP_batchQ_connect_view;
|
|
||||||
GOMP_stream_wait_until_connected;
|
GOMP_stream_wait_until_connected;
|
||||||
GOMP_stream_get_available_work;
|
GOMP_stream_get_available_work;
|
||||||
GOMP_stream_update;
|
GOMP_stream_update;
|
||||||
GOMP_batchQ_update;
|
|
||||||
GOMP_stream_stall;
|
GOMP_stream_stall;
|
||||||
GOMP_batchQ_stall;
|
|
||||||
GOMP_stream_release;
|
GOMP_stream_release;
|
||||||
GOMP_batchQ_release;
|
|
||||||
GOMP_stream_commit;
|
GOMP_stream_commit;
|
||||||
GOMP_batchQ_commit;
|
|
||||||
GOMP_stream_task_exit;
|
GOMP_stream_task_exit;
|
||||||
GOMP_stream_create_control_stream;
|
GOMP_stream_create_control_stream;
|
||||||
GOMP_stream_control_stream_set_eos;
|
GOMP_stream_control_stream_set_eos;
|
||||||
|
@ -199,6 +191,5 @@ GOMP_2.0 {
|
||||||
GOMP_stream_init;
|
GOMP_stream_init;
|
||||||
GOMP_stream_exit;
|
GOMP_stream_exit;
|
||||||
GOMP_stream_pre;
|
GOMP_stream_pre;
|
||||||
GOMP_batchQ_pre;
|
|
||||||
} GOMP_1.0;
|
} GOMP_1.0;
|
||||||
|
|
||||||
|
|
|
@ -109,17 +109,12 @@ int omp_get_active_level (void) __GOMP_NOTHROW;
|
||||||
|
|
||||||
extern void *GOMP_stream_create_stream (size_t, size_t)
|
extern void *GOMP_stream_create_stream (size_t, size_t)
|
||||||
__GOMP_NOTHROW;
|
__GOMP_NOTHROW;
|
||||||
extern void *GOMP_batchQ_create_stream (size_t, size_t)
|
|
||||||
__GOMP_NOTHROW;
|
|
||||||
extern void *GOMP_stream_create_read_view (size_t, size_t) __GOMP_NOTHROW;
|
extern void *GOMP_stream_create_read_view (size_t, size_t) __GOMP_NOTHROW;
|
||||||
extern void *GOMP_batchQ_create_read_view (size_t, size_t) __GOMP_NOTHROW;
|
|
||||||
extern void *GOMP_stream_create_write_view (size_t, size_t) __GOMP_NOTHROW;
|
extern void *GOMP_stream_create_write_view (size_t, size_t) __GOMP_NOTHROW;
|
||||||
extern void *GOMP_batchQ_create_write_view (size_t, size_t) __GOMP_NOTHROW;
|
|
||||||
extern void *GOMP_stream_create_task (void) __GOMP_NOTHROW;
|
extern void *GOMP_stream_create_task (void) __GOMP_NOTHROW;
|
||||||
extern void GOMP_stream_add_expected_views (void *, int, int, int)
|
extern void GOMP_stream_add_expected_views (void *, int, int, int)
|
||||||
__GOMP_NOTHROW;
|
__GOMP_NOTHROW;
|
||||||
extern void GOMP_stream_connect_view (void *, void *, void *) __GOMP_NOTHROW;
|
extern void GOMP_stream_connect_view (void *, void *, void *) __GOMP_NOTHROW;
|
||||||
extern void GOMP_batchQ_connect_view (void *, void *, void *) __GOMP_NOTHROW;
|
|
||||||
extern void GOMP_stream_wait_until_connected (void *) __GOMP_NOTHROW;
|
extern void GOMP_stream_wait_until_connected (void *) __GOMP_NOTHROW;
|
||||||
extern unsigned long long GOMP_stream_get_available_work (void *,
|
extern unsigned long long GOMP_stream_get_available_work (void *,
|
||||||
unsigned long long *)
|
unsigned long long *)
|
||||||
|
@ -128,24 +123,13 @@ extern void *GOMP_stream_update (void *,
|
||||||
const unsigned long long,
|
const unsigned long long,
|
||||||
const unsigned long long)
|
const unsigned long long)
|
||||||
__GOMP_NOTHROW;
|
__GOMP_NOTHROW;
|
||||||
extern void *GOMP_batchQ_update (void *,
|
|
||||||
const unsigned long long,
|
|
||||||
const unsigned long long)
|
|
||||||
__GOMP_NOTHROW;
|
|
||||||
extern void *GOMP_stream_stall (void *, const unsigned long long,
|
extern void *GOMP_stream_stall (void *, const unsigned long long,
|
||||||
const unsigned long long)
|
const unsigned long long)
|
||||||
__GOMP_NOTHROW;
|
__GOMP_NOTHROW;
|
||||||
extern void *GOMP_batchQ_stall (void *, const unsigned long long,
|
|
||||||
const unsigned long long)
|
|
||||||
__GOMP_NOTHROW;
|
|
||||||
extern void GOMP_stream_release (void *, const unsigned long long)
|
extern void GOMP_stream_release (void *, const unsigned long long)
|
||||||
__GOMP_NOTHROW;
|
__GOMP_NOTHROW;
|
||||||
extern void GOMP_batchQ_release (void *, const unsigned long long)
|
|
||||||
__GOMP_NOTHROW;
|
|
||||||
extern void GOMP_stream_commit (void *, const unsigned long long)
|
extern void GOMP_stream_commit (void *, const unsigned long long)
|
||||||
__GOMP_NOTHROW;
|
__GOMP_NOTHROW;
|
||||||
extern void GOMP_batchQ_commit (void *, const unsigned long long)
|
|
||||||
__GOMP_NOTHROW;
|
|
||||||
extern void GOMP_stream_task_exit (void *) __GOMP_NOTHROW;
|
extern void GOMP_stream_task_exit (void *) __GOMP_NOTHROW;
|
||||||
|
|
||||||
#endif /* OMP_H */
|
#endif /* OMP_H */
|
||||||
|
|
353
libgomp/stream.c
353
libgomp/stream.c
|
@ -1,6 +1,5 @@
|
||||||
/* Copyright (C) 2010 Free Software Foundation, Inc.
|
/* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||||
Contributed by Antoniu Pop <antoniu.pop@gmail.com>
|
Contributed by Antoniu Pop <antoniu.pop@gmail.com>.
|
||||||
and Thomas Preud'homme <thomas.preud-homme@lip6.fr>.
|
|
||||||
|
|
||||||
This file is part of the GNU OpenMP Library (libgomp).
|
This file is part of the GNU OpenMP Library (libgomp).
|
||||||
|
|
||||||
|
@ -31,10 +30,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include "wait.h"
|
#include "wait.h"
|
||||||
#include "sem.h"
|
#include "sem.h"
|
||||||
|
@ -43,23 +38,14 @@
|
||||||
|
|
||||||
#define AGGREGATION_FACTOR 32
|
#define AGGREGATION_FACTOR 32
|
||||||
|
|
||||||
#define ENSURE_BUFSIZE
|
//#define debug_log_init(S, V1, V2) printf (S, V1, V2); fflush (stdout)
|
||||||
//#define OMP_STREAM_DEBUG
|
#define debug_log_init(S, V1, V2)
|
||||||
#ifdef OMP_STREAM_DEBUG
|
|
||||||
#define debug_log_init(S, V1, V2) printf (S, V1, V2); fflush (stdout)
|
//#define debug_log_init3(S, V1, V2, V3) printf (S, V1, V2, V3); fflush (stdout)
|
||||||
#define debug_log_init3(S, V1, V2, V3) printf (S, V1, V2, V3); fflush (stdout)
|
#define debug_log_init3(S, V1, V2, V3)
|
||||||
#define debug_log(S, V1, V2) printf (S, V1, V2); fflush (stdout)
|
|
||||||
#define debug_log3(S, V1, V2, V3) printf (S, V1, V2, V3); fflush (stdout)
|
//#define debug_log(S, V1, V2) printf (S, V1, V2); fflush (stdout)
|
||||||
#define debug_log4(S, V1, V2, V3, V4) printf (S, V1, V2, V3, V4); fflush (stdout)
|
#define debug_log(S, V1, V2)
|
||||||
#define debug_log5(S, V1, V2, V3, V4, V5) printf (S, V1, V2, V3, V4, V5); fflush (stdout)
|
|
||||||
#else
|
|
||||||
#define debug_log_init(S, V1, V2)
|
|
||||||
#define debug_log_init3(S, V1, V2, V3)
|
|
||||||
#define debug_log(S, V1, V2)
|
|
||||||
#define debug_log3(S, V1, V2, V3)
|
|
||||||
#define debug_log4(S, V1, V2, V3, V4)
|
|
||||||
#define debug_log5(S, V1, V2, V3, V4, V5)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gomp_barrier_t gomp_stream_tasks_wait_until_connected_barrier;
|
gomp_barrier_t gomp_stream_tasks_wait_until_connected_barrier;
|
||||||
gomp_barrier_t gomp_stream_tasks_exit_barrier;
|
gomp_barrier_t gomp_stream_tasks_exit_barrier;
|
||||||
|
@ -140,89 +126,6 @@ GOMP_stream_create_stream (size_t element_size, size_t buffer_size)
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
GOMP_batchQ_create_stream (size_t element_size, size_t buffer_size)
|
|
||||||
{
|
|
||||||
#define BASE_SHM_NAME "/channel"
|
|
||||||
#define ROUNDUP(size) ((size + page_size) & ~(page_size - 1))
|
|
||||||
int ret, shm_fd;
|
|
||||||
static int chan_idx = 0;
|
|
||||||
char shm_name[NAME_MAX];
|
|
||||||
struct gomp_batchQ *stream;
|
|
||||||
size_t buffer_realsize, bq_size;
|
|
||||||
unsigned int page_size;
|
|
||||||
|
|
||||||
buffer_size *= element_size * AGGREGATION_FACTOR;
|
|
||||||
buffer_realsize = 1;
|
|
||||||
while(buffer_realsize < buffer_size)
|
|
||||||
buffer_realsize <<= 1;
|
|
||||||
|
|
||||||
/* Beginning of BatchQueue code */
|
|
||||||
stream = NULL;
|
|
||||||
ret = sysconf(_SC_PAGESIZE);
|
|
||||||
if (ret == -1)
|
|
||||||
{
|
|
||||||
perror("BatchQueue init sysconf");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
page_size = ret;
|
|
||||||
bq_size = ROUNDUP(sizeof(gomp_batchQ_t) - 1 + buffer_realsize * 2);
|
|
||||||
ret = snprintf(shm_name, NAME_MAX, BASE_SHM_NAME"%d\n", chan_idx);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BatchQueue init snprintf failed\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if (ret >= NAME_MAX)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Too many streams created: impossible to ");
|
|
||||||
fprintf(stderr, "create a stream named "BASE_SHM_NAME);
|
|
||||||
fprintf(stderr, "%d\n", chan_idx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
shm_fd = shm_open(shm_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
|
||||||
if (shm_fd == -1)
|
|
||||||
{
|
|
||||||
perror("BatchQueue init shm_open failed");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ret = ftruncate(shm_fd, bq_size);
|
|
||||||
if (ret == -1)
|
|
||||||
{
|
|
||||||
perror("BatchQueue init ftruncate failed");
|
|
||||||
goto close_file;
|
|
||||||
}
|
|
||||||
stream = mmap(NULL, bq_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, shm_fd, 0);
|
|
||||||
if (stream == MAP_FAILED)
|
|
||||||
{
|
|
||||||
perror("Batchqueue init mmap failed");
|
|
||||||
stream = NULL;
|
|
||||||
goto close_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream->state = 0;
|
|
||||||
|
|
||||||
stream->sender_ptr = stream->buf;
|
|
||||||
stream->receiver_ptr = stream->buf;
|
|
||||||
|
|
||||||
stream->buf_start1 = stream->buf;
|
|
||||||
stream->buf_start2 = stream->buf + buffer_realsize;
|
|
||||||
stream->sender_buf = stream->buf_start1;
|
|
||||||
stream->receiver_buf = stream->buf_start1;
|
|
||||||
|
|
||||||
stream->buffer_size = buffer_realsize;
|
|
||||||
stream->buffer_mask = buffer_realsize - 1;
|
|
||||||
|
|
||||||
stream->pre_shift = 0;
|
|
||||||
|
|
||||||
|
|
||||||
close_file:
|
|
||||||
shm_unlink(shm_name);
|
|
||||||
return stream;
|
|
||||||
#undef BASE_SHM_NAME
|
|
||||||
#undef ROUNDUP
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate and initialize a generic GOMP_STREAM_VIEW that can be
|
/* Allocate and initialize a generic GOMP_STREAM_VIEW that can be
|
||||||
connected to any stream to give either read or write access
|
connected to any stream to give either read or write access
|
||||||
depending on its TYPE. Returns a pointer to the newly allocated
|
depending on its TYPE. Returns a pointer to the newly allocated
|
||||||
|
@ -248,22 +151,6 @@ gomp_stream_create_view (int type, size_t view_size, size_t burst_size)
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
|
||||||
gomp_batchQ_create_view (int type, size_t view_size, size_t burst_size)
|
|
||||||
{
|
|
||||||
gomp_batchQ_view_p view =
|
|
||||||
(gomp_batchQ_view_p) gomp_malloc (sizeof(gomp_batchQ_view_t));
|
|
||||||
|
|
||||||
view->stream = NULL;
|
|
||||||
view->type = type | BATCHQ_VIEW;
|
|
||||||
view->view_size = view_size;
|
|
||||||
view->burst_size = burst_size;
|
|
||||||
view->pxxk_size = view_size - burst_size;
|
|
||||||
view->termination_flag = false;
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wrapper for creating a READ view . */
|
/* Wrapper for creating a READ view . */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
@ -273,13 +160,6 @@ GOMP_stream_create_read_view (size_t view_size, size_t burst_size)
|
||||||
return gomp_stream_create_view (READ_VIEW, view_size, burst_size);
|
return gomp_stream_create_view (READ_VIEW, view_size, burst_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
GOMP_batchQ_create_read_view (size_t view_size, size_t burst_size)
|
|
||||||
{
|
|
||||||
debug_log_init ("GOMP_stream_create_read_view %zu %zu\n", view_size, burst_size);
|
|
||||||
return gomp_batchQ_create_view(READ_VIEW, view_size, burst_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wrapper for creating a WRITE view. */
|
/* Wrapper for creating a WRITE view. */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
@ -289,13 +169,6 @@ GOMP_stream_create_write_view (size_t view_size, size_t burst_size)
|
||||||
return gomp_stream_create_view (WRITE_VIEW, view_size, burst_size);
|
return gomp_stream_create_view (WRITE_VIEW, view_size, burst_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
GOMP_batchQ_create_write_view (size_t view_size, size_t burst_size)
|
|
||||||
{
|
|
||||||
debug_log_init ("GOMP_stream_create_write_view %zu %zu\n", view_size, burst_size);
|
|
||||||
return gomp_batchQ_create_view(WRITE_VIEW, view_size, burst_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate and initialize a GOMP_STREAM_TASK data structure. */
|
/* Allocate and initialize a GOMP_STREAM_TASK data structure. */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
@ -309,19 +182,11 @@ GOMP_stream_create_task ()
|
||||||
task->read_view_list.nr_views = 0;
|
task->read_view_list.nr_views = 0;
|
||||||
task->read_view_list.size = 0;
|
task->read_view_list.size = 0;
|
||||||
gomp_mutex_init (&task->read_view_list.connect_view_mutex);
|
gomp_mutex_init (&task->read_view_list.connect_view_mutex);
|
||||||
task->batchQ_read_view_list.views = NULL;
|
|
||||||
task->batchQ_read_view_list.nr_views = 0;
|
|
||||||
task->batchQ_read_view_list.size = 0;
|
|
||||||
gomp_mutex_init (&task->batchQ_read_view_list.connect_view_mutex);
|
|
||||||
|
|
||||||
task->write_view_list.views = NULL;
|
task->write_view_list.views = NULL;
|
||||||
task->write_view_list.nr_views = 0;
|
task->write_view_list.nr_views = 0;
|
||||||
task->write_view_list.size = 0;
|
task->write_view_list.size = 0;
|
||||||
gomp_mutex_init (&task->write_view_list.connect_view_mutex);
|
gomp_mutex_init (&task->write_view_list.connect_view_mutex);
|
||||||
task->batchQ_write_view_list.views = NULL;
|
|
||||||
task->batchQ_write_view_list.nr_views = 0;
|
|
||||||
task->batchQ_write_view_list.size = 0;
|
|
||||||
gomp_mutex_init (&task->batchQ_write_view_list.connect_view_mutex);
|
|
||||||
|
|
||||||
task->activation_counter = 0;
|
task->activation_counter = 0;
|
||||||
task->termination_flag = false;
|
task->termination_flag = false;
|
||||||
|
@ -345,22 +210,8 @@ GOMP_stream_get_task_activation_counter (void *t)
|
||||||
void
|
void
|
||||||
GOMP_stream_set_task_termination_flag (void *t)
|
GOMP_stream_set_task_termination_flag (void *t)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
gomp_stream_view_list_p task_list;
|
|
||||||
gomp_stream_task_p task = (gomp_stream_task_p) t;
|
gomp_stream_task_p task = (gomp_stream_task_p) t;
|
||||||
int num_batchQ_read_views = task->batchQ_read_view_list.nr_views;
|
|
||||||
int num_batchQ_write_views = task->batchQ_write_view_list.nr_views;
|
|
||||||
|
|
||||||
task_list = &task->batchQ_read_view_list;
|
|
||||||
gomp_mutex_lock (&task_list->connect_view_mutex);
|
|
||||||
for (i = 0; i < num_batchQ_read_views; ++i)
|
|
||||||
((gomp_batchQ_view_p) task_list->views[i])->termination_flag = true;
|
|
||||||
gomp_mutex_unlock (&task_list->connect_view_mutex);
|
|
||||||
task_list = &task->batchQ_write_view_list;
|
|
||||||
gomp_mutex_lock (&task_list->connect_view_mutex);
|
|
||||||
for (i = 0; i < num_batchQ_write_views; ++i)
|
|
||||||
((gomp_batchQ_view_p) task_list->views[i])->termination_flag = true;
|
|
||||||
gomp_mutex_unlock (&task_list->connect_view_mutex);
|
|
||||||
task->termination_flag = true;
|
task->termination_flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,10 +290,10 @@ GOMP_stream_connect_view (void *t, void *s, void *v)
|
||||||
gomp_stream_p stream = (gomp_stream_p) s;
|
gomp_stream_p stream = (gomp_stream_p) s;
|
||||||
gomp_stream_view_p view = (gomp_stream_view_p) v;
|
gomp_stream_view_p view = (gomp_stream_view_p) v;
|
||||||
|
|
||||||
gomp_stream_view_handle_p vh = ((view->type & VIEW_TYPE_MASK) == READ_VIEW) ?
|
gomp_stream_view_handle_p vh = (view->type == READ_VIEW) ?
|
||||||
&stream->read_views : &stream->write_views;
|
&stream->read_views : &stream->write_views;
|
||||||
gomp_stream_view_list_p stream_list = &vh->view_list;
|
gomp_stream_view_list_p stream_list = &vh->view_list;
|
||||||
gomp_stream_view_list_p task_list = ((view->type & VIEW_TYPE_MASK) == READ_VIEW) ?
|
gomp_stream_view_list_p task_list = (view->type == READ_VIEW) ?
|
||||||
&task->read_view_list : &task->write_view_list;
|
&task->read_view_list : &task->write_view_list;
|
||||||
|
|
||||||
view->stream = stream;
|
view->stream = stream;
|
||||||
|
@ -451,7 +302,7 @@ GOMP_stream_connect_view (void *t, void *s, void *v)
|
||||||
stream is initially empty. This is equivalent to releasing the
|
stream is initially empty. This is equivalent to releasing the
|
||||||
original buffer_size elements. A write view will start with
|
original buffer_size elements. A write view will start with
|
||||||
buffer_size free space. */
|
buffer_size free space. */
|
||||||
if ((view->type & VIEW_TYPE_MASK) == READ_VIEW)
|
if (view->type == READ_VIEW)
|
||||||
view->lower_index = stream->buffer_size;
|
view->lower_index = stream->buffer_size;
|
||||||
else
|
else
|
||||||
view->local_min_value = stream->buffer_size;
|
view->local_min_value = stream->buffer_size;
|
||||||
|
@ -470,32 +321,6 @@ GOMP_stream_connect_view (void *t, void *s, void *v)
|
||||||
gomp_stream_add_view_to_list (view, stream_list);
|
gomp_stream_add_view_to_list (view, stream_list);
|
||||||
gomp_mutex_unlock (&vh->view_list.connect_view_mutex);
|
gomp_mutex_unlock (&vh->view_list.connect_view_mutex);
|
||||||
__sync_fetch_and_add (&vh->nr_registered_views, 1);
|
__sync_fetch_and_add (&vh->nr_registered_views, 1);
|
||||||
debug_log5 ("GOMP_stream_connect_view %p %lu %p %s %p\n", stream,
|
|
||||||
pthread_self(), view, ((view->type & VIEW_TYPE_MASK) == READ_VIEW) ? "In" : "Out",
|
|
||||||
task);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
GOMP_batchQ_connect_view (void *t, void *s, void *v)
|
|
||||||
{
|
|
||||||
gomp_stream_task_p task = (gomp_stream_task_p) t;
|
|
||||||
gomp_batchQ_p stream = (gomp_batchQ_p) s;
|
|
||||||
gomp_batchQ_view_p view = (gomp_batchQ_view_p) v;
|
|
||||||
|
|
||||||
gomp_stream_view_list_p task_list = ((view->type & VIEW_TYPE_MASK) == READ_VIEW) ?
|
|
||||||
&task->batchQ_read_view_list : &task->batchQ_write_view_list;
|
|
||||||
|
|
||||||
/* Register the view with the TASK to which it belongs. This
|
|
||||||
operation is local to the task, so there is no need to
|
|
||||||
synchronize. */
|
|
||||||
gomp_mutex_lock (&task_list->connect_view_mutex);
|
|
||||||
gomp_stream_add_view_to_list ((gomp_stream_view_p) view, task_list);
|
|
||||||
gomp_mutex_unlock (&task_list->connect_view_mutex);
|
|
||||||
|
|
||||||
view->stream = stream;
|
|
||||||
debug_log5 ("GOMP_batchQ_connect_view %p %lu %p %s %p\n", stream,
|
|
||||||
pthread_self(), view, ((view->type & VIEW_TYPE_MASK) == READ_VIEW) ? "In" : "Out",
|
|
||||||
task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether all the expected views on STREAM have already
|
/* Check whether all the expected views on STREAM have already
|
||||||
|
@ -537,12 +362,8 @@ GOMP_stream_wait_until_connected (void *t)
|
||||||
|
|
||||||
gomp_mutex_lock (&task->read_view_list.connect_view_mutex);
|
gomp_mutex_lock (&task->read_view_list.connect_view_mutex);
|
||||||
for (i = 0; i < task->read_view_list.nr_views; ++i)
|
for (i = 0; i < task->read_view_list.nr_views; ++i)
|
||||||
{
|
if (!gomp_stream_check_connected (task->read_view_list.views[i]->stream))
|
||||||
if (task->read_view_list.views[i]->type & BATCHQ_VIEW)
|
done = false;
|
||||||
continue;
|
|
||||||
if (!gomp_stream_check_connected (task->read_view_list.views[i]->stream))
|
|
||||||
done = false;
|
|
||||||
}
|
|
||||||
gomp_mutex_unlock (&task->read_view_list.connect_view_mutex);
|
gomp_mutex_unlock (&task->read_view_list.connect_view_mutex);
|
||||||
|
|
||||||
gomp_mutex_lock (&task->write_view_list.connect_view_mutex);
|
gomp_mutex_lock (&task->write_view_list.connect_view_mutex);
|
||||||
|
@ -669,7 +490,7 @@ GOMP_stream_update (void *v, const unsigned long long act_start,
|
||||||
gomp_stream_p stream = view->stream;
|
gomp_stream_p stream = view->stream;
|
||||||
void *buffer_pointer;
|
void *buffer_pointer;
|
||||||
|
|
||||||
debug_log4 ("GOMP_stream_update [in] %p %zd %llu %llu\n", stream, view->burst_size, act_start, act_end);
|
debug_log ("GOMP_stream_update [in] %llu %llu\n", act_start, act_end);
|
||||||
|
|
||||||
/* This update requests access to the buffer in [low_idx,up_idx[.
|
/* This update requests access to the buffer in [low_idx,up_idx[.
|
||||||
We will release up to low_idx-1 and acquire up to up_idx-1. */
|
We will release up to low_idx-1 and acquire up to up_idx-1. */
|
||||||
|
@ -711,41 +532,11 @@ GOMP_stream_update (void *v, const unsigned long long act_start,
|
||||||
guaranteed access to all the requested data. */
|
guaranteed access to all the requested data. */
|
||||||
buffer_pointer = stream->buffer + low_idx_loc;
|
buffer_pointer = stream->buffer + low_idx_loc;
|
||||||
|
|
||||||
debug_log4 ("GOMP_stream_update [out] %p %zd %llu %llu\n", stream, view->burst_size, act_start, act_end);
|
debug_log ("GOMP_stream_update [out] %llu %llu\n", act_start, act_end);
|
||||||
|
|
||||||
return buffer_pointer;
|
return buffer_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
GOMP_batchQ_update (void *v, const unsigned long long act_start,
|
|
||||||
const unsigned long long act_end)
|
|
||||||
{
|
|
||||||
unsigned long long low_idx, up_idx;
|
|
||||||
gomp_batchQ_view_p view = (gomp_batchQ_view_p) v;
|
|
||||||
gomp_batchQ_p stream = view->stream;
|
|
||||||
|
|
||||||
/* This update requests access to the buffer in [low_idx,up_idx[.
|
|
||||||
We will release up to low_idx-1 and acquire up to up_idx-1. */
|
|
||||||
low_idx = act_start * view->burst_size;
|
|
||||||
up_idx = act_end * view->burst_size + view->pxxk_size - 1;
|
|
||||||
|
|
||||||
#ifdef ENSURE_BUFSIZE
|
|
||||||
if (up_idx - low_idx + 1 != stream->buffer_size)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
if (up_idx - low_idx + 1 > stream->buffer_size)
|
|
||||||
gomp_fatal ("GOMP_batchQ: update requested access to more than buffer_size data.");
|
|
||||||
#ifdef ENSURE_BUFSIZE
|
|
||||||
else if (!view->termination_flag)
|
|
||||||
gomp_fatal ("GOMP_batchQ: update requested access to less than buffer_size data.");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (!stream->state);
|
|
||||||
|
|
||||||
return (void *) stream->receiver_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Request write access for the view V to the stream up to INDEX. */
|
/* Request write access for the view V to the stream up to INDEX. */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
@ -757,7 +548,7 @@ GOMP_stream_stall (void *v, const unsigned long long act_start,
|
||||||
gomp_stream_p stream = view->stream;
|
gomp_stream_p stream = view->stream;
|
||||||
void *buffer_pointer;
|
void *buffer_pointer;
|
||||||
|
|
||||||
debug_log4 ("GOMP_stream_stall [in] %p %zd %llu %llu\n", stream, view->burst_size, act_start, act_end);
|
debug_log ("GOMP_stream_stall [in] %llu %llu\n", act_start, act_end);
|
||||||
|
|
||||||
/* This update requests access to the buffer in [low_idx,up_idx[.
|
/* This update requests access to the buffer in [low_idx,up_idx[.
|
||||||
We will release up to low_idx-1 and acquire up to up_idx-1. */
|
We will release up to low_idx-1 and acquire up to up_idx-1. */
|
||||||
|
@ -783,41 +574,11 @@ GOMP_stream_stall (void *v, const unsigned long long act_start,
|
||||||
|
|
||||||
buffer_pointer = stream->buffer + (low_idx & stream->buffer_mask);
|
buffer_pointer = stream->buffer + (low_idx & stream->buffer_mask);
|
||||||
|
|
||||||
debug_log4 ("GOMP_stream_stall [out] %p %zd %llu %llu\n", stream, view->burst_size, act_start, act_end);
|
debug_log ("GOMP_stream_stall [out] %llu %llu\n", act_start, act_end);
|
||||||
|
|
||||||
return buffer_pointer;
|
return buffer_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
GOMP_batchQ_stall (void *v, const unsigned long long act_start,
|
|
||||||
const unsigned long long act_end)
|
|
||||||
{
|
|
||||||
unsigned long long low_idx, up_idx;
|
|
||||||
gomp_batchQ_view_p view = (gomp_batchQ_view_p) v;
|
|
||||||
gomp_batchQ_p stream = view->stream;
|
|
||||||
|
|
||||||
/* This update requests access to the buffer in [low_idx,up_idx[.
|
|
||||||
We will release up to low_idx-1 and acquire up to up_idx-1. */
|
|
||||||
low_idx = act_start * view->burst_size + stream->pre_shift;
|
|
||||||
up_idx = act_end * view->burst_size + view->pxxk_size + stream->pre_shift - 1;
|
|
||||||
|
|
||||||
#ifdef ENSURE_BUFSIZE
|
|
||||||
if (up_idx - low_idx + 1 != stream->buffer_size)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
if (up_idx - low_idx + 1 > stream->buffer_size)
|
|
||||||
{
|
|
||||||
gomp_fatal ("GOMP_batchQ: stall requested access to more than buffer_size.");
|
|
||||||
}
|
|
||||||
#ifdef ENSURE_BUFSIZE
|
|
||||||
else if (!view->termination_flag)
|
|
||||||
gomp_fatal ("GOMP_stream: stall requested access to less than buffer_size.");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (void *) stream->sender_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Relinquish read access for the view V to the stream up to
|
/* Relinquish read access for the view V to the stream up to
|
||||||
INDEX. */
|
INDEX. */
|
||||||
|
|
||||||
|
@ -829,25 +590,6 @@ GOMP_stream_release (void *v, const unsigned long long act_idx)
|
||||||
debug_log ("GOMP_stream_release %llu %llu\n", act_idx, act_idx);
|
debug_log ("GOMP_stream_release %llu %llu\n", act_idx, act_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
GOMP_batchQ_release (void *v, const unsigned long long act_idx)
|
|
||||||
{
|
|
||||||
gomp_batchQ_view_p view = (gomp_batchQ_view_p) v;
|
|
||||||
gomp_batchQ_p stream = view->stream;
|
|
||||||
|
|
||||||
stream->state = 0;
|
|
||||||
if (stream->receiver_buf == stream->buf_start1)
|
|
||||||
{
|
|
||||||
stream->receiver_ptr = stream->buf_start2;
|
|
||||||
stream->receiver_buf = stream->buf_start2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stream->receiver_ptr = stream->buf_start1;
|
|
||||||
stream->receiver_buf = stream->buf_start1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Relinquish write access for the view V to the stream up to
|
/* Relinquish write access for the view V to the stream up to
|
||||||
INDEX. */
|
INDEX. */
|
||||||
|
|
||||||
|
@ -880,26 +622,6 @@ GOMP_stream_commit (void *v, const unsigned long long act_idx)
|
||||||
debug_log ("GOMP_stream_commit %llu %llu\n", act_idx, act_idx);
|
debug_log ("GOMP_stream_commit %llu %llu\n", act_idx, act_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
GOMP_batchQ_commit (void *v, const unsigned long long act_idx)
|
|
||||||
{
|
|
||||||
gomp_batchQ_view_p view = (gomp_batchQ_view_p) v;
|
|
||||||
gomp_batchQ_p stream = view->stream;
|
|
||||||
|
|
||||||
while (stream->state);
|
|
||||||
stream->state = 1;
|
|
||||||
if (stream->sender_buf == stream->buf_start1)
|
|
||||||
{
|
|
||||||
stream->sender_ptr = stream->buf_start2;
|
|
||||||
stream->sender_buf = stream->buf_start2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stream->sender_ptr = stream->buf_start1;
|
|
||||||
stream->sender_buf = stream->buf_start1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Finalization and destruction of the streaming data structures. */
|
/* Finalization and destruction of the streaming data structures. */
|
||||||
|
|
||||||
/* Disconnects VIEW from the stream to which it is connected and free
|
/* Disconnects VIEW from the stream to which it is connected and free
|
||||||
|
@ -910,7 +632,7 @@ gomp_stream_unregister_view (gomp_stream_view_p view)
|
||||||
{
|
{
|
||||||
gomp_stream_p stream = view->stream;
|
gomp_stream_p stream = view->stream;
|
||||||
gomp_stream_view_handle_p vh =
|
gomp_stream_view_handle_p vh =
|
||||||
((view->type & VIEW_TYPE_MASK) == READ_VIEW) ? &stream->read_views : &stream->write_views;
|
(view->type == READ_VIEW) ? &stream->read_views : &stream->write_views;
|
||||||
int unregistered_views;
|
int unregistered_views;
|
||||||
|
|
||||||
__sync_fetch_and_add (&(vh->nr_unregistered_views), 1);
|
__sync_fetch_and_add (&(vh->nr_unregistered_views), 1);
|
||||||
|
@ -919,7 +641,7 @@ gomp_stream_unregister_view (gomp_stream_view_p view)
|
||||||
|
|
||||||
/* Make sure that when multiple views access a stream, the finished
|
/* Make sure that when multiple views access a stream, the finished
|
||||||
views do not hinder the others in the min computation. */
|
views do not hinder the others in the min computation. */
|
||||||
if ((view->type & VIEW_TYPE_MASK) == READ_VIEW)
|
if (view->type == READ_VIEW)
|
||||||
GOMP_stream_release (view, GOMP_STREAM_MAX_INDEX);
|
GOMP_stream_release (view, GOMP_STREAM_MAX_INDEX);
|
||||||
/* The last producer exiting will set the eos_p flag and allow the
|
/* The last producer exiting will set the eos_p flag and allow the
|
||||||
consumers to read up to the highest committed index. */
|
consumers to read up to the highest committed index. */
|
||||||
|
@ -952,12 +674,6 @@ gomp_stream_unregister_view (gomp_stream_view_p view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO */
|
|
||||||
static inline void
|
|
||||||
gomp_batchQ_unregister_view (gomp_stream_view_p view)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Invoked before terminating a stream TASK, this disconnects all the
|
/* Invoked before terminating a stream TASK, this disconnects all the
|
||||||
views and for all streams for which it is the last one to
|
views and for all streams for which it is the last one to
|
||||||
disconnect from, it frees up all data structures. */
|
disconnect from, it frees up all data structures. */
|
||||||
|
@ -967,9 +683,7 @@ GOMP_stream_task_exit (void *t)
|
||||||
{
|
{
|
||||||
gomp_stream_task_p task = (gomp_stream_task_p) t;
|
gomp_stream_task_p task = (gomp_stream_task_p) t;
|
||||||
int num_read_views = task->read_view_list.nr_views;
|
int num_read_views = task->read_view_list.nr_views;
|
||||||
int num_batchQ_read_views = task->batchQ_read_view_list.nr_views;
|
|
||||||
int num_write_views = task->write_view_list.nr_views;
|
int num_write_views = task->write_view_list.nr_views;
|
||||||
int num_batchQ_write_views = task->batchQ_write_view_list.nr_views;
|
|
||||||
int i, res;
|
int i, res;
|
||||||
debug_log_init ("GOMP_stream_task_exit %zu %zu\n", (size_t) t, (size_t) t);
|
debug_log_init ("GOMP_stream_task_exit %zu %zu\n", (size_t) t, (size_t) t);
|
||||||
|
|
||||||
|
@ -980,19 +694,11 @@ GOMP_stream_task_exit (void *t)
|
||||||
for (i = 0; i < num_read_views; ++i)
|
for (i = 0; i < num_read_views; ++i)
|
||||||
gomp_stream_unregister_view (task->read_view_list.views[i]);
|
gomp_stream_unregister_view (task->read_view_list.views[i]);
|
||||||
|
|
||||||
for (i = 0; i < num_batchQ_read_views; ++i)
|
|
||||||
gomp_batchQ_unregister_view (task->batchQ_read_view_list.views[i]);
|
|
||||||
|
|
||||||
for (i = 0; i < num_write_views; ++i)
|
for (i = 0; i < num_write_views; ++i)
|
||||||
gomp_stream_unregister_view (task->write_view_list.views[i]);
|
gomp_stream_unregister_view (task->write_view_list.views[i]);
|
||||||
|
|
||||||
for (i = 0; i < num_batchQ_write_views; ++i)
|
|
||||||
gomp_batchQ_unregister_view (task->batchQ_write_view_list.views[i]);
|
|
||||||
|
|
||||||
free (task->read_view_list.views);
|
free (task->read_view_list.views);
|
||||||
free (task->batchQ_read_view_list.views);
|
|
||||||
free (task->write_view_list.views);
|
free (task->write_view_list.views);
|
||||||
free (task->batchQ_write_view_list.views);
|
|
||||||
free (task);
|
free (task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1042,8 +748,6 @@ GOMP_stream_get_available_work (void *t, unsigned long long *start_idx)
|
||||||
return AGGREGATION_FACTOR;
|
return AGGREGATION_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO? GOMP_batchQ_get_available_work */
|
|
||||||
|
|
||||||
|
|
||||||
/* Initialize streaming in this region. */
|
/* Initialize streaming in this region. */
|
||||||
|
|
||||||
|
@ -1056,8 +760,6 @@ GOMP_stream_init ()
|
||||||
gomp_barrier_init (&gomp_stream_tasks_exit_barrier, gomp_stream_tasks_count);
|
gomp_barrier_init (&gomp_stream_tasks_exit_barrier, gomp_stream_tasks_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No GOMP_batchQ_init */
|
|
||||||
|
|
||||||
/* Wait until all streaming threads complete. */
|
/* Wait until all streaming threads complete. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1066,8 +768,6 @@ GOMP_stream_exit ()
|
||||||
gomp_barrier_wait (&gomp_stream_tasks_exit_barrier);
|
gomp_barrier_wait (&gomp_stream_tasks_exit_barrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No GOMP_batchQ_exit */
|
|
||||||
|
|
||||||
/* Request SIZE bytes for a PRE operator on stream S. Return a
|
/* Request SIZE bytes for a PRE operator on stream S. Return a
|
||||||
pointer where data should be stored. */
|
pointer where data should be stored. */
|
||||||
void *
|
void *
|
||||||
|
@ -1083,19 +783,6 @@ GOMP_stream_pre (void *s, const unsigned long long size)
|
||||||
return stream->buffer;
|
return stream->buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
GOMP_batchQ_pre (void *s, const unsigned long long size)
|
|
||||||
{
|
|
||||||
gomp_batchQ_p stream = (gomp_batchQ_p) s;
|
|
||||||
|
|
||||||
debug_log_init ("GOMP_stream_pre %zu \t %llu\n", (size_t) s, size);
|
|
||||||
|
|
||||||
gomp_fatal ("GOMP_batchQ_pre not supported now: missing code in GOMP_batchQ_commit and GOMP_batchQ_stall\n");
|
|
||||||
stream->pre_shift = size;
|
|
||||||
|
|
||||||
return (void *) stream->sender_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* This function is a pthread_create entry point for streaming
|
/* This function is a pthread_create entry point for streaming
|
||||||
tasks. */
|
tasks. */
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* Copyright (C) 2010 Free Software Foundation, Inc.
|
/* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||||
Contributed by Antoniu Pop <antoniu.pop@gmail.com>
|
Contributed by Antoniu Pop <antoniu.pop@gmail.com>.
|
||||||
and Thomas Preud'homme <thomas.preud-homme@lip6.fr>.
|
|
||||||
|
|
||||||
This file is part of the GNU OpenMP Library (libgomp).
|
This file is part of the GNU OpenMP Library (libgomp).
|
||||||
|
|
||||||
|
@ -57,13 +56,10 @@ typedef enum {
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
READ_VIEW = 0,
|
READ_VIEW,
|
||||||
WRITE_VIEW
|
WRITE_VIEW
|
||||||
} gomp_stream_view_type_t;
|
} gomp_stream_view_type_t;
|
||||||
|
|
||||||
#define VIEW_TYPE_MASK 1
|
|
||||||
#define BATCHQ_VIEW 2
|
|
||||||
|
|
||||||
struct gomp_stream;
|
struct gomp_stream;
|
||||||
struct gomp_stream_task;
|
struct gomp_stream_task;
|
||||||
|
|
||||||
|
@ -110,19 +106,6 @@ typedef struct gomp_stream_view
|
||||||
|
|
||||||
} gomp_stream_view_t, *gomp_stream_view_p;
|
} gomp_stream_view_t, *gomp_stream_view_p;
|
||||||
|
|
||||||
struct gomp_batchQ;
|
|
||||||
|
|
||||||
typedef struct gomp_batchQ_view
|
|
||||||
{
|
|
||||||
/* Type of this view (read or write). */
|
|
||||||
gomp_stream_view_type_t type;
|
|
||||||
size_t view_size;
|
|
||||||
size_t burst_size;
|
|
||||||
size_t pxxk_size;
|
|
||||||
struct gomp_batchQ *stream;
|
|
||||||
volatile bool termination_flag;
|
|
||||||
} gomp_batchQ_view_t, *gomp_batchQ_view_p;
|
|
||||||
|
|
||||||
/* List of GOMP_STREAM_VIEWs. As this list is only modified in the
|
/* List of GOMP_STREAM_VIEWs. As this list is only modified in the
|
||||||
initialization phase and we never remove items, we'll use an
|
initialization phase and we never remove items, we'll use an
|
||||||
array. */
|
array. */
|
||||||
|
@ -219,25 +202,6 @@ typedef struct gomp_stream
|
||||||
#endif
|
#endif
|
||||||
} gomp_stream_t, *gomp_stream_p;
|
} gomp_stream_t, *gomp_stream_p;
|
||||||
|
|
||||||
#define CACHE_LINE_SIZE 64
|
|
||||||
typedef struct gomp_batchQ
|
|
||||||
{
|
|
||||||
struct {
|
|
||||||
char volatile *buf_start1 __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
||||||
char volatile *buf_start2;
|
|
||||||
size_t buffer_size;
|
|
||||||
size_t buffer_mask;
|
|
||||||
size_t pre_shift;
|
|
||||||
volatile unsigned int state:1;
|
|
||||||
|
|
||||||
char volatile *sender_ptr __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
||||||
char volatile *sender_buf; /* Which buffer is sender using? */
|
|
||||||
char volatile *receiver_ptr __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
||||||
char volatile *receiver_buf; /* Which buffer is receiver using? */
|
|
||||||
};
|
|
||||||
/* 0 would not conform to C99 section 6.7.5.2 §1 */
|
|
||||||
volatile char buf[1] __attribute__ ((aligned (CACHE_LINE_SIZE)));
|
|
||||||
} gomp_batchQ_t, *gomp_batchQ_p;
|
|
||||||
|
|
||||||
/* GOMP_STREAM_TASK data structure. Runtime node in the task
|
/* GOMP_STREAM_TASK data structure. Runtime node in the task
|
||||||
graph. */
|
graph. */
|
||||||
|
@ -246,9 +210,7 @@ typedef struct gomp_stream_task
|
||||||
{
|
{
|
||||||
/* Lists of views on streams used by this task. */
|
/* Lists of views on streams used by this task. */
|
||||||
gomp_stream_view_list_t read_view_list;
|
gomp_stream_view_list_t read_view_list;
|
||||||
gomp_stream_view_list_t batchQ_read_view_list;
|
|
||||||
gomp_stream_view_list_t write_view_list;
|
gomp_stream_view_list_t write_view_list;
|
||||||
gomp_stream_view_list_t batchQ_write_view_list;
|
|
||||||
|
|
||||||
/* The following are used directly in the generated code and should
|
/* The following are used directly in the generated code and should
|
||||||
only be read here. A memory fence is guaranteed before the
|
only be read here. A memory fence is guaranteed before the
|
||||||
|
|
Loading…
Reference in New Issue