Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP][Clang] Allow passing target features in ISA trait for metadi…
…rective clause Passing any feature in the device-isa trait which is not supported by the host was causing a compilation failure. Differential Revision: https://reviews.llvm.org/D116549
- Loading branch information
Showing
6 changed files
with
96 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clang_cc1 -verify -w -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s | ||
// expected-no-diagnostics | ||
|
||
#ifndef HEADER | ||
#define HEADER | ||
|
||
void bar(); | ||
|
||
void x86_64_device_isa_selected() { | ||
#pragma omp metadirective when(device = {isa("sse2")} \ | ||
: parallel) default(single) | ||
bar(); | ||
} | ||
// CHECK-LABEL: void @_Z26x86_64_device_isa_selectedv() | ||
// CHECK: ...) @__kmpc_fork_call{{.*}}@.omp_outlined. | ||
// CHECK: ret void | ||
|
||
// CHECK: define internal void @.omp_outlined.( | ||
// CHECK: @_Z3barv | ||
// CHECK: ret void | ||
|
||
void x86_64_device_isa_not_selected() { | ||
#pragma omp metadirective when(device = {isa("some-unsupported-feature")} \ | ||
: parallel) default(single) | ||
bar(); | ||
} | ||
// CHECK-LABEL: void @_Z30x86_64_device_isa_not_selectedv() | ||
// CHECK: call i32 @__kmpc_single | ||
// CHECK: @_Z3barv | ||
// CHECK: call void @__kmpc_end_single | ||
// CHECK: ret void | ||
#endif |
53 changes: 53 additions & 0 deletions
53
clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// REQUIRES: amdgpu-registered-target | ||
|
||
// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc | ||
// RUN: %clang_cc1 -fopenmp -x c++ -w -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -target-cpu gfx906 -o - | FileCheck %s | ||
// expected-no-diagnostics | ||
|
||
#ifndef HEADER | ||
#define HEADER | ||
|
||
int amdgcn_device_isa_selected() { | ||
int threadCount = 0; | ||
|
||
#pragma omp target map(tofrom \ | ||
: threadCount) | ||
{ | ||
#pragma omp metadirective \ | ||
when(device = {isa("flat-address-space")} \ | ||
: parallel) default(single) | ||
threadCount++; | ||
} | ||
|
||
return threadCount; | ||
} | ||
|
||
// CHECK: define weak amdgpu_kernel void @__omp_offloading_{{.*}}amdgcn_device_isa_selected | ||
// CHECK: user_code.entry: | ||
// CHECK: call void @__kmpc_parallel_51 | ||
// CHECK-NOT: call i32 @__kmpc_single | ||
// CHECK: ret void | ||
|
||
int amdgcn_device_isa_not_selected() { | ||
int threadCount = 0; | ||
|
||
#pragma omp target map(tofrom \ | ||
: threadCount) | ||
{ | ||
#pragma omp metadirective \ | ||
when(device = {isa("sse")} \ | ||
: parallel) \ | ||
when(device = {isa("another-unsupported-gpu-feature")} \ | ||
: parallel) default(single) | ||
threadCount++; | ||
} | ||
|
||
return threadCount; | ||
} | ||
// CHECK: define weak amdgpu_kernel void @__omp_offloading_{{.*}}amdgcn_device_isa_not_selected | ||
// CHECK: user_code.entry: | ||
// CHECK: call i32 @__kmpc_single | ||
// CHECK-NOT: call void @__kmpc_parallel_51 | ||
// CHECK: ret void | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters