Anirban166 / Autocomment-atime-results

GitHub Action that automatically comments a plot and other atime-based results on PRs
https://github.com/marketplace/actions/autocomment-atime-results
0 stars 1 forks source link

Adding a step to repo-meta-tests.yaml @data.table to check for files where OpenMP is being currently used #31

Closed Anirban166 closed 7 months ago

Anirban166 commented 7 months ago

A working version with some toned-down constraints:

run: |
  # Filtering out all files that have OpenMP directives, capturing only the filename, and converting newlines to commas for awk processing:
  files_using_OpenMP=$(grep -Rl '#pragma omp' . | sed 's|./src/||' | tr '\n' ',')
  anchor_line="Internally parallelized code is used in the following places:"
  # Removing the existing list of C files:
  sed -i '' "/$anchor_line/,${/\.c$/d;}" testfile.Rd
  # Adding the updated list of file names:
  awk -v files_using_OpenMP="$files_using_OpenMP" -v anchor_line="$anchor_line" '{
    print;
    if ($0 ~ anchor_line) {
        n = split(files_using_OpenMP, lines, ",");
        for (i = 1; i <= n; i++) {
            if (lines[i] != "") print lines[i];
        }
    }
}' testfile.Rd > temporaryfile.md && mv temporaryfile.md testfile.Rd

testfile.Rd before:

Test to see if the replacement is done correctly.

Internally parallelized code is used in the following places:
froll.c

Test end.

testfile.Rd after:

Test to see if the replacement is done correctly.

Internally parallelized code is used in the following places:
forder.c
coalesce.c
gsumm.c
froll.c
nafill.c
between.c
fsort.c
frolladaptive.c
cj.c
types.c
fread.c
frollR.c
reorder.c
freadR.c
fifelse.c
fwrite.c
subset.c
froll.c

Test end.

I need to figure a way to do LaTeX patterns (since that's what used in man/openmp-utils.Rd), instead of using the end pattern in sed as that of files ending in .c.

Anirban166 commented 1 month ago

The filter can be extended further (from just #pragma omp to #pragma omp parallel or #pragma omp for) if we are just concerned about parallelization (and not stuff like critical sections and such, assuming one or two files might have just those)