Skip to content

Navigation Menu

Sign in
Sign up

cgeist not generating scf.parallel from OpenMP loop #432

nirhasabnis started this conversation in General
Discussion options

Hi,

May be I am missing something, but I am not able to produce scf.parallel from C code containing for loop with #pragma omp parallel for. I see scf.for but not scf.parallel. Am I missing something?

Polygeist is compiled with Polymer and Pluto using:

cmake -G Ninja ../llvm-project/llvm -DLLVM_ENABLE_PROJECTS="clang;mlir" -DLLVM_EXTERNAL_PROJECTS="polygeist" 
 -DLLVM_EXTERNAL_POLYGEIST_SOURCE_DIR=.. -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release -DPOLYGEIST_ENABLE_POLYMER=1 -DPOLYGEIST_POLYMER_ENABLE_PLUTO=1
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#define M 1000
#define INT_MAX 999
int main(void)
{
 int A[M];
 int i;
 int result= INT_MAX;
 #pragma omp parallel for
 for (i = 0; i < M; i++)
 {
 A[i] = i;
 }
 //non-parallel loop
 for (i = 0; i < 1000; i++)
 {
 if (A[i] < result)
 result = A[i];
 }
 printf("Suma %d\n", result);
 return 0;
}

$ ./cgeist ~/mlir/loops/pri1.c -fopenmp --scf-openmp -I /usr/lib/gcc/x86_64-linux-gnu/12/include -S --emit-openmpir --openmp-opt

./cgeist ~/mlir/loops/pri1.c -fopenmp --scf-openmp -I /usr/lib/gcc/x86_64-linux-gnu/12/include -S --emit-openmpir --openmp-opt
module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<f80, dense<128> : vector<2xi32>>, #dlti.dl_entry<!llvm.ptr<272>, dense<64> : vector<4xi32>>, #dlti.dl_entry<i64, dense<64> : vector<2xi32>>, #dlti.dl_entry<!llvm.ptr, dense<64> : vector<4xi32>>, #dlti.dl_entry<i1, dense<8> : vector<2xi32>>, #dlti.dl_entry<i32, dense<32> : vector<2xi32>>, #dlti.dl_entry<i16, dense<16> : vector<2xi32>>, #dlti.dl_entry<i8, dense<8> : vector<2xi32>>, #dlti.dl_entry<!llvm.ptr<270>, dense<32> : vector<4xi32>>, #dlti.dl_entry<!llvm.ptr<271>, dense<32> : vector<4xi32>>, #dlti.dl_entry<f64, dense<64> : vector<2xi32>>, #dlti.dl_entry<f128, dense<128> : vector<2xi32>>, #dlti.dl_entry<f16, dense<16> : vector<2xi32>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i32>, #dlti.dl_entry<"dlti.endianness", "little">>, llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu", "polygeist.target-cpu" = "x86-64", "polygeist.target-features" = "+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87", "polygeist.tune-cpu" = "generic"} {
 llvm.mlir.global internal constant @str0("Suma %d0円A00円") {addr_space = 0 : i32}
 llvm.func @printf(!llvm.ptr, ...) -> i32
 func.func @main() -> i32 attributes {llvm.linkage = #llvm.linkage<external>} {
 %c1000 = arith.constant 1000 : index
 %c0 = arith.constant 0 : index
 %c1 = arith.constant 1 : index
 %c0_i32 = arith.constant 0 : i32
 %c999_i32 = arith.constant 999 : i32
 %0 = scf.for %arg0 = %c0 to %c1000 step %c1 iter_args(%arg1 = %c999_i32) -> (i32) {
 %4 = arith.index_cast %arg0 : index to i32
 %5 = arith.cmpi slt, %4, %arg1 : i32
 %6 = arith.select %5, %4, %arg1 : i32
 scf.yield %6 : i32
 }
 %1 = llvm.mlir.addressof @str0 : !llvm.ptr
 %2 = llvm.getelementptr %1[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.array<9 x i8>
 %3 = llvm.call @printf(%2, %0) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i32) -> i32
 return %c0_i32 : i32
 }
}
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /