Skip to content

Commit effbee0

Browse files
committed
clang17 nosan tests compile and run on MacOS with M1
remove compile_commands.json from git
1 parent cef07cc commit effbee0

File tree

8 files changed

+74
-951
lines changed

8 files changed

+74
-951
lines changed

compile_commands.json

-917
This file was deleted.

include/Containers/Storage.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ using default_capacity_type_t = typename DefaultCapacityType<S>::type;
3434
static_assert(!SizeMultiple8<uint32_t>);
3535
static_assert(SizeMultiple8<uint64_t>);
3636
static_assert(std::is_same_v<default_capacity_type_t<uint32_t>, int32_t>);
37-
static_assert(std::is_same_v<default_capacity_type_t<uint64_t>, int64_t>);
37+
static_assert(std::is_same_v<default_capacity_type_t<uint64_t>, ptrdiff_t>);
3838

3939
consteval auto log2Floor(uint64_t x) -> uint64_t {
4040
return 63 - std::countl_zero(x);

include/Math/Array.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,14 @@ struct POLY_MATH_GSL_POINTER Array {
464464
if constexpr (MatrixDimension<S>) {
465465
for (ptrdiff_t i = 0; i < Row(sz); ++i) {
466466
if (i) (void)std::fprintf(f, "\n");
467-
(void)std::fprintf(f, "%ld", int64_t((*this)[i, 0]));
467+
(void)std::fprintf(f, "%ld", long((*this)[i, 0]));
468468
for (ptrdiff_t j = 1; j < Col(sz); ++j)
469-
(void)std::fprintf(f, " %ld", int64_t((*this)[i, j]));
469+
(void)std::fprintf(f, " %ld", long((*this)[i, j]));
470470
}
471471
} else {
472-
(void)std::fprintf(f, "%ld", int64_t((*this)[0]));
472+
(void)std::fprintf(f, "%ld", long((*this)[0]));
473473
for (ptrdiff_t i = 1; (i < ptrdiff_t(sz)); ++i)
474-
(void)std::fprintf(f, ", %ld", int64_t((*this)[i]));
474+
(void)std::fprintf(f, ", %ld", long((*this)[i]));
475475
}
476476
(void)std::fprintf(f, "]");
477477
(void)std::fclose(f);

include/Math/Exp.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,24 @@ constexpr auto magic_round_const(double) -> double {
341341
}
342342
constexpr auto magic_round_const(float) -> float { return 1.048576e7F; }
343343

344+
constexpr auto trunclo(double x) -> double {
345+
return std::bit_cast<double>(std::bit_cast<uint64_t>(x) & 0xfffffffff8000000);
346+
}
347+
344348
constexpr auto fma(double x, double y, double z) -> double {
345349
#ifdef __cpp_if_consteval
346350
if consteval { // TODO drop when c++23 constexpr fma support is available
351+
#if defined(__linux__) && __X86_64__
347352
__float128 a = x, b = y, c = z;
348353
return double(a * b + c);
354+
#else
355+
// This is not a perfect implementation!!!
356+
double hx = trunclo(x), hy = trunclo(y), lx = x - hx, ly = y - hy;
357+
double hxy = x * y;
358+
double lxy = (((hx * hy - hxy) + lx * hy + hx * ly) + lx * ly);
359+
double s = hxy + z;
360+
return s + (((hxy - s) + z) + lxy);
361+
#endif
349362
} else {
350363
#endif
351364
return std::fma(x, y, z);

include/Math/MatrixDimensions.hpp

+42-24
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,23 @@ template <ptrdiff_t R, ptrdiff_t C, ptrdiff_t X> struct StridedDims {
5757
// : M{m}, N{n}, strideM{x} {
5858
// invariant(N <= strideM);
5959
// }
60-
constexpr explicit operator int32_t() const {
61-
return int32_t(ptrdiff_t(M) * ptrdiff_t(strideM));
60+
constexpr explicit operator int() const {
61+
return int(ptrdiff_t(M) * ptrdiff_t(strideM));
6262
}
63-
constexpr explicit operator int64_t() const {
64-
return int64_t(ptrdiff_t(M) * ptrdiff_t(strideM));
63+
constexpr explicit operator long() const {
64+
return long(ptrdiff_t(M) * ptrdiff_t(strideM));
6565
}
66-
constexpr explicit operator uint32_t() const {
67-
return uint32_t(ptrdiff_t(M) * ptrdiff_t(strideM));
66+
constexpr explicit operator long long() const {
67+
return (long long)(ptrdiff_t(M) * ptrdiff_t(strideM));
6868
}
69-
constexpr explicit operator uint64_t() const {
70-
return uint64_t(ptrdiff_t(M) * ptrdiff_t(strideM));
69+
constexpr explicit operator unsigned int() const {
70+
return (unsigned int)(ptrdiff_t(M) * ptrdiff_t(strideM));
71+
}
72+
constexpr explicit operator unsigned long() const {
73+
return (unsigned long)(ptrdiff_t(M) * ptrdiff_t(strideM));
74+
}
75+
constexpr explicit operator unsigned long long() const {
76+
return (unsigned long long)(ptrdiff_t(M) * ptrdiff_t(strideM));
7177
}
7278
constexpr auto operator=(DenseDims<R, C> D) -> StridedDims &requires(C == X);
7379
constexpr auto operator=(SquareDims<R> D)
@@ -136,17 +142,23 @@ static_assert(sizeof(StridedDims<-1, 8, 8>) == sizeof(ptrdiff_t));
136142
template <ptrdiff_t R, ptrdiff_t C> struct DenseDims {
137143
[[no_unique_address]] Row<R> M{};
138144
[[no_unique_address]] Col<C> N{};
139-
constexpr explicit operator int32_t() const {
140-
return int32_t(ptrdiff_t(M) * ptrdiff_t(N));
145+
constexpr explicit operator int() const {
146+
return int(ptrdiff_t(M) * ptrdiff_t(N));
147+
}
148+
constexpr explicit operator long() const {
149+
return long(ptrdiff_t(M) * ptrdiff_t(N));
141150
}
142-
constexpr explicit operator int64_t() const {
143-
return int64_t(ptrdiff_t(M) * ptrdiff_t(N));
151+
constexpr explicit operator long long() const {
152+
return (long long)(ptrdiff_t(M) * ptrdiff_t(N));
144153
}
145-
constexpr explicit operator uint32_t() const {
146-
return uint32_t(ptrdiff_t(M) * ptrdiff_t(N));
154+
constexpr explicit operator unsigned int() const {
155+
return (unsigned int)(ptrdiff_t(M) * ptrdiff_t(N));
147156
}
148-
constexpr explicit operator uint64_t() const {
149-
return uint64_t(ptrdiff_t(M) * ptrdiff_t(N));
157+
constexpr explicit operator unsigned long() const {
158+
return (unsigned long)(ptrdiff_t(M) * ptrdiff_t(N));
159+
}
160+
constexpr explicit operator unsigned long long() const {
161+
return (unsigned long long)(ptrdiff_t(M) * ptrdiff_t(N));
150162
}
151163
// constexpr DenseDims() = default;
152164
// constexpr DenseDims(Row<R> m, Col<C> n) : M(unsigned(m)), N(unsigned(n)) {}
@@ -217,17 +229,23 @@ template <ptrdiff_t R, ptrdiff_t C> struct DenseDims {
217229
};
218230
template <ptrdiff_t R> struct SquareDims {
219231
[[no_unique_address]] Row<R> M{};
220-
constexpr explicit operator int32_t() const {
221-
return int32_t(ptrdiff_t(M) * ptrdiff_t(M));
232+
constexpr explicit operator int() const {
233+
return int(ptrdiff_t(M) * ptrdiff_t(M));
234+
}
235+
constexpr explicit operator long() const {
236+
return long(ptrdiff_t(M) * ptrdiff_t(M));
237+
}
238+
constexpr explicit operator long long() const {
239+
return (long long)(ptrdiff_t(M) * ptrdiff_t(M));
222240
}
223-
constexpr explicit operator int64_t() const {
224-
return int64_t(ptrdiff_t(M) * ptrdiff_t(M));
241+
constexpr explicit operator unsigned int() const {
242+
return (unsigned int)(ptrdiff_t(M) * ptrdiff_t(M));
225243
}
226-
constexpr explicit operator uint32_t() const {
227-
return uint32_t(ptrdiff_t(M) * ptrdiff_t(M));
244+
constexpr explicit operator unsigned long() const {
245+
return (unsigned long)(ptrdiff_t(M) * ptrdiff_t(M));
228246
}
229-
constexpr explicit operator uint64_t() const {
230-
return uint64_t(ptrdiff_t(M) * ptrdiff_t(M));
247+
constexpr explicit operator unsigned long long() const {
248+
return (unsigned long long)(ptrdiff_t(M) * ptrdiff_t(M));
231249
}
232250
// constexpr SquareDims() = default;
233251
// constexpr SquareDims(ptrdiff_t d) : M{d} {}

include/SIMD/Masks.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ template <ptrdiff_t W> struct Vector {
181181
if (m[w]) l = w;
182182
return l;
183183
}
184+
[[nodiscard]] explicit constexpr operator bool() const {
185+
if constexpr (W == 2) {
186+
return m[0] || m[1];
187+
} else {
188+
for (ptrdiff_t w = 0; w < W; ++w)
189+
if (m[w]) return true;
190+
return false;
191+
}
192+
}
184193
};
185194

186195
template <ptrdiff_t W> constexpr auto create(ptrdiff_t i) -> Vector<W> {

test/matrix_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ TEST(SparseIndexingTest, BasicAssertions) {
9393
int64_t i = 0;
9494
IntMatrix<> D{C};
9595
std::cout << "C=" << C << "\n";
96-
static_assert(std::same_as<decltype(D[0, _]), MutArray<long, long>>);
96+
static_assert(std::same_as<decltype(D[0, _]), MutArray<int64_t, ptrdiff_t>>);
9797
for (ptrdiff_t r : _(0, D.numRow())) D[r, _] += ptrdiff_t(r) + 1;
9898
for (auto r : C.eachRow()) {
9999
EXPECT_EQ(r.size(), ptrdiff_t(C.numCol()));

test/tuple_test.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ TEST(TupleTest, BasicAssertions) {
1111
double x = 2.3;
1212
double y = 4.5;
1313
long z = -5;
14-
ulong w = 15;
14+
unsigned long w = 15;
1515
Tuple t{w, x, y, z};
1616
{
1717
auto [a, b, c, d] = t;
18-
static_assert(std::same_as<decltype(a), ulong>);
18+
static_assert(std::same_as<decltype(a), unsigned long>);
1919
static_assert(std::same_as<decltype(x), double>);
2020
static_assert(std::same_as<decltype(y), double>);
2121
static_assert(std::same_as<decltype(z), long>);
@@ -27,7 +27,7 @@ TEST(TupleTest, BasicAssertions) {
2727
Tuple t1 = t.map([](auto arg) { return 3 * arg; });
2828
{
2929
auto [a, b, c, d] = t1;
30-
static_assert(std::same_as<decltype(a), ulong>);
30+
static_assert(std::same_as<decltype(a), unsigned long>);
3131
static_assert(std::same_as<decltype(x), double>);
3232
static_assert(std::same_as<decltype(y), double>);
3333
static_assert(std::same_as<decltype(z), long>);
@@ -39,7 +39,7 @@ TEST(TupleTest, BasicAssertions) {
3939
t1.apply([](auto &arg) { arg *= 2; });
4040
{
4141
auto [a, b, c, d] = t1;
42-
static_assert(std::same_as<decltype(a), ulong>);
42+
static_assert(std::same_as<decltype(a), unsigned long>);
4343
static_assert(std::same_as<decltype(x), double>);
4444
static_assert(std::same_as<decltype(y), double>);
4545
static_assert(std::same_as<decltype(z), long>);

0 commit comments

Comments
 (0)