generated from feelpp/feelpp-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
954 additions
and
793 deletions.
There are no files selected for viewing
302 changes: 302 additions & 0 deletions
302
docs/modules/ROOT/assets/images/domain-decomposition.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
= Heat Equation Parallel Programming Comparison | ||
|
||
|
||
|
||
.Heat equation in 2D | ||
[.examp] | ||
**** | ||
|
||
* Theory | ||
Heat (or diffusion) equation is a partial differential equation that describes the variation of temperature in a given region over time | ||
|
||
|
||
\begin{align*} | ||
\frac{\partial u}{\partial t} = \alpha \nabla^2 u | ||
\end{align*} | ||
|
||
|
||
image::eq1.png[Img901] | ||
|
||
where *u*(*x*, *y*, *t*) is the temperature field that varies in space and | ||
time, and α is the thermal diffusivity constant. | ||
|
||
We limit ourselvels to two dimensions (a plane) where Laplacian can be | ||
discretized in a grid with finite differences as | ||
|
||
|
||
\begin{align*} | ||
\nabla^2 u &= \frac{u(i-1,j)-2u(i,j)+u(i+1,j)}{(\Delta x)^2} \\ | ||
&+ \frac{u(i,j-1)-2u(i,j)+u(i,j+1)}{(\Delta y)^2} | ||
\end{align*} | ||
|
||
where ∆x and ∆y are the grid spacing of the temperature grid *u*. | ||
|
||
Given an initial condition (*u*(t=0) = u0) one can follow the time dependence | ||
of the temperature field with explicit time evolution method: | ||
|
||
\begin{align*} | ||
u^{m+1}(i,j) = u^m(i,j) + \Delta t \alpha \nabla^2 u^m(i,j) | ||
\end{align*} | ||
|
||
|
||
Note: The algorithm is stable only when | ||
|
||
\begin{align*} | ||
\Delta t < \frac{1}{2 \alpha} \frac{(\Delta x \Delta y)^2}{(\Delta x)^2 (\Delta y)^2} | ||
\end{align*} | ||
|
||
**** | ||
.Code | ||
[.examp] | ||
**** | ||
The solver carries out the time development of the 2D heat equation over the number of time steps provided by the user. The default geometry is a flat | ||
rectangle (with grid size provided by the user), but other shapes may be used via input files. The program will produce an image (PNG) of the temperature field after every 100 iterations. | ||
|
||
.Heat equation solver with MPI | ||
[source,cpp] | ||
---- | ||
include::ROOT:example$src/Heat_Equation_ParallelPrograming_Comparison/MPI/main.cpp[indent=0] | ||
---- | ||
|
||
.Heat equation solver with hybrid MPI+OpenMP | ||
[source,cpp] | ||
---- | ||
include::ROOT:example$src/Heat_Equation_ParallelPrograming_Comparison/MPI_OpenMP/main.cpp[indent=0] | ||
---- | ||
|
||
|
||
.Heat equation solver with Cuda | ||
[source,cu] | ||
---- | ||
include::ROOT:example$src/Heat_Equation_ParallelPrograming_Comparison/Cuda/core_cuda.cu[indent=0] | ||
---- | ||
**** | ||
.*Performance* | ||
**** | ||
ADD SOME RESULTS | ||
**** | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
#project(MPI_bcast) | ||
|
||
######## A simple cmakelists.txt file for ... ############# | ||
|
||
cmake_minimum_required(VERSION 3.17) | ||
#set(CMAKE_CXX_STANDARD 14) | ||
#set(CMAKE_BUILD_TYPE Debug) | ||
set(CMAKE_BUILD_TYPE Release) | ||
#set(CMAKE_CXX_COMPILER "/usr/local/bin/g++") | ||
#set(CMAKE_CXX_STANDARD 14) | ||
#set(CMAKE_CXX_COMPILER "/usr/local/bin/g++") | ||
#set(CMAKE_C_COMPILER "/usr/bin/clang-14") | ||
#set(CMAKE_CXX_COMPILER "/usr/bin/clang++-14") | ||
#set(CMAKE_CXX_COMPILER "/usr/bin/gcc") | ||
#set(CMAKE_CXX_COMPILER "/usr/bin/g++-11") | ||
|
||
|
||
|
||
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 OpenMPI") | ||
endif(OpenMP_CXX_FOUND) | ||
endif() | ||
|
||
|
||
find_package(CUDA REQUIRED) | ||
|
||
if (CUDA_FOUND) | ||
MESSAGE("{CUDA_CXX_LIBRARIES}") | ||
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 ) | ||
|
||
file(GLOB WFOPenMP_SRC | ||
"*.cu" | ||
) | ||
|
||
foreach (myfile ${WFOPenMP_SRC}) | ||
get_filename_component(myname ${myfile} NAME_WLE) | ||
get_filename_component(dirname ${myfile} DIRECTORY) | ||
message("${myname}.cu | ${dir_src}") | ||
#add_executable(${myname} "${myname}.c") | ||
|
||
cuda_add_executable(${myname} "${myname}.cu") | ||
|
||
#target_link_libraries( ${myname} -lfoobar -ljoestuff ) | ||
|
||
#if(MPI_FOUND) | ||
#include_directories(SYSTEM ${MPI_INCLUDES_PATH}) | ||
#target_include_directories(${myname} PUBLIC ${MPI_CXX_INCLUDE_DIRS}) | ||
#target_link_libraries(${myname} PUBLIC ${MPI_CXX_LIBRARIES} ) | ||
#endif() | ||
|
||
|
||
endforeach (file ${WFOPenMP_SRC}) | ||
|
||
|
||
if(FALSE) | ||
file(GLOB WFOPenMP_SRC | ||
"*.cpp" | ||
"*.h" | ||
) | ||
|
||
foreach (myfile ${WFOPenMP_SRC}) | ||
get_filename_component(myname ${myfile} NAME_WLE) | ||
get_filename_component(dirname ${myfile} DIRECTORY) | ||
message("${myname}.cpp | ${dir_src}") | ||
#add_executable(${myname} "${myname}.c") | ||
|
||
cuda_add_executable(${myname} "${myname}.cpp") | ||
|
||
#target_link_libraries( ${myname} -lfoobar -ljoestuff ) | ||
|
||
#if(MPI_FOUND) | ||
#include_directories(SYSTEM ${MPI_INCLUDES_PATH}) | ||
#target_include_directories(${myname} PUBLIC ${MPI_CXX_INCLUDE_DIRS}) | ||
#target_link_libraries(${myname} PUBLIC ${MPI_CXX_LIBRARIES} ) | ||
#endif() | ||
endforeach (file ${WFOPenMP_SRC}) | ||
endif() | ||
|
||
|
||
########### end #################################### |
103 changes: 103 additions & 0 deletions
103
src/Heat_Equation_ParallelPrograming_Comparison/Cuda/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
project(HEATDemoCuda) | ||
|
||
######## A simple cmakelists.txt file for Open... ############# | ||
#cmake_minimum_required(VERSION 3.26) | ||
cmake_minimum_required(VERSION 3.17) | ||
#set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_BUILD_TYPE Debug) | ||
#set(CMAKE_BUILD_TYPE Release) | ||
#set(CMAKE_CXX_COMPILER "/usr/local/bin/g++") | ||
#set(CMAKE_CXX_STANDARD 14) | ||
#set(CMAKE_CXX_COMPILER "/usr/local/bin/g++") | ||
#set(CMAKE_C_COMPILER "/usr/bin/clang-14") | ||
#set(CMAKE_CXX_COMPILER "/usr/bin/clang++-14") | ||
#set(CMAKE_CXX_COMPILER "/usr/bin/gcc") | ||
#set(CMAKE_CXX_COMPILER "/usr/bin/g++-11") | ||
|
||
|
||
include_directories("../common") | ||
|
||
|
||
|
||
if(TRUE) | ||
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() | ||
|
||
|
||
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 ) | ||
|
||
find_package(PNG REQUIRED) | ||
if (PNG_FOUND) | ||
MESSAGE("{PNG_LIBRARIES}") | ||
else (PNG_FOUND) | ||
MESSAGE (SEND_ERROR "This application cannot compile without PNG") | ||
endif(PNG_FOUND) | ||
|
||
|
||
#file(GLOB my_cpp_list "${CMAKE_CURRENT_SOURCE_DIR}/common/*.c") | ||
file(GLOB my_common_list | ||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/*.c" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/../common/*.h" | ||
) | ||
|
||
if (FALSE) | ||
message(${CMAKE_CURRENT_SOURCE_DIR}) | ||
foreach(file_path ${my_cpp_list} ${my_common_list}) | ||
message(${file_path}) | ||
endforeach() | ||
endif() | ||
|
||
|
||
file(GLOB All_SRC | ||
"*.h" | ||
"*.cpp" | ||
"*.cu" | ||
) | ||
|
||
|
||
#add_executable(HEATDemoCuda main.cpp ${All_SRC} ${my_common_list}) | ||
|
||
cuda_add_executable(HEATDemoCuda ${All_SRC} ${my_common_list}) | ||
|
||
include_directories(SYSTEM ${MPI_INCLUDES_PATH}) | ||
target_include_directories(HEATDemoCuda PUBLIC ${MPI_CXX_INCLUDE_DIRS} ${PNG_INCLUDE_DIR} ${CUDA_INCLUDE_DIRS}) | ||
#target_link_libraries(HEATDemoCuda PUBLIC ${MPI_CXX_LIBRARIES} ${PNG_LIBRARY} PUBLIC cuda) | ||
#cuda_add_library(HEATDemoCuda PUBLIC ${MPI_CXX_LIBRARIES} ${PNG_LIBRARY} ) | ||
#add_library(HEATDemoCuda PUBLIC ${MPI_CXX_LIBRARIES} ${PNG_LIBRARY}) | ||
|
||
#target_link_libraries(HEATDemoCuda PUBLIC ${MPI_CXX_LIBRARIES} ${PNG_LIBRARY} ${CUDA_LIBRARIES}) | ||
|
||
target_link_libraries(HEATDemoCuda ${MPI_CXX_LIBRARIES}) | ||
target_link_libraries(HEATDemoCuda ${PNG_LIBRARY}) | ||
#target_link_libraries(HEATDemoCuda ${CUDA_LIBRARIES}) | ||
|
||
|
File renamed without changes.
Oops, something went wrong.