[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing
This revision was automatically updated to reflect the committed changes. Closed by commit rC343260: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD… (authored by gbercea, committed by ). Changed prior to commit: https://reviews.llvm.org/D52629?vs=167386=167387#toc Repository: rC Clang https://reviews.llvm.org/D52629 Files: lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.h lib/CodeGen/CGStmtOpenMP.cpp test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp === --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp @@ -89,7 +89,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL2]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -103,7 +103,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL3]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -119,7 +119,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL4]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp === --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp @@ -94,7 +94,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL2]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -108,7 +108,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL3]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -124,7 +124,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL4]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h === --- lib/CodeGen/CGOpenMPRuntimeNVPTX.h +++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h @@ -340,11 +340,16 @@ /// void functionFinished(CodeGenFunction ) override; - /// Choose a default value for the schedule clause. + /// Choose a default value for the dist_schedule clause. void getDefaultDistScheduleAndChunk(CodeGenFunction , const OMPLoopDirective , OpenMPDistScheduleClauseKind , llvm::Value *) const override; + /// Choose a default value for the schedule clause. + void getDefaultScheduleAndChunk(CodeGenFunction , + const OMPLoopDirective , OpenMPScheduleClauseKind , + llvm::Value *) const override; + private: /// Track the execution mode when codegening directives within a target /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the Index: lib/CodeGen/CGOpenMPRuntime.h === --- lib/CodeGen/CGOpenMPRuntime.h +++ lib/CodeGen/CGOpenMPRuntime.h @@ -1496,6 +1496,12 @@ const OMPLoopDirective , OpenMPDistScheduleClauseKind , llvm::Value *) const {} + /// Choose default schedule type and chunk value for the + /// schedule clause. + virtual void getDefaultScheduleAndChunk(CodeGenFunction , + const OMPLoopDirective , OpenMPScheduleClauseKind , + llvm::Value *) const {} + /// Emits call of the outlined function with the provided arguments, /// translating these arguments to correct target-specific arguments. virtual void Index: lib/CodeGen/CGStmtOpenMP.cpp === --- lib/CodeGen/CGStmtOpenMP.cpp +++ lib/CodeGen/CGStmtOpenMP.cpp @@ -2310,6 +2310,10 @@ S.getIterationVariable()->getType(), S.getBeginLoc()); } + } else { +
[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG Repository: rC Clang https://reviews.llvm.org/D52629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing
gtbercea updated this revision to Diff 167386. gtbercea added a comment. Address comment. Repository: rC Clang https://reviews.llvm.org/D52629 Files: lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.h lib/CodeGen/CGStmtOpenMP.cpp test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp === --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp @@ -89,7 +89,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL2]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -103,7 +103,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL3]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -119,7 +119,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL4]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp === --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp @@ -94,7 +94,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL2]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -108,7 +108,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL3]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -124,7 +124,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL4]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void Index: lib/CodeGen/CGStmtOpenMP.cpp === --- lib/CodeGen/CGStmtOpenMP.cpp +++ lib/CodeGen/CGStmtOpenMP.cpp @@ -2310,6 +2310,10 @@ S.getIterationVariable()->getType(), S.getBeginLoc()); } + } else { +// Default behaviour for schedule clause. +CGM.getOpenMPRuntime().getDefaultScheduleAndChunk( +*this, S, ScheduleKind.Schedule, Chunk); } const unsigned IVSize = getContext().getTypeSize(IVExpr->getType()); const bool IVSigned = IVExpr->getType()->hasSignedIntegerRepresentation(); Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h === --- lib/CodeGen/CGOpenMPRuntimeNVPTX.h +++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h @@ -340,11 +340,16 @@ /// void functionFinished(CodeGenFunction ) override; - /// Choose a default value for the schedule clause. + /// Choose a default value for the dist_schedule clause. void getDefaultDistScheduleAndChunk(CodeGenFunction , const OMPLoopDirective , OpenMPDistScheduleClauseKind , llvm::Value *) const override; + /// Choose a default value for the schedule clause. + void getDefaultScheduleAndChunk(CodeGenFunction , + const OMPLoopDirective , OpenMPScheduleClauseKind , + llvm::Value *) const override; + private: /// Track the execution mode when codegening directives within a target /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp === --- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -4093,3 +4093,14 @@ S.getIterationVariable()->getType(), S.getBeginLoc()); } } + +void CGOpenMPRuntimeNVPTX::getDefaultScheduleAndChunk( +CodeGenFunction , const OMPLoopDirective , +OpenMPScheduleClauseKind , +llvm::Value *) const { + if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_SPMD) { +ScheduleKind = OMPC_SCHEDULE_static; +Chunk =
[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing
ABataev added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:4103 +ScheduleKind = OMPC_SCHEDULE_static; +Chunk = CGF.Builder.getIntN(CGM.getDataLayout().getTypeAllocSizeInBits( +CGF.ConvertType(S.getIterationVariable()->getType())), 1); Use `getContext().getTypeSize(S.getIterationVariable()->getType())` Repository: rC Clang https://reviews.llvm.org/D52629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing
gtbercea created this revision. gtbercea added reviewers: ABataev, Hahnfeld, caomhin. Herald added subscribers: cfe-commits, guansong, jholewinski. Set default schedule for parallel for loops to schedule(static, 1) when using SPMD mode on the NVPTX device offloading toolchain to ensure coalescing. Repository: rC Clang https://reviews.llvm.org/D52629 Files: lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.h lib/CodeGen/CGStmtOpenMP.cpp test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp === --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp @@ -89,7 +89,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL2]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -103,7 +103,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL3]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -119,7 +119,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL4]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp === --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp @@ -94,7 +94,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL2]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -108,7 +108,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL3]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void @@ -124,7 +124,7 @@ // CHECK: ret void // CHECK: define internal void [[OUTL4]]( -// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34, +// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33, // CHECK: call void @__kmpc_for_static_fini( // CHECK: ret void Index: lib/CodeGen/CGStmtOpenMP.cpp === --- lib/CodeGen/CGStmtOpenMP.cpp +++ lib/CodeGen/CGStmtOpenMP.cpp @@ -2310,6 +2310,10 @@ S.getIterationVariable()->getType(), S.getBeginLoc()); } + } else { +// Default behaviour for schedule clause. +CGM.getOpenMPRuntime().getDefaultScheduleAndChunk( +*this, S, ScheduleKind.Schedule, Chunk); } const unsigned IVSize = getContext().getTypeSize(IVExpr->getType()); const bool IVSigned = IVExpr->getType()->hasSignedIntegerRepresentation(); Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h === --- lib/CodeGen/CGOpenMPRuntimeNVPTX.h +++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h @@ -340,11 +340,16 @@ /// void functionFinished(CodeGenFunction ) override; - /// Choose a default value for the schedule clause. + /// Choose a default value for the dist_schedule clause. void getDefaultDistScheduleAndChunk(CodeGenFunction , const OMPLoopDirective , OpenMPDistScheduleClauseKind , llvm::Value *) const override; + /// Choose a default value for the schedule clause. + void getDefaultScheduleAndChunk(CodeGenFunction , + const OMPLoopDirective , OpenMPScheduleClauseKind , + llvm::Value *) const override; + private: /// Track the execution mode when codegening directives within a target /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp === --- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -4093,3 +4093,14 @@ S.getIterationVariable()->getType(), S.getBeginLoc()); } } + +void CGOpenMPRuntimeNVPTX::getDefaultScheduleAndChunk( +