Skip to content

Commit 0ffbf4b

Browse files
authored
[SYCL][NFC] Code clean up revealed by compiler self build. (#2801)
The effort of compiler self build has revealed a number of errors that can be cleaned. This is an effort to improve the code and reduce the errors.
1 parent ccd19d5 commit 0ffbf4b

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

sycl/source/detail/os_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ std::string OSUtil::getDirName(const char* Path) {
170170
std::string Tmp(Path);
171171
// dirname(3) needs a writable C string: a null-terminator is written where a
172172
// path should split.
173-
size_t TruncatedSize = strlen(dirname(const_cast<char*>(Tmp.c_str())));
173+
size_t TruncatedSize = strlen(dirname(const_cast<char *>(Tmp.c_str())));
174174
Tmp.resize(TruncatedSize);
175175
return Tmp;
176176
}
@@ -196,7 +196,7 @@ std::string OSUtil::getCurrentDSODir() {
196196
char Path[MAX_PATH];
197197
Path[0] = '\0';
198198
Path[sizeof(Path) - 1] = '\0';
199-
auto Handle = getOSModuleHandle(&getCurrentDSODir);
199+
auto Handle = getOSModuleHandle(reinterpret_cast<void *>(&getCurrentDSODir));
200200
DWORD Ret = GetModuleFileNameA(
201201
reinterpret_cast<HMODULE>(OSUtil::ExeModuleHandle == Handle ? 0 : Handle),
202202
reinterpret_cast<LPSTR>(&Path), sizeof(Path));

sycl/source/detail/pi.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,9 @@ static void initializePlugins(vector_class<plugin> *Plugins) {
303303
std::cerr << "SYCL_PI_TRACE[all]: "
304304
<< "No Plugins Found." << std::endl;
305305

306-
PiPlugin PluginInformation{_PI_H_VERSION_STRING, _PI_H_VERSION_STRING,
307-
nullptr};
306+
PiPlugin PluginInformation{
307+
_PI_H_VERSION_STRING, _PI_H_VERSION_STRING, nullptr, {}};
308+
PluginInformation.PiFunctionTable = {};
308309

309310
for (unsigned int I = 0; I < PluginNames.size(); I++) {
310311
void *Library = loadPlugin(PluginNames[I].first);

sycl/source/detail/platform_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ platform_impl::get_devices(info::device_type DeviceType) const {
337337
PlatformImplPtr PlatformImpl = getOrMakePlatformImpl(MPlatform, *MPlugin);
338338
std::transform(
339339
PiDevices.begin(), PiDevices.end(), std::back_inserter(Res),
340-
[this, PlatformImpl](const RT::PiDevice &PiDevice) -> device {
340+
[PlatformImpl](const RT::PiDevice &PiDevice) -> device {
341341
return detail::createSyclObjFromImpl<device>(
342342
PlatformImpl->getOrMakeDeviceImpl(PiDevice, PlatformImpl));
343343
});

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ std::pair<RT::PiKernel, std::mutex *> ProgramManager::getOrCreateKernel(
441441
[&Program](const Locked<KernelCacheT> &LockedCache) -> KernelByNameT & {
442442
return LockedCache.get()[Program];
443443
};
444-
auto BuildF = [this, &Program, &KernelName, &Ctx] {
444+
auto BuildF = [&Program, &KernelName, &Ctx] {
445445
PiKernelT *Result = nullptr;
446446

447447
// TODO need some user-friendly error/exception

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,10 @@ Scheduler::GraphBuilder::findDepsForReq(MemObjRecord *Record,
508508
std::vector<Command *> Visited;
509509
const bool ReadOnlyReq = Req->MAccessMode == access::mode::read;
510510

511-
std::vector<Command *> ToAnalyze{std::move(Record->MWriteLeaves.toVector())};
511+
std::vector<Command *> ToAnalyze{Record->MWriteLeaves.toVector()};
512512

513513
if (!ReadOnlyReq) {
514-
std::vector<Command *> V{std::move(Record->MReadLeaves.toVector())};
514+
std::vector<Command *> V{Record->MReadLeaves.toVector()};
515515

516516
ToAnalyze.insert(ToAnalyze.begin(), V.begin(), V.end());
517517
}
@@ -964,8 +964,7 @@ void Scheduler::GraphBuilder::cleanupCommandsForRecord(
964964
// Collect stream objects for a visited command.
965965
if (Cmd->getType() == Command::CommandType::RUN_CG) {
966966
auto ExecCmd = static_cast<ExecCGCommand *>(Cmd);
967-
std::vector<std::shared_ptr<stream_impl>> Streams =
968-
std::move(ExecCmd->getStreams());
967+
std::vector<std::shared_ptr<stream_impl>> Streams = ExecCmd->getStreams();
969968
ExecCmd->clearStreams();
970969
StreamsToDeallocate.insert(StreamsToDeallocate.end(), Streams.begin(),
971970
Streams.end());
@@ -1026,8 +1025,7 @@ void Scheduler::GraphBuilder::cleanupFinishedCommands(
10261025
// Collect stream objects for a visited command.
10271026
if (Cmd->getType() == Command::CommandType::RUN_CG) {
10281027
auto ExecCmd = static_cast<ExecCGCommand *>(Cmd);
1029-
std::vector<std::shared_ptr<stream_impl>> Streams =
1030-
std::move(ExecCmd->getStreams());
1028+
std::vector<std::shared_ptr<stream_impl>> Streams = ExecCmd->getStreams();
10311029
ExecCmd->clearStreams();
10321030
StreamsToDeallocate.insert(StreamsToDeallocate.end(), Streams.begin(),
10331031
Streams.end());

sycl/source/detail/windows_pi.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ void *loadOsLibrary(const std::string &PluginPath) {
2222
}
2323

2424
void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName) {
25-
return GetProcAddress((HMODULE)Library, FunctionName.c_str());
25+
return reinterpret_cast<void *>(
26+
GetProcAddress((HMODULE)Library, FunctionName.c_str()));
2627
}
2728

2829
} // namespace pi

xpti/src/xpti_proxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class ProxyLoader {
113113

114114
void *functionByIndex(int index) {
115115
if (index >= XPTI_INITIALIZE && index < XPTI_FW_API_COUNT) {
116-
return m_dispatch_table[index];
116+
return reinterpret_cast<void *>(m_dispatch_table[index]);
117117
}
118118
return nullptr;
119119
}

0 commit comments

Comments
 (0)