Browse Source

Same buffer size for BatchQueue and native algo

Ensure buffer size for BatchQueue and the native communication algorithm is the
same in case there is 1 producer and 1 consumer. In case of several
producers or several consumers, the size of the buffer is multiplied by
max(nb producers, nb consumers).
bq-ompstream
Thomas Preud'homme 10 years ago
parent
commit
7545a6222c
  1. 94
      gcc/omp-low.c

94
gcc/omp-low.c

@ -7867,29 +7867,38 @@ prepare_streaming_context (omp_region_p region)
parallel region. */
for (i = 0; VEC_iterate (stream_p, sinfo->streams, i, stream); ++i)
{
#ifdef BATCHQ_ENABLED
int nb_views = 0;
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_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_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;
}
}
@ -7903,55 +7912,76 @@ prepare_streaming_context (omp_region_p region)
/* 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 horizon_size;
#ifdef BATCHQ_ENABLED
tree read_burst_size, write_burst_size, burst_size;
view_p rview, wview;
#endif
gsi = gsi_last_bb (sinfo->initialization_bb);
horizon_size = create_tmp_var (size_type_node,
"horizon_size");
burst_size = create_tmp_var (size_type_node,
"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);
/* 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
{
horizon_size = create_tmp_var (size_type_node,
"horizon_size");
burst_size = create_tmp_var (size_type_node,
"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);
#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,
burst_size,
read_burst_size,
write_burst_size);
max_nbviews,
nbrviewscst,
nbrviewscst);
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,
stmt = gimple_build_assign_with_ops (MULT_EXPR,
horizon_size,
horizon_size,
burst_size,
type_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_BATCHQ_CREATE_STREAM];
}
else
#endif
{
horizon_size = build_int_cst (size_type_node,
HORIZON);
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);

Loading…
Cancel
Save