Skip to content
Open
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
35 changes: 35 additions & 0 deletions palace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,41 @@ if(NOT GIT_COMMIT_ID MATCHES "NOTFOUND")
)
endif()


# For each dependency with a git SHA, set a compile definition <DEPENDENCY>_COMMIT_SHA
set(dependency_folders
STRUMPACK
arpack-ng
eigen
fmt
gslib
hypre
json
libCEED
libxsmm
magma
metis
mfem
mumps
parmetis
petsc
scalapack
scn
slepc
sundials
superlu_dist
)
foreach(dep_folder IN LISTS dependency_folders)
message(DEBUG "Checking dependency in folder ${dep_folder}")
get_dependency_git_sha("${CMAKE_BINARY_DIR}/../extern/${dep_folder}" dep_sha)
message(DEBUG "Git SHA for ${dep_folder}: ${dep_sha}")
string(REPLACE "-" "_" dep_folder_sanitized "${dep_folder}")
set_property(
SOURCE ${CMAKE_SOURCE_DIR}/main.cpp
APPEND PROPERTY COMPILE_DEFINITIONS "${dep_folder_sanitized}_COMMIT_SHA=\"${dep_sha}\""
)
endforeach()

# Check C++ compiler support for constexpr std::sqrt and std::filesystem
include(CheckCompilerFeatureSupport)
if(NOT DEFINED STD_FS_LIBRARIES_CACHE)
Expand Down
27 changes: 27 additions & 0 deletions palace/cmake/GetGitDescription.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,30 @@ function(git_describe _var)
set(${_var} "${out}" PARENT_SCOPE)
endif()
endfunction()


# Helper to get git SHA for a dependency
function(get_dependency_git_sha dep_source_dir _var)
find_package(Git QUIET)
if(NOT GIT_FOUND)
message(WARNING "Git not found, cannot get SHA for ${dep_source_dir}")
return()
endif()

# Run git describe in the given source directory
# Do not consider parent directories (--git-dir .git)
execute_process(
COMMAND "${GIT_EXECUTABLE}" --git-dir .git describe --tags --always --dirty
WORKING_DIRECTORY "${dep_source_dir}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT res EQUAL 0)
message(DEBUG "Git SHA for not found in ${dep_source_dir}")
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
else()
message(DEBUG "Git SHA for ${dep_name_source_dir}: ${out}")
set(${_var} ${out} PARENT_SCOPE)
endif()
endfunction()
51 changes: 48 additions & 3 deletions palace/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,51 @@ static const char *GetPalaceGitTag()
return commit;
}

static void PrintPalaceVersionInfo(MPI_Comm comm)
{

if (std::strcmp(GetPalaceGitTag(), "UNKNOWN"))
{
Mpi::Print(comm, "Git commit: {}\n", GetPalaceGitTag());
}

Mpi::Print(comm, "\nBuild dependencies:\n");

// X-macro to check if a dependency macro is defined and print the SHA
#define X(DEP_NAME) \
Mpi::Print(comm, " " #DEP_NAME ": {}\n", DEP_NAME ## _COMMIT_SHA);

// List of dependencies and their corresponding macros
#define PRINT_DEP_SHA_LIST \
X(STRUMPACK) \
X(arpack_ng) \
X(eigen) \
X(fmt) \
X(gslib) \
X(hypre) \
X(json) \
X(libCEED) \
X(libxsmm) \
X(magma) \
X(metis) \
X(mfem) \
X(mumps) \
X(parmetis) \
X(petsc) \
X(scalapack) \
X(scn) \
X(slepc) \
X(sundials) \
X(superlu_dist)

// Iterate over the list and print if macro is defined
PRINT_DEP_SHA_LIST

#undef X


}

static const char *GetPalaceCeedJitSourceDir()
{
#if defined(PALACE_LIBCEED_JIT_SOURCE)
Expand Down Expand Up @@ -179,7 +224,7 @@ int main(int argc, char *argv[])
"Usage: {} [OPTIONS] CONFIG_FILE\n\n"
"Options:\n"
" -h, --help Show this help message and exit\n"
" --version Show version information and exit\n"
" -V, --version Show version information and exit\n"
" -dry-run, --dry-run Parse configuration file for errors and exit\n\n",
executable_path.substr(executable_path.find_last_of('/') + 1));
};
Expand All @@ -191,9 +236,9 @@ int main(int argc, char *argv[])
Help();
return 0;
}
if (argv_i == "--version")
if ((argv_i == "-V") || (argv_i == "--version"))
{
Mpi::Print(world_comm, "Palace version: {}\n", GetPalaceGitTag());
PrintPalaceVersionInfo(world_comm);
return 0;
}
if ((argv_i == "-dry-run") || (argv_i == "--dry-run"))
Expand Down
13 changes: 12 additions & 1 deletion scripts/palace
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Wrapper for launching Palace using MPI

Options:
-h, --help Show this help message and exit
-V, --version Show version information and exit
-dry-run, --dry-run Parse configuration file for errors and exit
-serial, --serial Call Palace without MPI launcher, default is false
-np, --np NUM_PROCS How many MPI processes to use, default is 1
Expand All @@ -23,6 +24,7 @@ Options:

# Parse arguments
DRY_RUN=""
VERSION=""
SERIAL="false"
NUM_PROCS="1"
NUM_THREADS=""
Expand All @@ -36,6 +38,10 @@ while [[ $# -gt 0 ]]; do
help
exit 0
;;
-V|--version)
VERSION="--version"
shift
;;
-dry-run|--dry-run)
DRY_RUN="--dry-run"
shift
Expand Down Expand Up @@ -77,7 +83,7 @@ done
set -- "${POSITIONAL[@]}" # Restore positional parameters

# Check arguments: Config file and everything remaining is passed to Palace binary
if [[ -z "$@" ]]; then
if [[ -z "$@" && -z "$VERSION" ]]; then
help
exit 1
else
Expand Down Expand Up @@ -116,6 +122,11 @@ if [[ -n "$DRY_RUN" ]]; then
PALACE="$PALACE $DRY_RUN"
fi

# Configure --version
if [[ -n "$VERSION" ]]; then
PALACE="$PALACE $VERSION"
fi

# Configure OpenMP threads
NUM_THREADS_BACKUP=$OMP_NUM_THREADS
if [[ -z "$NUM_THREADS" ]]; then
Expand Down