Skip to content

Commit f102408

Browse files
[NFC][SYCL] A few clang-tidy inspired changes (#18302)
Co-authored-by: Marcos Maronas <marcos.maronas@intel.com>
1 parent 087d620 commit f102408

File tree

4 files changed

+23
-28
lines changed

4 files changed

+23
-28
lines changed

sycl/source/detail/common.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ static thread_local detail::code_location GCodeLocTLS = {};
2323
/// @brief Default constructor to use in lower levels of the calling stack to
2424
/// check and see if code location object is available. If not, continue with
2525
/// instrumentation as needed
26-
tls_code_loc_t::tls_code_loc_t() {
27-
// Check TLS to see if a previously stashed code_location object is
28-
// available; if so, we are in a local scope.
29-
MLocalScope = GCodeLocTLS.fileName() && GCodeLocTLS.functionName();
30-
}
26+
tls_code_loc_t::tls_code_loc_t()
27+
: // Check TLS to see if a previously stashed code_location object is
28+
// available; if so, we are in a local scope.
29+
MLocalScope(GCodeLocTLS.fileName() && GCodeLocTLS.functionName()) {}
3130

3231
ur_code_location_t codeLocationCallback(void *) {
3332
ur_code_location_t codeloc;
@@ -44,12 +43,11 @@ ur_code_location_t codeLocationCallback(void *) {
4443
/// application code. In this case, we still check to see if another code
4544
/// location has been stashed in the TLS at a higher level. If not, we have the
4645
/// code location information that must be active for the current calling scope.
47-
tls_code_loc_t::tls_code_loc_t(const detail::code_location &CodeLoc) {
48-
// Check TLS to see if a previously stashed code_location object is
49-
// available; if so, then don't overwrite the previous information as we
50-
// are still in scope of the instrumented function
51-
MLocalScope = GCodeLocTLS.fileName() && GCodeLocTLS.functionName();
52-
46+
tls_code_loc_t::tls_code_loc_t(const detail::code_location &CodeLoc)
47+
: // Check TLS to see if a previously stashed code_location object is
48+
// available; if so, then don't overwrite the previous information as we
49+
// are still in scope of the instrumented function.
50+
MLocalScope(GCodeLocTLS.fileName() && GCodeLocTLS.functionName()) {
5351
if (!MLocalScope)
5452
// Update the TLS information with the code_location information
5553
GCodeLocTLS = CodeLoc;

sycl/source/detail/jit_device_binaries.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void DeviceBinaryContainer::setCompileOptions(std::string_view CompileOpts) {
104104
sycl_device_binary_struct DeviceBinaryContainer::getPIDeviceBinary(
105105
const unsigned char *BinaryStart, size_t BinarySize, const char *TargetSpec,
106106
sycl_device_binary_type Format) {
107-
sycl_device_binary_struct DeviceBinary;
107+
sycl_device_binary_struct DeviceBinary{};
108108
DeviceBinary.Version = SYCL_DEVICE_BINARY_VERSION;
109109
DeviceBinary.Kind = SYCL_DEVICE_BINARY_OFFLOAD_KIND_SYCL;
110110
DeviceBinary.Format = Format;

sycl/source/detail/queue_impl.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -466,22 +466,21 @@ class queue_impl {
466466
}
467467
CreationFlags |= UR_QUEUE_FLAG_PRIORITY_HIGH;
468468
}
469-
// Track that submission modes do not conflict.
470-
bool SubmissionSeen = false;
471-
if (PropList.has_property<
472-
ext::intel::property::queue::no_immediate_command_list>()) {
473-
SubmissionSeen = true;
474-
CreationFlags |= UR_QUEUE_FLAG_SUBMISSION_BATCHED;
475-
}
476-
if (PropList.has_property<
477-
ext::intel::property::queue::immediate_command_list>()) {
478-
if (SubmissionSeen) {
469+
{
470+
// Track that submission modes do not conflict.
471+
bool no_imm_cmdlist = PropList.has_property<
472+
ext::intel::property::queue::no_immediate_command_list>();
473+
bool imm_cmdlist = PropList.has_property<
474+
ext::intel::property::queue::immediate_command_list>();
475+
if (no_imm_cmdlist && imm_cmdlist) {
479476
throw sycl::exception(
480477
make_error_code(errc::invalid),
481-
"Queue cannot be constructed with different submission modes.");
478+
"Queue cannot be constructed with conflicting submission modes.");
482479
}
483-
SubmissionSeen = true;
484-
CreationFlags |= UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE;
480+
if (no_imm_cmdlist)
481+
CreationFlags |= UR_QUEUE_FLAG_SUBMISSION_BATCHED;
482+
if (imm_cmdlist)
483+
CreationFlags |= UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE;
485484
}
486485
return CreationFlags;
487486
}

sycl/source/detail/scheduler/commands.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,25 +1992,23 @@ void instrumentationAddExtraKernelMetadata(
19921992
auto FilterArgs = [&Args](detail::ArgDesc &Arg, int NextTrueIndex) {
19931993
Args.push_back({Arg.MType, Arg.MPtr, Arg.MSize, NextTrueIndex});
19941994
};
1995-
ur_program_handle_t Program = nullptr;
19961995
ur_kernel_handle_t Kernel = nullptr;
19971996
std::mutex *KernelMutex = nullptr;
19981997
const KernelArgMask *EliminatedArgMask = nullptr;
19991998

20001999
if (nullptr != SyclKernel) {
2001-
Program = SyclKernel->getProgramRef();
20022000
if (!SyclKernel->isCreatedFromSource())
20032001
EliminatedArgMask = SyclKernel->getKernelArgMask();
20042002
} else if (auto SyclKernelImpl =
20052003
KernelBundleImplPtr ? KernelBundleImplPtr->tryGetKernel(
20062004
KernelName, KernelBundleImplPtr)
20072005
: std::shared_ptr<kernel_impl>{nullptr}) {
20082006
EliminatedArgMask = SyclKernelImpl->getKernelArgMask();
2009-
Program = SyclKernelImpl->getDeviceImage()->get_ur_program_ref();
20102007
} else if (Queue) {
20112008
// NOTE: Queue can be null when kernel is directly enqueued to a command
20122009
// buffer
20132010
// by graph API, when a modifiable graph is finalized.
2011+
ur_program_handle_t Program = nullptr;
20142012
std::tie(Kernel, KernelMutex, EliminatedArgMask, Program) =
20152013
detail::ProgramManager::getInstance().getOrCreateKernel(
20162014
Queue->getContextImplPtr(), Queue->getDeviceImpl(), KernelName);

0 commit comments

Comments
 (0)