Skip to content

Commit

Permalink
Remove API interface, cleanup and restore test
Browse files Browse the repository at this point in the history
  • Loading branch information
mconcas committed Sep 9, 2024
1 parent 4c56558 commit 09fdad9
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 325 deletions.
27 changes: 2 additions & 25 deletions Common/DCAFitter/GPU/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")

o2_add_library(DCAFitterCUDA
TARGETVARNAME targetName
SOURCES DCAFitterN.cu
Expand All @@ -21,35 +19,14 @@ o2_add_library(DCAFitterCUDA
PRIVATE_LINK_LIBRARIES O2::GPUTrackingCUDAExternalProvider)
set_property(TARGET ${targetName} PROPERTY CUDA_SEPARABLE_COMPILATION ON)

o2_add_library(DCAFitterAPICUDA
# TARGETVARNAME targetName2
SOURCES DCAFitterGPUAPI.cu
PUBLIC_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/Common/DCAFitter/GPU
PUBLIC_LINK_LIBRARIES O2::GPUCommon
O2::ReconstructionDataFormats
PRIVATE_LINK_LIBRARIES O2::DCAFitterCUDA
# O2::GPUTrackingCUDAExternalProvider
)
# set_property(TARGET ${targetName2} PROPERTY CUDA_SEPARABLE_COMPILATION ON)

o2_add_test(DCAFitterNCUDA
SOURCES test/testDCAFitterNGPU.cxx
PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats
O2::DCAFitterAPICUDA
O2::DCAFitterCUDA
O2::DCAFitter
ROOT::Core
ROOT::Physics
COMPONENT_NAME gpu
LABELS vertexing
ENVIRONMENT O2_ROOT=${CMAKE_BINARY_DIR}/stage
VMCWORKDIR=${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_DATADIR})

o2_add_executable(dca-fitter-on-gpu-cuda
TARGETVARNAME targetName3
SOURCES test/main_prog.cxx
PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats
O2::DCAFitterCUDA
O2::DCAFitter
ROOT::Core
ROOT::Physics)
# add_compile_options("-g -O0")
VMCWORKDIR=${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_DATADIR})
86 changes: 0 additions & 86 deletions Common/DCAFitter/GPU/cuda/DCAFitterGPUAPI.cu

This file was deleted.

20 changes: 0 additions & 20 deletions Common/DCAFitter/GPU/cuda/DCAFitterGPUAPI.h

This file was deleted.

52 changes: 46 additions & 6 deletions Common/DCAFitter/GPU/cuda/DCAFitterN.cu
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,58 @@ GPUg() void processKernel(o2::vertexing::DCAFitterN<2>* ft, o2::track::TrackParC
{
*res = ft->process(*t1, *t2);
}
} // namespace kernel

void printKHost(o2::vertexing::DCAFitterN<2>* ft, int th, int bl)
void printOnDevice(o2::vertexing::DCAFitterN<2>* ft,
const int nBlocks,
const int nThreads)
{
DCAFitterN<2>* ft_device;
gpuCheckError(cudaMalloc(reinterpret_cast<void**>(&ft_device), sizeof(o2::vertexing::DCAFitterN<2>)));
gpuCheckError(cudaMemcpy(ft_device, ft, sizeof(o2::vertexing::DCAFitterN<2>), cudaMemcpyHostToDevice));
LOGP(info, "ft: {} ft_device: {} size: {}", (void*)ft, (void*)ft_device, sizeof(o2::vertexing::DCAFitterN<2>));
printKernel<<<bl, th>>>(ft);

kernel::printKernel<<<nBlocks, nThreads>>>(ft_device);

gpuCheckError(cudaPeekAtLastError());
gpuCheckError(cudaDeviceSynchronize());
// static_assert(false);
}
} // namespace kernel

} // namespace o2::vertexing::gpu
int processOnDevice(o2::vertexing::DCAFitterN<2>* fitter,
o2::track::TrackParCov& track1,
o2::track::TrackParCov& track2,
const int nBlocks,
const int nThreads)
{
DCAFitterN<2>* ft_device;
o2::track::TrackParCov* t1_device;
o2::track::TrackParCov* t2_device;
int result, *result_device;

gpuCheckError(cudaMalloc(reinterpret_cast<void**>(&ft_device), sizeof(o2::vertexing::DCAFitterN<2>)));
gpuCheckError(cudaMalloc(reinterpret_cast<void**>(&t1_device), sizeof(o2::track::TrackParCov)));
gpuCheckError(cudaMalloc(reinterpret_cast<void**>(&t2_device), sizeof(o2::track::TrackParCov)));
gpuCheckError(cudaMalloc(reinterpret_cast<void**>(&result_device), sizeof(int)));

gpuCheckError(cudaMemcpy(ft_device, fitter, sizeof(o2::vertexing::DCAFitterN<2>), cudaMemcpyHostToDevice));
gpuCheckError(cudaMemcpy(t1_device, &track1, sizeof(o2::track::TrackParCov), cudaMemcpyHostToDevice));
gpuCheckError(cudaMemcpy(t2_device, &track2, sizeof(o2::track::TrackParCov), cudaMemcpyHostToDevice));

kernel::processKernel<<<nBlocks, nThreads>>>(ft_device, t1_device, t2_device, result_device);

gpuCheckError(cudaPeekAtLastError());
gpuCheckError(cudaDeviceSynchronize());

gpuCheckError(cudaMemcpy(&result, result_device, sizeof(int), cudaMemcpyDeviceToHost));
gpuCheckError(cudaMemcpy(fitter, ft_device, sizeof(o2::vertexing::DCAFitterN<2>), cudaMemcpyDeviceToHost));
gpuCheckError(cudaMemcpy(&track1, t1_device, sizeof(o2::track::TrackParCov), cudaMemcpyDeviceToHost));
gpuCheckError(cudaMemcpy(&track2, t2_device, sizeof(o2::track::TrackParCov), cudaMemcpyDeviceToHost));
gpuCheckError(cudaFree(ft_device));
gpuCheckError(cudaFree(t1_device));
gpuCheckError(cudaFree(t2_device));

gpuCheckError(cudaFree(result_device));

return result;
}

} // namespace o2::vertexing::gpu
138 changes: 0 additions & 138 deletions Common/DCAFitter/GPU/cuda/test/main_prog.cxx

This file was deleted.

Loading

0 comments on commit 09fdad9

Please sign in to comment.