@@ -3476,55 +3476,55 @@ p2r_convert(Arena *arena, P2R_User2Convert *in)
3476
3476
internal TS_TASK_FUNCTION_DEF (p2r_bake_src_files_strings_task__entry_point )
3477
3477
{
3478
3478
P2R_BakeSrcFilesStringsIn * in = (P2R_BakeSrcFilesStringsIn * )p ;
3479
- RDIM_BakeStringChunkListMap * map = rdim_bake_string_chunk_list_map_make (arena , in -> top );
3480
- ProfScope ("bake src file strings" ) rdim_bake_string_chunk_list_map_push_src_files (arena , in -> top , map , in -> list );
3481
- return map ;
3479
+ ProfScope ("bake src file strings" ) rdim_bake_string_chunk_list_map_push_src_files (arena , in -> top , in -> maps [thread_idx ], in -> list );
3480
+ return 0 ;
3482
3481
}
3483
3482
3484
3483
internal TS_TASK_FUNCTION_DEF (p2r_bake_units_strings_task__entry_point )
3485
3484
{
3486
3485
P2R_BakeUnitsStringsIn * in = (P2R_BakeUnitsStringsIn * )p ;
3487
- RDIM_BakeStringChunkListMap * map = rdim_bake_string_chunk_list_map_make (arena , in -> top );
3488
- ProfScope ("bake unit strings" ) rdim_bake_string_chunk_list_map_push_units (arena , in -> top , map , in -> list );
3489
- return map ;
3486
+ ProfScope ("bake unit strings" ) rdim_bake_string_chunk_list_map_push_units (arena , in -> top , in -> maps [thread_idx ], in -> list );
3487
+ return 0 ;
3490
3488
}
3491
3489
3492
3490
internal TS_TASK_FUNCTION_DEF (p2r_bake_types_strings_task__entry_point )
3493
3491
{
3494
3492
P2R_BakeTypesStringsIn * in = (P2R_BakeTypesStringsIn * )p ;
3495
- RDIM_BakeStringChunkListMap * map = rdim_bake_string_chunk_list_map_make (arena , in -> top );
3496
3493
ProfScope ("bake type strings" )
3497
3494
{
3498
3495
for (P2R_BakeTypesStringsInNode * n = in -> first ; n != 0 ; n = n -> next )
3499
3496
{
3500
- rdim_bake_string_chunk_list_map_push_type_slice (arena , in -> top , map , n -> v , n -> count );
3497
+ rdim_bake_string_chunk_list_map_push_type_slice (arena , in -> top , in -> maps [ thread_idx ] , n -> v , n -> count );
3501
3498
}
3502
3499
}
3503
- return map ;
3500
+ return 0 ;
3504
3501
}
3505
3502
3506
3503
internal TS_TASK_FUNCTION_DEF (p2r_bake_udts_strings_task__entry_point )
3507
3504
{
3508
3505
P2R_BakeUDTsStringsIn * in = (P2R_BakeUDTsStringsIn * )p ;
3509
- RDIM_BakeStringChunkListMap * map = rdim_bake_string_chunk_list_map_make (arena , in -> top );
3510
- ProfScope ("bake udt strings" ) rdim_bake_string_chunk_list_map_push_udts (arena , in -> top , map , in -> list );
3511
- return map ;
3506
+ ProfScope ("bake udt strings" )
3507
+ {
3508
+ for (P2R_BakeUDTsStringsInNode * n = in -> first ; n != 0 ; n = n -> next )
3509
+ {
3510
+ rdim_bake_string_chunk_list_map_push_udt_slice (arena , in -> top , in -> maps [thread_idx ], n -> v , n -> count );
3511
+ }
3512
+ }
3513
+ return 0 ;
3512
3514
}
3513
3515
3514
3516
internal TS_TASK_FUNCTION_DEF (p2r_bake_symbols_strings_task__entry_point )
3515
3517
{
3516
3518
P2R_BakeSymbolsStringsIn * in = (P2R_BakeSymbolsStringsIn * )p ;
3517
- RDIM_BakeStringChunkListMap * map = rdim_bake_string_chunk_list_map_make (arena , in -> top );
3518
- ProfScope ("bake symbol strings" ) rdim_bake_string_chunk_list_map_push_symbols (arena , in -> top , map , in -> list );
3519
- return map ;
3519
+ ProfScope ("bake symbol strings" ) rdim_bake_string_chunk_list_map_push_symbols (arena , in -> top , in -> maps [thread_idx ], in -> list );
3520
+ return 0 ;
3520
3521
}
3521
3522
3522
3523
internal TS_TASK_FUNCTION_DEF (p2r_bake_scopes_strings_task__entry_point )
3523
3524
{
3524
3525
P2R_BakeScopesStringsIn * in = (P2R_BakeScopesStringsIn * )p ;
3525
- RDIM_BakeStringChunkListMap * map = rdim_bake_string_chunk_list_map_make (arena , in -> top );
3526
- ProfScope ("bake scope strings" ) rdim_bake_string_chunk_list_map_push_scopes (arena , in -> top , map , in -> list );
3527
- return map ;
3526
+ ProfScope ("bake scope strings" ) rdim_bake_string_chunk_list_map_push_scopes (arena , in -> top , in -> maps [thread_idx ], in -> list );
3527
+ return 0 ;
3528
3528
}
3529
3529
3530
3530
//- rjf: bake string map sorting
@@ -3742,12 +3742,18 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
3742
3742
params -> global_variables .total_count * 2 +
3743
3743
params -> thread_variables .total_count * 2 +
3744
3744
params -> types .total_count * 2 )};
3745
+ RDIM_BakeStringChunkListMap * * bake_string_chunk_list_maps__in_progress = push_array (scratch .arena , RDIM_BakeStringChunkListMap * , ts_thread_count ());
3746
+ for (U64 idx = 0 ; idx < ts_thread_count (); idx += 1 )
3747
+ {
3748
+ bake_string_chunk_list_maps__in_progress [idx ] = rdim_bake_string_chunk_list_map_make (arena , & bake_string_chunk_list_map_topology );
3749
+ }
3745
3750
TS_TicketList bake_string_map_build_tickets = {0 };
3746
3751
{
3747
3752
// rjf: src files
3748
3753
{
3749
3754
P2R_BakeSrcFilesStringsIn * in = push_array (scratch .arena , P2R_BakeSrcFilesStringsIn , 1 );
3750
3755
in -> top = & bake_string_chunk_list_map_topology ;
3756
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3751
3757
in -> list = & params -> src_files ;
3752
3758
ts_ticket_list_push (scratch .arena , & bake_string_map_build_tickets , ts_kickoff (p2r_bake_src_files_strings_task__entry_point , 0 , in ));
3753
3759
}
@@ -3756,6 +3762,7 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
3756
3762
{
3757
3763
P2R_BakeUnitsStringsIn * in = push_array (scratch .arena , P2R_BakeUnitsStringsIn , 1 );
3758
3764
in -> top = & bake_string_chunk_list_map_topology ;
3765
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3759
3766
in -> list = & params -> units ;
3760
3767
ts_ticket_list_push (scratch .arena , & bake_string_map_build_tickets , ts_kickoff (p2r_bake_units_strings_task__entry_point , 0 , in ));
3761
3768
}
@@ -3764,12 +3771,13 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
3764
3771
{
3765
3772
for (RDIM_TypeChunkNode * chunk = params -> types .first ; chunk != 0 ; chunk = chunk -> next )
3766
3773
{
3767
- U64 types_per_task = chunk -> count ;
3774
+ U64 types_per_task = Min ( 4096 , chunk -> count ) ;
3768
3775
U64 tasks_per_this_chunk = (chunk -> count + types_per_task - 1 )/types_per_task ;
3769
3776
for (U64 task_idx = 0 ; task_idx < tasks_per_this_chunk ; task_idx += 1 )
3770
3777
{
3771
3778
P2R_BakeTypesStringsIn * in = push_array (scratch .arena , P2R_BakeTypesStringsIn , 1 );
3772
3779
in -> top = & bake_string_chunk_list_map_topology ;
3780
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3773
3781
P2R_BakeTypesStringsInNode * n = push_array (scratch .arena , P2R_BakeTypesStringsInNode , 1 );
3774
3782
SLLQueuePush (in -> first , in -> last , n );
3775
3783
n -> v = chunk -> v + task_idx * types_per_task ;
@@ -3779,18 +3787,42 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
3779
3787
}
3780
3788
}
3781
3789
3790
+ // rjf: UDTs
3791
+ {
3792
+ for (RDIM_UDTChunkNode * chunk = params -> udts .first ; chunk != 0 ; chunk = chunk -> next )
3793
+ {
3794
+ U64 udts_per_task = Min (4096 , chunk -> count );
3795
+ U64 tasks_per_this_chunk = (chunk -> count + udts_per_task - 1 )/udts_per_task ;
3796
+ for (U64 task_idx = 0 ; task_idx < tasks_per_this_chunk ; task_idx += 1 )
3797
+ {
3798
+ P2R_BakeUDTsStringsIn * in = push_array (scratch .arena , P2R_BakeUDTsStringsIn , 1 );
3799
+ in -> top = & bake_string_chunk_list_map_topology ;
3800
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3801
+ P2R_BakeUDTsStringsInNode * n = push_array (scratch .arena , P2R_BakeUDTsStringsInNode , 1 );
3802
+ SLLQueuePush (in -> first , in -> last , n );
3803
+ n -> v = chunk -> v + task_idx * udts_per_task ;
3804
+ n -> count = udts_per_task ;
3805
+ ts_ticket_list_push (scratch .arena , & bake_string_map_build_tickets , ts_kickoff (p2r_bake_udts_strings_task__entry_point , 0 , in ));
3806
+ }
3807
+ }
3808
+ }
3809
+
3810
+ #if 0
3782
3811
// rjf: UDTs
3783
3812
{
3784
3813
P2R_BakeUDTsStringsIn * in = push_array (scratch .arena , P2R_BakeUDTsStringsIn , 1 );
3785
3814
in -> top = & bake_string_chunk_list_map_topology ;
3815
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3786
3816
in -> list = & params -> udts ;
3787
3817
ts_ticket_list_push (scratch .arena , & bake_string_map_build_tickets , ts_kickoff (p2r_bake_udts_strings_task__entry_point , 0 , in ));
3788
3818
}
3819
+ #endif
3789
3820
3790
3821
// rjf: global variables
3791
3822
{
3792
3823
P2R_BakeSymbolsStringsIn * in = push_array (scratch .arena , P2R_BakeSymbolsStringsIn , 1 );
3793
3824
in -> top = & bake_string_chunk_list_map_topology ;
3825
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3794
3826
in -> list = & params -> global_variables ;
3795
3827
ts_ticket_list_push (scratch .arena , & bake_string_map_build_tickets , ts_kickoff (p2r_bake_symbols_strings_task__entry_point , 0 , in ));
3796
3828
}
@@ -3799,6 +3831,7 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
3799
3831
{
3800
3832
P2R_BakeSymbolsStringsIn * in = push_array (scratch .arena , P2R_BakeSymbolsStringsIn , 1 );
3801
3833
in -> top = & bake_string_chunk_list_map_topology ;
3834
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3802
3835
in -> list = & params -> thread_variables ;
3803
3836
ts_ticket_list_push (scratch .arena , & bake_string_map_build_tickets , ts_kickoff (p2r_bake_symbols_strings_task__entry_point , 0 , in ));
3804
3837
}
@@ -3807,6 +3840,7 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
3807
3840
{
3808
3841
P2R_BakeSymbolsStringsIn * in = push_array (scratch .arena , P2R_BakeSymbolsStringsIn , 1 );
3809
3842
in -> top = & bake_string_chunk_list_map_topology ;
3843
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3810
3844
in -> list = & params -> procedures ;
3811
3845
ts_ticket_list_push (scratch .arena , & bake_string_map_build_tickets , ts_kickoff (p2r_bake_symbols_strings_task__entry_point , 0 , in ));
3812
3846
}
@@ -3815,6 +3849,7 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
3815
3849
{
3816
3850
P2R_BakeScopesStringsIn * in = push_array (scratch .arena , P2R_BakeScopesStringsIn , 1 );
3817
3851
in -> top = & bake_string_chunk_list_map_topology ;
3852
+ in -> maps = bake_string_chunk_list_maps__in_progress ;
3818
3853
in -> list = & params -> scopes ;
3819
3854
ts_ticket_list_push (scratch .arena , & bake_string_map_build_tickets , ts_kickoff (p2r_bake_scopes_strings_task__entry_point , 0 , in ));
3820
3855
}
@@ -3833,17 +3868,21 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
3833
3868
}
3834
3869
3835
3870
//- rjf: join string map building tasks
3836
- RDIM_BakeStringChunkListMap * unsorted_bake_string_chunk_list_map = rdim_bake_string_chunk_list_map_make (arena , & bake_string_chunk_list_map_topology );
3837
3871
ProfScope ("join string map building tasks" )
3838
3872
{
3839
3873
for (TS_TicketNode * n = bake_string_map_build_tickets .first ; n != 0 ; n = n -> next )
3840
3874
{
3841
- ProfBegin ("waiting..." );
3842
- RDIM_BakeStringChunkListMap * map = ts_join_struct (n -> v , max_U64 , RDIM_BakeStringChunkListMap );
3843
- ProfEnd ();
3844
- ProfBegin ("joining map..." );
3845
- rdim_bake_string_chunk_list_map_join_in_place (& bake_string_chunk_list_map_topology , unsorted_bake_string_chunk_list_map , map );
3846
- ProfEnd ();
3875
+ ts_join (n -> v , max_U64 );
3876
+ }
3877
+ }
3878
+
3879
+ //- rjf: produce joined string map
3880
+ RDIM_BakeStringChunkListMap * unsorted_bake_string_chunk_list_map = rdim_bake_string_chunk_list_map_make (arena , & bake_string_chunk_list_map_topology );
3881
+ ProfScope ("produce joined string map" )
3882
+ {
3883
+ for (U64 idx = 0 ; idx < ts_thread_count (); idx += 1 )
3884
+ {
3885
+ rdim_bake_string_chunk_list_map_join_in_place (& bake_string_chunk_list_map_topology , unsorted_bake_string_chunk_list_map , bake_string_chunk_list_maps__in_progress [idx ]);
3847
3886
}
3848
3887
}
3849
3888
0 commit comments