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
73 lines
2.1 KiB
C
73 lines
2.1 KiB
C
// RUN: %libomp-compile -D_GNU_SOURCE
|
|
// RUN: env KMP_AFFINITY=granularity=thread,compact %libomp-run
|
|
// RUN: env KMP_AFFINITY=granularity=core,compact %libomp-run
|
|
// RUN: env KMP_AFFINITY=granularity=socket,compact %libomp-run
|
|
// REQUIRES: linux
|
|
// UNSUPPORTED: linux
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "libomp_test_affinity.h"
|
|
#include "libomp_test_topology.h"
|
|
|
|
// Compare place lists. Make sure every place in p1 is in p2.
|
|
static int compare_places(const place_list_t *p1, const place_list_t *p2) {
|
|
int i, j;
|
|
for (i = 0; i < p1->num_places; ++i) {
|
|
int found = 0;
|
|
for (j = 0; j < p2->num_places; ++j) {
|
|
if (affinity_mask_equal(p1->masks[i], p2->masks[j])) {
|
|
found = 1;
|
|
break;
|
|
}
|
|
}
|
|
if (!found) {
|
|
printf("Found place in p1 not in p2!\n");
|
|
printf("p1 places:\n");
|
|
topology_print_places(p1);
|
|
printf("\n");
|
|
printf("p2 places:\n");
|
|
topology_print_places(p2);
|
|
return EXIT_FAILURE;
|
|
}
|
|
}
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
static int check_places() {
|
|
int status;
|
|
const char *value = getenv("KMP_AFFINITY");
|
|
if (!value) {
|
|
fprintf(stderr, "error: must set OMP_PLACES envirable for this test!\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
place_list_t *places, *openmp_places;
|
|
if (strstr(value, "socket")) {
|
|
places = topology_alloc_type_places(TOPOLOGY_OBJ_SOCKET);
|
|
} else if (strstr(value, "core")) {
|
|
places = topology_alloc_type_places(TOPOLOGY_OBJ_CORE);
|
|
} else if (strstr(value, "thread")) {
|
|
places = topology_alloc_type_places(TOPOLOGY_OBJ_THREAD);
|
|
} else {
|
|
fprintf(
|
|
stderr,
|
|
"error: KMP_AFFINITY granularity must be one of thread,core,socket!\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
openmp_places = topology_alloc_openmp_places();
|
|
status = compare_places(openmp_places, places);
|
|
topology_free_places(places);
|
|
topology_free_places(openmp_places);
|
|
return status;
|
|
}
|
|
|
|
int main() {
|
|
if (!topology_using_full_mask()) {
|
|
printf("Thread does not have access to all logical processors. Skipping "
|
|
"test.\n");
|
|
return EXIT_SUCCESS;
|
|
}
|
|
return check_places();
|
|
}
|