Skip to content

[OpenMP][Clang] Migrate OpenMP UserDefinedMapper from Clang to OMPIRBuilder #110001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 49 additions & 317 deletions clang/lib/CodeGen/CGOpenMPRuntime.cpp

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions clang/lib/CodeGen/CGOpenMPRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,6 @@ class CGOpenMPRuntime {
llvm::Value *Ctor, llvm::Value *CopyCtor,
llvm::Value *Dtor, SourceLocation Loc);

/// Emit the array initialization or deletion portion for user-defined mapper
/// code generation.
void emitUDMapperArrayInitOrDel(CodeGenFunction &MapperCGF,
llvm::Value *Handle, llvm::Value *BasePtr,
llvm::Value *Ptr, llvm::Value *Size,
llvm::Value *MapType, llvm::Value *MapName,
CharUnits ElementSize,
llvm::BasicBlock *ExitBB, bool IsInit);

struct TaskResultTy {
llvm::Value *NewTask = nullptr;
llvm::Function *TaskEntry = nullptr;
Expand Down
48 changes: 4 additions & 44 deletions clang/test/OpenMP/declare_mapper_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,9 @@ class C {

#pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])

// CK0: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](ptr{{.*}}, ptr{{.*}}, ptr{{.*}}, i64{{.*}}, i64{{.*}}, ptr{{.*}})
// CK0: store ptr %{{[^,]+}}, ptr [[HANDLEADDR:%[^,]+]]
// CK0: store ptr %{{[^,]+}}, ptr [[BPTRADDR:%[^,]+]]
// CK0: store ptr %{{[^,]+}}, ptr [[VPTRADDR:%[^,]+]]
// CK0: store i64 %{{[^,]+}}, ptr [[SIZEADDR:%[^,]+]]
// CK0: store i64 %{{[^,]+}}, ptr [[TYPEADDR:%[^,]+]]
// CK0-DAG: [[BYTESIZE:%.+]] = load i64, ptr [[SIZEADDR]]
// CK0: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](ptr noundef [[HANDLE:%.+]], ptr noundef [[BPTR:%.+]], ptr noundef [[BEGIN:%.+]], i64 noundef [[BYTESIZE:%.+]], i64 noundef [[TYPE:%.+]], ptr{{.*}})
// CK0-64-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
// CK0-32-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 8
// CK0-DAG: [[TYPE:%.+]] = load i64, ptr [[TYPEADDR]]
// CK0-DAG: [[HANDLE:%.+]] = load ptr, ptr [[HANDLEADDR]]
// CK0-DAG: [[BPTR:%.+]] = load ptr, ptr [[BPTRADDR]]
// CK0-DAG: [[BEGIN:%.+]] = load ptr, ptr [[VPTRADDR]]
// CK0-DAG: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
// CK0-DAG: [[PTREND:%.+]] = getelementptr %class.C, ptr [[BEGIN]], i64 [[SIZE]]
// CK0-DAG: [[PTRSNE:%.+]] = icmp ne ptr [[BPTR]], [[BEGIN]]
Expand Down Expand Up @@ -597,18 +587,8 @@ class C {

#pragma omp declare mapper(id: C<int> s) map(s.a)

// CK1-LABEL: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id{{.*}}(ptr{{.*}}, ptr{{.*}}, ptr{{.*}}, i64{{.*}}, i64{{.*}}, ptr{{.*}})
// CK1: store ptr %{{[^,]+}}, ptr [[HANDLEADDR:%[^,]+]]
// CK1: store ptr %{{[^,]+}}, ptr [[BPTRADDR:%[^,]+]]
// CK1: store ptr %{{[^,]+}}, ptr [[VPTRADDR:%[^,]+]]
// CK1: store i64 %{{[^,]+}}, ptr [[SIZEADDR:%[^,]+]]
// CK1: store i64 %{{[^,]+}}, ptr [[TYPEADDR:%[^,]+]]
// CK1-DAG: [[BYTESIZE:%.+]] = load i64, ptr [[SIZEADDR]]
// CK1: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id{{.*}}(ptr noundef [[HANDLE:%.+]], ptr noundef [[BPTR:%.+]], ptr noundef [[BEGIN:%.+]], i64 noundef [[BYTESIZE:%.+]], i64 noundef [[TYPE:%.+]], ptr{{.*}})
// CK1-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 4
// CK1-DAG: [[TYPE:%.+]] = load i64, ptr [[TYPEADDR]]
// CK1-DAG: [[HANDLE:%.+]] = load ptr, ptr [[HANDLEADDR]]
// CK1-DAG: [[BPTR:%.+]] = load ptr, ptr [[BPTRADDR]]
// CK1-DAG: [[BEGIN:%.+]] = load ptr, ptr [[VPTRADDR]]
// CK1-DAG: [[PTREND:%.+]] = getelementptr %class.C, ptr [[BEGIN]], i64 [[SIZE]]
// CK1-DAG: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
// CK1-DAG: [[PTRSNE:%.+]] = icmp ne ptr [[BPTR]], [[BEGIN]]
Expand Down Expand Up @@ -717,18 +697,8 @@ class C {

// CK2: define {{.*}}void [[BMPRFUNC:@[.]omp_mapper[.].*B[.]default]](ptr{{.*}}, ptr{{.*}}, ptr{{.*}}, i64{{.*}}, i64{{.*}}, ptr{{.*}})

// CK2-LABEL: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id(ptr{{.*}}, ptr{{.*}}, ptr{{.*}}, i64{{.*}}, i64{{.*}}, ptr{{.*}})
// CK2: store ptr %{{[^,]+}}, ptr [[HANDLEADDR:%[^,]+]]
// CK2: store ptr %{{[^,]+}}, ptr [[BPTRADDR:%[^,]+]]
// CK2: store ptr %{{[^,]+}}, ptr [[VPTRADDR:%[^,]+]]
// CK2: store i64 %{{[^,]+}}, ptr [[SIZEADDR:%[^,]+]]
// CK2: store i64 %{{[^,]+}}, ptr [[TYPEADDR:%[^,]+]]
// CK2-DAG: [[BYTESIZE:%.+]] = load i64, ptr [[SIZEADDR]]
// CK2: define {{.*}}void @.omp_mapper.{{.*}}C{{.*}}.id(ptr noundef [[HANDLE:%.+]], ptr noundef [[BPTR:%.+]], ptr noundef [[BEGIN:%.+]], i64 noundef [[BYTESIZE:%.+]], i64 noundef [[TYPE:%.+]], ptr{{.*}})
// CK2-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
// CK2-DAG: [[TYPE:%.+]] = load i64, ptr [[TYPEADDR]]
// CK2-DAG: [[HANDLE:%.+]] = load ptr, ptr [[HANDLEADDR]]
// CK2-DAG: [[BPTR:%.+]] = load ptr, ptr [[BPTRADDR]]
// CK2-DAG: [[BEGIN:%.+]] = load ptr, ptr [[VPTRADDR]]
// CK2-DAG: [[PTREND:%.+]] = getelementptr %class.C, ptr [[BEGIN]], i64 [[SIZE]]
// CK2-DAG: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
// CK2-DAG: [[PTRSNE:%.+]] = icmp ne ptr [[BPTR]], [[BEGIN]]
Expand Down Expand Up @@ -921,19 +891,9 @@ class C {

#pragma omp declare mapper(id: C s) map(s.a, s.b[0:2])

// CK4: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](ptr{{.*}}, ptr{{.*}}, ptr{{.*}}, i64{{.*}}, i64{{.*}}, ptr{{.*}})
// CK4: store ptr %{{[^,]+}}, ptr [[HANDLEADDR:%[^,]+]]
// CK4: store ptr %{{[^,]+}}, ptr [[BPTRADDR:%[^,]+]]
// CK4: store ptr %{{[^,]+}}, ptr [[VPTRADDR:%[^,]+]]
// CK4: store i64 %{{[^,]+}}, ptr [[SIZEADDR:%[^,]+]]
// CK4: store i64 %{{[^,]+}}, ptr [[TYPEADDR:%[^,]+]]
// CK4-DAG: [[BYTESIZE:%.+]] = load i64, ptr [[SIZEADDR]]
// CK4: define {{.*}}void [[MPRFUNC:@[.]omp_mapper[.].*C[.]id]](ptr noundef [[HANDLE:%.+]], ptr noundef [[BPTR:%.+]], ptr noundef [[BEGIN:%.+]], i64 noundef [[BYTESIZE:%.+]], i64 noundef [[TYPE:%.+]], ptr{{.*}})
// CK4-64-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 16
// CK4-32-DAG: [[SIZE:%.+]] = udiv exact i64 [[BYTESIZE]], 8
// CK4-DAG: [[TYPE:%.+]] = load i64, ptr [[TYPEADDR]]
// CK4-DAG: [[HANDLE:%.+]] = load ptr, ptr [[HANDLEADDR]]
// CK4-DAG: [[BPTR:%.+]] = load ptr, ptr [[BPTRADDR]]
// CK4-DAG: [[BEGIN:%.+]] = load ptr, ptr [[VPTRADDR]]
// CK4-DAG: [[PTREND:%.+]] = getelementptr %class.C, ptr [[BEGIN]], i64 [[SIZE]]
// CK4-DAG: [[ISARRAY:%.+]] = icmp sgt i64 [[SIZE]], 1
// CK4-DAG: [[PTRSNE:%.+]] = icmp ne ptr [[BPTR]], [[BEGIN]]
Expand Down
4 changes: 1 addition & 3 deletions clang/test/OpenMP/target_map_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ void secondMapNameInClause() {
// DEBUG: store ptr @[[NAME:.offload_mapnames.[0-9]+]], ptr %[[ARG:.+]]
// CHECK-NOT: store ptr @[[NAME:.offload_mapnames.[0-9]+]], ptr %[[ARG:.+]]

// DEBUG: void @.omp_mapper._ZTS2S3.id(ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, i64 {{.*}}, i64 {{.*}}, ptr noundef [[NAME_ARG:%.+]])
// DEBUG: store ptr [[NAME_ARG]], ptr [[NAME_STACK:%.+]]
// DEBUG: [[MAPPER_NAME:%.+]] = load ptr, ptr [[NAME_STACK]]
// DEBUG: void @.omp_mapper._ZTS2S3.id(ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, i64 {{.*}}, i64 {{.*}}, ptr noundef [[MAPPER_NAME:%.+]])
// DEBUG: call void @__tgt_push_mapper_component(ptr %{{.*}}, ptr %{{.*}}, ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, ptr [[MAPPER_NAME]])

#endif
4 changes: 1 addition & 3 deletions clang/test/OpenMP/target_map_names_attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ void secondMapNameInClause() {
// DEBUG: store ptr @[[NAME:.offload_mapnames.[0-9]+]], ptr %[[ARG:.+]]
// CHECK-NOT: store ptr @[[NAME:.offload_mapnames.[0-9]+]], ptr %[[ARG:.+]]

// DEBUG: void @.omp_mapper._ZTS2S3.id(ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, i64 {{.*}}, i64 {{.*}}, ptr noundef [[NAME_ARG:%.+]])
// DEBUG: store ptr [[NAME_ARG]], ptr [[NAME_STACK:%.+]]
// DEBUG: [[MAPPER_NAME:%.+]] = load ptr, ptr [[NAME_STACK]]
// DEBUG: void @.omp_mapper._ZTS2S3.id(ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, i64 {{.*}}, i64 {{.*}}, ptr noundef [[MAPPER_NAME:%.+]])
// DEBUG: call void @__tgt_push_mapper_component(ptr %{{.*}}, ptr %{{.*}}, ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, ptr [[MAPPER_NAME]])

#endif
Expand Down
Loading
Loading