Page MenuHomePhabricator

[OpenMP] Add OpenMP 5.1 omp_calloc function implementation
ClosedPublic

Authored by Nawrin on Nov 6 2020, 1:07 PM.

Diff Detail

Event Timeline

Nawrin created this revision.Nov 6 2020, 1:07 PM
Nawrin requested review of this revision.Nov 6 2020, 1:07 PM
AndreyChurbanov added inline comments.Nov 9 2020, 6:54 AM
openmp/runtime/src/kmp_alloc.cpp
1448

This assertion is wrong, as the size is allowed to be 0. Please remove it.

1587

Both nmemb and size can be 0 and their type is unsigned. Please remove the assertions with them.

Nawrin updated this revision to Diff 304860.Nov 12 2020, 9:00 AM

Remove debug assert statements and added new test for size 0.

This revision is now accepted and ready to land.Nov 13 2020, 5:52 AM
This revision was automatically updated to reflect the committed changes.

Testing with cmake . -DOPENMP_TEST_FLAGS="-Werror -Wno-#warnings" && ninja check-libomp breaks for the newly added tests.

openmp/runtime/test/api/omp_calloc_def_fb.c
15

The compiler complains:

llvm-project/openmp/runtime/test/api/omp_calloc_def_fb.c:15:43: error: format specifies type 'void *' but the argument has underlying type 'unsigned long' [-Werror,-Wformat]
  printf("allocator large created: %p\n", a);
                                   ~~     ^
                                   %lu
openmp/runtime/test/api/omp_calloc_size_0.c
16

Similarly:

llvm-project/openmp/runtime/test/api/omp_calloc_size_0.c:16:43: error: format specifies type 'void *' but the argument has underlying type 'unsigned long' [-Werror,-Wformat]
  printf("allocator large created: %p\n", a);
                                   ~~     ^
                                   %lu

Cast to (void *) seems reasonable, if you want to print as a pointer.