16242f9b9SJoseph Huber.. _omp121: 26242f9b9SJoseph Huber 3*c44fa3e8SSirraideValue has potential side effects preventing SPMD-mode execution. Add `[[omp::assume(\"ompx_spmd_amenable\")]]` to the called function to override. [OMP121] 416164079SJoseph Huber=================================================================================================================================================================== 516164079SJoseph Huber 616164079SJoseph HuberThis analysis remarks indicates that a potential side-effect that cannot be 716164079SJoseph Huberguarded prevents the target region from executing in SPMD-mode. SPMD-mode 816164079SJoseph Huberrequires that each thread is active inside the region. Any instruction that 916164079SJoseph Hubercannot be either recomputed by each thread independently or guarded and executed 1016164079SJoseph Huberby a single thread prevents the region from executing in SPMD-mode. 1116164079SJoseph Huber 1216164079SJoseph HuberThis remark will attempt to print out the instructions preventing the region 1316164079SJoseph Huberfrom being executed in SPMD-mode. Calls to functions outside the current 1416164079SJoseph Hubertranslation unit will prevent this transformation from occurring as well, but 1516164079SJoseph Hubercan be overridden using an assumption stating that it contains no calls that 1616164079SJoseph Huberprevent SPMD execution. 1716164079SJoseph Huber 1816164079SJoseph HuberExamples 1916164079SJoseph Huber-------- 2016164079SJoseph Huber 2116164079SJoseph HuberCalls to functions outside the current translation unit may contain instructions 2216164079SJoseph Huberor operations that cannot be executed in SPMD-mode. 2316164079SJoseph Huber 2416164079SJoseph Huber.. code-block:: c++ 2516164079SJoseph Huber 2616164079SJoseph Huber extern int work(); 2716164079SJoseph Huber 2816164079SJoseph Huber void use(int x); 2916164079SJoseph Huber 3016164079SJoseph Huber void foo() { 3116164079SJoseph Huber #pragma omp target teams 3216164079SJoseph Huber { 3316164079SJoseph Huber int x = work(); 3416164079SJoseph Huber #pragma omp parallel 3516164079SJoseph Huber use(x); 3616164079SJoseph Huber 3716164079SJoseph Huber } 3816164079SJoseph Huber } 3916164079SJoseph Huber 4016164079SJoseph Huber 4116164079SJoseph Huber.. code-block:: console 4216164079SJoseph Huber 4316164079SJoseph Huber $ clang++ -fopenmp -fopenmp-targets=nvptx64 -O2 -Rpass-analysis=openmp-opt omp121.cpp 4416164079SJoseph Huber omp121.cpp:8:13: remark: Value has potential side effects preventing SPMD-mode 45*c44fa3e8SSirraide execution. Add `[[omp::assume("ompx_spmd_amenable")]]` to the called function 4616164079SJoseph Huber to override. [OMP121] 4716164079SJoseph Huber int x = work(); 4816164079SJoseph Huber ^ 4916164079SJoseph Huber 5016164079SJoseph HuberAs the remark suggests, the problem is caused by the unknown call to the 5116164079SJoseph Huberexternal function ``work``. This can be overridden by asserting that it does not 5216164079SJoseph Hubercontain any code that prevents SPMD-mode execution. 5316164079SJoseph Huber 5416164079SJoseph Huber.. code-block:: c++ 5516164079SJoseph Huber 56*c44fa3e8SSirraide [[omp::assume("ompx_spmd_amenable")]] extern int work(); 5716164079SJoseph Huber 5816164079SJoseph Huber void use(int x); 5916164079SJoseph Huber 6016164079SJoseph Huber void foo() { 6116164079SJoseph Huber #pragma omp target teams 6216164079SJoseph Huber { 6316164079SJoseph Huber int x = work(); 6416164079SJoseph Huber #pragma omp parallel 6516164079SJoseph Huber use(x); 6616164079SJoseph Huber 6716164079SJoseph Huber } 6816164079SJoseph Huber } 6916164079SJoseph Huber 7016164079SJoseph Huber.. code-block:: console 7116164079SJoseph Huber 7216164079SJoseph Huber $ clang++ -fopenmp -fopenmp-targets=nvptx64 -O2 -Rpass=openmp-opt omp121.cpp 7316164079SJoseph Huber omp121.cpp:6:1: remark: Transformed generic-mode kernel to SPMD-mode. [OMP120] 7416164079SJoseph Huber #pragma omp target teams 7516164079SJoseph Huber ^ 7616164079SJoseph Huber 7716164079SJoseph HuberDiagnostic Scope 7816164079SJoseph Huber---------------- 7916164079SJoseph Huber 8016164079SJoseph HuberOpenMP target offloading analysis remark. 81