Skip to content

Commit

Permalink
cleaned CMake and added Matar package capabilities to EVPFFT standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
djdunning committed Nov 16, 2023
1 parent f36313e commit 8dda60f
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 27 deletions.
15 changes: 0 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,6 @@ endif()
find_package(Trilinos REQUIRED)
find_package(Elements REQUIRED)

#if(BUILD_ELEMENTS)
# include_directories(lib/Elements)
# add_subdirectory(lib/Elements)
# set(ELEMENTS_DIRS matar/src elements swage common geometry slam)

# foreach(DIR ${ELEMENTS_DIRS})
# include_directories(lib/Elements/${DIR})
# endforeach()

# foreach(DIR ${ELEMENTS_DIRS})
# add_subdirectory(lib/Elements/${DIR})
# endforeach()
# add_subdirectory(lib/Elements/mesh_tools)
#endif()

include_directories(src)
add_subdirectory(src)

Expand Down
16 changes: 5 additions & 11 deletions src/EVPFFT/scripts/build-scripts/build_evpfft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,23 @@ source "$KOKKOS_CONFIG_SCRIPT" --kokkos_build_type=$kokkos_build_type --num_jobs
HDF5_CONFIG_SCRIPT="$PARENT_DIR/scripts/install-scripts/install_hdf5.sh"
source "$HDF5_CONFIG_SCRIPT" --num_jobs=$num_jobs

# Check if the 'MATAR' directory exists in the parent directory; if not, clone it
MATAR_DIR="$PARENT_DIR/MATAR"
if [ ! -d "$MATAR_DIR" ]; then
echo "Directory 'MATAR' does not exist in '$PARENT_DIR', downloading 'MATAR'...."
git clone https://github.com/lanl/MATAR.git "$MATAR_DIR"
else
echo "Directory 'MATAR' exists in '$PARENT_DIR', skipping 'MATAR' download"
fi
# --------building matar
MATAR_CONFIG_SCRIPT="$PARENT_DIR/scripts/install-scripts/install_matar.sh"
source "$MATAR_CONFIG_SCRIPT" --kokkos_build_type=$kokkos_build_type --num_jobs=$num_jobs

# --------building EVPFFT
EVPFFT_SOURCE_DIR="$PARENT_DIR/src"
EVPFFT_BUILD_DIR="$PARENT_DIR/evpfft_${heffte_build_type}_${kokkos_build_type}"
HEFFTE_INSTALL_DIR="$PARENT_DIR/heffte/install_heffte_$heffte_build_type"
KOKKOS_INSTALL_DIR="$PARENT_DIR/kokkos/install_kokkos_$kokkos_build_type"
MATAR_INSTALL_DIR="$PARENT_DIR/MATAR/install_MATAR_$kokkos_build_type"
HDF5_INSTALL_DIR="$PARENT_DIR/hdf5/install"
MATAR_SOURCE_DIR="$PARENT_DIR/MATAR/src"


# Configure EVPFFT using CMake
cmake_options=(
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_PREFIX_PATH="$HEFFTE_INSTALL_DIR;$KOKKOS_INSTALL_DIR;$HDF5_INSTALL_DIR"
-D CMAKE_CXX_FLAGS="-I$MATAR_SOURCE_DIR"
-D CMAKE_PREFIX_PATH="$HEFFTE_INSTALL_DIR;$KOKKOS_INSTALL_DIR;$HDF5_INSTALL_DIR;$MATAR_INSTALL_DIR"
-D ENABLE_PROFILING=ON
)

Expand Down
116 changes: 116 additions & 0 deletions src/EVPFFT/scripts/install-scripts/install_matar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash -e


#!/bin/bash -e

show_help() {
echo "Usage: source $(basename "$BASH_SOURCE") [OPTION]"
echo "Valid options:"
echo " --kokkos_build_type=<serial|openmp|pthreads|cuda|hip>"
echo " --num_jobs=<number>: Number of jobs for 'make' (default: 1, on Mac use 1)"
echo " --help: Display this help message"
return 1
}

# Initialize variables with default values
kokkos_build_type=""
num_jobs=1

# Define arrays of valid options
valid_kokkos_build_types=("serial" "openmp" "pthreads" "cuda" "hip")

# Parse command line arguments
for arg in "$@"; do
case "$arg" in
--kokkos_build_type=*)
option="${arg#*=}"
if [[ " ${valid_kokkos_build_types[*]} " == *" $option "* ]]; then
kokkos_build_type="$option"
else
echo "Error: Invalid --kokkos_build_type specified."
show_help
return 1
fi
;;
--num_jobs=*)
num_jobs="${arg#*=}"
if ! [[ "$num_jobs" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid --num_jobs value. Must be a positive integer."
show_help
return 1
fi
;;
--help)
show_help
return 1
;;
*)
echo "Error: Invalid argument or value specified."
show_help
return 1
;;
esac
done

# Check if required options are specified
if [ -z "$kokkos_build_type" ]; then
echo "Error: --kokkos_build_type is a required options."
show_help
return 1
fi

# Now you can use $kokkos_build_type in your code or build commands
echo "Kokkos build type will be: $kokkos_build_type"

# Determine the script's directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Script location: $SCRIPT_DIR"

# Determine the parent directory of the script's directory
PARENT_DIR=$(dirname $(dirname "${SCRIPT_DIR}"))

# Check if the 'MATAR' directory exists in the parent directory; if not, clone it
MATAR_DIR="$PARENT_DIR/MATAR"
if [ ! -d "$MATAR_DIR" ]; then
echo "Directory 'MATAR' does not exist in '$PARENT_DIR', downloading 'MATAR'...."
git clone https://github.com/lanl/MATAR.git "$MATAR_DIR"
else
echo "Directory 'MATAR' exists in '$PARENT_DIR', skipping 'MATAR' download"
fi

# Define kokkos directories
MATAR_SOURCE_DIR="$PARENT_DIR/MATAR"
MATAR_INSTALL_DIR="$PARENT_DIR/MATAR/install_MATAR_$kokkos_build_type"
MATAR_BUILD_DIR="$PARENT_DIR/MATAR/build_MATAR_$kokkos_build_type"
KOKKOS_INSTALL_DIR="${PARENT_DIR}/kokkos/install_kokkos_$kokkos_build_type"

cmake_options=(
-D CMAKE_INSTALL_PREFIX="${MATAR_INSTALL_DIR}"
-D CMAKE_PREFIX_PATH="${KOKKOS_INSTALL_DIR}"
)

if [ "$kokkos_build_type" = "none" ]; then
cmake_options+=(
-D Matar_ENABLE_KOKKOS=OFF
)
else
cmake_options+=(
-D Matar_ENABLE_KOKKOS=ON
)
fi

# Print CMake options for reference
echo "CMake Options: ${cmake_options[@]}"

# Configure Matar
cmake "${cmake_options[@]}" -B "${MATAR_BUILD_DIR}" -S "${MATAR_SOURCE_DIR}"

# Build Matar
echo "Building Matar..."
make -C ${MATAR_BUILD_DIR} -j"$num_jobs"

# Install Matar
echo "Installing Matar..."
make -C ${MATAR_BUILD_DIR} install

echo "Matar installation complete"
3 changes: 2 additions & 1 deletion src/EVPFFT/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ if (BUILD_EVPFFT_FIERRO)
target_include_directories(${This} PUBLIC Fierro-EVPFFT-Link)
target_include_directories(${This} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
else ()
find_package(Matar REQUIRED)
add_executable(${This} ${Sources})
target_link_libraries(${This} PRIVATE Kokkos::kokkos)
target_link_libraries(${This} PRIVATE matar Kokkos::kokkos)
endif ()
target_link_libraries(${This} PRIVATE Heffte::Heffte MPI::MPI_CXX ${HDF5_LIBRARIES})

Expand Down

0 comments on commit 8dda60f

Please sign in to comment.