[Mlir-commits] [mlir] [MLIR][SCFToOpenMP] Add num-threads option (PR #74854)

Kiran Chandramohan llvmlistbot at llvm.org
Sat Dec 9 07:44:22 PST 2023


================
@@ -390,6 +392,12 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
 
     // Create the parallel wrapper.
     auto ompParallel = rewriter.create<omp::ParallelOp>(loc);
+    if (numThreads > 1) {
+      rewriter.setInsertionPoint(ompParallel);
+      mlir::Value numThreadsVar = rewriter.create<LLVM::ConstantOp>(
+          loc, rewriter.getI32IntegerAttr(numThreads));
+      ompParallel.getNumThreadsVarMutable().assign(numThreadsVar);
----------------
kiranchandramohan wrote:

I don't know whether this is standard usage. Ideally, we should be creating the Parallel operation with the operands specified.

https://github.com/llvm/llvm-project/pull/74854


More information about the Mlir-commits mailing list