parent
79aebf71e2
commit
42c0661960
9 changed files with 415 additions and 14 deletions
@ -0,0 +1,44 @@ |
|||||||
|
# MakeLists files in this project can |
||||||
|
# refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and |
||||||
|
# to the root binary directory of the project as ${HELLO_BINARY_DIR}. |
||||||
|
cmake_minimum_required (VERSION 2.8.11) |
||||||
|
project (3DPoissonSolverGPU) |
||||||
|
|
||||||
|
# Recurse into the "Hello" and "Demo" subdirectories. This does not actually |
||||||
|
# cause another cmake executable to run. The same process will walk through |
||||||
|
# the project's entire directory structure. |
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH}) |
||||||
|
find_package(CUDA QUIET REQUIRED) |
||||||
|
find_package(Doxygen) |
||||||
|
|
||||||
|
if (DOXYGEN_FOUND) |
||||||
|
# set input and output files |
||||||
|
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in) |
||||||
|
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) |
||||||
|
|
||||||
|
# request to configure the file |
||||||
|
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) |
||||||
|
message("Doxygen build started") |
||||||
|
|
||||||
|
# note the option ALL which allows to build the docs together with the application |
||||||
|
add_custom_target( doc_doxygen ALL |
||||||
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} |
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
||||||
|
COMMENT "Generating API documentation with Doxygen" |
||||||
|
VERBATIM ) |
||||||
|
else (DOXYGEN_FOUND) |
||||||
|
message("Doxygen need to be installed to generate the doxygen documentation") |
||||||
|
endif (DOXYGEN_FOUND) |
||||||
|
|
||||||
|
|
||||||
|
enable_testing() |
||||||
|
set(TARGET_NAME poissonsolvergpu) |
||||||
|
|
||||||
|
set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF) |
||||||
|
set(BUILD_SHARED_LIBS ON) |
||||||
|
list(APPEND CUDA_NVCC_FLAGS) |
||||||
|
|
||||||
|
add_subdirectory (kernel) |
||||||
|
add_subdirectory (interface) |
||||||
|
|
@ -0,0 +1,114 @@ |
|||||||
|
/// \author Rifki Sadikin <rifki.sadikin@cern.ch>, Indonesian Institute of Sciences
|
||||||
|
/// \date Nov 20, 2017
|
||||||
|
|
||||||
|
#include <math.h> |
||||||
|
#include "PoissonSolver3DCylindricalGPU.h" |
||||||
|
|
||||||
|
///
|
||||||
|
PoissonSolver3DCylindricalGPU::PoissonSolver3DCylindricalGPU() { |
||||||
|
|
||||||
|
fErrorConvF = new float [fMgParameters.nMGCycle]; |
||||||
|
fErrorExactF = new float [fMgParameters.nMGCycle]; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
PoissonSolver3DCylindricalGPU::PoissonSolver3DCylindricalGPU(int nRRow, int nZColumn, int nPhiSlice) {
|
||||||
|
fNRRow = nRRow; |
||||||
|
fNZColumn = nZColumn; |
||||||
|
fPhiSlice = nPhiSlice; |
||||||
|
fErrorConvF = new float [fMgParameters.nMGCycle]; |
||||||
|
fErrorExactF = new float [fMgParameters.nMGCycle]; |
||||||
|
} |
||||||
|
/// destructor
|
||||||
|
PoissonSolver3DCylindricalGPU::~PoissonSolver3DCylindricalGPU() { |
||||||
|
delete fErrorConvF; |
||||||
|
delete fErrorExactF; |
||||||
|
delete fExactSolutionF; |
||||||
|
} |
||||||
|
|
||||||
|
/// function overriding
|
||||||
|
void PoissonSolver3DCylindricalGPU::PoissonSolver3D(float *matricesV, float *matricesCharge, |
||||||
|
int nRRow, int nZColumn, int phiSlice, int maxIteration, |
||||||
|
int symmetry) { |
||||||
|
|
||||||
|
fNRRow = nRRow; |
||||||
|
fNZColumn = nZColumn; |
||||||
|
fPhiSlice = phiSlice; |
||||||
|
|
||||||
|
PoissonMultiGrid3D2D(matricesV, matricesCharge, nRRow, nZColumn, phiSlice, symmetry); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// method to do multigrid3d2d
|
||||||
|
void PoissonSolver3DCylindricalGPU::PoissonMultiGrid3D2D(float *VPotential, float * RhoChargeDensities, int nRRow, |
||||||
|
int nZColumn, int phiSlice, int symmetry) { |
||||||
|
|
||||||
|
const float gridSizeR = (PoissonSolver3DCylindricalGPU::fgkOFCRadius-PoissonSolver3DCylindricalGPU::fgkIFCRadius) / (nRRow-1); // h_{r}
|
||||||
|
const float gridSizePhi = M_PI/phiSlice; // h_{phi}
|
||||||
|
const float gridSizeZ = PoissonSolver3DCylindricalGPU::fgkTPCZ0 / (nZColumn-1) ; // h_{z}
|
||||||
|
const float ratioPhi = gridSizeR*gridSizeR / (gridSizePhi*gridSizePhi) ; // ratio_{phi} = gridsize_{r} / gridsize_{phi}
|
||||||
|
const float ratioZ = gridSizeR*gridSizeR / (gridSizeZ*gridSizeZ) ; // ratio_{Z} = gridsize_{r} / gridsize_{z}
|
||||||
|
const float convErr = PoissonSolver3DCylindricalGPU::fgConvergenceError; |
||||||
|
const float IFCRadius = PoissonSolver3DCylindricalGPU::fgkIFCRadius; |
||||||
|
|
||||||
|
int fparamsize = 8; |
||||||
|
float * fparam = new float[fparamsize]; |
||||||
|
|
||||||
|
fparam[0] = gridSizeR; |
||||||
|
fparam[1] = gridSizePhi; |
||||||
|
fparam[2] = gridSizeZ; |
||||||
|
fparam[3] = ratioPhi; |
||||||
|
fparam[4] = ratioZ; |
||||||
|
fparam[5] = convErr; |
||||||
|
fparam[6] = IFCRadius; |
||||||
|
|
||||||
|
int iparamsize = 4; |
||||||
|
int * iparam = new int[iparamsize]; |
||||||
|
|
||||||
|
iparam[0] = fMgParameters.nPre;
|
||||||
|
iparam[1] = fMgParameters.nPost;
|
||||||
|
iparam[2] = fMgParameters.maxLoop; |
||||||
|
iparam[3] = fMgParameters.nMGCycle; |
||||||
|
|
||||||
|
|
||||||
|
if (fMgParameters.cycleType == kFCycle) |
||||||
|
{ |
||||||
|
if (fExactPresent == true) {
|
||||||
|
PoissonMultigrid3DSemiCoarseningGPUErrorFCycle(VPotential, RhoChargeDensities,nRRow, nZColumn,phiSlice,symmetry, fparam, iparam, fExactPresent, fErrorConvF, fErrorExactF, fExactSolutionF); |
||||||
|
} else { |
||||||
|
PoissonMultigrid3DSemiCoarseningGPUErrorFCycle(VPotential, RhoChargeDensities,nRRow, nZColumn,phiSlice,symmetry, fparam, iparam, fExactPresent, fErrorConvF, fErrorExactF, NULL); |
||||||
|
|
||||||
|
} |
||||||
|
} else if (fMgParameters.cycleType == kWCycle)
|
||||||
|
{ |
||||||
|
PoissonMultigrid3DSemiCoarseningGPUErrorWCycle(VPotential, RhoChargeDensities,nRRow, nZColumn,phiSlice,symmetry, fparam, iparam, fErrorConvF, fErrorExactF, fExactSolutionF); |
||||||
|
} else
|
||||||
|
{ |
||||||
|
if (fExactPresent == true) { |
||||||
|
PoissonMultigrid3DSemiCoarseningGPUError(VPotential, RhoChargeDensities,nRRow, nZColumn,phiSlice,symmetry, fparam, iparam, fExactPresent, fErrorConvF, fErrorExactF, fExactSolutionF); |
||||||
|
} else { |
||||||
|
PoissonMultigrid3DSemiCoarseningGPUError(VPotential, RhoChargeDensities,nRRow, nZColumn,phiSlice,symmetry, fparam, iparam, fExactPresent, fErrorConvF, fErrorExactF, NULL); |
||||||
|
} |
||||||
|
}
|
||||||
|
fIterations = iparam[3]; |
||||||
|
delete[] fparam; |
||||||
|
delete[] iparam; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PoissonSolver3DCylindricalGPU::SetExactSolution(float*exactSolution,int nRRow, int nZColumn, int phiSlice) { |
||||||
|
fNRRow = nRRow; |
||||||
|
fNZColumn = nZColumn; |
||||||
|
fPhiSlice = phiSlice; |
||||||
|
fExactSolutionF = new float[fNRRow * fPhiSlice,fNZColumn]; |
||||||
|
fExactPresent = true; |
||||||
|
fMaxExact = 0.0;; |
||||||
|
for (int i=0;i<nRRow*nZColumn*phiSlice;i++) { |
||||||
|
fExactSolutionF[i] = exactSolution[i]; |
||||||
|
if (abs(fExactSolutionF[i]) > fMaxExact) fMaxExact = abs(fExactSolutionF[i]);
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,129 @@ |
|||||||
|
#ifndef POISSONSOLVER3DCYLINDRICALGPU_H |
||||||
|
#define POISSONSOLVER3DCYLINDRICALGPU_H |
||||||
|
|
||||||
|
/// \author Rifki Sadikin <rifki.sadikin@cern.ch>, Indonesian Institute of Sciences
|
||||||
|
/// \date Nov 20, 2017
|
||||||
|
#include "PoissonSolver3DGPU.h" |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PoissonSolver3DCylindricalGPU { |
||||||
|
public: |
||||||
|
///< Enumeration of Poisson Solver Strategy Type
|
||||||
|
enum StrategyType { |
||||||
|
kRelaxation = 0, ///< S.O.R Cascaded MultiGrid
|
||||||
|
kMultiGrid = 1, ///< Geometric MG
|
||||||
|
kFastRelaxation = 2 ///< Spectral (TODO)
|
||||||
|
}; |
||||||
|
|
||||||
|
///< Enumeration of Cycles Type
|
||||||
|
enum CycleType { |
||||||
|
kVCycle = 0, ///< V Cycle
|
||||||
|
kWCycle = 1, ///< W Cycle (TODO)
|
||||||
|
kFCycle = 2 ///< Full Cycle
|
||||||
|
}; |
||||||
|
|
||||||
|
///< Fine -> Coarse Grid transfer operator types
|
||||||
|
enum GridTransferType { |
||||||
|
kHalf = 0, ///< Half weighting
|
||||||
|
kFull = 1, ///< Full weighting
|
||||||
|
}; |
||||||
|
|
||||||
|
///< Smoothing (Relax) operator types
|
||||||
|
enum RelaxType { |
||||||
|
kJacobi = 0, ///< Jacobi (5 Stencil 2D, 7 Stencil 3D_
|
||||||
|
kWeightedJacobi = 1, ///< (TODO)
|
||||||
|
kGaussSeidel = 2 ///< Gauss Seidel 2D (2 Color, 5 Stencil), 3D (7 Stencil)
|
||||||
|
}; |
||||||
|
|
||||||
|
///< Coarse -> fine operator types (TODO: Interp and Restrict in one packet, just one enumeration)
|
||||||
|
enum InterpType { |
||||||
|
kHalfInterp = 0, ///< Half bi linear interpolation
|
||||||
|
kFullInterp = 1 ///< Full bi linear interpolation
|
||||||
|
}; |
||||||
|
|
||||||
|
///< Parameters choice for MultiGrid algorithm
|
||||||
|
struct MGParameters { |
||||||
|
bool isFull3D; ///< TRUE: full coarsening, FALSE: semi coarsening
|
||||||
|
CycleType cycleType; ///< cycleType follow CycleType
|
||||||
|
GridTransferType gtType; ///< gtType grid transfer type follow GridTransferType
|
||||||
|
RelaxType relaxType; ///< relaxType follow RelaxType
|
||||||
|
int gamma; ///< number of iteration at coarsest level
|
||||||
|
int nPre; ///< number of iteration for pre smoothing
|
||||||
|
int nPost; ///< number of iteration for post smoothing
|
||||||
|
int nMGCycle; ///< number of multi grid cycle (V type)
|
||||||
|
int maxLoop; ///< the number of tree-deep of multi grid
|
||||||
|
|
||||||
|
|
||||||
|
// default values
|
||||||
|
MGParameters() { |
||||||
|
isFull3D = false; |
||||||
|
cycleType = kFCycle; |
||||||
|
gtType = kFull; // default full
|
||||||
|
relaxType = kGaussSeidel; // default relaxation method
|
||||||
|
nPre = 2; |
||||||
|
nPost = 2; |
||||||
|
nMGCycle = 200; |
||||||
|
maxLoop = 6; |
||||||
|
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static const float fgkTPCZ0; ///< nominal gating grid position
|
||||||
|
static const float fgkIFCRadius; ///< Mean Radius of the Inner Field Cage ( 82.43 min, 83.70 max) (cm)
|
||||||
|
static const float fgkOFCRadius; ///< Mean Radius of the Outer Field Cage (252.55 min, 256.45 max) (cm)
|
||||||
|
static const float fgkZOffSet; ///< Offset from CE: calculate all distortions closer to CE as if at this point
|
||||||
|
static const float fgkCathodeV; ///< Cathode Voltage (volts)
|
||||||
|
static const float fgkGG; ///< Gating Grid voltage (volts)
|
||||||
|
static const float fgkdvdE; ///< [cm/V] drift velocity dependency on the E field (from Magboltz for NeCO2N2 at standard environment)
|
||||||
|
static const float fgkEM; ///< charge/mass in [C/kg]
|
||||||
|
static const float fgke0; ///< vacuum permittivity [A·s/(V·m)]
|
||||||
|
|
||||||
|
static float fgExactErr; ///< Error tolerated
|
||||||
|
static float fgConvergenceError; ///< Error tolerated
|
||||||
|
int fIterations; ///< number of maximum iteration
|
||||||
|
MGParameters fMgParameters; ///< parameters multi grid
|
||||||
|
|
||||||
|
void SetExactSolution(float *exactSolution, const int fPhiSlices); |
||||||
|
void SetCycleType(PoissonSolver3DCylindricalGPU::CycleType cycleType) { |
||||||
|
fMgParameters.cycleType = cycleType; |
||||||
|
} |
||||||
|
|
||||||
|
StrategyType fStrategy; ///< strategy used default multiGrid
|
||||||
|
PoissonSolver3DCylindricalGPU(); |
||||||
|
PoissonSolver3DCylindricalGPU(int nRRow, int nZColumn, int nPhiSlice); |
||||||
|
PoissonSolver3DCylindricalGPU(const char *name, const char *title); |
||||||
|
virtual ~PoissonSolver3DCylindricalGPU(); |
||||||
|
void PoissonSolver3D(float *matricesV, float *matricesChargeDensities, int nRRow, int nZColumn, |
||||||
|
int phiSlice, int maxIterations, int symmetry); |
||||||
|
|
||||||
|
|
||||||
|
// setter and getter
|
||||||
|
void SetStrategy(StrategyType strategy) {fStrategy = strategy;} |
||||||
|
StrategyType GetStrategy() { return fStrategy; } |
||||||
|
void SetExactSolution(float *exactSolution,int nRRow, int nZColumn, int phiSlice); |
||||||
|
float *fExactSolutionF;
|
||||||
|
private: |
||||||
|
PoissonSolver3DCylindricalGPU(const PoissonSolver3DCylindricalGPU &); // not implemented
|
||||||
|
PoissonSolver3DCylindricalGPU &operator=(const PoissonSolver3DCylindricalGPU &); // not implemented
|
||||||
|
void PoissonMultiGrid3D2D(float *VPotential, float *RhoChargeDensities, int nRRow, |
||||||
|
int nZColumn, int phiSlice, int symmetry); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// store potential and charge
|
||||||
|
float * fVPotential; //-> hold potential in an object of tmatrixd
|
||||||
|
float * fRhoCharge; //-> pointer to an object of tmatrixd for storing charge
|
||||||
|
int fNRRow; |
||||||
|
int fNZColumn; |
||||||
|
int fPhiSlice; |
||||||
|
// error single precision for cuda-based
|
||||||
|
float *fErrorConvF; |
||||||
|
float *fErrorExactF; |
||||||
|
bool fExactPresent; |
||||||
|
float fMaxExact; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,37 @@ |
|||||||
|
set(SRCS |
||||||
|
${SCGPUDIR}/interface/AliTPCPoissonSolverMem.cxx |
||||||
|
# ${CAGPU_O} |
||||||
|
) |
||||||
|
|
||||||
|
# Headers from sources |
||||||
|
set(CINTHDRS |
||||||
|
${SCGPUDIR}/interface/AliTPCPoissonSolverMem.h |
||||||
|
${SCGPUDIR}/interface/AliCudaLinkDef.h |
||||||
|
) |
||||||
|
|
||||||
|
set(HDRS |
||||||
|
) |
||||||
|
|
||||||
|
# Generate the dictionary |
||||||
|
# It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument |
||||||
|
get_directory_property(incdirs INCLUDE_DIRECTORIES) |
||||||
|
generate_dictionary("${MODULE}" "" "${CINTHDRS}" "${incdirs}") |
||||||
|
|
||||||
|
# Generate the ROOT map |
||||||
|
# Dependecies |
||||||
|
generate_rootmap("${MODULE}" "" "") |
||||||
|
|
||||||
|
# Add a library to the project using the specified source files |
||||||
|
add_library_tested(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx) |
||||||
|
#CUDA run-time and driver |
||||||
|
target_link_libraries(${MODULE} ${CUDA_LIBRARIES} ${LIBCUDA_SO_PATH} AliTPCSpaceCharge3DDriftLine) |
||||||
|
|
||||||
|
# Additional compilation flags |
||||||
|
set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS "") |
||||||
|
|
||||||
|
# Installation |
||||||
|
install(TARGETS ${MODULE} |
||||||
|
ARCHIVE DESTINATION lib |
||||||
|
LIBRARY DESTINATION lib) |
||||||
|
|
||||||
|
install(FILES ${HDRS} DESTINATION include) |
Loading…
Reference in new issue