Changeset View
Changeset View
Standalone View
Standalone View
openmp/runtime/test/api/omp_calloc_size_0.c
// RUN: %libomp-compile-and-run | // RUN: %libomp-compile-and-run | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <omp.h> | #include <omp.h> | ||||
int main() | int main() | ||||
{ | { | ||||
omp_alloctrait_t at[2]; | omp_alloctrait_t at[2]; | ||||
omp_allocator_handle_t a; | omp_allocator_handle_t a; | ||||
void *p[2]; | void *p[2]; | ||||
at[0].key = omp_atk_pool_size; | at[0].key = omp_atk_pool_size; | ||||
at[0].value = 2*1024*1024; | at[0].value = 2*1024*1024; | ||||
at[1].key = omp_atk_fallback; | at[1].key = omp_atk_fallback; | ||||
at[1].value = omp_atv_default_mem_fb; | at[1].value = omp_atv_default_mem_fb; | ||||
a = omp_init_allocator(omp_large_cap_mem_space, 2, at); | a = omp_init_allocator(omp_large_cap_mem_space, 2, at); | ||||
printf("allocator large created: %p\n", a); | printf("allocator large created: %p\n", (void *)a); | ||||
#pragma omp parallel num_threads(2) | #pragma omp parallel num_threads(2) | ||||
{ | { | ||||
int i = omp_get_thread_num(); | int i = omp_get_thread_num(); | ||||
p[i] = omp_calloc(1024, 0, a); | p[i] = omp_calloc(1024, 0, a); | ||||
#pragma omp barrier | #pragma omp barrier | ||||
printf("th %d, ptr %p\n", i, p[i]); | printf("th %d, ptr %p\n", i, p[i]); | ||||
omp_free(p[i], a); | omp_free(p[i], a); | ||||
} | } | ||||
Show All 9 Lines |