[llvm-bugs] [Bug 46031] New: reduction on arrays target regions

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 21 21:25:08 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46031

            Bug ID: 46031
           Summary: reduction on arrays target regions
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: josem at udel.edu
                CC: llvm-bugs at lists.llvm.org

Hi all, 

I tried this code on Clang 10 and it breaks ungracefully

static double temps[2];

int main () {
   #pragma omp target
   {
       #pragma omp parallel reduction(+:temps[0], temps[1])
       {
           temps[0] += 1;
           temps[1] += 1;
       }
   }
   return 0;
}

Furthermore, If I use just temps in the reduction, it gives wrong results (nan)
if -O2 and breaks if no -O but -g is specified

int main () {
    double temps[2];
   #pragma omp target map(tofrom:temps)
   {
       temps[0] = 0;
       temps[1] = 0;
       #pragma omp parallel reduction(+:temps)
       {
           temps[0] += 1;
           temps[1] += 1;
       }
   }
   printf("%f - %f\n", temps[0], temps[1]);
   return 0;
}

I'm running on an Nvidia V100 on an x86 host. 

Here is the summary of the results:

Second code:
WORKS -- clang -fopenmp -fopenmp-targets=nvptx64-nvida-cuda
clang_bug_reduction.c

COMPILER BREAKS -- clang -g -fopenmp -fopenmp-targets=nvptx64-nvida-cuda
clang_bug_reduction.c

RESULT IS NAN. -- clang -O2 -fopenmp -fopenmp-targets=nvptx64-nvida-cuda
clang_bug_reduction.c

First code:

COMPILER BREAKS IN ALL POSSIBLE COMBINATIONS:

clang -fopenmp -fopenmp-targets=nvptx64-nvida-cuda clang_bug_reduction.c 
clang-10: llvm-clang/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:1172: void
clang::CodeGen::CodeGenFunction::EmitOMPReductionClauseInit(const
clang::OMPExecutableDirective &, CodeGenFunction::OMPPrivateScope &): Assertion
`IsRegistered && "private var already registered as private"' failed.
Stack dump:
0.      Program arguments: /soft/compilers/llvm/release-10.0/bin/clang-10 -cc1
-triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists
-disable-free -main-file-name clang_bug_reduction.c -mrelocation-model static
-mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/soft/compilers/llvm/release-10.0/lib/clang/10.0.0
-I/soft/compilers/gcc/8.2.0/linux-rhel7-x86_64/include/c++/8.2.0/x86_64-pc-linux-gnu/
-I/soft/compilers/gcc/8.2.0/linux-rhel7-x86_64/include/c++/8.2.0 -c-isystem
/soft/compilers/cuda/cuda-10.1.243/include -c-isystem
/soft/compilers/cuda/cuda-10.1.243/include -c-isystem
/soft/compilers/gcc/8.2.0/linux-rhel7-x86_64/include -c-isystem
/gpfs/jlse-fs0/users/jmonsalvediaz/soft/llvm/clang/1000/final/lib -c-isystem
/soft/compilers/cuda/cuda-9.1.85/include -c-isystem
/gpfs/jlse-fs0/users/jmonsalvediaz/soft/libelf/0.8.13/include -c-isystem
/gpfs/jlse-fs0/users/jmonsalvediaz/soft/libedit/3.1/include -c-isystem .
-cxx-isystem /soft/compilers/cuda/cuda-10.1.243/include -cxx-isystem
/soft/compilers/cuda/cuda-10.1.243/include -cxx-isystem
/soft/compilers/gcc/8.2.0/linux-rhel7-x86_64/include/c++/8.2.0
-internal-isystem /usr/local/include -internal-isystem
/soft/compilers/llvm/release-10.0/lib/clang/10.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-internal-isystem /usr/local/include -internal-isystem
/soft/compilers/llvm/release-10.0/lib/clang/10.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /home/jmonsalvediaz/tmp -ferror-limit 19
-fmessage-length 0 -fopenmp -fgnuc-version=4.2.1 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics
-fopenmp-targets=nvptx64-nvida-cuda -faddrsig -o
/tmp/clang_bug_reduction-ee7397.bc -x c clang_bug_reduction.c 
1.      <eof> parser at end of file
2.      clang_bug_reduction.c:26:5: LLVM IR generation of declaration 'main'
3.      clang_bug_reduction.c:26:5: Generating code for declaration 'main'
4.      clang_bug_reduction.c:28:4: LLVM IR generation of compound statement
('{}')
 #0 0x0000000002501544 PrintStackTraceSignalHandler(void*)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2501544)
 #1 0x00000000024ff1de llvm::sys::RunSignalHandlers()
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x24ff1de)
 #2 0x0000000002501945 SignalHandler(int)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2501945)
 #3 0x00007f89b2fbd630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x00007f89b1b2b377 raise (/lib64/libc.so.6+0x36377)
 #5 0x00007f89b1b2ca68 abort (/lib64/libc.so.6+0x37a68)
 #6 0x00007f89b1b24196 __assert_fail_base (/lib64/libc.so.6+0x2f196)
 #7 0x00007f89b1b24242 (/lib64/libc.so.6+0x2f242)
 #8 0x000000000274a943
clang::CodeGen::CodeGenFunction::EmitOMPReductionClauseInit(clang::OMPExecutableDirective
const&, clang::CodeGen::CodeGenFunction::OMPPrivateScope&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x274a943)
 #9 0x000000000276746d void
clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective
const&)::$_21>(long, clang::CodeGen::CodeGenFunction&,
clang::CodeGen::PrePostActionTy&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x276746d)
#10 0x0000000002a5aa5b (anonymous
namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&,
clang::Stmt const*) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x2a5aa5b)
#11 0x00000000027420c6
clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt
const&) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x27420c6)
#12 0x0000000002a2b7d7
emitParallelOrTeamsOutlinedFunction(clang::CodeGen::CodeGenModule&,
clang::OMPExecutableDirective const&, clang::CapturedStmt const*,
clang::VarDecl const*, llvm::omp::Directive, llvm::StringRef,
clang::CodeGen::RegionCodeGenTy const&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2a2b7d7)
#13 0x0000000002a2b596
clang::CodeGen::CGOpenMPRuntime::emitParallelOutlinedFunction(clang::OMPExecutableDirective
const&, clang::VarDecl const*, llvm::omp::Directive,
clang::CodeGen::RegionCodeGenTy const&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2a2b596)
#14 0x000000000274b927
emitCommonOMPParallelDirective(clang::CodeGen::CodeGenFunction&,
clang::OMPExecutableDirective const&, llvm::omp::Directive,
clang::CodeGen::RegionCodeGenTy const&, llvm::function_ref<void
(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&,
llvm::SmallVectorImpl<llvm::Value*>&)> const&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x274b927)
#15 0x000000000274b17c
clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective
const&) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x274b17c)
#16 0x000000000272ea58 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x272ea58)
#17 0x0000000002739780
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2739780)
#18 0x00000000027388f8
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x27388f8)
#19 0x000000000272f921
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x272f921)
#20 0x000000000272e55b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x272e55b)
#21 0x0000000002774286 emitTargetRegion(clang::CodeGen::CodeGenFunction&,
clang::OMPTargetDirective const&, clang::CodeGen::PrePostActionTy&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2774286)
#22 0x0000000002a5aa5b (anonymous
namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&,
clang::Stmt const*) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x2a5aa5b)
#23 0x00000000027420c6
clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt
const&) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x27420c6)
#24 0x0000000002a4a07f
clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(clang::OMPExecutableDirective
const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool,
clang::CodeGen::RegionCodeGenTy const&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2a4a07f)
#25 0x0000000002752969
emitCommonOMPTargetDirective(clang::CodeGen::CodeGenFunction&,
clang::OMPExecutableDirective const&, clang::CodeGen::RegionCodeGenTy const&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2752969)
#26 0x000000000275d4f2
clang::CodeGen::CodeGenFunction::EmitOMPTargetDirective(clang::OMPTargetDirective
const&) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x275d4f2)
#27 0x000000000272ee53 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x272ee53)
#28 0x0000000002739780
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2739780)
#29 0x0000000002786ef7
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2786ef7)
#30 0x00000000027a4886
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x27a4886)
#31 0x000000000279cf1c
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x279cf1c)
#32 0x00000000027a8aa2
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x27a8aa2)
#33 0x0000000003254f50 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x3254f50)
#34 0x0000000003251efb
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x3251efb)
#35 0x0000000003accf74 clang::ParseAST(clang::Sema&, bool, bool)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x3accf74)
#36 0x0000000002c67aa0 clang::FrontendAction::Execute()
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2c67aa0)
#37 0x0000000002c026f3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2c026f3)
#38 0x0000000002d119f0
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x2d119f0)
#39 0x000000000097eecd cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/soft/compilers/llvm/release-10.0/bin/clang-10+0x97eecd)
#40 0x000000000097ce9c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x97ce9c)
#41 0x000000000097cb84 main
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x97cb84)
#42 0x00007f89b1b17545 __libc_start_main (/lib64/libc.so.6+0x22545)
#43 0x0000000000979d0d _start
(/soft/compilers/llvm/release-10.0/bin/clang-10+0x979d0d)
clang-10: error: unable to execute command: Aborted
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0 (llvm-clang/llvm-project/clang
d32170dbd5b0d54436537b6b75beaf44324e0c28)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/release-10.0/bin
clang-10: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-10: note: diagnostic msg: Error generating preprocessed source(s).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200522/da6fe153/attachment.html>


More information about the llvm-bugs mailing list