Skip to content

Commit

Permalink
Merge pull request #283 from hvdijk/cxx17
Browse files Browse the repository at this point in the history
[NFC] Build Abacus in C++17 mode.
  • Loading branch information
hvdijk authored Jan 8, 2024
2 parents ece3cd0 + 3d708ba commit ce793d3
Show file tree
Hide file tree
Showing 63 changed files with 365 additions and 312 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#endif

#if __has_attribute(overloadable)
#define ABACUS_API __attribute__((overloadable))
#define ABACUS_EXPORT_API __attribute__((overloadable, visibility("hidden")))
#define ABACUS_API __attribute__((overloadable, nothrow))
#define ABACUS_EXPORT_API __attribute__((overloadable, nothrow, visibility("hidden")))
#else
#define ABACUS_API
#define ABACUS_EXPORT_API __attribute__((visibility("hidden")))
#define ABACUS_API __attribute__((nothrow))
#define ABACUS_EXPORT_API __attribute__((nothrow, visibility("hidden")))
#endif
#elif defined(__cplusplus)
#ifdef _MSC_VER
Expand All @@ -48,8 +48,8 @@

#define ABACUS_API ABACUS_EXPORT_API
#else
#define ABACUS_API
#define ABACUS_EXPORT_API __attribute__((visibility("default")))
#define ABACUS_API __attribute__((nothrow))
#define ABACUS_EXPORT_API __attribute__((nothrow, visibility("default")))
#endif
#else
#error Abacus only support C++ and OpenCL compilation!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ if(NOT DEFINED GENERATE_OUTPUT_FILE)
)
endif()

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/abacus_config.in" abacus_config)
string(CONFIGURE "${abacus_config}" abacus_config @ONLY)
file(WRITE "${GENERATE_OUTPUT_FILE}" "${abacus_config}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/abacus_config.in" "${GENERATE_OUTPUT_FILE}" @ONLY)
Original file line number Diff line number Diff line change
Expand Up @@ -782,40 +782,46 @@ T convert_sat_rtp(const U &u) {
}
} // namespace

#define DEF_WITH_BOTH_TYPES(IN_TYPE, OUT_TYPE) \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE(abacus_##IN_TYPE x) { \
return convert<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_rte(abacus_##IN_TYPE x) { \
return convert_rte<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_rtn(abacus_##IN_TYPE x) { \
return convert_rtn<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_rtz(abacus_##IN_TYPE x) { \
return convert_rtz<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_rtp(abacus_##IN_TYPE x) { \
return convert_rtp<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_sat(abacus_##IN_TYPE x) { \
return convert_sat<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_sat_rte( \
abacus_##IN_TYPE x) { \
return convert_sat_rte<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_sat_rtn( \
abacus_##IN_TYPE x) { \
return convert_sat_rtn<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_sat_rtz( \
abacus_##IN_TYPE x) { \
return convert_sat_rtz<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE __abacus_convert_##OUT_TYPE##_sat_rtp( \
abacus_##IN_TYPE x) { \
return convert_sat_rtp<abacus_##OUT_TYPE>(x); \
#define DEF_WITH_BOTH_TYPES(IN_TYPE, OUT_TYPE) \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE( \
abacus_##IN_TYPE x) { \
return convert<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_rte( \
abacus_##IN_TYPE x) { \
return convert_rte<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_rtn( \
abacus_##IN_TYPE x) { \
return convert_rtn<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_rtz( \
abacus_##IN_TYPE x) { \
return convert_rtz<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_rtp( \
abacus_##IN_TYPE x) { \
return convert_rtp<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_sat( \
abacus_##IN_TYPE x) { \
return convert_sat<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_sat_rte( \
abacus_##IN_TYPE x) { \
return convert_sat_rte<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_sat_rtn( \
abacus_##IN_TYPE x) { \
return convert_sat_rtn<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_sat_rtz( \
abacus_##IN_TYPE x) { \
return convert_sat_rtz<abacus_##OUT_TYPE>(x); \
} \
abacus_##OUT_TYPE ABACUS_API __abacus_convert_##OUT_TYPE##_sat_rtp( \
abacus_##IN_TYPE x) { \
return convert_sat_rtp<abacus_##OUT_TYPE>(x); \
}

#define DEF_INTERGRAL_TYPES(TYPE, SIZE) \
Expand Down
4 changes: 1 addition & 3 deletions modules/compiler/builtins/abacus/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ if(COMMAND add_ca_tidy)
endif()
endif()

set_property(TARGET abacus_static PROPERTY CXX_STANDARD 11)

target_include_directories(abacus_static PUBLIC
${CMAKE_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../include)
Expand Down Expand Up @@ -200,7 +198,7 @@ target datalayout = \"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:
set(DEPFILE_ARGS -dependency-file "${OUTPUT}.d" -MT "${OUTPUT}" -sys-header-deps)
if(SOURCE_TYPE STREQUAL ".cpp")
set(XTYPE "c++")
set(XOPTS "-std=c++11")
set(XOPTS "-std=c++17")
elseif(SOURCE_TYPE STREQUAL ".cl")
set(XTYPE "cl")
set(XOPTS "-cl-std=CL1.2")
Expand Down
12 changes: 6 additions & 6 deletions modules/compiler/builtins/abacus/source/abacus_common/clamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_clamp(TYPE x, TYPE y, TYPE z) { \
return abacus::detail::common::clamp(x, y, z); \
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_clamp(TYPE x, TYPE y, TYPE z) { \
return abacus::detail::common::clamp(x, y, z); \
}
#define DEF2(TYPE, TYPE2) \
TYPE __abacus_clamp(TYPE x, TYPE2 y, TYPE2 z) { \
return abacus::detail::common::clamp(x, y, z); \
#define DEF2(TYPE, TYPE2) \
TYPE ABACUS_API __abacus_clamp(TYPE x, TYPE2 y, TYPE2 z) { \
return abacus::detail::common::clamp(x, y, z); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_degrees(TYPE x) { return abacus::detail::common::degrees(x); }
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_degrees(TYPE x) { \
return abacus::detail::common::degrees(x); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
DEF(abacus_half);
Expand Down
12 changes: 6 additions & 6 deletions modules/compiler/builtins/abacus/source/abacus_common/max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_max(TYPE x, TYPE y) { \
return abacus::detail::common::max(x, y); \
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_max(TYPE x, TYPE y) { \
return abacus::detail::common::max(x, y); \
}
#define DEF2(TYPE, TYPE2) \
TYPE __abacus_max(TYPE x, TYPE2 y) { \
return abacus::detail::common::max(x, y); \
#define DEF2(TYPE, TYPE2) \
TYPE ABACUS_API __abacus_max(TYPE x, TYPE2 y) { \
return abacus::detail::common::max(x, y); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
12 changes: 6 additions & 6 deletions modules/compiler/builtins/abacus/source/abacus_common/min.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_min(TYPE x, TYPE y) { \
return abacus::detail::common::min(x, y); \
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_min(TYPE x, TYPE y) { \
return abacus::detail::common::min(x, y); \
}
#define DEF2(TYPE, TYPE2) \
TYPE __abacus_min(TYPE x, TYPE2 y) { \
return abacus::detail::common::min(x, y); \
#define DEF2(TYPE, TYPE2) \
TYPE ABACUS_API __abacus_min(TYPE x, TYPE2 y) { \
return abacus::detail::common::min(x, y); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
12 changes: 6 additions & 6 deletions modules/compiler/builtins/abacus/source/abacus_common/mix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_mix(TYPE x, TYPE y, TYPE a) { \
return abacus::detail::common::mix(x, y, a); \
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_mix(TYPE x, TYPE y, TYPE a) { \
return abacus::detail::common::mix(x, y, a); \
}
#define DEF2(TYPE, TYPE2) \
TYPE __abacus_mix(TYPE x, TYPE y, TYPE2 a) { \
return abacus::detail::common::mix(x, y, a); \
#define DEF2(TYPE, TYPE2) \
TYPE ABACUS_API __abacus_mix(TYPE x, TYPE y, TYPE2 a) { \
return abacus::detail::common::mix(x, y, a); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_radians(TYPE x) { return abacus::detail::common::radians(x); }
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_radians(TYPE x) { \
return abacus::detail::common::radians(x); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
DEF(abacus_half);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_sign(TYPE x) { return abacus::detail::common::sign(x); }
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_sign(TYPE x) { \
return abacus::detail::common::sign(x); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
DEF(abacus_half);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_smoothstep(TYPE e0, TYPE e1, TYPE x) { \
return abacus::detail::common::smoothstep(e0, e1, x); \
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_smoothstep(TYPE e0, TYPE e1, TYPE x) { \
return abacus::detail::common::smoothstep(e0, e1, x); \
}
#define DEF2(TYPE, TYPE2) \
TYPE __abacus_smoothstep(TYPE2 e0, TYPE2 e1, TYPE x) { \
return abacus::detail::common::smoothstep(e0, e1, x); \
#define DEF2(TYPE, TYPE2) \
TYPE ABACUS_API __abacus_smoothstep(TYPE2 e0, TYPE2 e1, TYPE x) { \
return abacus::detail::common::smoothstep(e0, e1, x); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
12 changes: 6 additions & 6 deletions modules/compiler/builtins/abacus/source/abacus_common/step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <abacus/abacus_common.h>
#include <abacus/abacus_detail_common.h>

#define DEF(TYPE) \
TYPE __abacus_step(TYPE e, TYPE x) { \
return abacus::detail::common::step(e, x); \
#define DEF(TYPE) \
TYPE ABACUS_API __abacus_step(TYPE e, TYPE x) { \
return abacus::detail::common::step(e, x); \
}
#define DEF2(TYPE, TYPE2) \
TYPE __abacus_step(TYPE2 e, TYPE x) { \
return abacus::detail::common::step(e, x); \
#define DEF2(TYPE, TYPE2) \
TYPE ABACUS_API __abacus_step(TYPE2 e, TYPE x) { \
return abacus::detail::common::step(e, x); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <abacus/abacus_geometric.h>

#define DEF(TYPE) \
TYPE __abacus_cross(TYPE x, TYPE y) { \
TYPE ABACUS_API __abacus_cross(TYPE x, TYPE y) { \
return abacus::detail::geometric::cross(x, y); \
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <abacus/abacus_detail_geometric.h>
#include <abacus/abacus_geometric.h>

#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType __abacus_distance(TYPE x, TYPE y) { \
return abacus::detail::geometric::distance(x, y); \
#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType ABACUS_API __abacus_distance(TYPE x, TYPE y) { \
return abacus::detail::geometric::distance(x, y); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <abacus/abacus_detail_geometric.h>
#include <abacus/abacus_geometric.h>

#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType __abacus_dot(TYPE x, TYPE y) { \
return abacus::detail::geometric::dot(x, y); \
#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType ABACUS_API __abacus_dot(TYPE x, TYPE y) { \
return abacus::detail::geometric::dot(x, y); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
#include <abacus/abacus_detail_geometric.h>
#include <abacus/abacus_geometric.h>

#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType __abacus_fast_distance(TYPE x, TYPE y) { \
return abacus::detail::geometric::fast_distance(x, y); \
#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType ABACUS_API __abacus_fast_distance(TYPE x, \
TYPE y) { \
return abacus::detail::geometric::fast_distance(x, y); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <abacus/abacus_detail_geometric.h>
#include <abacus/abacus_geometric.h>

#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType __abacus_fast_length(TYPE x) { \
return abacus::detail::geometric::fast_length(x); \
#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType ABACUS_API __abacus_fast_length(TYPE x) { \
return abacus::detail::geometric::fast_length(x); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <abacus/abacus_geometric.h>

#define DEF(TYPE) \
TYPE __abacus_fast_normalize(TYPE x) { \
TYPE ABACUS_API __abacus_fast_normalize(TYPE x) { \
return abacus::detail::geometric::fast_normalize(x); \
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <abacus/abacus_detail_geometric.h>
#include <abacus/abacus_geometric.h>

#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType __abacus_length(TYPE x) { \
return abacus::detail::geometric::length(x); \
#define DEF(TYPE) \
TypeTraits<TYPE>::ElementType ABACUS_API __abacus_length(TYPE x) { \
return abacus::detail::geometric::length(x); \
}

#ifdef __CA_BUILTINS_HALF_SUPPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
#include <abacus/abacus_geometric.h>

#define SCALAR_DEF(TYPE) \
TYPE __abacus_normalize(TYPE x) { \
TYPE ABACUS_API __abacus_normalize(TYPE x) { \
if (x == static_cast<TYPE>(0) || __abacus_isnan(x)) { \
return x; \
} \
return __abacus_copysign(static_cast<TYPE>(1.0), x); \
}

#define DEF(TYPE) \
TYPE __abacus_normalize(TYPE x) { \
TYPE ABACUS_API __abacus_normalize(TYPE x) { \
return abacus::detail::geometric::normalize(x); \
}

Expand Down
Loading

0 comments on commit ce793d3

Please sign in to comment.