Skip to content

Commit

Permalink
[SofaCUDA] Initialize module from another module (#4453)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger authored Jan 24, 2024
1 parent d614ca2 commit 308cfa5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
3 changes: 2 additions & 1 deletion applications/plugins/SofaCUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(SOFACUDA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/SofaCUDA")

set(HEADER_FILES
config.h.in
init.h

### Common
sofa/gpu/cuda/CudaBaseVector.h
Expand Down Expand Up @@ -99,7 +100,7 @@ set(HEADER_FILES

set(SOURCE_FILES
### Common
main.cpp
init.cpp
sofa/gpu/cuda/CudaBaseVector.cpp
sofa/gpu/cuda/mycuda.cpp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Contact information: [email protected] *
******************************************************************************/
#include <SofaCUDA/config.h>
#include <SofaCUDA/init.h>
#include <sofa/gpu/cuda/mycuda.h>
#include <sofa/core/ObjectFactory.h>

Expand All @@ -40,7 +41,7 @@ SOFA_GPU_CUDA_API bool moduleIsInitialized();

bool isModuleInitialized = false;

void initExternalModule()
void init()
{
static bool first = true;
if (first)
Expand All @@ -50,6 +51,11 @@ void initExternalModule()
}
}

void initExternalModule()
{
init();
}

const char* getModuleName()
{
return "SofaCUDA";
Expand Down
27 changes: 27 additions & 0 deletions applications/plugins/SofaCUDA/init.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: [email protected] *
******************************************************************************/
#pragma once
#include <SofaCUDA/config.h>
namespace sofa::gpu::cuda
{
SOFA_GPU_CUDA_API void init();
} // namespace sofa::gpu::cuda

0 comments on commit 308cfa5

Please sign in to comment.