CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
// clang-format off
|
|
// This test verifies correctness of Xteam Reduction when a pointer to a reduction
|
|
// variable is passed to a function. Currently, Xteam reduction does not kick in but
|
|
// the test executes successfully.
|
|
//
|
|
// RUN: %libomptarget-compile-generic -fopenmp-target-fast
|
|
// RUN: env LIBOMPTARGET_KERNEL_TRACE=1 %libomptarget-run-generic 2>&1 | %fcheck-generic
|
|
|
|
// UNSUPPORTED: nvptx64-nvidia-cuda
|
|
// UNSUPPORTED: nvptx64-nvidia-cuda-LTO
|
|
// UNSUPPORTED: aarch64-unknown-linux-gnu
|
|
// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
|
|
// UNSUPPORTED: x86_64-unknown-linux-gnu
|
|
// UNSUPPORTED: x86_64-unknown-linux-gnu-LTO
|
|
|
|
// clang-format on
|
|
|
|
#include <omp.h>
|
|
#include <stdio.h>
|
|
|
|
int compute_sum_res(int j, double *result, double a[]) {
|
|
*result += a[j];
|
|
return 1;
|
|
}
|
|
|
|
void compute_sum(int j, double *result, double a[]) { *result += a[j]; }
|
|
|
|
double compute_sum_rval(int j, double rval, double a[]) { return rval + a[j]; }
|
|
|
|
int foo(int i) { return 2 * i; }
|
|
|
|
int main() {
|
|
int N = 10000;
|
|
|
|
double a[N];
|
|
|
|
for (int i = 0; i < N; i++)
|
|
a[i] = i;
|
|
|
|
double sum1, sum2, sum3, sum4, sum5;
|
|
sum1 = sum2 = sum3 = sum4 = sum5 = 0;
|
|
|
|
int res = 0;
|
|
#pragma omp target teams distribute parallel for map(tofrom:sum1) reduction(+:sum1) map(tofrom:res)
|
|
for (int j = 0; j < N; j = j + 1)
|
|
res = compute_sum_res(j, &sum1, a);
|
|
|
|
#pragma omp target teams distribute parallel for reduction(+ : sum2)
|
|
for (int j = 0; j < N; j = j + 1)
|
|
compute_sum(j, &sum2, a);
|
|
|
|
#pragma omp target teams distribute parallel for reduction(+ : sum3)
|
|
for (int j = 0; j < N; j = j + 1)
|
|
sum3 = compute_sum_rval(j, *&sum3, a);
|
|
|
|
#pragma omp target teams distribute parallel for reduction(+ : sum4)
|
|
for (int j = 0; j < N; j = j + 1)
|
|
foo(compute_sum_res(j, &sum4, a));
|
|
|
|
#pragma omp target teams distribute parallel for reduction(+ : sum5)
|
|
for (int j = 0; j < N; j = j + 1)
|
|
compute_sum_res(j, &sum5, a);
|
|
|
|
printf("%f %f %f %f %f\n", sum1, sum2, sum3, sum4, sum5);
|
|
|
|
int rc = (sum1 != 49995000) || (sum2 != 49995000) || (sum3 != 49995000) ||
|
|
(sum4 != 49995000) || (sum5 != 49995000);
|
|
|
|
if (!rc)
|
|
printf("Success\n");
|
|
|
|
return rc;
|
|
}
|
|
|
|
/// CHECK: DEVID:[[S:[ ]*]][[DEVID:[0-9]+]] SGN:2
|
|
/// CHECK: DEVID:[[S:[ ]*]][[DEVID:[0-9]+]] SGN:2
|
|
/// CHECK: DEVID:[[S:[ ]*]][[DEVID:[0-9]+]] SGN:2
|
|
/// CHECK: DEVID:[[S:[ ]*]][[DEVID:[0-9]+]] SGN:2
|
|
/// CHECK: DEVID:[[S:[ ]*]][[DEVID:[0-9]+]] SGN:2
|