Author: abataev Date: Tue Dec 4 07:25:01 2018 New Revision: 348272 URL: http://llvm.org/viewvc/llvm-project?rev=348272&view=rev Log: [OPENMP][NVPTX]Fixed emission of the critical region.
Critical regions in NVPTX are the constructs, which, generally speaking, are not supported by the NVPTX target. Instead we're using special technique to handle the critical regions. Currently they are supported only within the loop and all the threads in the loop must execute the same critical region. Inside of this special regions the regions still must be emitted as critical, to avoid possible data races between the teams + synchronization must use __kmpc_barrier functions. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=348272&r1=348271&r2=348272&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Dec 4 07:25:01 2018 @@ -2743,14 +2743,16 @@ void CGOpenMPRuntimeNVPTX::emitCriticalR CGF.EmitBlock(BodyBB); // Output the critical statement. - CriticalOpGen(CGF); + CGOpenMPRuntime::emitCriticalRegion(CGF, CriticalName, CriticalOpGen, Loc, + Hint); // After the body surrounded by the critical region, the single executing // thread will jump to the synchronisation point. // Block waits for all threads in current team to finish then increments the // counter variable and returns to the loop. CGF.EmitBlock(SyncBB); - getNVPTXCTABarrier(CGF); + emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false, + /*ForceSimpleCall=*/true); llvm::Value *IncCounterVal = CGF.Builder.CreateNSWAdd(CounterVal, CGF.Builder.getInt32(1)); Modified: cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp?rev=348272&r1=348271&r2=348272&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp Tue Dec 4 07:25:01 2018 @@ -356,7 +356,13 @@ int bar(int n){ // CHECK: [[RES:%.+]] = icmp eq i32 [[TID]], [[CC_VAL]] // CHECK: br i1 [[RES]], label -// CHECK: call void @llvm.nvvm.barrier0() +// CHECK: call void @__kmpc_critical( +// CHECK: load i32, i32* +// CHECK: add nsw i32 +// CHECK: store i32 +// CHECK: call void @__kmpc_end_critical( + +// CHECK: call void @__kmpc_barrier(%struct.ident_t* @{{.+}}, i32 %{{.+}}) // CHECK: [[NEW_CC_VAL:%.+]] = add nsw i32 [[CC_VAL]], 1 // CHECK: store i32 [[NEW_CC_VAL]], i32* [[CC]], // CHECK: br label _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits