Skip to content

Commit 9377efb

Browse files
committed
eliminate rest of p2r_shared usage, just use lane syncs
1 parent d347e24 commit 9377efb

File tree

2 files changed

+93
-92
lines changed

2 files changed

+93
-92
lines changed

src/rdi_from_pdb/rdi_from_pdb.c

Lines changed: 93 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -408,16 +408,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
408408
{
409409
Temp scratch = scratch_begin(&arena, 1);
410410

411-
//////////////////////////////////////////////////////////////
412-
//- rjf: setup shared state
413-
//
414-
P2R_Shared *p2r_shared = 0;
415-
if(lane_idx() == 0)
416-
{
417-
p2r_shared = push_array(scratch.arena, P2R_Shared, 1);
418-
}
419-
lane_sync_u64(&p2r_shared, 0);
420-
421411
//////////////////////////////////////////////////////////////
422412
//- rjf: do base MSF parse
423413
//
@@ -2660,23 +2650,18 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
26602650
//////////////////////////////////////////////////////////////
26612651
//- rjf: types pass 4: build UDTs
26622652
//
2653+
RDIM_UDTChunkList *lanes_udts = 0;
26632654
ProfScope("types pass 4: build UDTs")
26642655
{
26652656
#define p2r_type_ptr_from_itype(itype) ((itype_type_ptrs && (itype) < tpi_leaf->itype_opl) ? (itype_type_ptrs[(itype_fwd_map[(itype)] ? itype_fwd_map[(itype)] : (itype))]) : 0)
26662657

2667-
//- rjf: set up
2668-
if(lane_idx() == 0)
2669-
{
2670-
p2r_shared->lanes_udts = push_array(arena, RDIM_UDTChunkList, lane_count());
2671-
}
2672-
lane_sync();
2673-
2674-
//- rjf: do wide fill
2658+
//- rjf: gather this lane's UDTs
2659+
RDIM_UDTChunkList lane_udts = {0};
26752660
if(params->subset_flags & RDIM_SubsetFlag_Types &&
26762661
params->subset_flags & RDIM_SubsetFlag_UDTs)
26772662
{
26782663
U64 udts_chunk_cap = 4096;
2679-
RDIM_UDTChunkList *udts = &p2r_shared->lanes_udts[lane_idx()];
2664+
RDIM_UDTChunkList *udts = &lane_udts;
26802665
Rng1U64 range = lane_range(itype_opl);
26812666
for EachInRange(idx, range)
26822667
{
@@ -3296,27 +3281,45 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
32963281
}
32973282
}
32983283
}
3284+
3285+
//- rjf: collect all lanes
3286+
if(lane_idx() == 0)
3287+
{
3288+
lanes_udts = push_array(scratch.arena, RDIM_UDTChunkList, lane_count());
3289+
}
3290+
lane_sync_u64(&lanes_udts, 0);
3291+
lanes_udts[lane_idx()] = lane_udts;
32993292
#undef p2r_type_ptr_from_itype
33003293
}
33013294
lane_sync();
3302-
RDIM_UDTChunkList *lanes_udts = p2r_shared->lanes_udts;
33033295

33043296
//////////////////////////////////////////////////////////////
33053297
//- rjf: join all UDTs
33063298
//
3299+
RDIM_UDTChunkList all_udts = {0};
33073300
ProfScope("join all UDTs") if(lane_idx() == 0)
33083301
{
33093302
for EachIndex(idx, lane_count())
33103303
{
3311-
rdim_udt_chunk_list_concat_in_place(&p2r_shared->all_udts, &lanes_udts[idx]);
3304+
rdim_udt_chunk_list_concat_in_place(&all_udts, &lanes_udts[idx]);
33123305
}
33133306
}
33143307
lane_sync();
3315-
RDIM_UDTChunkList all_udts = p2r_shared->all_udts;
3308+
RDIM_UDTChunkList *all_udts_ptr = &all_udts;
3309+
lane_sync_u64(&all_udts_ptr, 0);
3310+
all_udts = *all_udts_ptr;
33163311

33173312
//////////////////////////////////////////////////////////////
33183313
//- rjf: produce symbols from all streams
33193314
//
3315+
RDIM_LocationChunkList *syms_locations = 0;
3316+
RDIM_SymbolChunkList *syms_procedures = 0;
3317+
RDIM_SymbolChunkList *syms_global_variables = 0;
3318+
RDIM_SymbolChunkList *syms_thread_variables = 0;
3319+
RDIM_SymbolChunkList *syms_constants = 0;
3320+
RDIM_ScopeChunkList *syms_scopes = 0;
3321+
RDIM_InlineSiteChunkList *syms_inline_sites = 0;
3322+
RDIM_TypeChunkList *syms_typedefs = 0;
33203323
ProfScope("produce symbols from all streams")
33213324
{
33223325
#define p2r_type_ptr_from_itype(itype) ((itype_type_ptrs && (itype) < itype_opl) ? (itype_type_ptrs[(itype_fwd_map[(itype)] ? itype_fwd_map[(itype)] : (itype))]) : 0)
@@ -3326,16 +3329,23 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
33263329
//
33273330
if(lane_idx() == 0)
33283331
{
3329-
p2r_shared->syms_locations = push_array(arena, RDIM_LocationChunkList, all_syms_count);
3330-
p2r_shared->syms_procedures = push_array(arena, RDIM_SymbolChunkList, all_syms_count);
3331-
p2r_shared->syms_global_variables = push_array(arena, RDIM_SymbolChunkList, all_syms_count);
3332-
p2r_shared->syms_thread_variables = push_array(arena, RDIM_SymbolChunkList, all_syms_count);
3333-
p2r_shared->syms_constants = push_array(arena, RDIM_SymbolChunkList, all_syms_count);
3334-
p2r_shared->syms_scopes = push_array(arena, RDIM_ScopeChunkList, all_syms_count);
3335-
p2r_shared->syms_inline_sites = push_array(arena, RDIM_InlineSiteChunkList, all_syms_count);
3336-
p2r_shared->syms_typedefs = push_array(arena, RDIM_TypeChunkList, all_syms_count);
3332+
syms_locations = push_array(arena, RDIM_LocationChunkList, all_syms_count);
3333+
syms_procedures = push_array(arena, RDIM_SymbolChunkList, all_syms_count);
3334+
syms_global_variables = push_array(arena, RDIM_SymbolChunkList, all_syms_count);
3335+
syms_thread_variables = push_array(arena, RDIM_SymbolChunkList, all_syms_count);
3336+
syms_constants = push_array(arena, RDIM_SymbolChunkList, all_syms_count);
3337+
syms_scopes = push_array(arena, RDIM_ScopeChunkList, all_syms_count);
3338+
syms_inline_sites = push_array(arena, RDIM_InlineSiteChunkList, all_syms_count);
3339+
syms_typedefs = push_array(arena, RDIM_TypeChunkList, all_syms_count);
33373340
}
3338-
lane_sync();
3341+
lane_sync_u64(&syms_locations, 0);
3342+
lane_sync_u64(&syms_procedures, 0);
3343+
lane_sync_u64(&syms_global_variables, 0);
3344+
lane_sync_u64(&syms_thread_variables, 0);
3345+
lane_sync_u64(&syms_constants, 0);
3346+
lane_sync_u64(&syms_scopes, 0);
3347+
lane_sync_u64(&syms_inline_sites, 0);
3348+
lane_sync_u64(&syms_typedefs, 0);
33393349

33403350
////////////////////////////
33413351
//- rjf: fill outputs for all unit sym blocks in this lane
@@ -3375,14 +3385,14 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
33753385
U64 sym_constants_chunk_cap = 16384;
33763386
U64 sym_scopes_chunk_cap = 16384;
33773387
U64 sym_inline_sites_chunk_cap = 16384;
3378-
RDIM_LocationChunkList *sym_locations = &p2r_shared->syms_locations[sym_idx];
3379-
RDIM_SymbolChunkList *sym_procedures = &p2r_shared->syms_procedures[sym_idx];
3380-
RDIM_SymbolChunkList *sym_global_variables = &p2r_shared->syms_global_variables[sym_idx];
3381-
RDIM_SymbolChunkList *sym_thread_variables = &p2r_shared->syms_thread_variables[sym_idx];
3382-
RDIM_SymbolChunkList *sym_constants = &p2r_shared->syms_constants[sym_idx];
3383-
RDIM_ScopeChunkList *sym_scopes = &p2r_shared->syms_scopes[sym_idx];
3384-
RDIM_InlineSiteChunkList *sym_inline_sites = &p2r_shared->syms_inline_sites[sym_idx];
3385-
RDIM_TypeChunkList *typedefs = &p2r_shared->syms_typedefs[sym_idx];
3388+
RDIM_LocationChunkList *sym_locations = &syms_locations[sym_idx];
3389+
RDIM_SymbolChunkList *sym_procedures = &syms_procedures[sym_idx];
3390+
RDIM_SymbolChunkList *sym_global_variables = &syms_global_variables[sym_idx];
3391+
RDIM_SymbolChunkList *sym_thread_variables = &syms_thread_variables[sym_idx];
3392+
RDIM_SymbolChunkList *sym_constants = &syms_constants[sym_idx];
3393+
RDIM_ScopeChunkList *sym_scopes = &syms_scopes[sym_idx];
3394+
RDIM_InlineSiteChunkList *sym_inline_sites = &syms_inline_sites[sym_idx];
3395+
RDIM_TypeChunkList *typedefs = &syms_typedefs[sym_idx];
33863396

33873397
//////////////////////////
33883398
//- rjf: symbols pass 1: produce procedure frame info map (procedure -> frame info)
@@ -4284,74 +4294,93 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
42844294
//////////////////////////////////////////////////////////////
42854295
//- rjf: join all lane symbols
42864296
//
4297+
RDIM_LocationChunkList *all_locations = 0;
4298+
RDIM_SymbolChunkList *all_procedures = 0;
4299+
RDIM_SymbolChunkList *all_global_variables = 0;
4300+
RDIM_SymbolChunkList *all_thread_variables = 0;
4301+
RDIM_SymbolChunkList *all_constants = 0;
4302+
RDIM_ScopeChunkList *all_scopes = 0;
4303+
RDIM_InlineSiteChunkList *all_inline_sites = 0;
4304+
RDIM_TypeChunkList *all_types = 0;
42874305
{
4306+
if(lane_idx() == 0)
4307+
{
4308+
all_locations = push_array(scratch.arena, RDIM_LocationChunkList, 1);
4309+
all_procedures = push_array(scratch.arena, RDIM_SymbolChunkList, 1);
4310+
all_global_variables = push_array(scratch.arena, RDIM_SymbolChunkList, 1);
4311+
all_thread_variables = push_array(scratch.arena, RDIM_SymbolChunkList, 1);
4312+
all_constants = push_array(scratch.arena, RDIM_SymbolChunkList, 1);
4313+
all_scopes = push_array(scratch.arena, RDIM_ScopeChunkList, 1);
4314+
all_inline_sites = push_array(scratch.arena, RDIM_InlineSiteChunkList, 1);
4315+
all_types = push_array(scratch.arena, RDIM_TypeChunkList, 1);
4316+
}
4317+
lane_sync_u64(&all_locations, 0);
4318+
lane_sync_u64(&all_procedures, 0);
4319+
lane_sync_u64(&all_global_variables, 0);
4320+
lane_sync_u64(&all_thread_variables, 0);
4321+
lane_sync_u64(&all_constants, 0);
4322+
lane_sync_u64(&all_scopes, 0);
4323+
lane_sync_u64(&all_inline_sites, 0);
4324+
lane_sync_u64(&all_types, 0);
42884325
if(lane_idx() == lane_from_task_idx(0)) ProfScope("join locations")
42894326
{
42904327
for EachIndex(idx, all_syms_count)
42914328
{
4292-
rdim_location_chunk_list_concat_in_place(&p2r_shared->all_locations, &p2r_shared->syms_locations[idx]);
4329+
rdim_location_chunk_list_concat_in_place(all_locations, &syms_locations[idx]);
42934330
}
42944331
}
42954332
if(lane_idx() == lane_from_task_idx(1)) ProfScope("join procedures")
42964333
{
42974334
for EachIndex(idx, all_syms_count)
42984335
{
4299-
rdim_symbol_chunk_list_concat_in_place(&p2r_shared->all_procedures, &p2r_shared->syms_procedures[idx]);
4336+
rdim_symbol_chunk_list_concat_in_place(all_procedures, &syms_procedures[idx]);
43004337
}
43014338
}
43024339
if(lane_idx() == lane_from_task_idx(2)) ProfScope("join global variables")
43034340
{
43044341
for EachIndex(idx, all_syms_count)
43054342
{
4306-
rdim_symbol_chunk_list_concat_in_place(&p2r_shared->all_global_variables, &p2r_shared->syms_global_variables[idx]);
4343+
rdim_symbol_chunk_list_concat_in_place(all_global_variables, &syms_global_variables[idx]);
43074344
}
43084345
}
43094346
if(lane_idx() == lane_from_task_idx(3)) ProfScope("join thread variables")
43104347
{
43114348
for EachIndex(idx, all_syms_count)
43124349
{
4313-
rdim_symbol_chunk_list_concat_in_place(&p2r_shared->all_thread_variables, &p2r_shared->syms_thread_variables[idx]);
4350+
rdim_symbol_chunk_list_concat_in_place(all_thread_variables, &syms_thread_variables[idx]);
43144351
}
43154352
}
43164353
if(lane_idx() == lane_from_task_idx(4)) ProfScope("join constants")
43174354
{
43184355
for EachIndex(idx, all_syms_count)
43194356
{
4320-
rdim_symbol_chunk_list_concat_in_place(&p2r_shared->all_constants, &p2r_shared->syms_constants[idx]);
4357+
rdim_symbol_chunk_list_concat_in_place(all_constants, &syms_constants[idx]);
43214358
}
43224359
}
43234360
if(lane_idx() == lane_from_task_idx(5)) ProfScope("join scopes")
43244361
{
43254362
for EachIndex(idx, all_syms_count)
43264363
{
4327-
rdim_scope_chunk_list_concat_in_place(&p2r_shared->all_scopes, &p2r_shared->syms_scopes[idx]);
4364+
rdim_scope_chunk_list_concat_in_place(all_scopes, &syms_scopes[idx]);
43284365
}
43294366
}
43304367
if(lane_idx() == lane_from_task_idx(6)) ProfScope("join inline sites")
43314368
{
43324369
for EachIndex(idx, all_syms_count)
43334370
{
4334-
rdim_inline_site_chunk_list_concat_in_place(&p2r_shared->all_inline_sites, &p2r_shared->syms_inline_sites[idx]);
4371+
rdim_inline_site_chunk_list_concat_in_place(all_inline_sites, &syms_inline_sites[idx]);
43354372
}
43364373
}
43374374
if(lane_idx() == lane_from_task_idx(7)) ProfScope("join typedefs")
43384375
{
43394376
for EachIndex(idx, all_syms_count)
43404377
{
4341-
rdim_type_chunk_list_concat_in_place(&all_types__pre_typedefs, &p2r_shared->syms_typedefs[idx]);
4378+
rdim_type_chunk_list_concat_in_place(&all_types__pre_typedefs, &syms_typedefs[idx]);
43424379
}
4343-
p2r_shared->all_types = all_types__pre_typedefs;
4380+
*all_types = all_types__pre_typedefs;
43444381
}
43454382
}
43464383
lane_sync();
4347-
RDIM_LocationChunkList all_locations = p2r_shared->all_locations;
4348-
RDIM_SymbolChunkList all_procedures = p2r_shared->all_procedures;
4349-
RDIM_SymbolChunkList all_global_variables = p2r_shared->all_global_variables;
4350-
RDIM_SymbolChunkList all_thread_variables = p2r_shared->all_thread_variables;
4351-
RDIM_SymbolChunkList all_constants = p2r_shared->all_constants;
4352-
RDIM_ScopeChunkList all_scopes = p2r_shared->all_scopes;
4353-
RDIM_InlineSiteChunkList all_inline_sites = p2r_shared->all_inline_sites;
4354-
RDIM_TypeChunkList all_types = p2r_shared->all_types;
43554384

43564385
//////////////////////////////////////////////////////////////
43574386
//- rjf: bundle all outputs
@@ -4395,17 +4424,17 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
43954424
result.top_level_info = top_level_info;
43964425
result.binary_sections = binary_sections;
43974426
result.units = all_units;
4398-
result.types = all_types;
4427+
result.types = *all_types;
43994428
result.udts = all_udts;
44004429
result.src_files = all_src_files;
44014430
result.line_tables = all_line_tables;
4402-
result.locations = all_locations;
4403-
result.global_variables = all_global_variables;
4404-
result.thread_variables = all_thread_variables;
4405-
result.constants = all_constants;
4406-
result.procedures = all_procedures;
4407-
result.scopes = all_scopes;
4408-
result.inline_sites = all_inline_sites;
4431+
result.locations = *all_locations;
4432+
result.global_variables = *all_global_variables;
4433+
result.thread_variables = *all_thread_variables;
4434+
result.constants = *all_constants;
4435+
result.procedures = *all_procedures;
4436+
result.scopes = *all_scopes;
4437+
result.inline_sites = *all_inline_sites;
44094438
}
44104439

44114440
scratch_end(scratch);

src/rdi_from_pdb/rdi_from_pdb.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,6 @@ struct P2R_TypeIdChain
8787
CV_TypeId itype;
8888
};
8989

90-
//- rjf: main state bundle
91-
92-
typedef struct P2R_Shared P2R_Shared;
93-
struct P2R_Shared
94-
{
95-
RDIM_UDTChunkList *lanes_udts;
96-
97-
RDIM_UDTChunkList all_udts;
98-
99-
RDIM_LocationChunkList *syms_locations;
100-
RDIM_SymbolChunkList *syms_procedures;
101-
RDIM_SymbolChunkList *syms_global_variables;
102-
RDIM_SymbolChunkList *syms_thread_variables;
103-
RDIM_SymbolChunkList *syms_constants;
104-
RDIM_ScopeChunkList *syms_scopes;
105-
RDIM_InlineSiteChunkList *syms_inline_sites;
106-
RDIM_TypeChunkList *syms_typedefs;
107-
108-
RDIM_LocationChunkList all_locations;
109-
RDIM_SymbolChunkList all_procedures;
110-
RDIM_SymbolChunkList all_global_variables;
111-
RDIM_SymbolChunkList all_thread_variables;
112-
RDIM_SymbolChunkList all_constants;
113-
RDIM_ScopeChunkList all_scopes;
114-
RDIM_InlineSiteChunkList all_inline_sites;
115-
RDIM_TypeChunkList all_types;
116-
};
117-
11890
////////////////////////////////
11991
//~ rjf: Basic Helpers
12092

0 commit comments

Comments
 (0)