|
| 1 | +// Test for -mxnack/-mno-xnack and -msramecc/-mno-sramecc flags |
| 2 | + |
| 3 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a -mxnack %s 2>&1 | \ |
| 4 | +// RUN: FileCheck -check-prefix=XNACK-ON %s |
| 5 | +// XNACK-ON: "-target-feature" "+xnack" |
| 6 | + |
| 7 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a -mno-xnack %s 2>&1 | \ |
| 8 | +// RUN: FileCheck -check-prefix=XNACK-OFF %s |
| 9 | +// XNACK-OFF: "-target-feature" "-xnack" |
| 10 | + |
| 11 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a -msramecc %s 2>&1 | \ |
| 12 | +// RUN: FileCheck -check-prefix=SRAMECC-ON %s |
| 13 | +// SRAMECC-ON: "-target-feature" "+sramecc" |
| 14 | + |
| 15 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a -mno-sramecc %s 2>&1 | \ |
| 16 | +// RUN: FileCheck -check-prefix=SRAMECC-OFF %s |
| 17 | +// SRAMECC-OFF: "-target-feature" "-sramecc" |
| 18 | + |
| 19 | +// Test that target ID takes precedence over explicit flags |
| 20 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+ -mno-xnack %s 2>&1 | \ |
| 21 | +// RUN: FileCheck -check-prefix=TARGETID-OVERRIDES-XNACK %s |
| 22 | +// TARGETID-OVERRIDES-XNACK: "-target-feature" "+xnack" |
| 23 | + |
| 24 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack- -mxnack %s 2>&1 | \ |
| 25 | +// RUN: FileCheck -check-prefix=TARGETID-OVERRIDES-XNACK-OFF %s |
| 26 | +// TARGETID-OVERRIDES-XNACK-OFF: "-target-feature" "-xnack" |
| 27 | + |
| 28 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:sramecc+ -mno-sramecc %s 2>&1 | \ |
| 29 | +// RUN: FileCheck -check-prefix=TARGETID-OVERRIDES-SRAMECC %s |
| 30 | +// TARGETID-OVERRIDES-SRAMECC: "-target-feature" "+sramecc" |
| 31 | + |
| 32 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:sramecc- -msramecc %s 2>&1 | \ |
| 33 | +// RUN: FileCheck -check-prefix=TARGETID-OVERRIDES-SRAMECC-OFF %s |
| 34 | +// TARGETID-OVERRIDES-SRAMECC-OFF: "-target-feature" "-sramecc" |
| 35 | + |
| 36 | +// Test combining both flags |
| 37 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a -mxnack -msramecc %s 2>&1 | \ |
| 38 | +// RUN: FileCheck -check-prefixes=BOTH-ON %s |
| 39 | +// BOTH-ON: "-target-feature" "+xnack" |
| 40 | +// BOTH-ON-SAME: "-target-feature" "+sramecc" |
| 41 | + |
| 42 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a -mno-xnack -mno-sramecc %s 2>&1 | \ |
| 43 | +// RUN: FileCheck -check-prefixes=BOTH-OFF %s |
| 44 | +// BOTH-OFF: "-target-feature" "-xnack" |
| 45 | +// BOTH-OFF-SAME: "-target-feature" "-sramecc" |
| 46 | + |
| 47 | +// Test that target ID without explicit features doesn't synthesize flags |
| 48 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a %s 2>&1 | \ |
| 49 | +// RUN: FileCheck -check-prefix=NO-FEATURES %s |
| 50 | +// NO-FEATURES-NOT: "-target-feature" "{{[+-]}}xnack" |
| 51 | +// NO-FEATURES-NOT: "-target-feature" "{{[+-]}}sramecc" |
| 52 | + |
| 53 | +// Test target ID features are synthesized |
| 54 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+ %s 2>&1 | \ |
| 55 | +// RUN: FileCheck -check-prefix=TARGETID-XNACK %s |
| 56 | +// TARGETID-XNACK: "-target-feature" "+xnack" |
| 57 | + |
| 58 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:sramecc+ %s 2>&1 | \ |
| 59 | +// RUN: FileCheck -check-prefix=TARGETID-SRAMECC %s |
| 60 | +// TARGETID-SRAMECC: "-target-feature" "+sramecc" |
| 61 | + |
| 62 | +// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+:sramecc+ %s 2>&1 | \ |
| 63 | +// RUN: FileCheck -check-prefixes=TARGETID-BOTH %s |
| 64 | +// TARGETID-BOTH: "-target-feature" "+xnack" |
| 65 | +// TARGETID-BOTH-SAME: "-target-feature" "+sramecc" |
| 66 | + |
| 67 | +// |
| 68 | +// Offload tests |
| 69 | +// |
| 70 | + |
| 71 | +// Test offload with target ID features synthesized from --offload-arch |
| 72 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp --offload-arch=gfx90a:xnack+:sramecc- \ |
| 73 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=OMP-TARGETID %s |
| 74 | +// OMP-TARGETID: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" |
| 75 | +// OMP-TARGETID-SAME: "-target-feature" "+xnack" |
| 76 | +// OMP-TARGETID-SAME: "-target-feature" "-sramecc" |
| 77 | + |
| 78 | +// Test offload using -fopenmp-targets with target ID |
| 79 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \ |
| 80 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx908:xnack-:sramecc+ \ |
| 81 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=OMP-MARCH %s |
| 82 | +// OMP-MARCH: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx908" |
| 83 | +// OMP-MARCH-SAME: "-target-feature" "-xnack" |
| 84 | +// OMP-MARCH-SAME: "-target-feature" "+sramecc" |
| 85 | + |
| 86 | +// Test offload with explicit device flags using -Xopenmp-target |
| 87 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \ |
| 88 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx90a \ |
| 89 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -mxnack \ |
| 90 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -mno-sramecc \ |
| 91 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=OMP-FLAGS %s |
| 92 | +// OMP-FLAGS: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" |
| 93 | +// OMP-FLAGS-SAME: "-target-feature" "+xnack" |
| 94 | +// OMP-FLAGS-SAME: "-target-feature" "-sramecc" |
| 95 | + |
| 96 | +// Test offload with target ID taking precedence over explicit flags |
| 97 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \ |
| 98 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx90a:xnack- \ |
| 99 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -mxnack \ |
| 100 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=OMP-TARGETID-WINS %s |
| 101 | +// OMP-TARGETID-WINS: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" |
| 102 | +// OMP-TARGETID-WINS-SAME: "-target-feature" "-xnack" |
| 103 | + |
| 104 | +// Test offload using base architecture gfx90a with -mxnack flag for xnack+ |
| 105 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp \ |
| 106 | +// RUN: --offload-arch=gfx90a \ |
| 107 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -mxnack \ |
| 108 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=OMP-GFX90A-XNACK-ON %s |
| 109 | +// OMP-GFX90A-XNACK-ON: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" |
| 110 | +// OMP-GFX90A-XNACK-ON-SAME: "-target-feature" "+xnack" |
| 111 | + |
| 112 | +// Test offload using base architecture gfx90a with -mno-xnack flag for xnack- |
| 113 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp \ |
| 114 | +// RUN: --offload-arch=gfx90a \ |
| 115 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -mno-xnack \ |
| 116 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=OMP-GFX90A-XNACK-OFF %s |
| 117 | +// OMP-GFX90A-XNACK-OFF: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" |
| 118 | +// OMP-GFX90A-XNACK-OFF-SAME: "-target-feature" "-xnack" |
| 119 | + |
| 120 | +// Test offload with multiple device compilations for same base architecture. |
| 121 | +// To get both xnack+ and xnack- for gfx90a in the same invocation, you must use |
| 122 | +// target ID syntax in --offload-arch. |
| 123 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp \ |
| 124 | +// RUN: --offload-arch=gfx90a:xnack+ --offload-arch=gfx90a:xnack- -mxnack \ |
| 125 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=OMP-MULTI-XNACK %s |
| 126 | +// OMP-MULTI-XNACK: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" |
| 127 | +// OMP-MULTI-XNACK-SAME: "-target-feature" "+xnack" |
| 128 | +// OMP-MULTI-XNACK: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" |
| 129 | +// OMP-MULTI-XNACK-SAME: "-target-feature" "-xnack" |
| 130 | + |
| 131 | +// Test that -Xopenmp-target flags apply to all targets with matching triple. |
| 132 | +// When compiling for multiple different base architectures (gfx906, gfx90a), |
| 133 | +// -Xopenmp-target=amdgcn-amd-amdhsa applies the flag to all of them. |
| 134 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp \ |
| 135 | +// RUN: --offload-arch=gfx906 --offload-arch=gfx90a \ |
| 136 | +// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -mxnack \ |
| 137 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=OMP-MULTI-ARCH %s |
| 138 | +// OMP-MULTI-ARCH: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx906" |
| 139 | +// OMP-MULTI-ARCH-SAME: "-target-feature" "+xnack" |
| 140 | +// OMP-MULTI-ARCH: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" |
| 141 | +// OMP-MULTI-ARCH-SAME: "-target-feature" "+xnack" |
| 142 | + |
| 143 | +// Test that top-level -mxnack flags (not specified to the device are ignored). |
| 144 | +// TODO: Should this be forwarded? |
| 145 | +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp \ |
| 146 | +// RUN: --offload-arch=gfx90a -mxnack -mno-sramecc \ |
| 147 | +// RUN: -nogpulib %s 2>&1 | FileCheck -check-prefix=GENERIC-ARG %s |
| 148 | +// GENERIC-ARG: warning: argument unused during compilation: '-mxnack' |
| 149 | +// GENERIC-ARG: warning: argument unused during compilation: '-mno-sramecc' |
0 commit comments