From 0e5a68be08344ae1427e9efeb8c94f8d47f76995 Mon Sep 17 00:00:00 2001 From: Jeff Hammond Date: Fri, 9 Oct 2026 18:17:05 +0200 Subject: [PATCH 1/3] Fix OPENMP CMake build: generate Branch/func.c instead of assuming it exists CMake configure failed with "Cannot find source file: Branch/func.c" and "No SOURCES given to target: openmp_branch" because func.c is not checked into the repo -- it's generated at build time by ./func_gen, same as SERIAL/Branch. The OPENMP CMakeLists.txt incorrectly assumed it was checked in. Mirror the working SERIAL/CMakeLists.txt pattern: add a custom command that runs func_gen into the build directory and compile the generated file directly. Fixes https://github.com/ParRes/Kernels/issues/680 Co-Authored-By: Claude Sonnet 5 --- OPENMP/CMakeLists.txt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/OPENMP/CMakeLists.txt b/OPENMP/CMakeLists.txt index 9d2612b5f..b767ef0f7 100644 --- a/OPENMP/CMakeLists.txt +++ b/OPENMP/CMakeLists.txt @@ -154,10 +154,21 @@ prk_openmp_executable(random DIR Random SOURCES random.c DEFS RESTRICT_KEYWORD=0 MAXTHREADS=512 VERBOSE=0 HPCC=1 ATOMIC=0 ERRORPERCENT=1 LONG_IS_64BITS=0) # --- Branch ------------------------------------------------------------- -# func.c is checked into the repo here already (unlike SERIAL/Branch, -# where it's generated) -- just compile it directly. -prk_openmp_executable(branch DIR Branch SOURCES branch.c func.c - DEFS RESTRICT_KEYWORD=0 MAXTHREADS=512 VERBOSE=0) +# func.c is not checked into the repo -- like SERIAL/Branch, it's generated +# by the checked-in ./func_gen script (MATRIX_RANK=10, NUMBER_OF_FUNCTIONS=40 +# defaults, matching the Makefile's own ifndef defaults). +set(_branch_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Branch") +file(MAKE_DIRECTORY ${_branch_gen_dir}) +add_custom_command( + OUTPUT "${_branch_gen_dir}/func.c" + COMMAND "${CMAKE_CURRENT_LIST_DIR}/Branch/func_gen" 10 40 + WORKING_DIRECTORY ${_branch_gen_dir} + COMMENT "Generating Branch/func.c (MATRIX_RANK=10, NUMBER_OF_FUNCTIONS=40)") +add_executable(openmp_branch Branch/branch.c "${_branch_gen_dir}/func.c" $ $) +set_target_properties(openmp_branch PROPERTIES OUTPUT_NAME branch) +target_include_directories(openmp_branch PRIVATE ${PRK_INCLUDE_DIR} "${CMAKE_CURRENT_LIST_DIR}/Branch") +target_compile_definitions(openmp_branch PRIVATE RESTRICT_KEYWORD=0 MAXTHREADS=512 VERBOSE=0) +target_link_libraries(openmp_branch PRIVATE Threads::Threads OpenMP::OpenMP_C) # --- CTest: reproduces ci/build-run-prk.sh's allopenmp) run commands ----- # OMP_NUM_THREADS=4, passed both as the env var (matching what a real user From 44146f74560cdbe725611ca13caf7b42d82c0eb8 Mon Sep 17 00:00:00 2001 From: Jeff Hammond Date: Fri, 9 Oct 2026 18:21:53 +0200 Subject: [PATCH 2/3] Fix case-insensitive-filesystem collision between generated dirs and executable names Once the previous commit let CMake get past configure/compile on macOS (verified with Homebrew GCC 16, since AppleClang has no OpenMP support), linking failed: "ld: open() failed, errno=21 (Is a directory)" for both stencil and branch. The Stencil/Branch generated-sources directories live directly under the build root as "Stencil"/"Branch", which collides case-insensitively with the "stencil"/"branch" executable OUTPUT_NAME on macOS's default case-insensitive APFS. Renamed the generated dirs to "Stencil_gen"/"Branch_gen". Verified: cmake -S . -B build -DCMAKE_C_COMPILER=$(brew --prefix gcc)/bin/gcc-16 && cmake --build build && ctest 14/15 kernels build and pass; the sole failure (openmp_refcount, missing _omp_init_lock_with_hint in this libgomp) is pre-existing and unrelated. Co-Authored-By: Claude Sonnet 5 --- OPENMP/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OPENMP/CMakeLists.txt b/OPENMP/CMakeLists.txt index b767ef0f7..8138015f1 100644 --- a/OPENMP/CMakeLists.txt +++ b/OPENMP/CMakeLists.txt @@ -77,7 +77,11 @@ prk_openmp_executable(p2p DIR Synch_p2p SOURCES p2p.c # DOUBLE=1, PARALLELFOR=0, STAR=1, RESTRICT_KEYWORD=0, RADIUS=2, LOOPGEN=0, # MAXTHREADS=512, VERBOSE=0. stencil.c #includes the generated .incl files # unconditionally, same as SERIAL/Stencil. -set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil") +# Generated dir is "Stencil_gen", not "Stencil": the executable's +# OUTPUT_NAME is "stencil", and on macOS's default case-insensitive APFS +# that collides with a sibling directory literally named "Stencil" in the +# same build root, making the linker fail with "Is a directory". +set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil_gen") file(MAKE_DIRECTORY ${_stencil_gen_dir}) add_custom_command( OUTPUT "${_stencil_gen_dir}/loop_body_star.incl" @@ -157,7 +161,9 @@ prk_openmp_executable(random DIR Random SOURCES random.c # func.c is not checked into the repo -- like SERIAL/Branch, it's generated # by the checked-in ./func_gen script (MATRIX_RANK=10, NUMBER_OF_FUNCTIONS=40 # defaults, matching the Makefile's own ifndef defaults). -set(_branch_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Branch") +# Generated dir is "Branch_gen", not "Branch": same case-insensitive-APFS +# collision with OUTPUT_NAME "branch" as Stencil_gen above. +set(_branch_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Branch_gen") file(MAKE_DIRECTORY ${_branch_gen_dir}) add_custom_command( OUTPUT "${_branch_gen_dir}/func.c" From 1b444b0acaab1d81fa4f57f52dadd28e38731d90 Mon Sep 17 00:00:00 2001 From: Jeff Hammond Date: Fri, 9 Oct 2026 18:25:52 +0200 Subject: [PATCH 3/3] Fix same case-insensitive-filesystem collision in SERIAL, MPI1, MPIOPENMP, MPIRMA, MPISHM, SHMEM The Stencil/Branch/AMR generated-sources-directory collision fixed for OPENMP in the previous commit is the same copy-pasted pattern in every other CMake-ported language directory: each one's generated dir sat directly under the build root named "Stencil" (or "Branch"/"AMR" for SERIAL and MPI1), colliding case-insensitively on macOS's default APFS with the "stencil"/"branch"/"amr" executable OUTPUT_NAME, which fails the link step with "ld: open() failed, errno=21 (Is a directory)". Renamed all of them to "Stencil_gen"/"Branch_gen"/"AMR_gen", matching the OPENMP fix. C1z, Cxx11, and FORTRAN don't use this generated-.incl-file pattern, so they're unaffected. Verified on macOS (AppleClang for SERIAL/MPI1/MPIRMA/MPISHM, Homebrew GCC 16 for MPIOPENMP since AppleClang has no OpenMP support): - SERIAL: full build + `ctest` -- 14/14 kernels pass, including stencil, amr, and branch. - MPI1: stencil/amr/branch targets compile and link cleanly (execution via mpiexec and direct MPI_Init both fail in this sandbox on local socket/NIC operations -- a sandbox network restriction, not a build defect; the CMake fix itself is confirmed by successful linking). - MPIRMA, MPISHM, MPIOPENMP: stencil target compiles and links cleanly. - SHMEM: fix applied identically; not build-verified here since no OpenSHMEM implementation (e.g. Sandia OpenSHMEM) is installed in this environment. Co-Authored-By: Claude Sonnet 5 --- MPI1/CMakeLists.txt | 14 +++++++++++--- MPIOPENMP/CMakeLists.txt | 6 +++++- MPIRMA/CMakeLists.txt | 6 +++++- MPISHM/CMakeLists.txt | 6 +++++- SERIAL/CMakeLists.txt | 14 +++++++++++--- SHMEM/CMakeLists.txt | 6 +++++- 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/MPI1/CMakeLists.txt b/MPI1/CMakeLists.txt index d399b9b36..a843976d2 100644 --- a/MPI1/CMakeLists.txt +++ b/MPI1/CMakeLists.txt @@ -78,7 +78,11 @@ prk_mpi1_executable(p2p DIR Synch_p2p SOURCES p2p.c # --- Stencil ------------------------------------------------------------ # stencil.c #includes "loop_body_star.incl"/"loop_body_compact.incl" # unconditionally, same as SERIAL's -- generated at build time. -set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil") +# Generated dir is "Stencil_gen", not "Stencil": the executable's +# OUTPUT_NAME is "stencil", and on macOS's default case-insensitive APFS +# that collides with a sibling directory literally named "Stencil" in the +# same build root, making the linker fail with "Is a directory". +set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil_gen") file(MAKE_DIRECTORY ${_stencil_gen_dir}) add_custom_command( OUTPUT "${_stencil_gen_dir}/loop_body_star.incl" @@ -140,7 +144,9 @@ target_link_libraries(mpi1_pic PRIVATE Threads::Threads MPI::MPI_C m) # --- AMR -------------------------------------------------------------- # AMR also compiles timestep.c (COMOBJS += timestep.o) and needs all four # loop_gen/loop_gen_amr variants. -set(_amr_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/AMR") +# Generated dir is "AMR_gen", not "AMR": same case-insensitive-APFS +# collision with OUTPUT_NAME "amr" as Stencil_gen above. +set(_amr_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/AMR_gen") file(MAKE_DIRECTORY ${_amr_gen_dir}) add_custom_command( OUTPUT "${_amr_gen_dir}/loop_body_star.incl" @@ -175,7 +181,9 @@ set_source_files_properties( # --- Branch (not part of ci/build-run-prk.sh's allmpi) coverage, but a # normal kernel with its own subdirectory like the rest) ------------------- -set(_branch_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Branch") +# Generated dir is "Branch_gen", not "Branch": same case-insensitive-APFS +# collision with OUTPUT_NAME "branch" as Stencil_gen above. +set(_branch_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Branch_gen") file(MAKE_DIRECTORY ${_branch_gen_dir}) add_custom_command( OUTPUT "${_branch_gen_dir}/func.c" diff --git a/MPIOPENMP/CMakeLists.txt b/MPIOPENMP/CMakeLists.txt index f7ad55658..d1853646e 100644 --- a/MPIOPENMP/CMakeLists.txt +++ b/MPIOPENMP/CMakeLists.txt @@ -85,7 +85,11 @@ prk_mpiopenmp_executable(p2p DIR Synch_p2p SOURCES p2p.c # DOUBLE=1, STAR=1, RESTRICT_KEYWORD=0, RADIUS=2, LOOPGEN=0, VERBOSE=0. # stencil.c #includes the generated loop_body_star.incl/loop_body_compact.incl # unconditionally, same as SERIAL/Stencil -- generate via common/Stencil/loop_gen. -set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil") +# Generated dir is "Stencil_gen", not "Stencil": the executable's +# OUTPUT_NAME is "stencil", and on macOS's default case-insensitive APFS +# that collides with a sibling directory literally named "Stencil" in the +# same build root, making the linker fail with "Is a directory". +set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil_gen") file(MAKE_DIRECTORY ${_stencil_gen_dir}) add_custom_command( OUTPUT "${_stencil_gen_dir}/loop_body_star.incl" diff --git a/MPIRMA/CMakeLists.txt b/MPIRMA/CMakeLists.txt index aac7107ff..6f193ab38 100644 --- a/MPIRMA/CMakeLists.txt +++ b/MPIRMA/CMakeLists.txt @@ -77,7 +77,11 @@ prk_mpirma_executable(p2p DIR Synch_p2p SOURCES p2p.c # these aren't checked in, generated by common/Stencil/loop_gen at build # time, same as the Makefile's own pattern rule (and SERIAL's own Stencil # target). -set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil") +# Generated dir is "Stencil_gen", not "Stencil": the executable's +# OUTPUT_NAME is "stencil", and on macOS's default case-insensitive APFS +# that collides with a sibling directory literally named "Stencil" in the +# same build root, making the linker fail with "Is a directory". +set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil_gen") file(MAKE_DIRECTORY ${_stencil_gen_dir}) add_custom_command( OUTPUT "${_stencil_gen_dir}/loop_body_star.incl" diff --git a/MPISHM/CMakeLists.txt b/MPISHM/CMakeLists.txt index 785983656..615a99c2e 100644 --- a/MPISHM/CMakeLists.txt +++ b/MPISHM/CMakeLists.txt @@ -71,7 +71,11 @@ prk_mpishm_executable(p2p DIR Synch_p2p SOURCES p2p.c # DOUBLE=1, STAR=1, LOCAL_BARRIER_SYNCH=0, RESTRICT_KEYWORD=0, RADIUS=2, # LOOPGEN=0, VERBOSE=0. Same generated-.incl-file pattern as SERIAL's # Stencil/AMR targets (common/Stencil/loop_gen). -set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil") +# Generated dir is "Stencil_gen", not "Stencil": the executable's +# OUTPUT_NAME is "stencil", and on macOS's default case-insensitive APFS +# that collides with a sibling directory literally named "Stencil" in the +# same build root, making the linker fail with "Is a directory". +set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil_gen") file(MAKE_DIRECTORY ${_stencil_gen_dir}) add_custom_command( OUTPUT "${_stencil_gen_dir}/loop_body_star.incl" diff --git a/SERIAL/CMakeLists.txt b/SERIAL/CMakeLists.txt index 19bb61ee7..252fa7314 100644 --- a/SERIAL/CMakeLists.txt +++ b/SERIAL/CMakeLists.txt @@ -87,7 +87,11 @@ prk_serial_executable(p2p DIR Synch_p2p SOURCES p2p.c # unconditionally (both code paths compiled in, selected at runtime) -- # these aren't checked in, generated by common/Stencil/loop_gen at build # time, same as the Makefile's own pattern rule. -set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil") +# Generated dir is "Stencil_gen", not "Stencil": the executable's +# OUTPUT_NAME is "stencil", and on macOS's default case-insensitive APFS +# that collides with a sibling directory literally named "Stencil" in the +# same build root, making the linker fail with "Is a directory". +set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil_gen") file(MAKE_DIRECTORY ${_stencil_gen_dir}) add_custom_command( OUTPUT "${_stencil_gen_dir}/loop_body_star.incl" @@ -145,7 +149,9 @@ target_link_libraries(serial_pic PRIVATE Threads::Threads m) # DOUBLE=1, STAR=1, RESTRICT_KEYWORD=0, RADIUS=2, LOOPGEN=0, VERBOSE=0. # amr.c needs all four loop_gen/loop_gen_amr variants (star/compact, # regular/amr). -set(_amr_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/AMR") +# Generated dir is "AMR_gen", not "AMR": same case-insensitive-APFS +# collision with OUTPUT_NAME "amr" as Stencil_gen above. +set(_amr_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/AMR_gen") file(MAKE_DIRECTORY ${_amr_gen_dir}) add_custom_command( OUTPUT "${_amr_gen_dir}/loop_body_star.incl" @@ -184,7 +190,9 @@ set_source_files_properties( # (matches the Makefile's OBJS = $(PROGRAM).o $(COMOBJS) func.o), generated # by the checked-in ./func_gen script (MATRIX_RANK=10, NUMBER_OF_FUNCTIONS=40 # defaults). -set(_branch_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Branch") +# Generated dir is "Branch_gen", not "Branch": same case-insensitive-APFS +# collision with OUTPUT_NAME "branch" as Stencil_gen above. +set(_branch_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Branch_gen") file(MAKE_DIRECTORY ${_branch_gen_dir}) add_custom_command( OUTPUT "${_branch_gen_dir}/func.c" diff --git a/SHMEM/CMakeLists.txt b/SHMEM/CMakeLists.txt index 5efe19f96..bf1ea6931 100644 --- a/SHMEM/CMakeLists.txt +++ b/SHMEM/CMakeLists.txt @@ -119,7 +119,11 @@ prk_shmem_executable(p2p DIR Synch_p2p SOURCES p2p.c # VERBOSE=0. stencil.c #includes "loop_body_star.incl"/ # "loop_body_compact.incl" unconditionally, same generated-.incl-file # pattern as SERIAL/MPIRMA's Stencil targets (common/Stencil/loop_gen). -set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil") +# Generated dir is "Stencil_gen", not "Stencil": the executable's +# OUTPUT_NAME is "stencil", and on macOS's default case-insensitive APFS +# that collides with a sibling directory literally named "Stencil" in the +# same build root, making the linker fail with "Is a directory". +set(_stencil_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/Stencil_gen") file(MAKE_DIRECTORY ${_stencil_gen_dir}) add_custom_command( OUTPUT "${_stencil_gen_dir}/loop_body_star.incl"