editting PETUNJUKPENGGUNAAN.md

master
rifki sadikin 6 years ago
parent 3037b9b3a4
commit 427669a9db
  1. 2
      CMakeLists.txt
  2. 92
      PETUNJUKPENGGUNAAN.md
  3. 43
      example/CMakeLists.txt
  4. 18
      interface/PoissonSolver3DCylindricalGPU.cxx

@ -101,7 +101,7 @@ set(HDRS
)
enable_testing()
set(TARGET_NAME poissonsolvergpu)
set(TARGET_NAME PoissonSolver3DCylindricalGPU)
add_library(${TARGET_NAME} SHARED ${SRCS})

@ -126,10 +126,94 @@ $ make
```console
$ make install
..
Install the project...
-- Install configuration: ""
-- Installing: /home/usertest/buildpoissonsolver/lib/libpoissonsolvergpu.so
-- Installing: /home/usertest/buildpoissonsolver/include/PoissonSolver3DCylindricalGPU.h
-- Installing: /home/usertest/buildpoissonsolver/include/PoissonSolver3DGPU.h
-- Installing: /home/usertest/trypoissonsolver/buildpoissonsolver/lib/libPoissonSolver3DCylindricalGPU.so
-- Installing: /home/usertest/trypoissonsolver/buildpoissonsolver/include/PoissonSolver3DCylindricalGPU.h
-- Installing: /home/usertest/trypoissonsolver/buildpoissonsolver/include/PoissonSolver3DGPU.h
```
Hasil instalasi adalah sebuah pustaka yang dapat digunakan (**shared library**) yaitu libPoissonSolver3DCylindricalGPU.so pada direktori **lib** dan 2 berkas header yang mengandung definisi kelas /fungsi sehingga pengguna pustaka dapat menggunakannya.
## Penggunaan Pustaka
### Penggunaan Dalam CMAKE
Dalam folder **example** di struktur direktori sumber terdapat contoh penggunaan pustaka libpoissonsolvergpu.so dengan menggunakan **cmake**. Berikut ini langkah-langkahnya:
1. Buat file **CMakeLists.txt** dengan struktur sebagai berikut untuk menambahkan pustaka cuda (**libcuda.so**) dan pustaka PoissonSolver3DCylindricalGPU (**libPoissonSolver3DCylindricalGPU.so**) pada proyek cmake:
```cmake
cmake_minimum_required (VERSION 2.8.11)
project (3DPoissonSolverGPUTest)
find_package(CUDA)
if(NOT CUDA_FOUND)
message( FATAL_ERROR "NVIDIA CUDA package not found" )
else()
find_library(LIBCUDA_SO_PATH libcuda.so)
string(FIND ${LIBCUDA_SO_PATH} "-NOTFOUND" LIBCUDA_SO_PATH_NOTFOUND )
endif(NOT CUDA_FOUND)
message( STATUS "Building Poisson Solver with CUDA support" )
if(LIBCUDA_SO_PATH_NOTFOUND GREATER -1)
message( FATAL_ERROR "NVIDIA CUDA libcuda.so not found" )
endif(LIBCUDA_SO_PATH_NOTFOUND GREATER -1)
#set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH})
#find_package(CUDA QUIET REQUIRED)
set(PSLIBNAME libPoissonSolver3DCylindricalGPU.so)
find_library(PSLIB ${PSLIBNAME})
string(FIND ${PSLIB} "-NOTFOUND" PSLIB_NOTFOUND )
if(PSLIB_NOTFOUND GREATER -1)
message( FATAL_ERROR "Poisson Solver Cuda Library libPoissonSolver3DCylindricalGPU.o not found" )
endif(PSLIB_NOTFOUND GREATER -1)
```
Setelah itu, baru tambahkan perintah pada CMakeLists.txt (dilanjutkan) untuk mengikut sertakan kode sumber user yaitu:
```
# tambah disini kode sumber user
set(CPP_SOURCE PoissonSolver3DGPUTest.cpp)
set(HEADERS PoissonSolver3DGPUTest.h)
set(TARGET_NAME poissonsolvergputest)
add_executable(${TARGET_NAME}
PoissonSolver3DGPUTest.cpp
)
# ikut sertakan shared library cuda dan poisson solver
target_link_libraries(${TARGET_NAME} ${PSLIB} ${LIBCUDA_SO_PATH})
```
2. Buat folder terpisah untuk mebangun proyek yang menggunakan pustaka misal **buildexamplepoissonsolver** lalu jalankan **cmake** dengan flag spesial yaitu **-DCMAKE_PREFIX_PATH** yang ditetapkan dengan absolute path tempat direktori PoissonSolver3DCylindricalGPU dibangun.
```console
$ mkdir buildexamplepoissonsolver
$ cd buildexamplepoissonsolver
$ cmake ../PoissonSolver3D/example/ -DCMAKE_PREFIX_PATH=/home/usertest/trypoissonsolver/buildpoissonsolver
...
-- Found CUDA: /apps/tools/cuda-9.1 (found version "9.1")
-- Building Poisson Solver with CUDA support
-- Configuring done
-- Generating done
-- Build files have been written to: /home/usertest/trypoissonsolver/buildexamplepoissonsolver
```
3. Jalankan **make** untuk membuat *executable file*
```console
$ make
-- Building Poisson Solver with CUDA support
-- Configuring done
-- Generating done
-- Build files have been written to: /home/usertest/trypoissonsolver/buildexamplepoissonsolver
[ 50%] Linking CXX executable poissonsolvergputest
[100%] Built target poissonsolvergputest
```

@ -20,62 +20,33 @@ endif(LIBCUDA_SO_PATH_NOTFOUND GREATER -1)
#set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH})
#find_package(CUDA QUIET REQUIRED)
set(PSLIBNAME libPoissonSolver3DGPU.so)
set(PSLIBNAME libPoissonSolver3DCylindricalGPU.so)
find_library(PSLIB ${PSLIBNAME})
string(FIND ${PSLIB} "-NOTFOUND" PSLIB_NOTFOUND )
if(PSLIB_NOTFOUND GREATER -1)
message( FATAL_ERROR "Poisson Solver Cuda Library libPoissonSolver3DGPU.so not found" )
message( FATAL_ERROR "Poisson Solver Cuda Library libPoissonSolver3DCylindricalGPU.so not found" )
endif(PSLIB_NOTFOUND GREATER -1)
#set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
# set(BUILD_SHARED_LIBS ON)
#list(APPEND CUDA_NVCC_FLAGS)
#cuda_add_executable(poissonsolvertest
# PoissonSolver3DGPUTest.cpp
#i)
# add_executable(poissonsolvergputest PoissonSolver3DGPUTest.cpp ${PSLIB})
# install(TARGETS poissonsolvergputest DESTINATION bin)
INCLUDE_DIRECTORIES(
${CMAKE_PREFIX_PATH}/include
)
# tambah disini kode sumber user
set(CPP_SOURCE PoissonSolver3DGPUTest.cpp)
set(HEADERS PoissonSolver3DGPUTest.h)
enable_testing()
set(TARGET_NAME poissonsolvergputest)
#set(UNIT_TEST_LIST
# poissonsolver)
#foreach(NAME IN LISTS UNIT_TEST_LIST)
# list(APPEND UNIT_TEST_SOURCE_LIST ${NAME}.test.cpp)
#endforeach()
add_executable(${TARGET_NAME}
PoissonSolver3DGPUTest.cpp
#main.cpp
#${UNIT_TEST_SOURCE_LIST}
)
target_link_libraries(${TARGET_NAME} ${PSLIB} ${LIBCUDA_SO_PATH})
install(TARGETS ${TARGET_NAME} DESTINATION bin)
#target_link_libraries(${TARGET_NAME}
# PUBLIC string_utils)i
# ikut sertakan shared library cuda dan poisson solver
target_link_libraries(${TARGET_NAME} ${PSLIB} ${LIBCUDA_SO_PATH})
#target_include_directories(${TARGET_NAME}
# PUBLIC external/catch2/)
#add_test(
# NAME ${TARGET_NAME}
# COMMAND ${TARGET_NAME} -o report.xml -r junit)

@ -1,9 +1,23 @@
/// \author Rifki Sadikin <rifki.sadikin@cern.ch>, Indonesian Institute of Sciences
/// \date Nov 20, 2017
/// \author Rifki Sadikin <rifki.sadikin@lipi.go.id>, Indonesian Institute of Sciences
/// \date Nov 8, 2018
#include <math.h>
#include "PoissonSolver3DCylindricalGPU.h"
const float PoissonSolver3DCylindricalGPU::fgkTPCZ0 = 249.7; ///< nominal gating grid position
const float PoissonSolver3DCylindricalGPU::fgkIFCRadius = 83.5; ///< radius which renders the "18 rod manifold" best -> compare calc. of Jim Thomas
const float PoissonSolver3DCylindricalGPU::fgkOFCRadius = 254.5; ///< Mean Radius of the Outer Field Cage (252.55 min, 256.45 max) (cm)
const float PoissonSolver3DCylindricalGPU::fgkZOffSet = 0.2; ///< Offset from CE: calculate all distortions closer to CE as if at this point
const float PoissonSolver3DCylindricalGPU::fgkCathodeV = -100000.0; ///< Cathode Voltage (volts)
const float PoissonSolver3DCylindricalGPU::fgkGG = -70.0; ///< Gating Grid voltage (volts)
const float PoissonSolver3DCylindricalGPU::fgkdvdE = 0.0024; ///< [cm/V] drift velocity dependency on the E field (from Magboltz for NeCO2N2 at standard environment)
const float PoissonSolver3DCylindricalGPU::fgkEM = -1.602176487e-19 / 9.10938215e-31; ///< charge/mass in [C/kg]
const float PoissonSolver3DCylindricalGPU::fgke0 = 8.854187817e-12; ///< vacuum permittivity [A·s/(V·m)]
float PoissonSolver3DCylindricalGPU::fgExactErr = 1e-4;
float PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-3;
/// constructor
///
PoissonSolver3DCylindricalGPU::PoissonSolver3DCylindricalGPU() {

Loading…
Cancel
Save