Skip to content

Commit

Permalink
[SYCL][NFC] Fix formatting after handler member changes (#14597)
Browse files Browse the repository at this point in the history
intel/llvm#14460 appears to have introduced
clang formatting violations, despite pre-commit not reporting these.
This commit makes the formatting changes that should have been part of
that patch.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
  • Loading branch information
steffenlarsen authored Jul 18, 2024
1 parent 7a9d3b1 commit 0b60f43
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 77 deletions.
2 changes: 1 addition & 1 deletion sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ class __SYCL_EXPORT handler {
processProperties<NameT, PropertiesT>(Props);
StoreLambda<NameT, KernelType, Dims, TransformedArgType>(
std::move(KernelFunc));
setType(detail::CGType::Kernel);
setType(detail::CGType::Kernel);
setNDRangeUsed(true);
#endif
}
Expand Down
36 changes: 19 additions & 17 deletions sycl/source/detail/cg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class NDRDescT {
}
}

template <int Dims>
static sycl::range<3> padRange(sycl::range<Dims> Range) {
template <int Dims> static sycl::range<3> padRange(sycl::range<Dims> Range) {
if constexpr (Dims == 3) {
return Range;
} else {
Expand Down Expand Up @@ -108,21 +107,23 @@ class NDRDescT {
setNDRangeLeftover();
}

NDRDescT(sycl::range<3> NumWorkItems, sycl::id<3> Offset, int DimsArg)
NDRDescT(sycl::range<3> NumWorkItems, sycl::id<3> Offset, int DimsArg)
: GlobalSize{NumWorkItems}, GlobalOffset{Offset}, Dims{size_t(DimsArg)} {}

NDRDescT(sycl::range<3> NumWorkItems, sycl::range<3> LocalSize,
sycl::id<3> Offset, int DimsArg)
: GlobalSize{NumWorkItems}, LocalSize{LocalSize}, GlobalOffset{Offset},
Dims{size_t(DimsArg)} {
setNDRangeLeftover();}
setNDRangeLeftover();
}

template <int Dims_>
NDRDescT(sycl::nd_range<Dims_> ExecutionRange, int DimsArg)
: NDRDescT(padRange(ExecutionRange.get_global_range()),
padRange(ExecutionRange.get_local_range()),
padId(ExecutionRange.get_offset()), size_t(DimsArg)) {
setNDRangeLeftover();}
setNDRangeLeftover();
}

template <int Dims_>
NDRDescT(sycl::nd_range<Dims_> ExecutionRange)
Expand Down Expand Up @@ -360,8 +361,8 @@ class CGCopyUSM : public CG {
public:
CGCopyUSM(void *Src, void *Dst, size_t Length, CG::StorageInitHelper CGData,
detail::code_location loc = {})
: CG(CGType::CopyUSM, std::move(CGData), std::move(loc)), MSrc(Src), MDst(Dst),
MLength(Length) {}
: CG(CGType::CopyUSM, std::move(CGData), std::move(loc)), MSrc(Src),
MDst(Dst), MLength(Length) {}

void *getSrc() { return MSrc; }
void *getDst() { return MDst; }
Expand Down Expand Up @@ -392,8 +393,8 @@ class CGPrefetchUSM : public CG {
public:
CGPrefetchUSM(void *DstPtr, size_t Length, CG::StorageInitHelper CGData,
detail::code_location loc = {})
: CG(CGType::PrefetchUSM, std::move(CGData), std::move(loc)), MDst(DstPtr),
MLength(Length) {}
: CG(CGType::PrefetchUSM, std::move(CGData), std::move(loc)),
MDst(DstPtr), MLength(Length) {}
void *getDst() { return MDst; }
size_t getLength() { return MLength; }
};
Expand Down Expand Up @@ -445,8 +446,8 @@ class CGCopy2DUSM : public CG {
CGCopy2DUSM(void *Src, void *Dst, size_t SrcPitch, size_t DstPitch,
size_t Width, size_t Height, CG::StorageInitHelper CGData,
detail::code_location loc = {})
: CG(CGType::Copy2DUSM, std::move(CGData), std::move(loc)), MSrc(Src), MDst(Dst),
MSrcPitch(SrcPitch), MDstPitch(DstPitch), MWidth(Width),
: CG(CGType::Copy2DUSM, std::move(CGData), std::move(loc)), MSrc(Src),
MDst(Dst), MSrcPitch(SrcPitch), MDstPitch(DstPitch), MWidth(Width),
MHeight(Height) {}

void *getSrc() const { return MSrc; }
Expand Down Expand Up @@ -491,8 +492,9 @@ class CGMemset2DUSM : public CG {
CGMemset2DUSM(char Value, void *DstPtr, size_t Pitch, size_t Width,
size_t Height, CG::StorageInitHelper CGData,
detail::code_location loc = {})
: CG(CGType::Memset2DUSM, std::move(CGData), std::move(loc)), MValue(Value),
MDst(DstPtr), MPitch(Pitch), MWidth(Width), MHeight(Height) {}
: CG(CGType::Memset2DUSM, std::move(CGData), std::move(loc)),
MValue(Value), MDst(DstPtr), MPitch(Pitch), MWidth(Width),
MHeight(Height) {}
void *getDst() const { return MDst; }
size_t getPitch() const { return MPitch; }
size_t getWidth() const { return MWidth; }
Expand Down Expand Up @@ -536,8 +538,8 @@ class CGCopyToDeviceGlobal : public CG {
bool IsDeviceImageScoped, size_t NumBytes, size_t Offset,
CG::StorageInitHelper CGData,
detail::code_location loc = {})
: CG(CGType::CopyToDeviceGlobal, std::move(CGData), std::move(loc)), MSrc(Src),
MDeviceGlobalPtr(DeviceGlobalPtr),
: CG(CGType::CopyToDeviceGlobal, std::move(CGData), std::move(loc)),
MSrc(Src), MDeviceGlobalPtr(DeviceGlobalPtr),
MIsDeviceImageScoped(IsDeviceImageScoped), MNumBytes(NumBytes),
MOffset(Offset) {}

Expand Down Expand Up @@ -593,8 +595,8 @@ class CGCopyImage : public CG {
sycl::detail::pi::PiImageRegion HostExtent,
sycl::detail::pi::PiImageRegion CopyExtent,
CG::StorageInitHelper CGData, detail::code_location loc = {})
: CG(CGType::CopyImage, std::move(CGData), std::move(loc)), MSrc(Src), MDst(Dst),
MImageDesc(ImageDesc), MImageFormat(ImageFormat),
: CG(CGType::CopyImage, std::move(CGData), std::move(loc)), MSrc(Src),
MDst(Dst), MImageDesc(ImageDesc), MImageFormat(ImageFormat),
MImageCopyFlags(ImageCopyFlags), MSrcOffset(SrcOffset),
MDstOffset(DstOffset), MHostExtent(HostExtent),
MCopyExtent(CopyExtent) {}
Expand Down
6 changes: 3 additions & 3 deletions sycl/source/detail/handler_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#pragma once

#include "sycl/handler.hpp"
#include <detail/kernel_bundle_impl.hpp>
#include <detail/cg.hpp>
#include <detail/kernel_bundle_impl.hpp>
#include <memory>
#include <sycl/ext/oneapi/experimental/graph.hpp>

Expand Down Expand Up @@ -155,7 +155,7 @@ class handler_impl {
// Track whether an NDRange was used when submitting a kernel (as opposed to a
// range), needed for graph update
bool MNDRangeUsed = false;

/// The storage for the arguments passed.
/// We need to store a copy of values that are passed explicitly through
/// set_arg, require and so on, because we need them to be alive after
Expand Down Expand Up @@ -188,7 +188,7 @@ class handler_impl {
std::shared_ptr<ext::oneapi::experimental::detail::node_impl> MSubgraphNode;
/// Storage for the CG created when handling graph nodes added explicitly.
std::unique_ptr<detail::CG> MGraphNodeCG;

/// Storage for lambda/function when using HostTask
std::shared_ptr<detail::HostTask> MHostTask;
/// The list of valid SYCL events that need to complete
Expand Down
97 changes: 51 additions & 46 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include <detail/global_handler.hpp>
#include <detail/graph_impl.hpp>
#include <detail/handler_impl.hpp>
#include <detail/host_task.hpp>
#include <detail/image_impl.hpp>
#include <detail/kernel_bundle_impl.hpp>
#include <detail/kernel_impl.hpp>
#include <detail/queue_impl.hpp>
#include <detail/scheduler/commands.hpp>
#include <detail/scheduler/scheduler.hpp>
#include <detail/host_task.hpp>
#include <detail/usm/usm_impl.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/helpers.hpp>
Expand Down Expand Up @@ -90,8 +90,8 @@ handler::handler(std::shared_ptr<detail::queue_impl> Queue,
std::shared_ptr<detail::queue_impl> SecondaryQueue,
bool CallerNeedsEvent)
: impl(std::make_shared<detail::handler_impl>(std::move(PrimaryQueue),
std::move(SecondaryQueue),
CallerNeedsEvent)),
std::move(SecondaryQueue),
CallerNeedsEvent)),
MQueue(std::move(Queue)) {}

handler::handler(
Expand Down Expand Up @@ -123,7 +123,8 @@ bool handler::isStateExplicitKernelBundle() const {
std::shared_ptr<detail::kernel_bundle_impl>
handler::getOrInsertHandlerKernelBundle(bool Insert) const {
if (!impl->MKernelBundle && Insert) {
auto Ctx = impl->MGraph ? impl->MGraph->getContext() : MQueue->get_context();
auto Ctx =
impl->MGraph ? impl->MGraph->getContext() : MQueue->get_context();
auto Dev = impl->MGraph ? impl->MGraph->getDevice() : MQueue->get_device();
impl->MKernelBundle = detail::getSyclObjImpl(
get_kernel_bundle<bundle_state::input>(Ctx, {Dev}, {}));
Expand Down Expand Up @@ -199,7 +200,8 @@ event handler::finalize() {
// Make sure implicit non-interop kernel bundles have the kernel
if (!KernelBundleImpPtr->isInterop() &&
!impl->isStateExplicitKernelBundle()) {
auto Dev = impl->MGraph ? impl->MGraph->getDevice() : MQueue->get_device();
auto Dev =
impl->MGraph ? impl->MGraph->getDevice() : MQueue->get_device();
kernel_id KernelID =
detail::ProgramManager::getInstance().getSYCLKernelID(
MKernelName.c_str());
Expand Down Expand Up @@ -356,21 +358,22 @@ event handler::finalize() {
new detail::CGUpdateHost(MDstPtr, std::move(impl->CGData), MCodeLoc));
break;
case detail::CGType::CopyUSM:
CommandGroup.reset(new detail::CGCopyUSM(MSrcPtr, MDstPtr, MLength,
std::move(impl->CGData), MCodeLoc));
CommandGroup.reset(new detail::CGCopyUSM(
MSrcPtr, MDstPtr, MLength, std::move(impl->CGData), MCodeLoc));
break;
case detail::CGType::FillUSM:
CommandGroup.reset(new detail::CGFillUSM(
std::move(MPattern), MDstPtr, MLength, std::move(impl->CGData), MCodeLoc));
CommandGroup.reset(new detail::CGFillUSM(std::move(MPattern), MDstPtr,
MLength, std::move(impl->CGData),
MCodeLoc));
break;
case detail::CGType::PrefetchUSM:
CommandGroup.reset(new detail::CGPrefetchUSM(MDstPtr, MLength,
std::move(impl->CGData), MCodeLoc));
CommandGroup.reset(new detail::CGPrefetchUSM(
MDstPtr, MLength, std::move(impl->CGData), MCodeLoc));
break;
case detail::CGType::AdviseUSM:
CommandGroup.reset(new detail::CGAdviseUSM(MDstPtr, MLength, impl->MAdvice,
std::move(impl->CGData), getType(),
MCodeLoc));
std::move(impl->CGData),
getType(), MCodeLoc));
break;
case detail::CGType::Copy2DUSM:
CommandGroup.reset(new detail::CGCopy2DUSM(
Expand All @@ -388,8 +391,9 @@ event handler::finalize() {
std::move(impl->CGData), MCodeLoc));
break;
case detail::CGType::CodeplayHostTask: {
auto context = impl->MGraph ? detail::getSyclObjImpl(impl->MGraph->getContext())
: MQueue->getContextImplPtr();
auto context = impl->MGraph
? detail::getSyclObjImpl(impl->MGraph->getContext())
: MQueue->getContextImplPtr();
CommandGroup.reset(new detail::CGHostTask(
std::move(impl->MHostTask), MQueue, context, std::move(impl->MArgs),
std::move(impl->CGData), getType(), MCodeLoc));
Expand All @@ -399,13 +403,13 @@ event handler::finalize() {
case detail::CGType::BarrierWaitlist: {
if (auto GraphImpl = getCommandGraph(); GraphImpl != nullptr) {
impl->CGData.MEvents.insert(std::end(impl->CGData.MEvents),
std::begin(impl->MEventsWaitWithBarrier),
std::end(impl->MEventsWaitWithBarrier));
std::begin(impl->MEventsWaitWithBarrier),
std::end(impl->MEventsWaitWithBarrier));
// Barrier node is implemented as an empty node in Graph
// but keep the barrier type to help managing dependencies
setType(detail::CGType::Barrier);
CommandGroup.reset(
new detail::CG(detail::CGType::Barrier, std::move(impl->CGData), MCodeLoc));
CommandGroup.reset(new detail::CG(detail::CGType::Barrier,
std::move(impl->CGData), MCodeLoc));
} else {
CommandGroup.reset(
new detail::CGBarrier(std::move(impl->MEventsWaitWithBarrier),
Expand All @@ -414,7 +418,8 @@ event handler::finalize() {
break;
}
case detail::CGType::ProfilingTag: {
CommandGroup.reset(new detail::CGProfilingTag(std::move(impl->CGData), MCodeLoc));
CommandGroup.reset(
new detail::CGProfilingTag(std::move(impl->CGData), MCodeLoc));
break;
}
case detail::CGType::CopyToDeviceGlobal: {
Expand Down Expand Up @@ -466,17 +471,18 @@ event handler::finalize() {
CommandGroup.reset(new detail::CGCopyImage(
MSrcPtr, MDstPtr, impl->MImageDesc, impl->MImageFormat,
impl->MImageCopyFlags, impl->MSrcOffset, impl->MDestOffset,
impl->MHostExtent, impl->MCopyExtent, std::move(impl->CGData), MCodeLoc));
impl->MHostExtent, impl->MCopyExtent, std::move(impl->CGData),
MCodeLoc));
break;
case detail::CGType::SemaphoreWait:
CommandGroup.reset(new detail::CGSemaphoreWait(
impl->MInteropSemaphoreHandle, impl->MWaitValue, std::move(impl->CGData),
MCodeLoc));
impl->MInteropSemaphoreHandle, impl->MWaitValue,
std::move(impl->CGData), MCodeLoc));
break;
case detail::CGType::SemaphoreSignal:
CommandGroup.reset(new detail::CGSemaphoreSignal(
impl->MInteropSemaphoreHandle, impl->MSignalValue, std::move(impl->CGData),
MCodeLoc));
impl->MInteropSemaphoreHandle, impl->MSignalValue,
std::move(impl->CGData), MCodeLoc));
break;
case detail::CGType::None:
if (detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_ALL)) {
Expand All @@ -487,8 +493,8 @@ event handler::finalize() {
// For Standard mode (non-graph),
// empty nodes are not sent to the scheduler to save time
if (impl->MGraph || (MQueue && MQueue->getCommandGraph())) {
CommandGroup.reset(
new detail::CG(detail::CGType::None, std::move(impl->CGData), MCodeLoc));
CommandGroup.reset(new detail::CG(detail::CGType::None,
std::move(impl->CGData), MCodeLoc));
} else {
detail::EventImplPtr Event = std::make_shared<sycl::detail::event_impl>();
MLastEvent = detail::createSyclObjFromImpl<event>(Event);
Expand Down Expand Up @@ -524,8 +530,7 @@ event handler::finalize() {
GraphImpl->MMutex);

ext::oneapi::experimental::node_type NodeType =
impl->MUserFacingNodeType !=
ext::oneapi::experimental::node_type::empty
impl->MUserFacingNodeType != ext::oneapi::experimental::node_type::empty
? impl->MUserFacingNodeType
: ext::oneapi::experimental::detail::getNodeTypeFromCG(getType());

Expand Down Expand Up @@ -675,17 +680,17 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
static_cast<detail::AccessorBaseHost *>(&S->GlobalBuf);
detail::AccessorImplPtr GBufImpl = detail::getSyclObjImpl(*GBufBase);
detail::Requirement *GBufReq = GBufImpl.get();
addArgsForGlobalAccessor(GBufReq, Index, IndexShift, Size,
IsKernelCreatedFromSource,
impl->MNDRDesc.GlobalSize.size(), impl->MArgs, IsESIMD);
addArgsForGlobalAccessor(
GBufReq, Index, IndexShift, Size, IsKernelCreatedFromSource,
impl->MNDRDesc.GlobalSize.size(), impl->MArgs, IsESIMD);
++IndexShift;
detail::AccessorBaseHost *GOffsetBase =
static_cast<detail::AccessorBaseHost *>(&S->GlobalOffset);
detail::AccessorImplPtr GOfssetImpl = detail::getSyclObjImpl(*GOffsetBase);
detail::Requirement *GOffsetReq = GOfssetImpl.get();
addArgsForGlobalAccessor(GOffsetReq, Index, IndexShift, Size,
IsKernelCreatedFromSource,
impl->MNDRDesc.GlobalSize.size(), impl->MArgs, IsESIMD);
addArgsForGlobalAccessor(
GOffsetReq, Index, IndexShift, Size, IsKernelCreatedFromSource,
impl->MNDRDesc.GlobalSize.size(), impl->MArgs, IsESIMD);
++IndexShift;
detail::AccessorBaseHost *GFlushBase =
static_cast<detail::AccessorBaseHost *>(&S->GlobalFlushBuf);
Expand Down Expand Up @@ -738,7 +743,7 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
// make it a minimum allocation of 1 byte.
SizeInBytes = std::max(SizeInBytes, 1);
impl->MArgs.emplace_back(kernel_param_kind_t::kind_std_layout, nullptr,
SizeInBytes, Index + IndexShift);
SizeInBytes, Index + IndexShift);
// TODO ESIMD currently does not suport MSize field passing yet
// accessor::init for ESIMD-mode accessor has a single field, translated
// to a single kernel argument set above.
Expand Down Expand Up @@ -880,8 +885,8 @@ void handler::verifyUsedKernelBundleInternal(detail::string_view KernelName) {
return;

kernel_id KernelID = detail::get_kernel_id_impl(KernelName);
device Dev =
impl->MGraph ? impl->MGraph->getDevice() : detail::getDeviceFromHandler(*this);
device Dev = impl->MGraph ? impl->MGraph->getDevice()
: detail::getDeviceFromHandler(*this);
if (!UsedKernelBundleImplPtr->has_kernel(KernelID, Dev))
throw sycl::exception(
make_error_code(errc::kernel_not_supported),
Expand Down Expand Up @@ -1461,8 +1466,10 @@ void handler::use_kernel_bundle(
const kernel_bundle<bundle_state::executable> &ExecBundle) {
std::shared_ptr<detail::queue_impl> PrimaryQueue =
impl->MSubmissionPrimaryQueue;
if ((!impl->MGraph && (PrimaryQueue->get_context() != ExecBundle.get_context())) ||
(impl->MGraph && (impl->MGraph->getContext() != ExecBundle.get_context())))
if ((!impl->MGraph &&
(PrimaryQueue->get_context() != ExecBundle.get_context())) ||
(impl->MGraph &&
(impl->MGraph->getContext() != ExecBundle.get_context())))
throw sycl::exception(
make_error_code(errc::invalid),
"Context associated with the primary queue is different from the "
Expand Down Expand Up @@ -1836,16 +1843,14 @@ void handler::addArg(detail::kernel_param_kind_t ArgKind, void *Req,
impl->MArgs.emplace_back(ArgKind, Req, AccessTarget, ArgIndex);
}

void handler::clearArgs() {
impl->MArgs.clear();
}
void handler::clearArgs() { impl->MArgs.clear(); }

void handler::setArgsToAssociatedAccessors() {
impl->MArgs = impl->MAssociatedAccesors;
}

bool handler::HasAssociatedAccessor(detail::AccessorImplHost *Req,
access::target AccessTarget) const {
access::target AccessTarget) const {
return std::find_if(
impl->MAssociatedAccesors.cbegin(),
impl->MAssociatedAccesors.cend(), [&](const detail::ArgDesc &AD) {
Expand All @@ -1867,8 +1872,8 @@ void handler::setNDRangeDescriptorPadded(sycl::range<3> NumWorkItems,
impl->MNDRDesc = NDRDescT{NumWorkItems, Offset, Dims};
}
void handler::setNDRangeDescriptorPadded(sycl::range<3> NumWorkItems,
sycl::range<3> LocalSize, sycl::id<3> Offset,
int Dims) {
sycl::range<3> LocalSize,
sycl::id<3> Offset, int Dims) {
impl->MNDRDesc = NDRDescT{NumWorkItems, LocalSize, Offset, Dims};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class MockHandler : public sycl::handler {

return CommandGroup;
}

};

const sycl::detail::KernelArgMask *getKernelArgMaskFromBundle(
Expand Down
Loading

0 comments on commit 0b60f43

Please sign in to comment.