Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new omp_set_nested_linter for C #6347

Merged
merged 7 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .ci/linters/c/omp_set_nested_linter.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ensure no calls to omp_set_nested() as
# i) it's hard to fully honor OMP_THREAD_LIMIT as required by CRAN, and
# ii) a simpler non-nested approach is always preferable if possible, as has been the case so far
omp_set_nested_linter = function(c_obj) {
idx = grep("omp_set_nested", c_obj$lines, fixed=TRUE)
if (!length(idx)) return()
stop(sprintf(
"In %s, found omp_set_nested() usage, please reconsider:\n%s",
c_obj$path, paste0(" ", format(idx), ":", c_obj$lines[idx], collapse = "\n")
))
}
5 changes: 0 additions & 5 deletions .dev/CRAN_Release.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ grep -RI --exclude-dir=".git" --exclude="*.md" --exclude="*~" --color='auto' -P
# Unicode is now ok. This unicode in tests.Rraw is passing on CRAN.
grep -RI --exclude-dir=".git" --exclude="*.md" --exclude="*~" --color='auto' -n "[\]u[0-9]" ./


# Ensure no calls to omp_set_nested() as i) it's hard to fully honor OMP_THREAD_LIMIT as required by CRAN, and
# ii) a simpler non-nested approach is always preferable if possible, as has been the case so far
grep omp_set_nested ./src/*.c

# Ensure no calls to omp_get_max_threads() also since access should be via getDTthreads()
grep --exclude="./src/openmp-utils.c" omp_get_max_threads ./src/*

Expand Down
1 change: 0 additions & 1 deletion src/myomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#define omp_get_max_threads() 1
#define omp_get_thread_limit() 1
#define omp_get_num_procs() 1
#define omp_set_nested(a) // empty statement to remove the call
#define omp_get_wtime() 0
#define MY_OPENMP 0
#endif
Expand Down
Loading