Does
“#pragma parallel loop”
work for a loop contain a function call ?
Say,
for (int i = 0; i < n ; i++)
{
fun1();
}
I want each thread execute the fun1() independently.
I am not quite sure about the usage of “routine” here.
Does
“#pragma parallel loop”
work for a loop contain a function call ?
Say,
for (int i = 0; i < n ; i++)
{
fun1();
}
I want each thread execute the fun1() independently.
I am not quite sure about the usage of “routine” here.
Hi EvanzzzZ,
You could try to inline fun1 but it’s better to use “routine” here. To create a device version of fun1, simply add “#pragma acc routine seq” just before the routine’s prototype and definition. For example:
Header file:
#pragma acc routine seq
void fun1();
C source:
#pragma acc routine seq
void fun1() {
// do something
}
Note that if you are accessing a global variable from within a device routine, you need to add “#pragma acc declare create(<var_name>)” to the variables declaration.
Hope this helps,
Mat
Thanks.
I guess the “seq” here means not to parallelize within the function fun1(), is it correct ?
Correct. “seq” means the routine will be run sequentially by each thread.