From bb6eeba2340c9374d3d38358d1da400a179db2ea Mon Sep 17 00:00:00 2001 From: "Gregory C. Sharp" Date: Tue, 1 Nov 2022 14:27:05 -0400 Subject: [PATCH 1/4] Better fix for ITK issue on 32-bit Windows --- libs/ransac/RANSAC.h | 11 ++++++++--- libs/ransac/RANSAC.txx | 2 +- src/plastimatch/register/registration.cxx | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/ransac/RANSAC.h b/libs/ransac/RANSAC.h index 15667488e..b9dbfc31c 100644 --- a/libs/ransac/RANSAC.h +++ b/libs/ransac/RANSAC.h @@ -144,9 +144,14 @@ 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; diff --git a/libs/ransac/RANSAC.txx b/libs/ransac/RANSAC.txx index b0f628e4b..1149ce61c 100644 --- a/libs/ransac/RANSAC.txx +++ b/libs/ransac/RANSAC.txx @@ -150,7 +150,7 @@ double RANSAC::Compute( std::vector ¶meters, template #if ITK_VERSION_MAJOR >= 5 -itk::ITK_THREAD_RETURN_TYPE +ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION #else ITK_THREAD_RETURN_TYPE #endif diff --git a/src/plastimatch/register/registration.cxx b/src/plastimatch/register/registration.cxx index dcc956056..0e40db7d9 100644 --- a/src/plastimatch/register/registration.cxx +++ b/src/plastimatch/register/registration.cxx @@ -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 From 3eb024aa0fc9b0d5a66d6d8a32d0ee3bccc828ae Mon Sep 17 00:00:00 2001 From: "Gregory C. Sharp" Date: Mon, 31 Oct 2022 16:49:12 -0400 Subject: [PATCH 2/4] Fix CUDA build --- cmake/FindCUDA_wrap.cmake | 27 +++++++++++++++--------- src/plastimatch/base/direction_cosines.h | 8 ++++++- src/plastimatch/base/itk_image.h | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/cmake/FindCUDA_wrap.cmake b/cmake/FindCUDA_wrap.cmake index 40275bba9..d2de422a0 100755 --- a/cmake/FindCUDA_wrap.cmake +++ b/cmake/FindCUDA_wrap.cmake @@ -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 @@ -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 diff --git a/src/plastimatch/base/direction_cosines.h b/src/plastimatch/base/direction_cosines.h index 11f61eda4..26af47024 100644 --- a/src/plastimatch/base/direction_cosines.h +++ b/src/plastimatch/base/direction_cosines.h @@ -8,7 +8,9 @@ #include #include -#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 @@ -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: @@ -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; diff --git a/src/plastimatch/base/itk_image.h b/src/plastimatch/base/itk_image.h index 2c633948f..51f55c001 100644 --- a/src/plastimatch/base/itk_image.h +++ b/src/plastimatch/base/itk_image.h @@ -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; From 209d54799465d28022976151d60fb1ecb16c932b Mon Sep 17 00:00:00 2001 From: "Gregory C. Sharp" Date: Tue, 1 Nov 2022 14:27:05 -0400 Subject: [PATCH 3/4] Better fix for ITK issue on 32-bit Windows --- libs/ransac/RANSAC.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ransac/RANSAC.h b/libs/ransac/RANSAC.h index b9dbfc31c..c454bc5d0 100644 --- a/libs/ransac/RANSAC.h +++ b/libs/ransac/RANSAC.h @@ -144,7 +144,7 @@ class RANSAC : public Object { } return false; } - }; + }; static #if ITK_VERSION_MAJOR >= 5 ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION From aab53574e9257ddd0733e714ac8f38c9c5f0d3d3 Mon Sep 17 00:00:00 2001 From: "Gregory C. Sharp" Date: Mon, 31 Oct 2022 16:49:55 -0400 Subject: [PATCH 4/4] Add missing file from CUDA fix --- src/plastimatch/base/itk_direction_type.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/plastimatch/base/itk_direction_type.h diff --git a/src/plastimatch/base/itk_direction_type.h b/src/plastimatch/base/itk_direction_type.h new file mode 100644 index 000000000..a60bee266 --- /dev/null +++ b/src/plastimatch/base/itk_direction_type.h @@ -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