Skip to content

Commit e65bc12

Browse files
committed
more work on pdb -> rdi determinism; almost done hitting all of the issues...
1 parent e1575f8 commit e65bc12

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

src/lib_rdi_make/rdi_make.c

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ rdim_bake_string_chunk_list_sorted_from_unsorted(RDIM_Arena *arena, RDIM_BakeStr
13451345
// build new sort tasks for buckets with many elements
13461346
{
13471347
RDI_U64 write_idx = 0;
1348-
for(U64 bucket_idx = 0; bucket_idx < 256; bucket_idx += 1)
1348+
for(RDI_U64 bucket_idx = 0; bucket_idx < 256; bucket_idx += 1)
13491349
{
13501350
// rjf: write each chunk node's array into original array, detect if there is size left to sort
13511351
RDI_U64 bucket_base_idx = write_idx;
@@ -1379,6 +1379,57 @@ rdim_bake_string_chunk_list_sorted_from_unsorted(RDIM_Arena *arena, RDIM_BakeStr
13791379
scratch_end(scratch);
13801380
}
13811381

1382+
//- rjf: iterate sorted chunk node, remove duplicates, count # to pop
1383+
RDI_U64 num_to_pop = 0;
1384+
RDI_U64 arena_pos_pre_pop = rdim_arena_pos(arena);
1385+
if(dst.first != 0)
1386+
{
1387+
RDI_U64 last_idx = 0;
1388+
for(RDI_U64 idx = 1; idx < dst.first->count; idx += 1)
1389+
{
1390+
if(rdim_str8_match(dst.first->v[last_idx].string, dst.first->v[idx].string, 0))
1391+
{
1392+
rdim_memzero_struct(&dst.first->v[idx]);
1393+
num_to_pop += 1;
1394+
}
1395+
else
1396+
{
1397+
last_idx = idx;
1398+
}
1399+
}
1400+
}
1401+
1402+
//- rjf: iterate sorted chunk node, make non-empty elements contiguous
1403+
if(num_to_pop != 0)
1404+
{
1405+
RDI_U64 last_idx = 0;
1406+
for(RDI_U64 idx = 1; idx < dst.first->count; idx += 1)
1407+
{
1408+
if(dst.first->v[idx].string.RDIM_String8_SizeMember == 0 &&
1409+
dst.first->v[idx].hash == 0)
1410+
{
1411+
last_idx = idx;
1412+
}
1413+
else if(last_idx != 0 && last_idx != idx)
1414+
{
1415+
rdim_memcpy_struct(&dst.first->v[last_idx], &dst.first->v[idx]);
1416+
rdim_memzero_struct(&dst.first->v[idx]);
1417+
idx = last_idx;
1418+
last_idx = 0;
1419+
}
1420+
}
1421+
1422+
//- rjf: pop extras
1423+
if(num_to_pop != 0)
1424+
{
1425+
rdim_arena_pop_to(arena, arena_pos_pre_pop - num_to_pop*sizeof(dst.first->v[0]));
1426+
dst.first->count -= num_to_pop;
1427+
dst.first->cap -= num_to_pop;
1428+
dst.total_count -= num_to_pop;
1429+
}
1430+
}
1431+
1432+
13821433
return dst;
13831434
}
13841435

src/rdi_from_pdb/rdi_from_pdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4639,7 +4639,7 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
46394639
{
46404640
for EachIndex(idx, n->count)
46414641
{
4642-
printf("string: %.*s\n", str8_varg(n->v[idx].string));
4642+
printf("string: \"%.*s\"\n", str8_varg(n->v[idx].string));
46434643
}
46444644
}
46454645
}

src/tester/tester_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ entry_point(CmdLine *cmdline)
4545
String8List out = {0};
4646
{
4747
name = str8_lit("pdb2rdi_determinism");
48-
U64 num_repeats_per_pdb = 4;
48+
U64 num_repeats_per_pdb = 16;
4949
String8 pdb_paths[] =
5050
{
5151
// str8_lit_comp("odintest/test.pdb"),

0 commit comments

Comments
 (0)