Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
db59e9f
r12541/sofa-dev : WARNING: move cuda library into a plugin.
JeremieA Jun 28, 2012
60d7c80
r12640/sofa-dev : Move GPU SPH code to SofaCUDA plugin
JeremieA Aug 6, 2012
0c9e5aa
r12738/sofa-dev : FIX: for win32 Cuda configuration: windows needs th…
fspadoni Sep 11, 2012
8e37c21
r10105/sofa : Completing Rayleigh damping directly in Mass & ForceFie…
matthieu-nesme Oct 24, 2013
0d825c3
r10771/sofa : Reorganize modules/ by project (BIG CHANGE WARNING)
Mar 4, 2014
aa5911f
r10777/sofa : Roll back to revision 10770
Mar 5, 2014
5e7e99d
Fix modules includes for the whole repository
Jun 24, 2014
564369e
plugins: replace getX() calls with read()
Jul 17, 2014
a894897
SofaCUDA: fix compilation
Oct 29, 2014
813ac9e
removing all /* PARAMS FIRST */ comments, I cannot see them any longer
matthieu-nesme Mar 4, 2015
4f639dd
[SofaCUDA] fix compilation on mac (clang 3.7, CUDA 7.0)
BenjaminGilles Apr 20, 2015
6b96a09
[SofaCUDA] fix compilation on mac (clang 3.7, CUDA 7.0)
BenjaminGilles Apr 20, 2015
34888d6
Merge branch 'master' into unstable-buildsystem
Apr 22, 2015
79e6160
applications: clean up some includes
Jun 29, 2015
a9d8123
Merge branch master' into unstable-buildsystem
Jul 2, 2015
6717a03
Merge branch 'build-system' into master
Sep 15, 2015
5a2bd7a
updated the license.
etienneschmitt Nov 1, 2015
f093558
updating licenses.
etienneschmitt Feb 13, 2016
1a8b87a
[SOFA] Update the year 2017 in all file headers
Jan 9, 2017
2ec30f8
Merge pull request #123 from hugtalbot/update_year_2017
damienmarchal Jan 11, 2017
db9968c
[SofaCUDA] Update to properly handle the dependency with plugin/SofaS…
damienmarchal Sep 18, 2017
6b6e1e9
[SofaCUDA] fix compilation
fredroy Sep 29, 2017
6d101b6
Merge pull request #425 from mimesis-inria/update_draw_tool
guparan Oct 16, 2017
697c95d
[All] Update license headers 2018
guparan Feb 7, 2018
5124a22
[all] Remove all #ifdef SOFA_DEV
damienmarchal Nov 20, 2018
3344ab8
[All] Remove SOFA_DECL_CLASS and SOFA_LINK_CLASS (#837)
damienmarchal Nov 26, 2018
5ac6a41
Merge pull request #834 from sofa-framework/stc5
guparan Nov 29, 2018
b04ca4f
[All] Update license headers 2019
guparan Mar 1, 2019
7369291
Merge pull request #899 from guparan/clang_tidy_and_license_update
guparan Mar 8, 2019
bc11207
Merge remote-tracking branch 'upstream/master'
epernod Apr 8, 2019
4d1c5e2
[SofaCUDA] Fix CudaSPHFluidFF compilation due to Data prefix changes …
epernod Oct 16, 2019
26c67b2
[SofaCUDA] Fix CudaParticleSource compilation
epernod Oct 21, 2019
8a88bd7
Allowing SofaCUDA to compile without opengl
fredroy Jan 17, 2020
7036d56
fix CUDA collision models
hugtalbot Apr 3, 2020
e848f96
Update and simplify license header
hugtalbot May 7, 2020
cd2c499
Merge pull request #1375 from hugtalbot/update_header_202004
fredroy May 15, 2020
840331e
[All] Standardize index type for Vector/Matrix templates (#1453)
fredroy Sep 24, 2020
e932049
Merge remote-tracking branch 'defrost/pr-fix-default-APIVersion' into…
damienmarchal Sep 30, 2020
d760557
Merge remote-tracking branch 'defrost/pr-fix-default-APIVersion' into…
damienmarchal Sep 30, 2020
1787a9e
Merge remote-tracking branch 'defrost/pr-fix-default-APIVersion' into…
damienmarchal Sep 30, 2020
31e43ce
Merge remote-tracking branch 'sofa1/pr-remove-sout-serr' into pr-remo…
damienmarchal Oct 2, 2020
c1021cd
Merge remote-tracking branch 'defrost/pr-remove-sout-serr' into pr-re…
damienmarchal Oct 2, 2020
a1a6fad
Merge pull request #1513 from SofaDefrost/pr-remove-sout-serr
epernod Oct 6, 2020
b328dd0
[All] Uniform size type (#1515)
fredroy Oct 26, 2020
1c3ef1b
[All] Remove SOFA_NO_OPENGL (not the cmake option) (#1888)
fredroy Mar 10, 2021
8651b65
[All] Add forward declaration and opaque API for ExecParams, Mechanic…
damienmarchal Mar 15, 2021
6cb55c1
[Sofa.GL] Remove warnings from deprecated headers (#2045)
fredroy May 3, 2021
44bee83
[All] Remove use of compatibility layer (#2179)
fredroy Jul 1, 2021
09c5f62
[SofaCUDA] Remove calls to __umul24 on device (#2715)
epernod Mar 2, 2022
f9103fe
[Sofa] Compilation without Compatibility mode (#2975)
fredroy Jun 17, 2022
7694931
[SofaCUDA] Reorganize following SOFA structure (1/n) (#3601)
alxbilger Feb 8, 2023
f543a92
[SofaCUDA] Generalize the use of MessageDispatcher in SofaCUDA (#4430)
alxbilger Jan 24, 2024
0092e0d
[SofaCUDA] Fix spatial grid compilation with double (#4478)
alxbilger Feb 6, 2024
676aabc
[all] Apply nested namespaces (#4482)
alxbilger Feb 22, 2024
6fae386
[all] Set of fixes before lifecycle (#5306)
hugtalbot Mar 6, 2025
40818c8
[all] Lifecycle : Remove SOFA_ATTRIBUTE_DEPRECATED (part 2) (#5347)
hugtalbot Mar 26, 2025
c44d61c
skeleton for the CUDA extension of SPH
alxbilger May 12, 2025
5c254fc
Merge remote-tracking branch 'sofa/master' into cudaextension
alxbilger May 12, 2025
166670c
move files from the sofa structure to the extension structure
alxbilger May 12, 2025
c0652fb
adapt includes
alxbilger May 12, 2025
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sofa_find_package(Sofa.GL QUIET)
set(PLUGIN_SPH_SRC_DIR src/SofaSphFluid)
set(HEADER_FILES
${PLUGIN_SPH_SRC_DIR}/config.h.in
${PLUGIN_SPH_SRC_DIR}/initSPHFluid.h
${PLUGIN_SPH_SRC_DIR}/ParticleSink.h
${PLUGIN_SPH_SRC_DIR}/ParticleSink.inl
${PLUGIN_SPH_SRC_DIR}/ParticleSource.h
Expand Down Expand Up @@ -74,3 +75,5 @@ sofa_create_package_with_targets(
INCLUDE_INSTALL_DIR ${PROJECT_NAME}
RELOCATABLE "plugins"
)

sofa_add_subdirectory(plugin extensions/CUDA SofaSphFluid.CUDA)
48 changes: 48 additions & 0 deletions extensions/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.12)
project(SofaSphFluid.CUDA CUDA CXX)

set(HEADER_FILES
src/SofaSphFluid/CUDA/init.h
src/SofaSphFluid/CUDA/config.h.in

src/SofaSphFluid/CUDA/CudaParticleSource.h
src/SofaSphFluid/CUDA/CudaParticleSource.inl
src/SofaSphFluid/CUDA/CudaSPHFluidForceField.h
src/SofaSphFluid/CUDA/CudaSPHFluidForceField.inl
src/SofaSphFluid/CUDA/CudaParticlesRepulsionForceField.h
src/SofaSphFluid/CUDA/CudaParticlesRepulsionForceField.inl
src/SofaSphFluid/CUDA/CudaSpatialGridContainer.h
src/SofaSphFluid/CUDA/CudaSpatialGridContainer.inl
)

set(SOURCE_FILES
src/SofaSphFluid/CUDA/init.cpp

src/SofaSphFluid/CUDA/CudaParticleSource.cpp
src/SofaSphFluid/CUDA/CudaSPHFluidForceField.cpp
src/SofaSphFluid/CUDA/CudaParticlesRepulsionForceField.cpp
src/SofaSphFluid/CUDA/CudaSpatialGridContainer.cpp
)

set(CUDA_SOURCES
src/SofaSphFluid/CUDA/CudaParticleSource.cu
src/SofaSphFluid/CUDA/CudaSPHFluidForceField.cu
src/SofaSphFluid/CUDA/CudaParticlesRepulsionForceField.cu
src/SofaSphFluid/CUDA/CudaSpatialGridContainer.cu
)

sofa_find_package(SofaSphFluid REQUIRED)
sofa_find_package(SofaCUDA REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${CUDA_SOURCES})
target_link_libraries(${PROJECT_NAME} SofaSphFluid)
target_link_libraries(${PROJECT_NAME} SofaCUDA)

sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
PACKAGE_VERSION ${Sofa_VERSION}
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
RELOCATABLE "plugins"
)
9 changes: 9 additions & 0 deletions extensions/CUDA/SofaSphFluid.CUDAConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CMake package configuration file for the SofaSphFluid.CUDA library

@PACKAGE_GUARD@
@PACKAGE_INIT@

find_package(SofaSphFluid QUIET REQUIRED)
find_package(SofaCUDA QUIET REQUIRED)

check_required_components(SofaSphFluid.CUDA)
56 changes: 56 additions & 0 deletions extensions/CUDA/src/SofaSphFluid/CUDA/CudaParticleSource.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <SofaCUDA/sofa/gpu/cuda/CudaTypes.h>
#include "CudaParticleSource.inl"
#include <sofa/core/ObjectFactory.h>
#include <sofa/core/behavior/ProjectiveConstraintSet.h>
#include <SofaSphFluid/ParticleSource.inl>

namespace sofa
{


namespace core::behavior
{
template class ProjectiveConstraintSet<gpu::cuda::CudaVec3fTypes>;
#ifdef SOFA_GPU_CUDA_DOUBLE
template class ProjectiveConstraintSet<gpu::cuda::CudaVec3dTypes>;
#endif
} // namespace core::behavior


namespace gpu::cuda
{



int ParticleSourceCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA")
.add< component::misc::ParticleSource<CudaVec3fTypes> >()
#ifdef SOFA_GPU_CUDA_DOUBLE
.add< component::misc::ParticleSource<CudaVec3dTypes> >()
#endif // SOFA_GPU_CUDA_DOUBLE
;

} // namespace gpu::cuda


} // namespace sofa
132 changes: 132 additions & 0 deletions extensions/CUDA/src/SofaSphFluid/CUDA/CudaParticleSource.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <SofaCUDA/sofa/gpu/cuda/CudaCommon.h>
#include <SofaCUDA/sofa/gpu/cuda/CudaMath.h>
#include "cuda.h"

#if defined(__cplusplus) && CUDA_VERSION < 2000
namespace sofa
{
namespace gpu
{
namespace cuda
{
#endif

extern "C"
{

void ParticleSourceCuda3f_fillValues(unsigned int totalsize, unsigned int subsetsize, void* dest, const void* indices, float fx, float fy, float fz);
void ParticleSourceCuda3f_copyValuesWithOffset(unsigned int totalsize, unsigned int subsetsize, void* dest, const void* indices, const void* src, float fx, float fy, float fz);

#ifdef SOFA_GPU_CUDA_DOUBLE

void ParticleSourceCuda3d_fillValues(unsigned int totalsize, unsigned int subsetsize, void* dest, const void* indices, double fx, double fy, double fz);
void ParticleSourceCuda3d_copyValuesWithOffset(unsigned int totalsize, unsigned int subsetsize, void* dest, const void* indices, const void* src, double fx, double fy, double fz);

#endif // SOFA_GPU_CUDA_DOUBLE
}

//////////////////////
// GPU-side methods //
//////////////////////


template<class real>
__global__ void ParticleSourceCuda3t_fillValues_kernel(unsigned int totalsize, unsigned int subsetsize, real* dest, const unsigned int* indices, real fx, real fy, real fz)
{
unsigned int index0 = blockIdx.x * BSIZE;
unsigned int index = index0+threadIdx.x;
if (index < subsetsize)
{
unsigned int dindex = indices[index];
if (dindex < totalsize)
{
unsigned int dindex3 = dindex * 3;
dest[dindex3+0] = fx;
dest[dindex3+1] = fy;
dest[dindex3+2] = fz;
}
}
}

template<class real>
__global__ void ParticleSourceCuda3t_copyValuesWithOffset_kernel(unsigned int totalsize, unsigned int subsetsize, real* dest, const unsigned int* indices, const real* src, real fx, real fy, real fz)
{
unsigned int index0 = blockIdx.x * BSIZE;
unsigned int index = index0+threadIdx.x;
if (index < subsetsize)
{
unsigned int dindex = indices[index];
if (dindex < totalsize)
{
unsigned int dindex3 = dindex * 3;
unsigned int index3 = index * 3;
dest[dindex3+0] = src[index3+0]+fx;
dest[dindex3+1] = src[index3+1]+fy;
dest[dindex3+2] = src[index3+2]+fz;
}
}
}

//////////////////////
// CPU-side methods //
//////////////////////


void ParticleSourceCuda3f_fillValues(unsigned int totalsize, unsigned int subsetsize, void* dest, const void* indices, float fx, float fy, float fz)
{
dim3 threads(BSIZE,1);
dim3 grid((subsetsize+BSIZE-1)/BSIZE,1);
{ParticleSourceCuda3t_fillValues_kernel<float><<< grid, threads >>>(totalsize, subsetsize, (float*)dest, (const unsigned int*)indices, fx, fy, fz); mycudaDebugError("ParticleSourceCuda3t_fillValues_kernel<float>");}
}

void ParticleSourceCuda3f_copyValuesWithOffset(unsigned int totalsize, unsigned int subsetsize, void* dest, const void* indices, const void* src, float fx, float fy, float fz)
{
dim3 threads(BSIZE,1);
dim3 grid((subsetsize+BSIZE-1)/BSIZE,1);
{ParticleSourceCuda3t_copyValuesWithOffset_kernel<float><<< grid, threads >>>(totalsize, subsetsize, (float*)dest, (const unsigned int*)indices, (const float*)src, fx, fy, fz); mycudaDebugError("ParticleSourceCuda3t_copyValuesWithOffset_kernel<float>");}
}

#ifdef SOFA_GPU_CUDA_DOUBLE

void ParticleSourceCuda3d_fillValues(unsigned int totalsize, unsigned int subsetsize, void* dest, const void* indices, double fx, double fy, double fz)
{
dim3 threads(BSIZE,1);
dim3 grid((subsetsize+BSIZE-1)/BSIZE,1);
{ParticleSourceCuda3t_fillValues_kernel<double><<< grid, threads >>>(totalsize, subsetsize, (double*)dest, (const unsigned int*)indices, fx, fy, fz); mycudaDebugError("ParticleSourceCuda3t_fillValues_kernel<double>");}
}

void ParticleSourceCuda3d_copyValuesWithOffset(unsigned int totalsize, unsigned int subsetsize, void* dest, const void* indices, const void* src, double fx, double fy, double fz)
{
dim3 threads(BSIZE,1);
dim3 grid((subsetsize+BSIZE-1)/BSIZE,1);
{ParticleSourceCuda3t_copyValuesWithOffset_kernel<double><<< grid, threads >>>(totalsize, subsetsize, (double*)dest, (const unsigned int*)indices, (const double*)src, fx, fy, fz); mycudaDebugError("ParticleSourceCuda3t_copyValuesWithOffset_kernel<double>");}
}

#endif // SOFA_GPU_CUDA_DOUBLE

#if defined(__cplusplus) && CUDA_VERSION < 2000
} // namespace cuda
} // namespace gpu
} // namespace sofa
#endif
27 changes: 27 additions & 0 deletions extensions/CUDA/src/SofaSphFluid/CUDA/CudaParticleSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef SOFA_GPU_CUDA_CUDAPARTICLESOURCE_H
#define SOFA_GPU_CUDA_CUDAPARTICLESOURCE_H

#include <SofaCUDA/sofa/gpu/cuda/CudaTypes.h>

#endif
Loading
Loading