Compare commits

..

5 Commits

Author SHA1 Message Date
Rifki Sadikin 76b0868517 Update PoissonSolver3DCylindricalGPU.cxx 6 years ago
Rifki Sadikin a0688993b6 Update PETUNJUKPENGGUNAAN.md 6 years ago
Rifki Sadikin 37fa9320bb Update README.md 6 years ago
Rifki Sadikin 86df11e0ce Update PETUNJUKPENGGUNAAN.md 6 years ago
Rifki Sadikin 52a6fa8451 Update PETUNJUKPENGGUNAAN.md 6 years ago
  1. 265
      PETUNJUKPENGGUNAAN.md
  2. 2
      README.md
  3. 7
      interface/PoissonSolver3DCylindricalGPU.cxx

@ -48,7 +48,7 @@ module load cuda
## Instalasi ## Instalasi
Untuk menginstall pustaka PoissonSolver3DCylindricalGPU lakukan langkah-langkah berikut: Untuk menginstall pustaka PoissonSolver3DCylindricalGPU lakukan langkah-langkah berikut:
1. Jalankan git clone untuk menyalin kode sumber ke direktori local. Perintah ini akan menyalin kode sumber ke direktori **PoissonSolver3D** 1. Jalankan git clone untuk menyalin kode sumber ke direktori local. Perintah ini akan menyalin kode sumber ke direktori **PoissonSolver3DCylindricalGPU**
``` ```
$ git clone http://gitlab.lipi.go.id/rifki.sadikin/PoissonSolver3DCylindricalGPU.git $ git clone http://gitlab.lipi.go.id/rifki.sadikin/PoissonSolver3DCylindricalGPU.git
``` ```
@ -140,145 +140,154 @@ Dalam folder **example** di struktur direktori sumber terdapat contoh penggunaan
1. Buat file **CMakeLists.txt** dengan struktur sebagai berikut untuk menambahkan pustaka cuda (**libcuda.so**) dan pustaka PoissonSolver3DCylindricalGPU (**libPoissonSolver3DCylindricalGPU.so**) pada proyek cmake: 1. Buat file **CMakeLists.txt** dengan struktur sebagai berikut untuk menambahkan pustaka cuda (**libcuda.so**) dan pustaka PoissonSolver3DCylindricalGPU (**libPoissonSolver3DCylindricalGPU.so**) pada proyek cmake:
``` ```
cmake_minimum_required (VERSION 2.8.11) cmake_minimum_required (VERSION 2.8.11)
project (3DPoissonSolverGPUTest) project (3DPoissonSolverGPUTest)
find_package(CUDA) find_package(CUDA)
if(NOT CUDA_FOUND) if(NOT CUDA_FOUND)
message( FATAL_ERROR "NVIDIA CUDA package not found" ) message( FATAL_ERROR "NVIDIA CUDA package not found" )
else() else()
find_library(LIBCUDA_SO_PATH libcuda.so) find_library(LIBCUDA_SO_PATH libcuda.so)
string(FIND ${LIBCUDA_SO_PATH} "-NOTFOUND" LIBCUDA_SO_PATH_NOTFOUND ) string(FIND ${LIBCUDA_SO_PATH} "-NOTFOUND" LIBCUDA_SO_PATH_NOTFOUND )
endif(NOT CUDA_FOUND) endif(NOT CUDA_FOUND)
message( STATUS "Building Poisson Solver with CUDA support" ) message( STATUS "Building Poisson Solver with CUDA support" )
if(LIBCUDA_SO_PATH_NOTFOUND GREATER -1) if(LIBCUDA_SO_PATH_NOTFOUND GREATER -1)
message( FATAL_ERROR "NVIDIA CUDA libcuda.so not found" ) message( FATAL_ERROR "NVIDIA CUDA libcuda.so not found" )
endif(LIBCUDA_SO_PATH_NOTFOUND GREATER -1) endif(LIBCUDA_SO_PATH_NOTFOUND GREATER -1)
#set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH}) #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH})
#find_package(CUDA QUIET REQUIRED) #find_package(CUDA QUIET REQUIRED)
set(PSLIBNAME libPoissonSolver3DCylindricalGPU.so) set(PSLIBNAME libPoissonSolver3DCylindricalGPU.so)
find_library(PSLIB ${PSLIBNAME}) find_library(PSLIB ${PSLIBNAME})
string(FIND ${PSLIB} "-NOTFOUND" PSLIB_NOTFOUND ) 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})
```
if(PSLIB_NOTFOUND GREATER -1) 2. Pada kode sumber include header file sehingga definisi fungsi dan kelas dapat dipanggil di badan kode.
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} ```c++
PoissonSolver3DGPUTest.cpp #include "PoissonSolver3DCylindricalGPU.h"
) ...
# ikut sertakan shared library cuda dan poisson solver // create poissonSolver
target_link_libraries(${TARGET_NAME} ${PSLIB} ${LIBCUDA_SO_PATH}) PoissonSolver3DCylindricalGPU *poissonSolver = new PoissonSolver3DCylindricalGPU();
``` PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-8;
poissonSolver->SetExactSolution(VPotentialExact,kRows,kColumns, kPhiSlices);
poissonSolver->SetStrategy(PoissonSolver3DCylindricalGPU::kMultiGrid);
poissonSolver->SetCycleType(PoissonSolver3DCylindricalGPU::kFCycle);
poissonSolver->PoissonSolver3D(VPotential,RhoCharge,kRows,kColumns,kPhiSlices, kIterations,kSymmetry) ;
```
2. Pada kode sumber include header file sehingga definisi fungsi dan kelas dapat dipanggil di badan kode.
```c++
#include "PoissonSolver3DCylindricalGPU.h"
...
// create poissonSolver
PoissonSolver3DCylindricalGPU *poissonSolver = new PoissonSolver3DCylindricalGPU();
PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-8;
poissonSolver->SetExactSolution(VPotentialExact,kRows,kColumns, kPhiSlices);
poissonSolver->SetStrategy(PoissonSolver3DCylindricalGPU::kMultiGrid);
poissonSolver->SetCycleType(PoissonSolver3DCylindricalGPU::kFCycle);
poissonSolver->PoissonSolver3D(VPotential,RhoCharge,kRows,kColumns,kPhiSlices, kIterations,kSymmetry) ;
```
3. 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. 3. 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.
``` ```
$ mkdir buildexamplepoissonsolver $ mkdir buildexamplepoissonsolver
$ cd buildexamplepoissonsolver $ cd buildexamplepoissonsolver
$ cmake ../PoissonSolver3D/example/ -DCMAKE_PREFIX_PATH=/home/usertest/trypoissonsolver/buildpoissonsolver $ cmake ../PoissonSolver3D/example/ -DCMAKE_PREFIX_PATH=/home/usertest/trypoissonsolver/buildpoissonsolver
... ...
-- Found CUDA: /apps/tools/cuda-9.1 (found version "9.1") -- Found CUDA: /apps/tools/cuda-9.1 (found version "9.1")
-- Building Poisson Solver with CUDA support -- Building Poisson Solver with CUDA support
-- Configuring done -- Configuring done
-- Generating done -- Generating done
-- Build files have been written to: /home/usertest/trypoissonsolver/buildexamplepoissonsolver -- Build files have been written to: /home/usertest/trypoissonsolver/buildexamplepoissonsolver
``` ```
4. Jalankan **make** untuk membuat *executable file* 4. Jalankan **make** untuk membuat *executable file*
``` ```
$ make $ make
-- Building Poisson Solver with CUDA support -- Building Poisson Solver with CUDA support
-- Configuring done -- Configuring done
-- Generating done -- Generating done
-- Build files have been written to: /home/usertest/trypoissonsolver/buildexamplepoissonsolver -- Build files have been written to: /home/usertest/trypoissonsolver/buildexamplepoissonsolver
[ 50%] Linking CXX executable poissonsolvergputest [ 50%] Linking CXX executable poissonsolvergputest
[100%] Built target poissonsolvergputest [100%] Built target poissonsolvergputest
``` ```
5. Hasil dari **make** adalah program yang dapat dieksekusi yang berjalan di GPU card 5. Hasil dari **make** adalah program yang dapat dieksekusi yang berjalan di GPU card
``` ```
$ ./poissonsolvergputest $ ./poissonsolvergputest
Poisson Solver 3D Cylindrical GPU test Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (17,17,18) Ukuran grid (r,phi,z) = (17,17,18)
Waktu komputasi: 0.55 s Waktu komputasi: 0.55 s
Jumlah iterasi siklus multigrid: 5 Jumlah iterasi siklus multigrid: 5
Iterasi Error Convergen Error Absolut Iterasi Error Convergen Error Absolut
[0]: 8.362587e-01 2.430797e-03 [0]: 8.362587e-01 2.430797e-03
[1]: 5.126660e-02 4.434380e-04 [1]: 5.126660e-02 4.434380e-04
[2]: 9.490424e-03 1.892288e-04 [2]: 9.490424e-03 1.892288e-04
[3]: 2.084086e-03 1.314385e-04 [3]: 2.084086e-03 1.314385e-04
[4]: 1.141812e-03 1.217592e-04 [4]: 1.141812e-03 1.217592e-04
Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (33,33,36)
Waktu komputasi: 1.000000e-02 s
Jumlah iterasi siklus multigrid: 10
Iterasi Error Convergen Error Absolut
[0]: 1.724319e-03 1.315177e-04
[1]: 8.652242e-05 1.266415e-04
[2]: 5.450314e-05 1.256187e-04
[3]: 5.081671e-05 1.249848e-04
[4]: 4.951065e-05 1.244460e-04
[5]: 4.904093e-05 1.241379e-04
[6]: 4.890266e-05 1.239894e-04
[7]: 4.885175e-05 1.239208e-04
[8]: 4.883604e-05 1.238959e-04
[9]: 4.883501e-05 1.238844e-04
Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (65,65,72)
Waktu komputasi: 5.000000e-02 s
Jumlah iterasi siklus multigrid: 3
Iterasi Error Convergen Error Absolut
[0]: 1.084726e-04 1.291784e-04
[1]: 5.680057e-06 1.283386e-04
[2]: 1.501479e-06 1.278558e-04
Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (129,129,144)
Waktu komputasi: 1.200000e-01 s
Jumlah iterasi siklus multigrid: 3
Iterasi Error Convergen Error Absolut
[0]: 1.373293e-05 1.302576e-04
[1]: 2.154564e-06 1.299626e-04
[2]: 1.048384e-06 1.297261e-04
Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (257,257,288)
Waktu komputasi: 6.900000e-01 s
Jumlah iterasi siklus multigrid: 5
Iterasi Error Convergen Error Absolut
[0]: 5.469890e-06 1.388922e-04
[1]: 1.783695e-06 1.384964e-04
[2]: 1.345343e-06 1.381199e-04
[3]: 1.156555e-06 1.377524e-04
[4]: 1.050234e-06 1.373983e-04
```
Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (33,33,36)
Waktu komputasi: 1.000000e-02 s
Jumlah iterasi siklus multigrid: 10
Iterasi Error Convergen Error Absolut
[0]: 1.724319e-03 1.315177e-04
[1]: 8.652242e-05 1.266415e-04
[2]: 5.450314e-05 1.256187e-04
[3]: 5.081671e-05 1.249848e-04
[4]: 4.951065e-05 1.244460e-04
[5]: 4.904093e-05 1.241379e-04
[6]: 4.890266e-05 1.239894e-04
[7]: 4.885175e-05 1.239208e-04
[8]: 4.883604e-05 1.238959e-04
[9]: 4.883501e-05 1.238844e-04
Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (65,65,72)
Waktu komputasi: 5.000000e-02 s
Jumlah iterasi siklus multigrid: 3
Iterasi Error Convergen Error Absolut
[0]: 1.084726e-04 1.291784e-04
[1]: 5.680057e-06 1.283386e-04
[2]: 1.501479e-06 1.278558e-04
Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (129,129,144)
Waktu komputasi: 1.200000e-01 s
Jumlah iterasi siklus multigrid: 3
Iterasi Error Convergen Error Absolut
[0]: 1.373293e-05 1.302576e-04
[1]: 2.154564e-06 1.299626e-04
[2]: 1.048384e-06 1.297261e-04
Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (257,257,288)
Waktu komputasi: 6.900000e-01 s
Jumlah iterasi siklus multigrid: 5
Iterasi Error Convergen Error Absolut
[0]: 5.469890e-06 1.388922e-04
[1]: 1.783695e-06 1.384964e-04
[2]: 1.345343e-06 1.381199e-04
[3]: 1.156555e-06 1.377524e-04
[4]: 1.050234e-06 1.373983e-04
```

@ -1,6 +1,6 @@
# PoissonSolver3DCylindricalGPU # PoissonSolver3DCylindricalGPU
PoissonSolver3D adalah pustaka yang dikembangkan untuk menyelesaikan persamaan Poisson 3 dimensi dalam sistem koordinat silinder. Persamaan Poisson secara umum berbentuk $$\nabla^{2}(r,\phi,z) = \rho(r,\phi,z)$$ dengan diketahui nilai tepi pada potensial $$\mathbf{V}$$ dan distribusi buatan $$\rho$$. PoissonSolver3D adalah pustaka yang dikembangkan untuk menyelesaikan persamaan Poisson 3 dimensi dalam sistem koordinat silinder. Persamaan Poisson secara umum berbentuk $$\nabla^{2}(r,\phi,z) = \rho(r,\phi,z)$$ dengan diketahui nilai tepi pada potensial $\mathbf{V}$ dan distribusi muatan $\rho$.
Untuk menyelesaikan persamaan tersebut digunakan metode multigrid yang diimplementasikan pada akselerator GPU. Untuk menyelesaikan persamaan tersebut digunakan metode multigrid yang diimplementasikan pada akselerator GPU.

@ -1,4 +1,3 @@
/************************************************************************** /**************************************************************************
* Copyright(c) 2018, * * Copyright(c) 2018, *
* Kelompok penelitian komputasi berkinerja tinggi * * Kelompok penelitian komputasi berkinerja tinggi *
@ -30,9 +29,9 @@
#include <math.h> #include <math.h>
#include "PoissonSolver3DCylindricalGPU.h" #include "PoissonSolver3DCylindricalGPU.h"
const float PoissonSolver3DCylindricalGPU::fgkZ0 = 249.7; ///< nominal gating grid position const float PoissonSolver3DCylindricalGPU::fgkZ0 = 249.7; ///< panjang z
const float PoissonSolver3DCylindricalGPU::fgkIFCRadius = 83.5; ///< radius which renders the "18 rod manifold" best -> compare calc. of Jim Thomas const float PoissonSolver3DCylindricalGPU::fgkIFCRadius = 83.5; ///< radius dalam
const float PoissonSolver3DCylindricalGPU::fgkOFCRadius = 254.5; ///< Mean Radius of the Outer Field Cage (252.55 min, 256.45 max) (cm) const float PoissonSolver3DCylindricalGPU::fgkOFCRadius = 254.5; ///< radius luar
float PoissonSolver3DCylindricalGPU::fgExactErr = 1e-4; float PoissonSolver3DCylindricalGPU::fgExactErr = 1e-4;
float PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-3; float PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-3;

Loading…
Cancel
Save