Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 5 additions & 25 deletions applications/plugins/SofaCUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,6 @@ if(Sofa.Qt_FOUND)
list(APPEND SOURCE_FILES ${SOFACUDACORE_SOURCE_DIR}/sofa/gpu/gui/CudaDataWidget.cpp)
endif()

sofa_find_package(SofaValidation QUIET)
if(SofaValidation_FOUND)
list(APPEND SOURCE_FILES
${SOFACUDACORE_SOURCE_DIR}/sofa/gpu/cuda/CudaExtraMonitor.cpp
)
message(STATUS "SofaCUDA: found SofaValidation, enabling CudaExtraMonitor (Warning: this component is being deprecated). ")
endif()

option(SOFACUDA_VERBOSE_PTXAS "???" OFF)

option(SOFACUDA_CUBLAS "Activate cublas support in CUDA (requires SOFACUDA_DOUBLE)." OFF)
Expand All @@ -306,11 +298,6 @@ if(SOFACUDA_CUBLAS)
find_package(CUDASparse REQUIRED)
endif()

option(SOFACUDA_CUDPP "Activate CUDPP (for RadixSort)." OFF)
if(SOFACUDA_CUDPP)
set(SOFA_GPU_CUDPP 1) # #cmakedefine
endif()

# Note: THRUST is included in CUDA SDK 4.0+, it is recommended to use it if available
option(SOFACUDA_THRUST "Activate THRUST (for RadixSort)." ON)
if(SOFACUDA_THRUST)
Expand All @@ -323,14 +310,17 @@ if(SOFACUDA_DOUBLE)
endif()


option(SOFACUDA_DOUBLE_PRECISE "Enable double-precision for sqrt/div... (requires compute capability >= 2)" OFF)
# Note: with SOFA_GPU_CUDA_PRECISE and SOFA_GPU_CUDA_DOUBLE you get IEEE
# 754-compliant floating point operations for addition and multiplication only.
option(SOFACUDA_PRECISE "Use IEEE 754-compliant floating point operations." OFF)
option(SOFACUDA_DOUBLE_PRECISE "Enable double-precision for sqrt/div..." OFF)
if(SOFACUDA_PRECISE)
set(SOFA_GPU_CUDA_PRECISE 1) # #cmakedefine
endif()
if(SOFACUDA_DOUBLE_PRECISE)
set(SOFA_GPU_CUDA_DOUBLE_PRECISE 1) # #cmakedefine
endif()

option(SOFACUDA_PRECISE "Use IEEE 754-compliant floating point operations." OFF)

sofa_find_package(CUDAToolkit 11.0 REQUIRED)

Expand All @@ -342,9 +332,6 @@ if (${CUDA_HOST_COMPILER} MATCHES "ccache$")
set(CUDA_HOST_COMPILER "g++" CACHE STRING "Host side compiler used by NVCC" FORCE)
endif()

# quick and dirty fix for nvcc compatibility with -fno-partial-inlining flag
set(CUDA_PROPAGATE_HOST_FLAGS OFF)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${CUDA_SOURCES} ${README_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${SOFACUDA_COMPILE_DEFINITIONS}")
if(SOFACUDA_VERBOSE_PTXAS)
Expand Down Expand Up @@ -391,17 +378,10 @@ if(Sofa.Qt_FOUND)
target_link_libraries(${PROJECT_NAME} Sofa.Qt)
endif()

if(SofaValidation_FOUND)
target_link_libraries(${PROJECT_NAME} SofaValidation)
endif()

if(SOFACUDA_CUBLAS)
target_link_libraries(${PROJECT_NAME} ${CUDA_cusparse_LIBRARY} CUDA::cublas)

endif()
if(SOFACUDA_CUDPP)
target_link_libraries(${PROJECT_NAME} cudpp)
endif()

## Install rules for the library and headers; CMake package configurations files
sofa_create_package_with_targets(
Expand Down
14 changes: 0 additions & 14 deletions applications/plugins/SofaCUDA/SofaCUDAConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@ if(SOFACUDA_HAVE_SOFA_GUI_QT)
find_package(Sofa.Qt QUIET REQUIRED)
endif()

set(SOFACUDA_HAVE_SOFADISTANCEGRID @SOFACUDA_HAVE_SOFADISTANCEGRID@)
set(SOFACUDA_HAVE_MINIFLOWVR @SOFACUDA_HAVE_MINIFLOWVR@)
if(SOFACUDA_HAVE_SOFADISTANCEGRID)
find_package(SofaDistanceGrid QUIET REQUIRED)
if(SOFACUDA_HAVE_MINIFLOWVR)
find_package(miniFlowVR QUIET REQUIRED)
endif()
endif()

set(SOFACUDA_HAVE_SOFAVALIDATION @SOFACUDA_HAVE_SOFAVALIDATION@)
if(SOFACUDA_HAVE_SOFAVALIDATION)
find_package(SofaValidation QUIET REQUIRED)
endif()

if(NOT TARGET SofaCUDA)
include("${CMAKE_CURRENT_LIST_DIR}/SofaCUDATargets.cmake")
endif()
Expand Down
3 changes: 1 addition & 2 deletions applications/plugins/SofaCUDA/src/SofaCUDA/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
#define SOFACUDA_MAJOR_VERSION ${SOFACUDA_MAJOR_VERSION}
#define SOFACUDA_MINOR_VERSION ${SOFACUDA_MINOR_VERSION}

#cmakedefine SOFA_GPU_CUDPP
#cmakedefine SOFA_GPU_THRUST
#cmakedefine SOFA_GPU_CUDA_DOUBLE
#cmakedefine SOFA_GPU_CUDA_PRECISE
#cmakedefine SOFA_GPU_CUDA_DOUBLE_PRECISE
#cmakedefine SOFA_GPU_CUBLAS
#cmakedefine01 SOFACUDA_HAVE_MINIFLOWVR
#cmakedefine01 SOFACUDA_HAVE_SOFA_GL

#ifdef SOFA_BUILD_SOFACUDA
Expand Down

This file was deleted.

86 changes: 0 additions & 86 deletions applications/plugins/SofaCUDA/src/sofa/gpu/cuda/CudaScan.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,11 @@

#include <cuda.h>

#if defined(SOFA_GPU_CUDPP)
#include <cudpp.h>
#include <cudpp_plan.h>
#include <cudpp_plan_manager.h>
#include <cudpp_scan.h>
#endif

#if defined(SOFA_GPU_THRUST)
#include <thrust/device_vector.h>
#include <thrust/scan.h>
#endif

//#if !defined(SOFA_GPU_CUDPP) && !defined(SOFA_GPU_THRUST)
//#warning CUDA: please define either SOFA_GPU_CUDPP or SOFA_GPU_THRUST to activate scan on GPU
//#endif

#if defined(__cplusplus)
namespace sofa
{
Expand Down Expand Up @@ -281,60 +270,6 @@ bool CudaScanSOFA(const void* input, void* output, unsigned int size, ScanType t
}
}


#if defined(SOFA_GPU_CUDPP)

CUDPPHandle cudppHandleScan[2];
unsigned int cudppHandleScanMaxElements[2] = { 0, 0 };
bool cudppScanFailed = false;

bool CudaScanCUDPPAvailable(unsigned int size, ScanType type)
{
if (cudppScanFailed) return false;
int plan = (type == SCAN_INCLUSIVE ? 0 : 1);
if (size > cudppHandleScanMaxElements[plan])
{
if (cudppHandleScanMaxElements[plan] > 0)
{
cudppDestroyPlan(cudppHandleScan[plan]);
cudppHandleScanMaxElements[plan] = (((cudppHandleScanMaxElements[plan]>>10)+1)<<10); // increase size to at least the next multiple of 1024
}
if (size > cudppHandleScanMaxElements[plan])
cudppHandleScanMaxElements[plan] = size;
// if (cudppHandleScanMaxElements[plan] < (1<<18))
// cudppHandleScanMaxElements[plan] = (1<<18);
cudppHandleScanMaxElements[plan] = ((cudppHandleScanMaxElements[plan] + 255) & ~255);

mycudaPrintf("CudaScan: Creating CUDPP %s Scan Plan for %d elements.\n", (type == SCAN_INCLUSIVE ? "Inclusive" : "Exclusive"), cudppHandleScanMaxElements[plan]);
CUDPPConfiguration config;
config.algorithm = CUDPP_SCAN;
config.op = CUDPP_ADD;
config.datatype = CUDPP_UINT;
config.options = (type == SCAN_INCLUSIVE ? CUDPP_OPTION_INCLUSIVE : CUDPP_OPTION_EXCLUSIVE);

if (cudppPlan(&cudppHandleScan[plan], config, cudppHandleScanMaxElements[plan], 1, 0) != CUDPP_SUCCESS)
{
mycudaPrintf("CudaScan: ERROR creating CUDPP %s Scan Plan for %d elements.\n", (type == SCAN_INCLUSIVE ? "Inclusive" : "Exclusive"), cudppHandleScanMaxElements[plan]);
cudppHandleScanMaxElements[plan] = 0;
cudppDestroyPlan(cudppHandleScan[plan]);
cudppScanFailed = true;
return false;
}
}
return true;
}

bool CudaScanCUDPP(const void * d_input, void * d_output, unsigned int size, ScanType type)
{
if (!CudaScanCUDPPAvailable(size, type))
return false;
int plan = (type == SCAN_INCLUSIVE ? 0 : 1);
if (cudppScan(cudppHandleScan[plan],d_output,d_input,size) != CUDPP_SUCCESS)
return false;
return true;
}
#endif

#if defined(SOFA_GPU_THRUST)

unsigned int thrustScanMaxElements = 0;
Expand Down Expand Up @@ -379,9 +314,6 @@ enum ScanImplType
{
SCANDEFAULT = 0,
SCAN_SOFA,
#if defined(SOFA_GPU_CUDPP)
SCAN_CUDPP,
#endif
#if defined(SOFA_GPU_THRUST)
SCAN_THRUST,
#endif
Expand All @@ -401,10 +333,6 @@ ScanImplType CudaScanImpl()
impl = SCANDEFAULT;
else if ((str[0] == 'S' || str[0] == 's') && (str[1] == 'O' || str[1] == 'o'))
impl = SCAN_SOFA;
#if defined(SOFA_GPU_CUDPP)
else if ((str[0] == 'C' || str[0] == 'c') && (str[1] == 'U' || str[1] == 'u'))
impl = SCAN_CUDPP;
#endif
#if defined(SOFA_GPU_THRUST)
else if ((str[0] == 'T' || str[0] == 't') && (str[1] == 'H' || str[1] == 'h'))
impl = SCAN_THRUST;
Expand All @@ -422,13 +350,6 @@ bool CudaScanGPUAvailable(unsigned int size, ScanType type)
switch(impl)
{
case SCANDEFAULT: // alias for the first active implementation
#if defined(SOFA_GPU_CUDPP)
case SCAN_CUDPP:
if (CudaScanCUDPPAvailable(size, type))
return true;
if (impl != SCANDEFAULT)
break;
#endif
#if defined(SOFA_GPU_THRUST)
case SCAN_THRUST:
if (CudaScanTHRUSTAvailable(size, type))
Expand All @@ -448,13 +369,6 @@ bool CudaScanGPU(const void* input, void* output, unsigned int size, ScanType ty
switch(impl)
{
case SCANDEFAULT: // alias for the first active implementation
#if defined(SOFA_GPU_CUDPP)
case SCAN_CUDPP:
if (CudaScanCUDPP(input, output, size, type))
return true;
if (impl != SCANDEFAULT)
break;
#endif
#if defined(SOFA_GPU_THRUST)
case SCAN_THRUST:
if (CudaScanTHRUST(input, output, size, type))
Expand Down
Loading
Loading