@@ -210,9 +210,9 @@ void writeToFile(const std::string &Filename, const std::string &Content) {
210
210
OS.close ();
211
211
}
212
212
213
- // Describes scope covered by each entry in the module-kernel map populated by
214
- // the collectKernelModuleMap function.
215
- enum KernelMapEntryScope {
213
+ // Describes scope covered by each entry in the module-entry points map
214
+ // populated by the collectEntryPointToModuleMap function.
215
+ enum EntryPointsSplitScope {
216
216
Scope_PerKernel, // one entry per kernel
217
217
Scope_PerModule, // one entry per module
218
218
Scope_Global // single entry in the map for all kernels
@@ -245,7 +245,7 @@ bool hasIndirectFunctionCalls(const Module &M) {
245
245
return false ;
246
246
}
247
247
248
- KernelMapEntryScope selectDeviceCodeSplitScope (const Module &M) {
248
+ EntryPointsSplitScope selectDeviceCodeSplitScope (const Module &M) {
249
249
bool DoSplit = SplitMode.getNumOccurrences () > 0 ;
250
250
if (DoSplit) {
251
251
switch (SplitMode) {
@@ -288,7 +288,7 @@ bool isSpirvSyclBuiltin(StringRef FName) {
288
288
}
289
289
290
290
bool isEntryPoint (const Function &F) {
291
- // Skip declarations, if any: they should not be included into KernelModuleMap
291
+ // Skip declarations, if any: they should not be included into EntryPointsMap
292
292
// or otherwise we will end up with incorrectly generated list of symbols.
293
293
if (F.isDeclaration ())
294
294
return false ;
@@ -311,12 +311,12 @@ bool isEntryPoint(const Function &F) {
311
311
// This function decides how entry points of the input module M will be
312
312
// distributed ("split") into multiple modules based on the command options and
313
313
// IR attributes. The decision is recorded in the output map parameter
314
- // ResKernelModuleMap which maps some key to a group of entry points. Each such
314
+ // EntryPointsSplitMap which maps some key to a group of entry points. Each such
315
315
// group along with IR it depends on (globals, functions from its call graph,
316
316
// ...) will constitute a separate module.
317
317
void collectEntryPointToModuleMap (const Module &M,
318
- EntryPointsMap &ResKernelModuleMap ,
319
- KernelMapEntryScope EntryScope) {
318
+ EntryPointsMap &EntryPointsSplitMap ,
319
+ EntryPointsSplitScope EntryScope) {
320
320
321
321
// Only process module entry points:
322
322
for (const auto &F : M.functions ()) {
@@ -325,7 +325,7 @@ void collectEntryPointToModuleMap(const Module &M,
325
325
326
326
switch (EntryScope) {
327
327
case Scope_PerKernel:
328
- ResKernelModuleMap [F.getName ()].push_back (&F);
328
+ EntryPointsSplitMap [F.getName ()].push_back (&F);
329
329
break ;
330
330
case Scope_PerModule: {
331
331
if (!F.hasFnAttribute (ATTR_SYCL_MODULE_ID))
@@ -338,12 +338,12 @@ void collectEntryPointToModuleMap(const Module &M,
338
338
339
339
Attribute Id = F.getFnAttribute (ATTR_SYCL_MODULE_ID);
340
340
StringRef Val = Id.getValueAsString ();
341
- ResKernelModuleMap [Val].push_back (&F);
341
+ EntryPointsSplitMap [Val].push_back (&F);
342
342
break ;
343
343
}
344
344
case Scope_Global:
345
345
// the map key is not significant here
346
- ResKernelModuleMap [GLOBAL_SCOPE_NAME].push_back (&F);
346
+ EntryPointsSplitMap [GLOBAL_SCOPE_NAME].push_back (&F);
347
347
break ;
348
348
}
349
349
}
@@ -487,15 +487,15 @@ std::vector<uint32_t> getKernelReqdWorkGroupSizeMetadata(const Function &Func) {
487
487
return {X, Y, Z};
488
488
}
489
489
490
- // Input parameter KernelModuleMap is a map containing groups of entry points
491
- // with same values of the sycl-module-id attribute. Return value is a vector
492
- // of entry points names lists. Each vector element is a string with entry point
493
- // names from the same module separated by \n.
490
+ // Input parameter EntryPointsSplitMap contains a map of entry points or groups
491
+ // of entry points with same values of the sycl-module-id attribute.
492
+ // Return value is a vector of entry points names lists. Each vector element is
493
+ // a string with entry point names from the same module separated by \n.
494
494
// The function saves names of entry points from one group to a single
495
495
// std::string and stores this string to the ResSymbolsLists vector.
496
- string_vector collectSymbolsLists (const EntryPointsMap &KernelModuleMap ) {
496
+ string_vector collectSymbolsLists (const EntryPointsMap &EntryPointsSplitMap ) {
497
497
string_vector ResSymbolsLists{};
498
- for (const auto &It : KernelModuleMap ) {
498
+ for (const auto &It : EntryPointsSplitMap ) {
499
499
std::string SymbolsList;
500
500
for (const auto &F : It.second ) {
501
501
SymbolsList =
@@ -507,21 +507,21 @@ string_vector collectSymbolsLists(const EntryPointsMap &KernelModuleMap) {
507
507
}
508
508
509
509
struct ResultModule {
510
- StringRef KernelModuleName ;
510
+ StringRef SplitModuleId ;
511
511
std::unique_ptr<Module> ModulePtr;
512
512
};
513
513
514
- // Input parameter KernelModuleMap is a map containing groups of entry points
515
- // with same values of the sycl-module-id attribute. For each group of entry
516
- // points a separate IR module will be produced.
517
- // ResModules is a vector of pairs of kernel module names and produced modules.
518
- // The function splits input LLVM IR module M into smaller ones and stores them
519
- // to the ResModules vector.
520
- std::vector<ResultModule> splitModule ( const Module &M,
521
- const EntryPointsMap &KernelModuleMap ) {
514
+ // Input parameter EntryPointsSplitMap contains a map of entry points or groups
515
+ // of entry points with same values of the sycl-module-id attribute.
516
+ // For each group of entry points a separate IR module will be produced.
517
+ // ResModules is a vector of pairs of split module identifiers and produced
518
+ // modules. The function splits input LLVM IR module M into smaller ones and
519
+ // stores them to the ResModules vector.
520
+ std::vector<ResultModule>
521
+ splitModule ( const Module &M, const EntryPointsMap &EntryPointsSplitMap ) {
522
522
std::vector<ResultModule> ResModules{};
523
523
524
- for (const auto &It : KernelModuleMap ) {
524
+ for (const auto &It : EntryPointsSplitMap ) {
525
525
// For each group of entry points collect all dependencies.
526
526
SetVector<const GlobalValue *> GVs;
527
527
std::vector<const Function *> Workqueue;
@@ -617,7 +617,7 @@ string_vector saveResultModules(const std::vector<ResultModule> &ResModules,
617
617
618
618
string_vector
619
619
saveDeviceImageProperty (const std::vector<ResultModule> &ResultModules,
620
- const EntryPointsMap &KernelModuleMap ,
620
+ const EntryPointsMap &EntryPointsSplitMap ,
621
621
const ImagePropSaveInfo &ImgPSInfo) {
622
622
using PropSetRegTy = llvm::util::PropertySetRegistry;
623
623
@@ -682,8 +682,8 @@ saveDeviceImageProperty(const std::vector<ResultModule> &ResultModules,
682
682
if (ImgPSInfo.EmitExportedSymbols ) {
683
683
// For each result module, extract the exported functions
684
684
auto ModuleFunctionsIt =
685
- KernelModuleMap .find (ResultModules[I].KernelModuleName );
686
- if (ModuleFunctionsIt != KernelModuleMap .end ()) {
685
+ EntryPointsSplitMap .find (ResultModules[I].SplitModuleId );
686
+ if (ModuleFunctionsIt != EntryPointsSplitMap .end ()) {
687
687
for (const auto &F : ModuleFunctionsIt->second ) {
688
688
if (F->getCallingConv () == CallingConv::SPIR_FUNC) {
689
689
PropSet[PropSetRegTy::SYCL_EXPORTED_SYMBOLS].insert (
@@ -812,7 +812,7 @@ TableFiles processOneModule(std::unique_ptr<Module> M, bool IsEsimd,
812
812
bool DoSplit = SplitMode.getNumOccurrences () > 0 ;
813
813
814
814
if (DoSplit || DoSymGen) {
815
- KernelMapEntryScope Scope = selectDeviceCodeSplitScope (*M);
815
+ EntryPointsSplitScope Scope = selectDeviceCodeSplitScope (*M);
816
816
collectEntryPointToModuleMap (*M, GlobalsSet, Scope);
817
817
}
818
818
@@ -920,13 +920,14 @@ ModulePair splitSyclEsimd(std::unique_ptr<Module> M) {
920
920
if (SyclFunctions.empty ())
921
921
return std::make_pair (std::unique_ptr<Module>(nullptr ), std::move (M));
922
922
923
- // Key values in KernelModuleMap are not significant, but they define the
924
- // order, in which entry points are processed in the splitModule function. The
925
- // caller of the splitSyclEsimd function expects a pair of 1-Sycl and 2-Esimd
926
- // modules, hence the strings names below.
927
- EntryPointsMap KernelModuleMap (
923
+ // Key values in SyclEsimdEntryPointsMap are not significant, but they define
924
+ // the order, in which entry points are processed in the splitModule function.
925
+ // The caller of the splitSyclEsimd function expects a pair of 1-Sycl and
926
+ // 2-Esimd modules, hence the strings names below.
927
+ EntryPointsMap SyclEsimdEntryPointsMap (
928
928
{{" 1-SYCL" , SyclFunctions}, {" 2-ESIMD" , EsimdFunctions}});
929
- std::vector<ResultModule> ResultModules = splitModule (*M, KernelModuleMap);
929
+ std::vector<ResultModule> ResultModules =
930
+ splitModule (*M, SyclEsimdEntryPointsMap);
930
931
assert (ResultModules.size () == 2 );
931
932
return std::make_pair (std::move (ResultModules[0 ].ModulePtr ),
932
933
std::move (ResultModules[1 ].ModulePtr ));
0 commit comments