Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
98f8a36
feat: cross-platform thread lib abstraction layer
nihiL7331 Aug 4, 2026
b99df96
refactor: rename `PS_MAX_THREADS` to `PS_MAX_THRDS`
nihiL7331 Aug 4, 2026
62daa30
feat: `PS_THRD_FAIL` error code
nihiL7331 Aug 4, 2026
2f16fcc
feat: `ps_impl_pool_submit` helper
nihiL7331 Aug 4, 2026
a52afe3
feat: `ps_impl_pool_wait` helper
nihiL7331 Aug 4, 2026
d56dd93
feat: `ps_impl_worker_loop` helper
nihiL7331 Aug 4, 2026
cafa5cf
feat: `ps_impl_pool_init` helper
nihiL7331 Aug 4, 2026
dbd37e2
feat: `ps_impl_pool_destroy` helper
nihiL7331 Aug 4, 2026
49fd9f5
refactor: complete architectural overhaul to support multithreading
nihiL7331 Aug 4, 2026
674f829
fix: match the new API in demos
nihiL7331 Aug 4, 2026
2ec1b20
refactor: multi-threaded radix sort implementation (map->reduce->scat…
nihiL7331 Aug 5, 2026
91115ca
chore: lower theta on accuracy test to 2.0
nihiL7331 Aug 5, 2026
3cd81d5
chore: update ver to 2.0
nihiL7331 Aug 5, 2026
df66ff4
chore: remove `#define`s
nihiL7331 Aug 5, 2026
3460dfb
feat: add spinlock capabilities
nihiL7331 Aug 5, 2026
d54c126
feat: `max_particles` in `ps_config_t`
nihiL7331 Aug 5, 2026
82768b9
fix: make `off` in `ps_arena_t` volatile
nihiL7331 Aug 5, 2026
838d29f
feat: add tree union to data in `ps_job_t`
nihiL7331 Aug 5, 2026
e4ef013
fix: void ctx on single thread in `ps_impl_pool_submit` to avoid err
nihiL7331 Aug 5, 2026
6d2265a
feat: `ps_destroy` in public api
nihiL7331 Aug 5, 2026
a44a34a
refactor: lightweight spinlock based thread polling
nihiL7331 Aug 5, 2026
1f0e0c9
feat: `ps_impl_dispatch_fmm`/`ps_impl_dispatch_downward` helpers
nihiL7331 Aug 5, 2026
45c73a9
fix: use context-originated `theta` in P2P pass
nihiL7331 Aug 5, 2026
2641cc3
refactor: full multithreading support
nihiL7331 Aug 5, 2026
92f3a3e
chore: update `README.md` benchmark graphs
nihiL7331 Aug 5, 2026
06bf552
chore: update `README.md` benchmark graphs
nihiL7331 Aug 5, 2026
9af8d4d
chore: silence clang-format in unnecessary places
nihiL7331 Aug 5, 2026
c078dd6
fix: move `#endif` higher in multithreading setup to add spinlock for…
nihiL7331 Aug 5, 2026
73341d1
fix: explicitly cast values on possible loss of data
nihiL7331 Aug 5, 2026
9327f8f
fix: explicitly cast `total_thrds` in `ps_init`
nihiL7331 Aug 5, 2026
f219810
fix: make `get_wall_time` cross-platform (win support added)
nihiL7331 Aug 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions demo/binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#define POLESITTER_IMPLEMENTATION
#include "../src/polesitter.h"

#define PARTICLE_COUNT 5000
#define PARTICLE_COUNT 10000
#define BLACKHOLE_MASS 1000.0F
#define ARENA_SIZE (1024ULL * 1024ULL * 256ULL)
#define MAX_EXPECTED_SPEED 20
#define THETA 3.4641F // sqrt of 12
#define THETA 2.0F // sqrt of 12

float vx[PARTICLE_COUNT] = {0};
float vy[PARTICLE_COUNT] = {0};
Expand Down Expand Up @@ -51,7 +51,7 @@ void* init_polesitter(void) {
return NULL;
}

ps_config_t cfg = {buffer, ARENA_SIZE, THETA};
ps_config_t cfg = {buffer, ARENA_SIZE, PARTICLE_COUNT, THETA, 1};
ps_init(&ctx, &cfg);

arrs.x = px;
Expand Down Expand Up @@ -155,7 +155,7 @@ void update(void) {

UpdateCamera(&camera, CAMERA_ORBITAL);

ps_arena_clear(&ctx->arena);
ps_impl_arena_clear(&ctx->arena);

for (int i = 0; i < PARTICLE_COUNT; ++i) {
id[i] = i;
Expand Down Expand Up @@ -253,7 +253,7 @@ void draw(void) {
(unsigned char)(180 - (f * 100)),
(unsigned char)(255 - (f * 255)), 255};
}
DrawPoint3D((Vector3){px[i], py[i], pz[i]}, p_color);
DrawSphereEx((Vector3){px[i], py[i], pz[i]}, 0.1F, 3, 3, p_color);
}

EndBlendMode();
Expand Down
9 changes: 5 additions & 4 deletions demo/unary.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#include <stdint.h>
#include <stdlib.h>

#define PS_MULTITHREADING
#define POLESITTER_IMPLEMENTATION
#include "../src/polesitter.h"

#define PARTICLE_COUNT 5000
#define PARTICLE_COUNT 40000
#define BLACKHOLE_MASS 1000.0F
#define ARENA_SIZE (1024ULL * 1024ULL * 256ULL)
#define MAX_EXPECTED_SPEED 20
#define THETA 3.4641F // sqrt of 12
#define THETA 2.00F // sqrt of 12

float vx[PARTICLE_COUNT] = {0};
float vy[PARTICLE_COUNT] = {0};
Expand Down Expand Up @@ -51,7 +52,7 @@ void* init_polesitter(void) {
return NULL;
}

ps_config_t cfg = {buffer, ARENA_SIZE, THETA};
ps_config_t cfg = {buffer, ARENA_SIZE, PARTICLE_COUNT, THETA, 4};
ps_init(&ctx, &cfg);

arrs.x = px;
Expand Down Expand Up @@ -116,7 +117,7 @@ int main(void) {
void update(void) {
UpdateCamera(&camera, CAMERA_ORBITAL);

ps_arena_clear(&ctx->arena);
ps_impl_arena_clear(&ctx->arena);

for (int i = 0; i < PARTICLE_COUNT; ++i) {
id[i] = i;
Expand Down
358 changes: 213 additions & 145 deletions docs/performance_graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
749 changes: 468 additions & 281 deletions docs/performance_graph_log.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions docs/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
COL_TEXT = '#C9D1D9'
COL_BORDER = '#8B949E'
COL_NAIVE = '#D29922'
COL_FMM = '#1F6FEB'
COL_FMM_ST = '#1F6FEB'
COL_FMM_MT = '#8957E5'
COL_BG = '#21262D'

plt.rcParams.update({
Expand All @@ -26,12 +27,14 @@
data = pd.read_csv('results.csv')
N = data['N']
t_direct = data['Direct_Time']
t_fmm = data['FMM_Time']
t_fmm_st = data['FMM_Time_ST']
t_fmm_mt = data['FMM_Time_MT']

fig, ax = plt.subplots(figsize=(8, 5))

ax.plot(N, t_direct, marker='o', linewidth=2.5, color=COL_NAIVE, label='naive $\mathcal{O}(N^2)$')
ax.plot(N, t_fmm, marker='o', linewidth=2.5, color=COL_FMM, label='FMM $\mathcal{O}(N)$')
ax.plot(N, t_fmm_st, marker='o', linewidth=2.5, color=COL_FMM_ST, label='FMM $\mathcal{O}(N)$ 1-core')
ax.plot(N, t_fmm_mt, marker='o', linewidth=2.5, color=COL_FMM_MT, label='FMM $\mathcal{O}(N)$ 8-core')

ax.set_title('perf scaling: direct evaluation vs FMM', fontsize=14, pad=15, fontweight='bold')
ax.set_xlabel('# of particles (N)', fontsize=12)
Expand All @@ -48,16 +51,14 @@

fig_log, ax_log = plt.subplots(figsize=(8, 5))

ax_log.plot(N, t_direct, marker='o', linewidth=2.5, color=COL_NAIVE,
label='naive $\mathcal{O}(N^2)$')
ax_log.plot(N, t_fmm, marker='o', linewidth=2.5, color=COL_FMM,
label='FMM $\mathcal{O}(N)$')
ax_log.plot(N, t_direct, marker='o', linewidth=2.5, color=COL_NAIVE, label='naive $\mathcal{O}(N^2)$')
ax_log.plot(N, t_fmm_st, marker='o', linewidth=2.5, color=COL_FMM_ST, label='FMM $\mathcal{O}(N)$ 1-core')
ax_log.plot(N, t_fmm_mt, marker='o', linewidth=2.5, color=COL_FMM_MT, label='FMM $\mathcal{O}(N)$ 8-core')

ax_log.set_xscale('log')
ax_log.set_yscale('log')

ax_log.set_title('algorithmic scaling (log-log)', fontsize=14, pad=15,
fontweight='bold')
ax_log.set_title('algorithmic scaling (log-log)', fontsize=14, pad=15, fontweight='bold')
ax_log.set_xlabel('# of particles (N)', fontsize=12)
ax_log.set_ylabel('exec time (secs)', fontsize=12)

Expand Down
Loading