Skip to content

Commit 9518fbf

Browse files
authored
Various bug fixes for older compilers (#588)
* Various bug fixes for older compilers * Stop CMake if g++ is too old
1 parent ad4009d commit 9518fbf

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ rapids_cmake_write_version_file(include/version_config.h)
7878
set(CMAKE_CXX_STANDARD 17)
7979
set(CUDA_CXX_STANDARD 17)
8080

81+
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
82+
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
83+
if (NOT GCC_VERSION VERSION_GREATER 8)
84+
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 9 or higher if using g++ host compiler")
85+
endif()
86+
endif()
87+
8188
# CPM is required for all package management
8289
include(public/cpm-cmake/cmake/CPM.cmake)
8390
# Helper for selecting build type

include/matx/core/allocator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct MemTracker {
102102
}
103103

104104
template <typename StreamType>
105-
auto deallocate_internal(void *ptr, StreamType st) {
105+
auto deallocate_internal(void *ptr, [[maybe_unused]] StreamType st) {
106106
MATX_NVTX_START("", matx::MATX_NVTX_LOG_INTERNAL)
107107

108108
std::unique_lock lck(memory_mtx);

include/matx/core/defines.h

+3
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,7 @@ static_assert(false, "Must choose either 64-bit or 32-bit index mode");
6868
#define __MATX_INLINE__ inline
6969
#endif
7070

71+
// std::ceil is not constexpr until C++23
72+
#define MATX_ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
73+
7174
}

include/matx/kernels/conv.cuh

+1-3
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,7 @@ __global__ void Conv2D(OutType d_out, InType1 d_in1, InType2 d_in2,
232232

233233
constexpr int Rank = OutType::Rank();
234234

235-
constexpr int type2off =
236-
std::ceil(static_cast<double>(sizeof(in1type) * SIGNAL_CHUNK_Y * SIGNAL_CHUNK_X) / sizeof(in2type) *
237-
sizeof(in2type));
235+
constexpr int type2off = MATX_ROUND_UP(sizeof(in1type) * SIGNAL_CHUNK_Y * SIGNAL_CHUNK_X, sizeof(in2type));
238236
__shared__ char shared_buf[type2off + sizeof(in2type) * FILTER_SHARED_CHUNK_Y * FILTER_SHARED_CHUNK_X];
239237

240238
// __shared__ Uninitialized<in1type> s_signal[SIGNAL_CHUNK_Y][SIGNAL_CHUNK_X];

include/matx/transforms/fft/fft_fftw.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ struct FftFFTWparams_t {
261261

262262
auto exec_plans = [&](typename OutputTensor::value_type *out_ptr,
263263
typename InputTensor::value_type *in_ptr) {
264-
fftwf_plan plan{};
265264
if constexpr (fp32) {
265+
fftwf_plan plan{};
266266
if constexpr (DeduceFFTTransformType<OutputTensor, InputTensor>() == FFTType::C2C) {
267267
plan = fftwf_plan_many_dft( params.fft_rank,
268268
params.n,
@@ -312,6 +312,7 @@ struct FftFFTWparams_t {
312312
fftwf_cleanup();
313313
}
314314
else {
315+
fftw_plan plan{};
315316
if constexpr (DeduceFFTTransformType<OutputTensor, InputTensor>() == FFTType::Z2Z) {
316317
plan = fftw_plan_many_dft( params.fft_rank,
317318
params.n,

0 commit comments

Comments
 (0)