llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Runtime fails with declare mapper due clang generate extra mapper component for non-array map variable.

Open jyu2-git opened this issue 5 years ago • 3 comments

Bugzilla Link 48423
Resolution FIXED
Resolved on Mar 30, 2021 13:27
Version trunk
OS Linux
Attachments Test to reproduce the problem.
CC @alexey-bataev
Fixed by commit(s) 60d71a286b5a

Extended Description

Test failed at runtime: command line to reproduce:

clang++ -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu -g -O0 j.cpp bash-4.4$ ./a.out Sizeof C = 16 8 Sizeof C.s = 1cf8f808 1cf8f810 Libomptarget message: explicit extension not allowed: host address specified is 0x00007ffe1cf8f808 (16 bytes), but device allocation maps to host at 0x00007ffe1cf8f808 (4 bytes) Libomptarget error: Call to getOrAllocTgtPtr returned null pointer (device failure or illegal mapping). Libomptarget error: Call to targetDataBegin via targetDataMapper for custom mapper failed. Libomptarget error: Call to targetDataBegin failed, abort target. Libomptarget error: Failed to process data before launching the kernel. Libomptarget error: run with env LIBOMPTARGET_INFO>1 to dump host-target pointer maps j.cpp:17:3: Libomptarget fatal error 1: failure of target construct while offloading is mandatory Aborted (core dumped)

The problem clang generate 4 Mapper components should be 3:

$11 = std::vector of length 4, capacity 4 = {{Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 32}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 32}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 4, Type = 562949953421315}, { Base = 0x7fffffff9f30, Begin = 0x7fffffff9f10, Size = 16, Type = 562949953421331}}

During run mapper_id(clang generated), isarray gets set true cause extra MapperComponent is generated.

%omp.arrayinit.isarray = icmp sge i64 %6, 1

In emitUDMapperArrayInitOrDel: following code seems not right. llvm::Value *IsArray = MapperCGF.Builder.CreateICmpSGE( Size, MapperCGF.Builder.getInt64(1), "omp.arrayinit.isarray");

“C c” is not same with “C c[1]”; but both Size are 1;

Compiler knows map variable type, should not necessary to generate runtime code for isarray.

jyu2-git avatar Dec 07 '20 04:12 jyu2-git

Must be fixed by https://reviews.llvm.org/D86119

Interest after change, still 4 mapper components gets generated

std::vector of length 4, capacity 4 = {{Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 0}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 4, Type = 281474976710659}, { Base = 0x7fffffff9f30, Begin = 0x7fffffff9f10, Size = 16, Type = 281474976710675}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 32}}

The different is the array one gets pushed last instead at beginning. But for some reason, runtime works for this one

I would expect: std::vector of length 3, capacity 4 = {{Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 32}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 4, Type = 281474976710659}, { Base = 0x7fffffff9f30, Begin = 0x7fffffff9f10, Size = 16, Type = 281474976710675}}

It is different problem that was discussed in the patch. The frontend just does not optimize some of the mappings, which can be merged. This problem should be addressed in a separate patch.

alexey-bataev avatar Dec 08 '20 14:12 alexey-bataev

Must be fixed by https://reviews.llvm.org/D86119

Interest after change, still 4 mapper components gets generated

std::vector of length 4, capacity 4 = {{Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 0}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 4, Type = 281474976710659}, { Base = 0x7fffffff9f30, Begin = 0x7fffffff9f10, Size = 16, Type = 281474976710675}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 32}}

The different is the array one gets pushed last instead at beginning. But for some reason, runtime works for this one

I would expect: std::vector of length 3, capacity 4 = {{Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 32}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 4, Type = 281474976710659}, { Base = 0x7fffffff9f30, Begin = 0x7fffffff9f10, Size = 16, Type = 281474976710675}}

jyu2-git avatar Dec 07 '20 21:12 jyu2-git

Created attachment 24242 [details] Test to reproduce the problem.

Test failed at runtime: command line to reproduce:

clang++ -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu -g -O0 j.cpp bash-4.4$ ./a.out Sizeof C = 16 8 Sizeof C.s = 1cf8f808 1cf8f810 Libomptarget message: explicit extension not allowed: host address specified is 0x00007ffe1cf8f808 (16 bytes), but device allocation maps to host at 0x00007ffe1cf8f808 (4 bytes) Libomptarget error: Call to getOrAllocTgtPtr returned null pointer (device failure or illegal mapping). Libomptarget error: Call to targetDataBegin via targetDataMapper for custom mapper failed. Libomptarget error: Call to targetDataBegin failed, abort target. Libomptarget error: Failed to process data before launching the kernel. Libomptarget error: run with env LIBOMPTARGET_INFO>1 to dump host-target pointer maps j.cpp:17:3: Libomptarget fatal error 1: failure of target construct while offloading is mandatory Aborted (core dumped)

The problem clang generate 4 Mapper components should be 3:

$11 = std::vector of length 4, capacity 4 = {{Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 32}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 16, Type = 32}, {Base = 0x7fffffff9f28, Begin = 0x7fffffff9f28, Size = 4, Type = 562949953421315}, { Base = 0x7fffffff9f30, Begin = 0x7fffffff9f10, Size = 16, Type = 562949953421331}}

During run mapper_id(clang generated), isarray gets set true cause extra MapperComponent is generated.

%omp.arrayinit.isarray = icmp sge i64 %6, 1

In emitUDMapperArrayInitOrDel: following code seems not right. llvm::Value *IsArray = MapperCGF.Builder.CreateICmpSGE( Size, MapperCGF.Builder.getInt64(1), "omp.arrayinit.isarray");

“C c” is not same with “C c[1]”; but both Size are 1;

Compiler knows map variable type, should not necessary to generate runtime code for isarray.

Must be fixed by https://reviews.llvm.org/D86119

alexey-bataev avatar Dec 07 '20 14:12 alexey-bataev