Skip to content

Commit 9072d49

Browse files
authored
[SYCL][NFC] Format program_manager.cpp (#1788)
Signed-off-by: gejin <[email protected]>
1 parent 0ae9729 commit 9072d49

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,15 @@ static RT::PiProgram createBinaryProgram(const ContextImplPtr Context,
9292
if (Backend == backend::cuda) {
9393
// TODO: Reemplace CreateWithSource with CreateWithBinary in CUDA backend
9494
const char *SignedData = reinterpret_cast<const char *>(Data);
95-
Plugin.call<PiApiKind::piclProgramCreateWithSource>(Context->getHandleRef(), 1 /*one binary*/, &SignedData,
96-
&DataLen, &Program);
95+
Plugin.call<PiApiKind::piclProgramCreateWithSource>(
96+
Context->getHandleRef(), 1 /*one binary*/, &SignedData, &DataLen,
97+
&Program);
9798
} else {
9899
RT::PiDevice Device = getFirstDevice(Context);
99100
pi_int32 BinaryStatus = CL_SUCCESS;
100-
Plugin.call<PiApiKind::piclProgramCreateWithBinary>(Context->getHandleRef(), 1 /*one binary*/, &Device,
101-
&DataLen, &Data, &BinaryStatus,
102-
&Program);
101+
Plugin.call<PiApiKind::piclProgramCreateWithBinary>(
102+
Context->getHandleRef(), 1 /*one binary*/, &Device, &DataLen, &Data,
103+
&BinaryStatus, &Program);
103104
}
104105

105106
return Program;
@@ -189,7 +190,7 @@ RetT *getOrBuild(KernelProgramCache &KPCache, KeyT &&CacheKey,
189190
RetT *Result = waitUntilBuilt<ExceptionT>(KPCache, BuildResult);
190191

191192
if (Result)
192-
return Result;
193+
return Result;
193194

194195
// Previous build is failed. There was no SYCL exception though.
195196
// We might try to build once more.
@@ -360,7 +361,7 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(OSModuleHandle M,
360361
auto AcquireF = [](KernelProgramCache &Cache) {
361362
return Cache.acquireCachedPrograms();
362363
};
363-
auto GetF = [](const Locked<ProgramCacheT> &LockedCache) -> ProgramCacheT& {
364+
auto GetF = [](const Locked<ProgramCacheT> &LockedCache) -> ProgramCacheT & {
364365
return LockedCache.get();
365366
};
366367
auto BuildF = [this, &M, &KSId, &Context, Prg] {
@@ -381,9 +382,10 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(OSModuleHandle M,
381382

382383
const std::vector<device> &Devices = ContextImpl->getDevices();
383384
std::vector<RT::PiDevice> PiDevices(Devices.size());
384-
std::transform(
385-
Devices.begin(), Devices.end(), PiDevices.begin(),
386-
[](const device Dev) { return getRawSyclObjImpl(Dev)->getHandleRef(); });
385+
std::transform(Devices.begin(), Devices.end(), PiDevices.begin(),
386+
[](const device Dev) {
387+
return getRawSyclObjImpl(Dev)->getHandleRef();
388+
});
387389

388390
ProgramPtr BuiltProgram =
389391
build(std::move(ProgramManaged), ContextImpl, Img.getCompileOptions(),
@@ -420,10 +422,11 @@ RT::PiKernel ProgramManager::getOrCreateKernel(OSModuleHandle M,
420422

421423
KernelProgramCache &Cache = Ctx->getKernelProgramCache();
422424

423-
auto AcquireF = [] (KernelProgramCache &Cache) {
425+
auto AcquireF = [](KernelProgramCache &Cache) {
424426
return Cache.acquireKernelsPerProgramCache();
425427
};
426-
auto GetF = [&Program] (const Locked<KernelCacheT> &LockedCache) -> KernelByNameT& {
428+
auto GetF =
429+
[&Program](const Locked<KernelCacheT> &LockedCache) -> KernelByNameT & {
427430
return LockedCache.get()[Program];
428431
};
429432
auto BuildF = [this, &Program, &KernelName, &Ctx] {
@@ -438,8 +441,8 @@ RT::PiKernel ProgramManager::getOrCreateKernel(OSModuleHandle M,
438441
return Result;
439442
};
440443

441-
return getOrBuild<PiKernelT, invalid_object_error>(
442-
Cache, KernelName, AcquireF, GetF, BuildF);
444+
return getOrBuild<PiKernelT, invalid_object_error>(Cache, KernelName,
445+
AcquireF, GetF, BuildF);
443446
}
444447

445448
RT::PiProgram
@@ -506,7 +509,7 @@ static bool loadDeviceLib(const ContextImplPtr Context, const char *Name,
506509
return Prog != nullptr;
507510
}
508511

509-
static const char* getDeviceLibFilename(DeviceLibExt Extension) {
512+
static const char *getDeviceLibFilename(DeviceLibExt Extension) {
510513
switch (Extension) {
511514
case cl_intel_devicelib_assert:
512515
return "libsycl-fallback-cassert.spv";
@@ -523,7 +526,7 @@ static const char* getDeviceLibFilename(DeviceLibExt Extension) {
523526
PI_INVALID_OPERATION);
524527
}
525528

526-
static const char* getDeviceLibExtensionStr(DeviceLibExt Extension) {
529+
static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) {
527530
switch (Extension) {
528531
case cl_intel_devicelib_assert:
529532
return "cl_intel_devicelib_assert";
@@ -673,18 +676,17 @@ getDeviceLibPrograms(const ContextImplPtr Context,
673676
{cl_intel_devicelib_math, false},
674677
{cl_intel_devicelib_math_fp64, false},
675678
{cl_intel_devicelib_complex, false},
676-
{cl_intel_devicelib_complex_fp64, false}
677-
};
679+
{cl_intel_devicelib_complex_fp64, false}};
678680

679681
// Disable all devicelib extensions requiring fp64 support if at least
680682
// one underlying device doesn't support cl_khr_fp64.
681683
bool fp64Support = true;
682684
for (RT::PiDevice Dev : Devices) {
683685
std::string DevExtList =
684-
get_device_info<std::string, info::device::extensions>::get(
686+
get_device_info<std::string, info::device::extensions>::get(
685687
Dev, Context->getPlugin());
686-
fp64Support = fp64Support &&
687-
(DevExtList.npos != DevExtList.find("cl_khr_fp64"));
688+
fp64Support =
689+
fp64Support && (DevExtList.npos != DevExtList.find("cl_khr_fp64"));
688690
}
689691

690692
// Load a fallback library for an extension if at least one device does not
@@ -702,11 +704,12 @@ getDeviceLibPrograms(const ContextImplPtr Context,
702704
}
703705

704706
if ((Ext == cl_intel_devicelib_math_fp64 ||
705-
Ext == cl_intel_devicelib_complex_fp64) && !fp64Support) {
707+
Ext == cl_intel_devicelib_complex_fp64) &&
708+
!fp64Support) {
706709
continue;
707710
}
708711

709-
const char* ExtStr = getDeviceLibExtensionStr(Ext);
712+
const char *ExtStr = getDeviceLibExtensionStr(Ext);
710713

711714
bool InhibitNativeImpl = false;
712715
if (const char *Env = getenv("SYCL_DEVICELIB_INHIBIT_NATIVE")) {
@@ -823,8 +826,7 @@ void ProgramManager::addImages(pi_device_binaries DeviceBinary) {
823826
KernelSetId KSId = getNextKernelSetId();
824827
for (_pi_offload_entry EntriesIt = EntriesB; EntriesIt != EntriesE;
825828
++EntriesIt) {
826-
auto Result =
827-
KSIdMap.insert(std::make_pair(EntriesIt->name, KSId));
829+
auto Result = KSIdMap.insert(std::make_pair(EntriesIt->name, KSId));
828830
(void)Result;
829831
assert(Result.second && "Kernel sets are not disjoint");
830832
}

0 commit comments

Comments
 (0)