Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
erincatto committed Sep 15, 2024
1 parent b072e44 commit 9044b4d
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 53 deletions.
16 changes: 8 additions & 8 deletions benchmark/amd7950x_avx2/joint_grid.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
threads,fps
1,333.07
2,641.434
3,944.038
4,1206.21
5,1496.76
6,1722.19
7,1956.35
8,2146.81
1,335.063
2,645.534
3,948.765
4,1211.25
5,1467.57
6,1739.37
7,1956.88
8,2122.49
16 changes: 8 additions & 8 deletions benchmark/amd7950x_avx2/large_pyramid.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
threads,fps
1,337.452
2,623.273
3,889.504
4,1124.83
5,1339.88
6,1493.98
7,1689.74
8,1726.49
1,328.676
2,620.91
3,875.192
4,1099.74
5,1334.52
6,1492.16
7,1679.75
8,1695.15
16 changes: 8 additions & 8 deletions benchmark/amd7950x_avx2/many_pyramids.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
threads,fps
1,87.7948
2,165.138
3,244.692
4,310.302
5,379.072
6,436.226
7,503.71
8,554.489
1,84.7363
2,162.366
3,240.102
4,304.455
5,364.151
6,421.873
7,487.649
8,512.498
16 changes: 8 additions & 8 deletions benchmark/amd7950x_avx2/smash.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
threads,fps
1,178.234
2,282.589
3,360.22
4,431.746
5,485.852
6,529.01
7,570.548
8,599.725
1,174.354
2,278.703
3,351.379
4,426.281
5,481.017
6,522.679
7,563.934
8,568.804
16 changes: 8 additions & 8 deletions benchmark/amd7950x_avx2/tumbler.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
threads,fps
1,379.168
2,593.692
3,768.849
4,908.277
5,1050.74
6,1145.49
7,1231.01
8,1298.58
1,374.049
2,583.15
3,757.448
4,900.05
5,1035.64
6,1142.83
7,1210.4
8,1256.37
12 changes: 10 additions & 2 deletions src/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void b2Array_Resize( void** a, int elementSize, int count );
if ( a->count == a->capacity ) \
{ \
int newCapacity = a->capacity < 2 ? 2 : a->capacity + ( a->capacity >> 1 ); \
PREFIX##Array_Reserve( a, newCapacity ); \
PREFIX##Array_Reserve( a, newCapacity ); \
} \
a->data[a->count] = value; \
a->count += 1; \
Expand All @@ -104,13 +104,21 @@ void b2Array_Resize( void** a, int elementSize, int count );
a->count -= 1; \
} \
\
static inline T PREFIX##Array_Pop( PREFIX##Array* a ) \
{ \
B2_ASSERT( a->count > 0 ); \
T value = a->data[a->count - 1]; \
a->count -= 1; \
return value; \
} \
\
static inline int PREFIX##Array_ByteCount( PREFIX##Array* a ) \
{ \
return (int)( a->capacity * sizeof( T ) ); \
}

// Array implementations to be instantiated in a source file where the type T is known
#define B2_ARRAY_SOURCE( T, PREFIX ) \
#define B2_ARRAY_SOURCE( T, PREFIX ) \
PREFIX##Array PREFIX##Array_Create( int capacity ) \
{ \
PREFIX##Array a; \
Expand Down
16 changes: 8 additions & 8 deletions src/id_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
b2IdPool b2CreateIdPool()
{
b2IdPool pool = { 0 };
pool.freeArray = b2CreateArray( sizeof( int ), 32 );
pool.freeArray = b2IntArray_Create( 32 );
return pool;
}

void b2DestroyIdPool( b2IdPool* pool )
{
b2DestroyArray( pool->freeArray, sizeof( int ) );
b2IntArray_Destroy( &pool->freeArray );
*pool = ( b2IdPool ){ 0 };
}

int b2AllocId( b2IdPool* pool )
{
if ( b2Array( pool->freeArray ).count > 0 )
int count = pool->freeArray.count;
if (count > 0 )
{
int id = b2Array_Last( pool->freeArray );
b2Array_Pop( pool->freeArray );
int id = b2IntArray_Pop(&pool->freeArray);
return id;
}

Expand All @@ -43,17 +43,17 @@ void b2FreeId( b2IdPool* pool, int id )
return;
}

b2Array_Push( pool->freeArray, id );
b2IntArray_Push( &pool->freeArray, id );
}

#if B2_VALIDATE

void b2ValidateFreeId( b2IdPool* pool, int id )
{
int freeCount = b2Array( pool->freeArray ).count;
int freeCount = pool->freeArray.count;
for ( int i = 0; i < freeCount; ++i )
{
if ( pool->freeArray[i] == id )
if ( pool->freeArray.data[i] == id )
{
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/id_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

typedef struct b2IdPool
{
int* freeArray;
b2IntArray freeArray;
int nextIndex;
} b2IdPool;

Expand All @@ -20,7 +20,7 @@ void b2ValidateFreeId( b2IdPool* pool, int id );

static inline int b2GetIdCount( b2IdPool* pool )
{
return pool->nextIndex - b2Array( pool->freeArray ).count;
return pool->nextIndex - pool->freeArray.count;
}

static inline int b2GetIdCapacity( b2IdPool* pool )
Expand All @@ -30,5 +30,5 @@ static inline int b2GetIdCapacity( b2IdPool* pool )

static inline int b2GetIdBytes( b2IdPool* pool )
{
return b2GetArrayBytes( pool->freeArray, sizeof( int ) );
return b2IntArray_ByteCount(&pool->freeArray);
}

0 comments on commit 9044b4d

Please sign in to comment.