Skip to content

Commit 1b21aa7

Browse files
committed
Fix: Type-casting issues
1 parent fe330d2 commit 1b21aa7

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

scripts/nbody.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ namespace fu = ashvardanian::fork_union;
6060

6161
#pragma region - Shared Logic
6262

63-
static constexpr float g_const = 6.674e-11;
64-
static constexpr float dt_const = 0.01;
65-
static constexpr float softening_const = 1e-9;
63+
static constexpr float g_const = 6.674e-11f;
64+
static constexpr float dt_const = 0.01f;
65+
static constexpr float softening_const = 1e-9f;
6666

6767
struct vector3_t {
6868
float x, y, z;

scripts/test.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ bool test_coprime_permutation() noexcept {
5959

6060
// Create a coprime permutation and make sure it only covers the range [start, end)
6161
index_type_ const range_size = static_cast<index_type_>(end - start);
62-
fu::coprime_permutation_range<index_type_> permutation(start, range_size, seed);
62+
fu::coprime_permutation_range<index_type_> permutation(static_cast<index_type_>(start), range_size,
63+
static_cast<index_type_>(seed));
6364

6465
std::size_t count_matches = 0;
6566
for (auto value : permutation) {
@@ -390,12 +391,12 @@ static bool stress_test_composite(std::size_t const threads_count,
390391
using prong_t = fu::prong<index_t>;
391392

392393
pool_t pool;
393-
if (!pool.try_spawn(threads_count)) return false;
394+
if (!pool.try_spawn(static_cast<index_t>(threads_count))) return false;
394395

395396
// Make sure that no overflow happens in the static scheduling
396397
std::atomic<std::size_t> counter(0);
397398
std::vector<aligned_visit_t> visited(default_parallel_tasks_k);
398-
pool.for_n(default_parallel_tasks_k, [&](prong_t prong) noexcept {
399+
pool.for_n(static_cast<index_t>(default_parallel_tasks_k), [&](prong_t prong) noexcept {
399400
// ? Relax the memory order, as we don't care about the order of the results, will sort 'em later
400401
std::size_t const count_populated = counter.fetch_add(1, std::memory_order_relaxed);
401402
visited[count_populated].task = prong.task;
@@ -405,7 +406,7 @@ static bool stress_test_composite(std::size_t const threads_count,
405406

406407
// Make sure that no overflow happens in the dynamic scheduling
407408
counter = 0;
408-
pool.for_n_dynamic(default_parallel_tasks_k, [&](prong_t prong) noexcept {
409+
pool.for_n_dynamic(static_cast<index_t>(default_parallel_tasks_k), [&](prong_t prong) noexcept {
409410
// ? Relax the memory order, as we don't care about the order of the results, will sort 'em later
410411
std::size_t const count_populated = counter.fetch_add(1, std::memory_order_relaxed);
411412
visited[count_populated].task = prong.task;

0 commit comments

Comments
 (0)