[PATCH] D103770: Injection of kernel features into the LLVM IR during the OpenMP transform stage

Konstantin Sidorov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 14 04:37:11 PST 2021


ksidorov updated this revision to Diff 387065.
ksidorov marked an inline comment as done.
ksidorov added a comment.

Aligned the order of kernel features to the order in the struct definition


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103770/new/

https://reviews.llvm.org/D103770

Files:
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/gpu_kernel_features.ll


Index: llvm/test/Transforms/OpenMP/gpu_kernel_features.ll
===================================================================
--- llvm/test/Transforms/OpenMP/gpu_kernel_features.ll
+++ llvm/test/Transforms/OpenMP/gpu_kernel_features.ll
@@ -1,9 +1,9 @@
 ; RUN: opt -passes=openmp-opt-cgscc -openmp-inject-kernel-features -S < %s | FileCheck %s
 
-; CHECK-DAG: @empty_kernel1.KernelFeatures = constant [8 x i64] [i64 1, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 1]
-; CHECK-DAG: @empty_kernel2.KernelFeatures = constant [8 x i64] [i64 1, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 1]
-; CHECK-DAG: @matmul_kernel.KernelFeatures = constant [8 x i64] [i64 1, i64 0, i64 1, i64 0, i64 0, i64 1, i64 0, i64 1]
-; CHECK-DAG: @multiply_kernel.KernelFeatures = constant [8 x i64] [i64 13, i64 6, i64 0, i64 21, i64 3, i64 11, i64 1, i64 2]
+; CHECK-DAG: @empty_kernel1_KernelFeatures = constant [8 x i64] [i64 1, i64 0, i64 1, i64 0, i64 0, i64 0, i64 0, i64 0]
+; CHECK-DAG: @empty_kernel2_KernelFeatures = constant [8 x i64] [i64 1, i64 0, i64 1, i64 0, i64 0, i64 0, i64 0, i64 0]
+; CHECK-DAG: @matmul_kernel_KernelFeatures = constant [8 x i64] [i64 1, i64 0, i64 1, i64 1, i64 0, i64 1, i64 0, i64 0]
+; CHECK-DAG: @multiply_kernel_KernelFeatures = constant [8 x i64] [i64 13, i64 6, i64 2, i64 0, i64 21, i64 11, i64 3, i64 1]
 
 define void @empty_kernel1() {
   ret void
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1500,20 +1500,20 @@
       }
       // OMPInfoCache has returned the analysis result -- pack the feature
       // values into the [* x i64] array and inject them as the constant
-      // global variable with the name '$KernelName.KernelFeatures'
+      // global variable with the name '$KernelName_KernelFeatures'
       IntegerType *FeatureType = Type::getInt64Ty(M.getContext());
       ArrayRef<Constant *> FeatureArrayRef{
           ConstantInt::get(FeatureType, FunctionInfo->BasicBlockCount),
           ConstantInt::get(
               FeatureType,
               FunctionInfo->BlocksReachedFromConditionalInstruction),
+          ConstantInt::get(FeatureType, FunctionInfo->Uses),
           ConstantInt::get(FeatureType,
                            FunctionInfo->DirectCallsToDefinedFunctions),
           ConstantInt::get(FeatureType, FunctionInfo->LoadInstCount),
-          ConstantInt::get(FeatureType, FunctionInfo->MaxLoopDepth),
           ConstantInt::get(FeatureType, FunctionInfo->StoreInstCount),
+          ConstantInt::get(FeatureType, FunctionInfo->MaxLoopDepth),
           ConstantInt::get(FeatureType, FunctionInfo->TopLevelLoopCount),
-          ConstantInt::get(FeatureType, FunctionInfo->Uses),
       };
       ArrayType *FeatureArrayType =
           ArrayType::get(FeatureType, FeatureArrayRef.size());
@@ -1521,7 +1521,7 @@
           ConstantArray::get(FeatureArrayType, FeatureArrayRef);
       GlobalVariable *FeatureVector = new GlobalVariable(
           M, FeatureArrayType, true, GlobalValue::ExternalLinkage, FeatureArray,
-          F->getName() + ".KernelFeatures");
+          F->getName() + "_KernelFeatures");
       (void)FeatureVector;
       IsChanged = true;
       LLVM_DEBUG({


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103770.387065.patch
Type: text/x-patch
Size: 3311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211114/79941083/attachment.bin>


More information about the llvm-commits mailing list