Compare commits

..

No commits in common. '76b08685172f0a567f3f9a02d1f3eb000f374468' and '7be1315932c450cfde37ff08eebfc6709c1c71f1' have entirely different histories.

  1. 247
      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 **PoissonSolver3DCylindricalGPU** 1. Jalankan git clone untuk menyalin kode sumber ke direktori local. Perintah ini akan menyalin kode sumber ke direktori **PoissonSolver3D**
``` ```
$ git clone http://gitlab.lipi.go.id/rifki.sadikin/PoissonSolver3DCylindricalGPU.git $ git clone http://gitlab.lipi.go.id/rifki.sadikin/PoissonSolver3DCylindricalGPU.git
``` ```
@ -140,154 +140,145 @@ 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) if(PSLIB_NOTFOUND GREATER -1)
message( FATAL_ERROR "Poisson Solver Cuda Library libPoissonSolver3DCylindricalGPU.o not found" ) message( FATAL_ERROR "Poisson Solver Cuda Library libPoissonSolver3DCylindricalGPU.o not found" )
endif(PSLIB_NOTFOUND GREATER -1) endif(PSLIB_NOTFOUND GREATER -1)
``` ```
Setelah itu, baru tambahkan perintah pada CMakeLists.txt (dilanjutkan) untuk mengikut sertakan kode sumber user yaitu:
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)
# tambah disini kode sumber user set(HEADERS PoissonSolver3DGPUTest.h)
set(CPP_SOURCE PoissonSolver3DGPUTest.cpp)
set(HEADERS PoissonSolver3DGPUTest.h)
set(TARGET_NAME poissonsolvergputest) set(TARGET_NAME poissonsolvergputest)
add_executable(${TARGET_NAME} add_executable(${TARGET_NAME}
PoissonSolver3DGPUTest.cpp PoissonSolver3DGPUTest.cpp
) )
# ikut sertakan shared library cuda dan poisson solver # ikut sertakan shared library cuda dan poisson solver
target_link_libraries(${TARGET_NAME} ${PSLIB} ${LIBCUDA_SO_PATH}) target_link_libraries(${TARGET_NAME} ${PSLIB} ${LIBCUDA_SO_PATH})
``` ```
2. Pada kode sumber include header file sehingga definisi fungsi dan kelas dapat dipanggil di badan kode. 2. Pada kode sumber include header file sehingga definisi fungsi dan kelas dapat dipanggil di badan kode.
```c++
```c++ #include "PoissonSolver3DCylindricalGPU.h"
#include "PoissonSolver3DCylindricalGPU.h" ...
... // create poissonSolver
// create poissonSolver PoissonSolver3DCylindricalGPU *poissonSolver = new PoissonSolver3DCylindricalGPU();
PoissonSolver3DCylindricalGPU *poissonSolver = new PoissonSolver3DCylindricalGPU(); PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-8;
PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-8; poissonSolver->SetExactSolution(VPotentialExact,kRows,kColumns, kPhiSlices);
poissonSolver->SetExactSolution(VPotentialExact,kRows,kColumns, kPhiSlices); poissonSolver->SetStrategy(PoissonSolver3DCylindricalGPU::kMultiGrid);
poissonSolver->SetStrategy(PoissonSolver3DCylindricalGPU::kMultiGrid); poissonSolver->SetCycleType(PoissonSolver3DCylindricalGPU::kFCycle);
poissonSolver->SetCycleType(PoissonSolver3DCylindricalGPU::kFCycle); poissonSolver->PoissonSolver3D(VPotential,RhoCharge,kRows,kColumns,kPhiSlices, kIterations,kSymmetry) ;
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 Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (33,33,36) Ukuran grid (r,phi,z) = (33,33,36)
Waktu komputasi: 1.000000e-02 s Waktu komputasi: 1.000000e-02 s
Jumlah iterasi siklus multigrid: 10 Jumlah iterasi siklus multigrid: 10
Iterasi Error Convergen Error Absolut Iterasi Error Convergen Error Absolut
[0]: 1.724319e-03 1.315177e-04 [0]: 1.724319e-03 1.315177e-04
[1]: 8.652242e-05 1.266415e-04 [1]: 8.652242e-05 1.266415e-04
[2]: 5.450314e-05 1.256187e-04 [2]: 5.450314e-05 1.256187e-04
[3]: 5.081671e-05 1.249848e-04 [3]: 5.081671e-05 1.249848e-04
[4]: 4.951065e-05 1.244460e-04 [4]: 4.951065e-05 1.244460e-04
[5]: 4.904093e-05 1.241379e-04 [5]: 4.904093e-05 1.241379e-04
[6]: 4.890266e-05 1.239894e-04 [6]: 4.890266e-05 1.239894e-04
[7]: 4.885175e-05 1.239208e-04 [7]: 4.885175e-05 1.239208e-04
[8]: 4.883604e-05 1.238959e-04 [8]: 4.883604e-05 1.238959e-04
[9]: 4.883501e-05 1.238844e-04 [9]: 4.883501e-05 1.238844e-04
Poisson Solver 3D Cylindrical GPU test Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (65,65,72) Ukuran grid (r,phi,z) = (65,65,72)
Waktu komputasi: 5.000000e-02 s Waktu komputasi: 5.000000e-02 s
Jumlah iterasi siklus multigrid: 3 Jumlah iterasi siklus multigrid: 3
Iterasi Error Convergen Error Absolut Iterasi Error Convergen Error Absolut
[0]: 1.084726e-04 1.291784e-04 [0]: 1.084726e-04 1.291784e-04
[1]: 5.680057e-06 1.283386e-04 [1]: 5.680057e-06 1.283386e-04
[2]: 1.501479e-06 1.278558e-04 [2]: 1.501479e-06 1.278558e-04
Poisson Solver 3D Cylindrical GPU test Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (129,129,144) Ukuran grid (r,phi,z) = (129,129,144)
Waktu komputasi: 1.200000e-01 s Waktu komputasi: 1.200000e-01 s
Jumlah iterasi siklus multigrid: 3 Jumlah iterasi siklus multigrid: 3
Iterasi Error Convergen Error Absolut Iterasi Error Convergen Error Absolut
[0]: 1.373293e-05 1.302576e-04 [0]: 1.373293e-05 1.302576e-04
[1]: 2.154564e-06 1.299626e-04 [1]: 2.154564e-06 1.299626e-04
[2]: 1.048384e-06 1.297261e-04 [2]: 1.048384e-06 1.297261e-04
Poisson Solver 3D Cylindrical GPU test Poisson Solver 3D Cylindrical GPU test
Ukuran grid (r,phi,z) = (257,257,288) Ukuran grid (r,phi,z) = (257,257,288)
Waktu komputasi: 6.900000e-01 s Waktu komputasi: 6.900000e-01 s
Jumlah iterasi siklus multigrid: 5 Jumlah iterasi siklus multigrid: 5
Iterasi Error Convergen Error Absolut Iterasi Error Convergen Error Absolut
[0]: 5.469890e-06 1.388922e-04 [0]: 5.469890e-06 1.388922e-04
[1]: 1.783695e-06 1.384964e-04 [1]: 1.783695e-06 1.384964e-04
[2]: 1.345343e-06 1.381199e-04 [2]: 1.345343e-06 1.381199e-04
[3]: 1.156555e-06 1.377524e-04 [3]: 1.156555e-06 1.377524e-04
[4]: 1.050234e-06 1.373983e-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 muatan $\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 buatan $$\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,3 +1,4 @@
/************************************************************************** /**************************************************************************
* Copyright(c) 2018, * * Copyright(c) 2018, *
* Kelompok penelitian komputasi berkinerja tinggi * * Kelompok penelitian komputasi berkinerja tinggi *
@ -29,9 +30,9 @@
#include <math.h> #include <math.h>
#include "PoissonSolver3DCylindricalGPU.h" #include "PoissonSolver3DCylindricalGPU.h"
const float PoissonSolver3DCylindricalGPU::fgkZ0 = 249.7; ///< panjang z const float PoissonSolver3DCylindricalGPU::fgkZ0 = 249.7; ///< nominal gating grid position
const float PoissonSolver3DCylindricalGPU::fgkIFCRadius = 83.5; ///< radius dalam 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; ///< radius luar const float PoissonSolver3DCylindricalGPU::fgkOFCRadius = 254.5; ///< Mean Radius of the Outer Field Cage (252.55 min, 256.45 max) (cm)
float PoissonSolver3DCylindricalGPU::fgExactErr = 1e-4; float PoissonSolver3DCylindricalGPU::fgExactErr = 1e-4;
float PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-3; float PoissonSolver3DCylindricalGPU::fgConvergenceError = 1e-3;

Loading…
Cancel
Save