Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMP: Fix compilation issues with CUDA after recent ITK updates in 3D Slicer #3

Open
wants to merge 4 commits into
base: slicerrt-1.9.3-2022.06.15-77b40bd3
Choose a base branch
from
Open
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
27 changes: 17 additions & 10 deletions cmake/FindCUDA_wrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ endif ()

# 14-5-2016 PAOLO: WORKAROUND GCC 6.1 AND CUDA 7.5 INCOMPATIBILITY
if (CMAKE_COMPILER_IS_GNUCC
AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0))
set (CUDA_CXX_FLAGS "${CUDA_CXX_FLAGS},-std=c++98")
AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
AND (NOT CUDA_VERSION_MAJOR VERSION_GREATER 7))
set (CUDA_CXX_FLAGS "${CUDA_CXX_FLAGS},-std=c++98")
endif ()

# ITK headers cannot be processed by nvcc, so we define
Expand Down Expand Up @@ -181,19 +182,25 @@ if (CUDA_FOUND)
--Wno-deprecated-gpu-targets)
endif ()

if (CUDA_VERSION_MAJOR EQUAL "9"
AND CMAKE_COMPILER_IS_GNUCC
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
list (APPEND CUDA_NVCC_FLAGS
--compiler-options -D__GNUC__=6)
endif ()

# GCS 2017-10-24: Let CUDA work with gcc 6 and CUDA 8
# Let CUDA work with unsupported (too new) gcc versions
# Note: CUDA 10 cannot be used with gcc 10 or greater.
if (CUDA_VERSION_MAJOR EQUAL "8"
AND CMAKE_COMPILER_IS_GNUCC
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
list (APPEND CUDA_NVCC_FLAGS
--compiler-options -D__GNUC__=5)
elseif (CUDA_VERSION_MAJOR EQUAL "9"
AND CMAKE_COMPILER_IS_GNUCC
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
list (APPEND CUDA_NVCC_FLAGS
--compiler-options -D__GNUC__=6)
elseif (CUDA_VERSION_MAJOR EQUAL "10"
AND CMAKE_COMPILER_IS_GNUCC)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
list (APPEND CUDA_NVCC_FLAGS
--compiler-options -D__GNUC__=8)
# For gcc 10, let it fail.
endif()
endif ()

# Choose compute capabilities
Expand Down
9 changes: 7 additions & 2 deletions libs/ransac/RANSAC.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ class RANSAC : public Object {
return false;
}
};

static ITK_THREAD_RETURN_TYPE RANSACThreadCallback( void *arg );
static
#if ITK_VERSION_MAJOR >= 5
ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
#else
ITK_THREAD_RETURN_TYPE
#endif
RANSACThreadCallback( void *arg );

//number of threads used in computing the RANSAC hypotheses
unsigned int numberOfThreads;
Expand Down
2 changes: 1 addition & 1 deletion libs/ransac/RANSAC.txx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ double RANSAC<T,S>::Compute( std::vector<S> &parameters,

template<class T, class S>
#if ITK_VERSION_MAJOR >= 5
itk::ITK_THREAD_RETURN_TYPE
ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
#else
ITK_THREAD_RETURN_TYPE
#endif
Expand Down
8 changes: 7 additions & 1 deletion src/plastimatch/base/direction_cosines.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <string>
#include <stdio.h>

#include "itk_image.h"
#ifndef PLM_CUDA_COMPILE
#include "itk_direction_type.h"
#endif
#include "plm_math.h"

#define DIRECTION_COSINES_IDENTITY_THRESH 1e-9
Expand All @@ -25,7 +27,9 @@ class PLMBASE_API Direction_cosines {
public:
Direction_cosines ();
Direction_cosines (const float *dm);
#ifndef PLM_CUDA_COMPILE
Direction_cosines (const DirectionType& itk_dc);
#endif
~Direction_cosines ();

public:
Expand All @@ -45,7 +49,9 @@ class PLMBASE_API Direction_cosines {
float* get_matrix ();
const float* get_inverse () const;
void set (const float dc[]);
#ifndef PLM_CUDA_COMPILE
void set (const DirectionType& itk_dc);
#endif
bool set_from_string (std::string& str);
bool is_identity ();
std::string get_string () const;
Expand Down
11 changes: 11 additions & 0 deletions src/plastimatch/base/itk_direction_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* -----------------------------------------------------------------------
See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
----------------------------------------------------------------------- */
#ifndef _itk_direction_type_h_
#define _itk_direction_type_h_

#include "itkMatrix.h"

typedef itk::Matrix < double, 3, 3 > DirectionType;

#endif
2 changes: 1 addition & 1 deletion src/plastimatch/base/itk_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include "plmbase_config.h"
#include "plm_int.h"

#include "itk_direction_type.h"
#include "itk_image_type.h"

class Plm_image_header;
class Volume_header;

/* Other types */
typedef itk::Matrix < double, 3, 3 > DirectionType;
typedef itk::Index < 3 > IndexType;
typedef itk::Point < double, 3 > OriginType;
typedef itk::ImageRegion < 3 > RegionType;
Expand Down
2 changes: 1 addition & 1 deletion src/plastimatch/register/registration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ Registration::run_main_thread ()

static
#if ITK_VERSION_MAJOR >= 5
itk::ITK_THREAD_RETURN_TYPE
ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
#else
ITK_THREAD_RETURN_TYPE
#endif
Expand Down