Files
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

86 lines
2.3 KiB
C

// RUN: %libomp-compile-and-run
// UNSUPPORTED: gnu
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#define NTH 8
#define AL0 64
#define AL1 128
int main()
{
int err = 0;
omp_alloctrait_t at[3];
omp_allocator_handle_t a;
void *p[NTH];
at[0].key = omp_atk_pool_size;
at[0].value = 16*1024*1024;
at[1].key = omp_atk_fallback;
at[1].value = omp_atv_null_fb;
a = omp_init_allocator(omp_large_cap_mem_space, 2, at);
printf("allocator large created: %p\n", (void *)a);
#pragma omp parallel num_threads(8)
{
int i = omp_get_thread_num();
p[i] = omp_aligned_calloc(AL0, 1024*128, 8, a); // API's alignment only
#pragma omp barrier
printf("th %d, ptr %p\n", i, p[i]);
if ((size_t)p[i] % AL0) {
#pragma omp atomic
err++;
printf("Error param: th %d, ptr %p is not %d-byte aligned\n",
i, p[i], AL0);
}
omp_free(p[i], a);
}
omp_destroy_allocator(a);
at[2].key = omp_atk_alignment;
at[2].value = AL1;
a = omp_init_allocator(omp_large_cap_mem_space, 3, at);
printf("allocator large aligned %d created: %p\n", AL1, (void *)a);
if (a != omp_null_allocator)
#pragma omp parallel num_threads(8)
{
int i = omp_get_thread_num();
p[i] = omp_aligned_calloc(AL0, 1024*128, 8, a); // allocator's alignment wins
#pragma omp barrier
printf("th %d, ptr %p\n", i, p[i]);
if ((size_t)p[i] % AL1) {
#pragma omp atomic
err++;
printf("Error allocator: th %d, ptr %p is not %d-byte aligned\n",
i, p[i], AL1);
}
omp_free(p[i], a);
}
omp_destroy_allocator(a);
at[2].key = omp_atk_alignment;
at[2].value = AL0;
a = omp_init_allocator(omp_large_cap_mem_space, 3, at);
printf("allocator large aligned %d created: %p\n", AL0, (void *)a);
#pragma omp parallel num_threads(8)
{
int i = omp_get_thread_num();
p[i] = omp_aligned_calloc(AL1, 1024*128, 8, a); // API's alignment wins
#pragma omp barrier
printf("th %d, ptr %p\n", i, p[i]);
if ((size_t)p[i] % AL1) {
#pragma omp atomic
err++;
printf("Error param: th %d, ptr %p is not %d-byte aligned\n",
i, p[i], AL1);
}
omp_free(p[i], a);
}
omp_destroy_allocator(a);
if (err == 0) {
printf("passed\n");
return 0;
} else {
printf("failed\n");
return 1;
}
}