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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,5 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
include(windeployqt)
windeployqt(${PROJECT_NAME} ${CMAKE_BINARY_DIR}/bin bin)
endif()

add_subdirectory(extensions)
6 changes: 6 additions & 0 deletions extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.22)

find_package(Sofa.Config)

sofa_add_subdirectory(plugin CUDA Sofa.Qt.CUDA)

30 changes: 30 additions & 0 deletions extensions/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.22)
project(Sofa.Qt.CUDA LANGUAGES CXX CUDA)

set(SOFAQTCUDA_SOURCE_DIR "src/sofa/qt/cuda")
set(HEADER_FILES
${SOFAQTCUDA_SOURCE_DIR}/init.h
${SOFAQTCUDA_SOURCE_DIR}/config.h.in
${SOFAQTCUDA_SOURCE_DIR}/CudaDataWidget.h
)

set(SOURCE_FILES
${SOFAQTCUDA_SOURCE_DIR}/init.cpp
${SOFAQTCUDA_SOURCE_DIR}/CudaDataWidget.cpp
)

sofa_find_package(Sofa.Qt REQUIRED)
sofa_find_package(SofaCUDA REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} Sofa.Qt)
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/Sofa.Qt.CUDAConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CMake package configuration file for the Sofa.QT.CUDA library

@PACKAGE_GUARD@
@PACKAGE_INIT@

find_package(Sofa.Qt QUIET REQUIRED)
find_package(SofaCUDA QUIET REQUIRED)

check_required_components(Sofa.Qt.CUDA)
81 changes: 81 additions & 0 deletions extensions/CUDA/src/sofa/qt/cuda/CudaDataWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/******************************************************************************
* 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 <sofa/qt/cuda/config.h>

#include <sofa/qt/cuda/CudaDataWidget.h>
#include <sofa/gpu/cuda/CudaTypes.h>
#include <sofa/helper/Factory.inl>
#include <sofa/qt/DataWidget.h>
#include <sofa/qt/SimpleDataWidget.h>
#include <sofa/qt/TableDataWidget.h>

namespace sofa::qt
{
using sofa::helper::Creator;
using namespace sofa::type;
using namespace sofa::defaulttype;

Creator<DataWidgetFactory, SimpleDataWidget< Vec<1, int> > > DWClass_Vec12i("default", true);

template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<int> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<unsigned int> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<float> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<double> >;

template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec1i> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec2i> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec3i> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec4i> >;

template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec1f> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec2f> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec3f> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec4f> >;

template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec1d> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec2d> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec3d> >;
template class SOFA_QT_CUDA_API TDataWidget<sofa::gpu::cuda::CudaVector<Vec4d> >;


Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<int>, TABLE_HORIZONTAL > > DWClass_cudaVectori("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<unsigned int>, TABLE_HORIZONTAL > > DWClass_cudaVectorui("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<float>, TABLE_HORIZONTAL > > DWClass_cudaVectorf("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<double>, TABLE_HORIZONTAL > > DWClass_cudaVectord("default", true);

Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec1i> > > DWClass_cudaVectorVec1i("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec2i> > > DWClass_cudaVectorVec2i("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec3i> > > DWClass_cudaVectorVec3i("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec4i> > > DWClass_cudaVectorVec4i("default", true);

Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec1f> > > DWClass_cudaVectorVec1f("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec2f> > > DWClass_cudaVectorVec2f("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec3f> > > DWClass_cudaVectorVec3f("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec4f> > > DWClass_cudaVectorVec4f("default", true);

Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec1d> > > DWClass_cudaVectorVec1d("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec2d> > > DWClass_cudaVectorVec2d("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec3d> > > DWClass_cudaVectorVec3d("default", true);
Creator<DataWidgetFactory, TableDataWidget< sofa::gpu::cuda::CudaVector<Vec4d> > > DWClass_cudaVectorVec4d("default", true);


} // namespace sofa::qt
62 changes: 62 additions & 0 deletions extensions/CUDA/src/sofa/qt/cuda/CudaDataWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/******************************************************************************
* 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 *
******************************************************************************/
#pragma once
#include <sofa/gpu/cuda/CudaTypes.h>
#include <sofa/qt/QModelViewTableDataContainer.h>

namespace sofa::qt
{
////////////////////////////////////////////////////////////////
/// variable-sized vectors support
////////////////////////////////////////////////////////////////

template<class T>
class vector_data_trait < sofa::gpu::cuda::CudaVector<T> >
{
public:
typedef sofa::gpu::cuda::CudaVector<T> data_type;
typedef T value_type;
enum { NDIM = 1 };
static int size(const data_type& d) {
return d.size();
}
static const char* header(const data_type& /*d*/, int /*i*/ = 0)
{
return nullptr;
}
static const value_type* get(const data_type& d, int i = 0)
{
return ((unsigned)i < (unsigned)size(d)) ? &(d[i]) : nullptr;
}
static void set(const value_type& v, data_type& d, int i = 0)
{
if ((unsigned)i < (unsigned)size(d))
d[i] = v;
}
static void resize(int s, data_type& d)
{
d.resize(s);
}
};


} // namespace sofa::qt
40 changes: 40 additions & 0 deletions extensions/CUDA/src/sofa/qt/cuda/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/******************************************************************************
* BeamAdapter plugin *
* (c) 2006 Inria, University of Lille, CNRS *
* *
* 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: see Authors.md *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once

#include <sofa/config.h>
#include <sofa/config/sharedlibrary_defines.h>

#define SOFA_QT_CUDA_VERSION @PROJECT_VERSION@

#ifdef SOFA_BUILD_SOFA_QT_CUDA
# define SOFA_TARGET @PROJECT_NAME@
# define SOFA_QT_CUDA_API SOFA_EXPORT_DYNAMIC_LIBRARY
#else
# define SOFA_QT_CUDA_API SOFA_IMPORT_DYNAMIC_LIBRARY
#endif

namespace sofa::qt::cuda
{
constexpr const char* MODULE_NAME = "@PROJECT_NAME@";
constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@";
} // namespace sofa::qt::cuda
83 changes: 83 additions & 0 deletions extensions/CUDA/src/sofa/qt/cuda/init.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/******************************************************************************
* BeamAdapter plugin *
* (c) 2006 Inria, University of Lille, CNRS *
* *
* 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: see Authors.md *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <sofa/qt/cuda/init.h>

#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/system/PluginManager.h>

namespace sofa::qt::cuda
{

extern "C" {
SOFA_QT_CUDA_API void initExternalModule();
SOFA_QT_CUDA_API const char* getModuleLicense();
SOFA_QT_CUDA_API const char* getModuleName();
SOFA_QT_CUDA_API const char* getModuleVersion();
SOFA_QT_CUDA_API const char* getModuleDescription();
SOFA_QT_CUDA_API void registerObjects(sofa::core::ObjectFactory* factory);
}

void init()
{
static bool first = true;
if (first)
{
// make sure that this plugin is registered into the PluginManager
sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME);

first = false;
}
}

//Here are just several convenient functions to help user to know what contains the plugin

void initExternalModule()
{
init();
}

const char* getModuleLicense()
{
return "LGPL";
}

const char* getModuleName()
{
return MODULE_NAME;
}

const char* getModuleVersion()
{
return MODULE_VERSION;
}

const char* getModuleDescription()
{
return "CUDA extension of the Sofa.Qt plugin.";
}

void registerObjects(sofa::core::ObjectFactory* factory)
{
SOFA_UNUSED(factory);
}

} // namespace sofa::qt::cuda
30 changes: 30 additions & 0 deletions extensions/CUDA/src/sofa/qt/cuda/init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/******************************************************************************
* BeamAdapter plugin *
* (c) 2006 Inria, University of Lille, CNRS *
* *
* 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: see Authors.md *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <sofa/qt/cuda/config.h>

namespace sofa::qt::cuda
{

void SOFA_QT_CUDA_API init();

} // namespace sofa::qt::cuda
Loading