Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI benchmark driver #138

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
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
34 changes: 29 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(BabelStream VERSION 4.0 LANGUAGES CXX)

# uncomment for debugging build issues:
#set(CMAKE_VERBOSE_MAKEFILE ON)
# set(CMAKE_VERBOSE_MAKEFILE ON)

option(WITH_MPI "Enable MPI" OFF)

# some nicer defaults for standard C++
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -67,6 +69,10 @@ hint_flag(CXX_EXTRA_LIBRARIES "
Use this for linking extra libraries (e.g `-lmylib`, or simply `mylib`)")
hint_flag(CXX_EXTRA_LINKER_FLAGS "
Append to linker flags (i.e GCC's `-Wl` or equivalent)")
hint_flag(MPI_CXX_FLAGS "
Append MPI flags to common compile flags.")
hint_flag(MPI_CXX_LINKER_FLAGS "
Append linking flags specific to MPI.")

# Honor user's CXX_EXTRA_LINK_FLAGS
set(CXX_EXTRA_LINK_FLAGS ${CXX_EXTRA_FLAGS} ${CXX_EXTRA_LINK_FLAGS})
Expand Down Expand Up @@ -140,10 +146,12 @@ message(STATUS "CXX Flags : ${CMAKE_CXX_FLAGS_${BUILD_TYPE}} ${ACTUAL_${BUILD_
Default = `${DEFAULT_${BUILD_TYPE}_FLAGS}`
Override (RELEASE_FLAGS) = `${${BUILD_TYPE}_FLAGS}`
Extras (CXX_EXTRA_FLAGS) = `${CXX_EXTRA_FLAGS}`")
message(STATUS "Link Flags : ${LINK_FLAGS} ${CXX_EXTRA_LINK_FLAGS}")
message(STATUS "Linker Flags: ${CMAKE_EXE_LINKER_FLAGS} ${CXX_EXTRA_LINKER_FLAGS} ")
message(STATUS "Defs : ${IMPL_DEFINITIONS}")
message(STATUS "Executable : ${EXE_NAME}")
message(STATUS "MPI CXX Flags : ${MPI_CXX_FLAGS}")
message(STATUS "Link Flags : ${LINK_FLAGS} ${CXX_EXTRA_LINK_FLAGS}")
message(STATUS "MPI Link Flags : ${MPI_CXX_LINKER_FLAGS}")
message(STATUS "Linker Flags : ${CMAKE_EXE_LINKER_FLAGS} ${CXX_EXTRA_LINKER_FLAGS} ")
message(STATUS "Defs : ${IMPL_DEFINITIONS}")
message(STATUS "Executable : ${EXE_NAME}")

# below we have all the usual CMake target setup steps

Expand All @@ -162,6 +170,22 @@ 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 requested, link relevant libraries
if (WITH_MPI)
add_definitions(-DUSE_MPI)
find_package(MPI)
if (MPI_FOUND)
message(STATUS "MPI requested and found. Linking relevant MPI libraries.")
target_link_libraries(${EXE_NAME} PUBLIC MPI::MPI_CXX)
elseif (MPI_CXX_FLAGS OR MPI_CXX_LINKER_FLAGS)
message(STATUS "MPI requested. Using provided MPI_CXX_FLAGS and MPI_CXX_LINKER_FLAGS.")
target_compile_options(${EXE_NAME} PUBLIC ${MPI_CXX_FLAGS})
target_link_libraries(${EXE_NAME} PUBLIC ${MPI_CXX_LINKER_FLAGS})
else ()
message(FATAL_ERROR "MPI requested, but no implementation has been detected. Please specify MPI_CXX_FLAGS and MPI_CXX_LINKER_FLAGS.")
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
if (COMMAND setup_target)
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