llvm-project/clang/test/OpenMP/declare_variant_device_isa_codegen_1.c
Alex Bradbury d9e986e915
[clang][OpenMP][test] Use x86_64-linux-gnu triple for test referencing avx512f feature (#111337)
This test passes as-is on non-X86 hosts only because almost no target
implements `isValidFeatureName` (the default implementation
unconditionally returns true). RISC-V does implement it, and like X86
checks that the feature name is one supported by the architecture. This
means the test creates an additional warning on RISC-V due to
`_attribute__((target("avx512f")))`.

The simple solution here is to just explicitly target x86_64-linux-gnu.
2024-10-07 11:47:15 +01:00

58 lines
3.1 KiB
C

// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-linux-gnu -emit-llvm %s -o - -fopenmp-version=45 | FileCheck %s --check-prefix=GENERIC
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=45 %s
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --check-prefix=GENERIC
// RUN: %clang_cc1 -target-feature +avx512f -verify -fopenmp -x c -triple x86_64-linux-gnu -emit-llvm %s -o - -fopenmp-version=45 | FileCheck %s --check-prefix=WITHFEATURE
// RUN: %clang_cc1 -target-feature +avx512f -fopenmp -x c++ -std=c++11 -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=45 %s
// RUN: %clang_cc1 -target-feature +avx512f -fopenmp -x c++ -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --check-prefix=WITHFEATURE
// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=GENERIC
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=GENERIC
// RUN: %clang_cc1 -target-feature +avx512f -verify -fopenmp -x c -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=WITHFEATURE
// RUN: %clang_cc1 -target-feature +avx512f -fopenmp -x c++ -std=c++11 -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t %s
// RUN: %clang_cc1 -target-feature +avx512f -fopenmp -x c++ -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=WITHFEATURE
// expected-no-diagnostics
// Test taken from PR46338 (by linna su)
#ifndef HEADER
#define HEADER
void base_saxpy(int, float, float *, float *);
void avx512_saxpy(int, float, float *, float *);
#pragma omp declare variant(avx512_saxpy) \
match(device = {isa(avx512f)})
void base_saxpy(int n, float s, float *x, float *y) {
#pragma omp parallel for
for (int i = 0; i < n; i++)
y[i] = s * x[i] + y[i];
}
void avx512_saxpy(int n, float s, float *x, float *y) {
#pragma omp parallel for simd simdlen(16) aligned(x, y : 64)
for (int i = 0; i < n; i++)
y[i] = s * x[i] + y[i];
}
void caller(int n, float s, float *x, float *y) {
// GENERIC: define {{.*}}void @{{.*}}caller
// GENERIC: call void @{{.*}}base_saxpy
// WITHFEATURE: define {{.*}}void @{{.*}}caller
// WITHFEATURE: call void @{{.*}}avx512_saxpy
base_saxpy(n, s, x, y);
}
__attribute__((target("avx512f"))) void variant_caller(int n, float s, float *x, float *y) {
// GENERIC: define {{.*}}void @{{.*}}variant_caller
// GENERIC: call void @{{.*}}avx512_saxpy
// WITHFEATURE: define {{.*}}void @{{.*}}variant_caller
// WITHFEATURE: call void @{{.*}}avx512_saxpy
base_saxpy(n, s, x, y);
}
#endif