2019-07-05 03:00:52 +02:00
|
|
|
|
|
|
|
// Test library configuration for openmp.cfg
|
|
|
|
//
|
|
|
|
// Usage:
|
2023-01-26 22:28:04 +01:00
|
|
|
// $ cppcheck --check-library --library=openmp --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/openmp.c
|
2019-07-05 03:00:52 +02:00
|
|
|
// =>
|
|
|
|
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <omp.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
void validCode()
|
|
|
|
{
|
|
|
|
int arr[20] = { 0 };
|
|
|
|
#pragma omp parallel for
|
|
|
|
for (int i = 0; i < 20; ++i) {
|
2021-05-14 22:16:54 +02:00
|
|
|
// cppcheck-suppress unreadVariable
|
2019-07-05 03:00:52 +02:00
|
|
|
arr[i] = i * i;
|
|
|
|
}
|
|
|
|
|
|
|
|
char * pChars = (char *) omp_target_alloc(4, 1);
|
|
|
|
printf("pChars: %p", pChars);
|
|
|
|
omp_target_free(pChars, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void memleak_omp_target_alloc()
|
|
|
|
{
|
|
|
|
char * pChars = (char *) omp_target_alloc(2, 0);
|
|
|
|
printf("pChars: %p", pChars);
|
|
|
|
// cppcheck-suppress memleak
|
|
|
|
}
|