[Openmp-commits] [openmp] [Flang][OpenMP][MLIR] Initial array section mapping MLIR -> LLVM-IR lowering utilising omp.bounds (PR #68689)
Kiran Chandramohan via Openmp-commits
openmp-commits at lists.llvm.org
Thu Oct 19 02:33:21 PDT 2023
================
@@ -1629,13 +1622,153 @@ getRefPtrIfDeclareTarget(mlir::Value value,
return nullptr;
}
+// A small helper structure to contain data gathered
+// for map lowering and coalese it into one area and
+// avoiding extra computations such as searches in the
+// llvm module for lowered mapped varibles or checking
+// if something is declare target (and retrieving the
+// value).
+struct MapData {
+ bool isDeclareTarget = false;
+ mlir::Operation *mapClause;
+ llvm::Value *basePointer;
+ llvm::Value *pointer;
+ llvm::Value *kernelValue;
+ llvm::Type *underlyingType;
+ llvm::Value *sizeInBytes;
+};
+
+uint64_t getArrayElementSizeInBits(LLVM::LLVMArrayType arrTy, DataLayout &dl) {
+ if (auto nestedArrTy = llvm::dyn_cast_if_present<LLVM::LLVMArrayType>(
+ arrTy.getElementType()))
+ return getArrayElementSizeInBits(nestedArrTy, dl);
+ return dl.getTypeSizeInBits(arrTy.getElementType());
+}
+
+// This function calculates the size to be offloaded for a specified type, given
+// its associated map clause (which can contain bounds information which affects
+// the total size), this size is calculated based on the underlying element type
+// e.g. given a 1-D array of ints, we will calculate the size from the integer
+// type * number of elements in the array. This size can be used in other
+// calculations but is ultimately used as an argument to the OpenMP runtimes
+// kernel argument structure which is generated through the combinedInfo data
+// structures.
+// This function is somewhat equivalent to Clang's getExprTypeSize inside of
+// CGOpenMPRuntime.cpp.
+llvm::Value *getSizeInBytes(DataLayout &dl, const mlir::Type &type,
----------------
kiranchandramohan wrote:
I don't think we currently have a mechanism to get all the information about arrays represented as descriptors in the LLVM Dialect. Without such a mechanism, we cannot get all the information to do the mapping. `omp.bounds` provides all the information currently, so I think we should stick with that for uniformity.
https://github.com/llvm/llvm-project/pull/68689
More information about the Openmp-commits
mailing list