Skip to content

Commit

Permalink
Addendum Cholesky Benchmark and GPU AMD with Specx
Browse files Browse the repository at this point in the history
  • Loading branch information
lemoinep committed Apr 26, 2024
1 parent fdc0980 commit 0cc9d89
Show file tree
Hide file tree
Showing 7 changed files with 2,261 additions and 0 deletions.
190 changes: 190 additions & 0 deletions src/Benchmark/Cholesky/Cholesky_GPU_HIP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@


project(main)

cmake_minimum_required(VERSION 3.22)

#set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Release)



#set(CMAKE_CXX_COMPILER "/usr/local/bin/g++")
#set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
#set(CMAKE_CXX_STANDARD 23)

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MD /02")
#string(REGEX REPLACE "/MD" "/02" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")


if(FALSE)
find_package(MPI REQUIRED)
if (MPI_FOUND)
MESSAGE("{MPI_CXX_LIBRARIES}")
else (MPI_FOUND)
MESSAGE (SEND_ERROR "This application cannot compile without MPI")
endif(MPI_FOUND)
endif()

if(FALSE)
find_package(OpenMP)
if (OpenMP_CXX_FOUND)
MESSAGE("{OpenMP_CXX_LIBRARIES}")
else (OpenMP_CXX_FOUND)
MESSAGE (SEND_ERROR "This application cannot compile without OpenMP")
endif(OpenMP_CXX_FOUND)
endif()

if(FALSE)
find_package(CUDA REQUIRED)
if (CUDA_FOUND)
MESSAGE("{CUDA_CXX_LIBRARIES}")
MESSAGE(STATUS "Found headers CUDA : ${CUDA_INCLUDE_DIRS}")
MESSAGE(STATUS "Found lib CUDA : ${CUDA_LIBRARIES}")
MESSAGE(STATUS "Found CUDA nvcc : ${CUDA_NVCC_EXECUTABLE}")
else (CUDA_FOUND)
MESSAGE (SEND_ERROR "This application cannot compile without CUDA")
endif(CUDA_FOUND)

add_definitions(-D_FORCE_INLINES)
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --gpu-architecture sm_21 -std=c++11)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -O3 )
endif()


if(TRUE)
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
message("${CMAKE_MODULE_PATH}")
message("${EIGEN3_INCLUDE_DIR}")
endif()


#set(THREADS_PREFER_PTHREAD_FLAG ON)
#find_package(Threads REQUIRED)
find_package(Threads)


#find_package(TBB REQUIRED)
#if (TBB_FOUND)
# MESSAGE("{TBB_CXX_LIBRARIES}")
#endif(TBB_FOUND)


MESSAGE("{COMPILE_WITH_HIP}")
#include_directories(/opt/rocm/hip/include)
include_directories(/opt/rocm-5.7.2/hip/include)
#list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
list(APPEND CMAKE_PREFIX_PATH /opt/rocm-5.7.2 /opt/rocm-5.7.2)
# Find hip
#find_package(hip)
# Set the GPU to compile for
#set(GPU_TARGETS "gfx900:gfx906:gfx1032;gfx1035" CACHE STRING "GPU targets to compile for")

set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIMES "HIP" "CUDA")
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})

if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
set(ERROR_MESSAGE "GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA.")
message(FATAL_ERROR ${ERROR_MESSAGE})
endif()

enable_language(${GPU_RUNTIME})

set(CMAKE_${GPU_RUNTIME}_STANDARD 17)
set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)

#set(ROCM_ROOT "/opt/rocm" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT "/opt/rocm-5.7.2" CACHE PATH "Root directory of the ROCm installation")
list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")


message(CURRENT DIR= [${CMAKE_CURRENT_SOURCE_DIR}])

#BEGIN::SPECX

file(GLOB_RECURSE Specx_list
#"${CMAKE_CURRENT_SOURCE_DIR}/../../specxpp/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../Specx20/specx/*.hpp"
)

if (TRUE)
foreach(file_path ${Specx_list})
message(${file_path})
endforeach()
endif()


MACRO(HEADER_DIRECTORIES return_list)
FILE(GLOB_RECURSE new_list ${CMAKE_CURRENT_SOURCE_DIR}/../../../Specx20/specx/Src/*.hpp)
SET(dir_list "")
FOREACH(file_path ${new_list})
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
SET(dir_list ${dir_list} ${dir_path})
ENDFOREACH()
LIST(REMOVE_DUPLICATES dir_list)
SET(${return_list} ${dir_list})
ENDMACRO()

HEADER_DIRECTORIES(header_specx_dir_list)

list(LENGTH header_specx_dir_list header_dir_list_count)
message(STATUS "[INFO] Found ${header_dir_list_count} header directories.")

if (TRUE)
foreach(dir_path ${header_specx_dir_list})
message(${dir_path})
endforeach()
endif()

#include_directories("/home/u2/lemoine/SpecxProjects/specxpp/build/Src")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../Specx20/specx/build/Src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../Specx20/specx/Src)

#END::SPECX

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../Test13)

set(include_dirs "../Test13")

file(GLOB SOURCES
"*.cpp"
)

add_executable(main ${SOURCES} ${Specx_list})

#/home/u2/lemoine/Specx20/specx/build/Src/libspecx.a

target_link_libraries(main
${PTHREADS}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../../Specx20/specx/build/Src/libspecx.a
#PUBLIC
#TBB::tbb
#PRIVATE
# pthread
)

#target_include_directories(MiniTest PRIVATE "/home/u2/lemoine/SpecxProjects/specxpp")

#if(GPU_RUNTIME STREQUAL "CUDA")
# list(APPEND include_dirs "${ROCM_ROOT}/include")
#endif()

if(GPU_RUNTIME STREQUAL "HIP")
list(APPEND include_dirs "${ROCM_ROOT}/include")
MESSAGE(${ROCM_ROOT}/include)
endif()

set_source_files_properties(main.cpp PROPERTIES LANGUAGE ${GPU_RUNTIME})

target_include_directories(
main
PRIVATE
${header_specx_dir_list}
)

53 changes: 53 additions & 0 deletions src/Benchmark/Cholesky/Cholesky_GPU_HIP/DataAnalysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pandas as pd
import csv
import json
import matplotlib.pyplot as plt

df = pd.read_csv('Data.csv')
#print(df.head())
#print(df)
x=df['DimMatrix']
nb=len(x)
y1=df['ModeSerial']
y2=df['ModeGpuHipAMD']
y3=df['pthread']

for i in range(0,nb):
sc=1000.0
y1[i]=y1[i]/sc
y2[i]=y2[i]/sc
y3[i]=y3[i]/sc

figure1 = plt.figure()
plt.plot(x,y1,label='CPU-Serial',marker='o', linestyle='--', color='r')
plt.plot(x,y2,label='HIP-AMD-GPU',marker='o', linestyle='--', color='g')
plt.plot(x,y3,label='pthread 9',marker='o', linestyle='--', color='b')
plt.grid()
plt.xlabel('Dim Matrix')
#plt.ylabel('Time in microsecond')
plt.ylabel('Time in millisecond')
plt.title('Cholesky factorisation resolution')
plt.xticks(rotation=90)
plt.legend()
plt.show()
plt.savefig("Data.jpg")


ratio=[]
for i in range(0,nb):
ratio.append(y1[i]/y2[i])

figure2 = plt.figure()
plt.plot(x,ratio,label='Ratio',marker='o', linestyle='--', color='r')
plt.grid()
plt.xlabel('Dim Matrix')
plt.ylabel('Ratio')
plt.title('Cholesky factorisation resolution')
plt.xticks(rotation=90)
plt.legend()
plt.show()
plt.savefig("DataRatio.jpg")




Loading

0 comments on commit 0cc9d89

Please sign in to comment.