Skip to content

Commit

Permalink
Add MPI support
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgibson committed Oct 18, 2022
1 parent 0ed56af commit a33e593
Show file tree
Hide file tree
Showing 3 changed files with 247 additions and 112 deletions.
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ project(BabelStream VERSION 4.0 LANGUAGES CXX)
# uncomment for debugging build issues:
# set(CMAKE_VERBOSE_MAKEFILE ON)

option(WITH_MPI "Enable MPI" OFF)
find_package(MPI)

# some nicer defaults for standard C++
Expand Down Expand Up @@ -164,11 +165,16 @@ target_compile_options(${EXE_NAME} PUBLIC "$<$<CONFIG:Debug>:${ACTUAL_DEBUG_FLAG
target_link_options(${EXE_NAME} PUBLIC LINKER:${CXX_EXTRA_LINKER_FLAGS})
target_link_options(${EXE_NAME} PUBLIC ${LINK_FLAGS} ${CXX_EXTRA_LINK_FLAGS})

# If MPI is available, link relevant libraries
if(MPI_FOUND)
message(STATUS "MPI Detected. Linking relevant MPI libraries")
target_link_libraries(${EXE_NAME} PUBLIC MPI::MPI_CXX)
endif()
# If MPI is requested, link relevant libraries
if (WITH_MPI)
if (MPI_FOUND)
message(STATUS "MPI requested and found. Linking relevant MPI libraries.")
target_link_libraries(${EXE_NAME} PUBLIC MPI::MPI_CXX)
add_definitions(-DUSE_MPI)
else ()
message(FATAL_ERROR "MPI requested, but no implementation has been detected.")
endif ()
endif ()

# some models require the target to be already specified so they can finish their setup here
# this only happens if the model.cmake definition contains the `setup_target` macro
Expand Down
3 changes: 2 additions & 1 deletion src/hip/HIPStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ HIPStream<T>::HIPStream(const int ARRAY_SIZE, const int device_index)
check_error();

// Print out device information
std::cout << "Using HIP device " << getDeviceName(device_index) << std::endl;
std::cout << "Using HIP device " << getDeviceName(device_index)
<< " with index: " << device_index << std::endl;
std::cout << "Driver: " << getDeviceDriver(device_index) << std::endl;

array_size = ARRAY_SIZE;
Expand Down
Loading

0 comments on commit a33e593

Please sign in to comment.