@@ -9769,6 +9769,12 @@ Enable creation of gridified GPU kernels out of loops within target
OpenMP constructs. This conversion is enabled by default when
offloading to HSA, to disable it, use @option{--param omp-gpu-gridify=0}
+@item hsa-expand-omp-parallel
+Enable compiling non-gridified OpenMP parallel constructs into HSAIL as
+invocations of child kernels in their own grid. This behavior is
+disabled by default because in many scenarios it does not work
+properly. To enable it, use @option{--param hsa-expand-omp-parallel=1}.
+
@item hsa-gen-debug-stores
Enable emission of special debug stores within HSA kernels which are
then read and reported by libgomp plugin. Generation of these stores
@@ -5870,20 +5870,25 @@ gen_hsa_insns_for_call (gimple *stmt, hsa_bb *hbb)
BRIG_WIDTH_ALL));
break;
case BUILT_IN_GOMP_PARALLEL:
- {
- gcc_checking_assert (gimple_call_num_args (stmt) == 4);
- tree called = gimple_call_arg (stmt, 0);
- gcc_checking_assert (TREE_CODE (called) == ADDR_EXPR);
- called = TREE_OPERAND (called, 0);
- gcc_checking_assert (TREE_CODE (called) == FUNCTION_DECL);
-
- const char *name
- = hsa_brig_function_name (hsa_get_declaration_name (called));
- hsa_add_kernel_dependency (hsa_cfun->m_decl, name);
- gen_hsa_insns_for_kernel_call (hbb, as_a <gcall *> (stmt));
+ if (PARAM_VALUE (PARAM_HSA_EXPAND_GOMP_PARALLEL) == 1)
+ {
+ gcc_checking_assert (gimple_call_num_args (stmt) == 4);
+ tree called = gimple_call_arg (stmt, 0);
+ gcc_checking_assert (TREE_CODE (called) == ADDR_EXPR);
+ called = TREE_OPERAND (called, 0);
+ gcc_checking_assert (TREE_CODE (called) == FUNCTION_DECL);
+
+ const char *name
+ = hsa_brig_function_name (hsa_get_declaration_name (called));
+ hsa_add_kernel_dependency (hsa_cfun->m_decl, name);
+ gen_hsa_insns_for_kernel_call (hbb, as_a <gcall *> (stmt));
+ }
+ else
+ HSA_SORRY_AT (gimple_location (stmt), "expansion of ungridified "
+ "omp parallel is epxerimental, enable with "
+ "--param hsa-expand-omp-parallel");
+ break;
- break;
- }
case BUILT_IN_OMP_GET_THREAD_NUM:
{
query_hsa_grid_nodim (stmt, BRIG_OPCODE_WORKITEMFLATABSID, hbb);
@@ -1242,6 +1242,12 @@ DEFPARAM (PARAM_OMP_GPU_GRIDIFY,
"constructs",
1, 0, 1)
+DEFPARAM (PARAM_HSA_EXPAND_GOMP_PARALLEL,
+ "hsa-expand-omp-parallel",
+ "Expand ungridified OpenMP parallel via dynamic parallelism "
+ "constructs",
+ 0, 0, 1)
+
DEFPARAM (PARAM_HSA_GEN_DEBUG_STORES,
"hsa-gen-debug-stores",
"Level of hsa debug stores verbosity",