28
28
#include < CL/sycl/sampler.hpp>
29
29
#include < CL/sycl/stl.hpp>
30
30
31
- #include < algorithm>
32
31
#include < functional>
33
32
#include < limits>
34
33
#include < memory>
@@ -250,7 +249,7 @@ class __SYCL_EXPORT handler {
250
249
typename std::remove_reference<T>::type>::type>
251
250
F *storePlainArg (T &&Arg) {
252
251
MArgsStorage.emplace_back (sizeof (T));
253
- F * Storage = ( F *) MArgsStorage.back ().data ();
252
+ auto Storage = reinterpret_cast < F *>( MArgsStorage.back ().data () );
254
253
*Storage = Arg;
255
254
return Storage;
256
255
}
@@ -308,8 +307,8 @@ class __SYCL_EXPORT handler {
308
307
// / Streams are then forwarded to command group and flushed in the scheduler.
309
308
// /
310
309
// / \param Stream is a pointer to SYCL stream.
311
- void addStream (shared_ptr_class<detail::stream_impl> Stream) {
312
- MStreamStorage.push_back (std::move ( Stream) );
310
+ void addStream (const shared_ptr_class<detail::stream_impl> & Stream) {
311
+ MStreamStorage.push_back (Stream);
313
312
}
314
313
315
314
// / Saves buffers created by handling reduction feature in handler.
@@ -318,28 +317,16 @@ class __SYCL_EXPORT handler {
318
317
// / The 'MSharedPtrStorage' suits that need.
319
318
// /
320
319
// / @param ReduObj is a pointer to object that must be stored.
321
- void addReduction (shared_ptr_class<const void > ReduObj) {
322
- MSharedPtrStorage.push_back (std::move ( ReduObj) );
320
+ void addReduction (const shared_ptr_class<const void > & ReduObj) {
321
+ MSharedPtrStorage.push_back (ReduObj);
323
322
}
324
323
325
324
~handler () = default ;
326
325
327
326
bool is_host () { return MIsHost; }
328
327
329
328
void associateWithHandler (detail::AccessorBaseHost *AccBase,
330
- access::target AccTarget) {
331
- detail::AccessorImplPtr AccImpl = detail::getSyclObjImpl (*AccBase);
332
- detail::Requirement *Req = AccImpl.get ();
333
- // Add accessor to the list of requirements.
334
- MRequirements.push_back (Req);
335
- // Store copy of the accessor.
336
- MAccStorage.push_back (std::move (AccImpl));
337
- // Add an accessor to the handler list of associated accessors.
338
- // For associated accessors index does not means nothing.
339
- MAssociatedAccesors.emplace_back (detail::kernel_param_kind_t ::kind_accessor,
340
- Req, static_cast <int >(AccTarget),
341
- /* index*/ 0 );
342
- }
329
+ access::target AccTarget);
343
330
344
331
// Recursively calls itself until arguments pack is fully processed.
345
332
// The version for regular(standard layout) argument.
@@ -387,7 +374,7 @@ class __SYCL_EXPORT handler {
387
374
}
388
375
389
376
template <typename T> void setArgHelper (int ArgIndex, T &&Arg) {
390
- void * StoredArg = ( void *) storePlainArg (Arg);
377
+ auto StoredArg = static_cast < void *>( storePlainArg (Arg) );
391
378
392
379
if (!std::is_same<cl_mem, T>::value && std::is_pointer<T>::value) {
393
380
MArgs.emplace_back (detail::kernel_param_kind_t ::kind_pointer, StoredArg,
@@ -399,7 +386,7 @@ class __SYCL_EXPORT handler {
399
386
}
400
387
401
388
void setArgHelper (int ArgIndex, sampler &&Arg) {
402
- void * StoredArg = ( void *) storePlainArg (Arg);
389
+ auto StoredArg = static_cast < void *>( storePlainArg (Arg) );
403
390
MArgs.emplace_back (detail::kernel_param_kind_t ::kind_sampler, StoredArg,
404
391
sizeof (sampler), ArgIndex);
405
392
}
@@ -791,8 +778,8 @@ class __SYCL_EXPORT handler {
791
778
// / Registers event dependencies on this command group.
792
779
// /
793
780
// / \param Events is a vector of valid SYCL events to wait on.
794
- void depends_on (vector_class<event> Events) {
795
- for (event &Event : Events) {
781
+ void depends_on (const vector_class<event> & Events) {
782
+ for (const event &Event : Events) {
796
783
MEvents.push_back (detail::getSyclObjImpl (Event));
797
784
}
798
785
}
@@ -1572,8 +1559,8 @@ class __SYCL_EXPORT handler {
1572
1559
detail::AccessorImplPtr AccImpl = detail::getSyclObjImpl (*AccBase);
1573
1560
1574
1561
MRequirements.push_back (AccImpl.get ());
1575
- MSrcPtr = ( void *) AccImpl.get ();
1576
- MDstPtr = ( void *) Dst;
1562
+ MSrcPtr = static_cast < void *>( AccImpl.get () );
1563
+ MDstPtr = static_cast < void *>( Dst) ;
1577
1564
// Store copy of accessor to the local storage to make sure it is alive
1578
1565
// until we finish
1579
1566
MAccStorage.push_back (std::move (AccImpl));
@@ -1679,7 +1666,7 @@ class __SYCL_EXPORT handler {
1679
1666
detail::AccessorBaseHost *AccBase = (detail::AccessorBaseHost *)&Acc;
1680
1667
detail::AccessorImplPtr AccImpl = detail::getSyclObjImpl (*AccBase);
1681
1668
1682
- MDstPtr = ( void *) AccImpl.get ();
1669
+ MDstPtr = static_cast < void *>( AccImpl.get () );
1683
1670
MRequirements.push_back (AccImpl.get ());
1684
1671
MAccStorage.push_back (std::move (AccImpl));
1685
1672
}
@@ -1708,12 +1695,12 @@ class __SYCL_EXPORT handler {
1708
1695
detail::AccessorBaseHost *AccBase = (detail::AccessorBaseHost *)&Dst;
1709
1696
detail::AccessorImplPtr AccImpl = detail::getSyclObjImpl (*AccBase);
1710
1697
1711
- MDstPtr = ( void *) AccImpl.get ();
1698
+ MDstPtr = static_cast < void *>( AccImpl.get () );
1712
1699
MRequirements.push_back (AccImpl.get ());
1713
1700
MAccStorage.push_back (std::move (AccImpl));
1714
1701
1715
1702
MPattern.resize (sizeof (T));
1716
- T * PatternPtr = ( T *) MPattern.data ();
1703
+ auto PatternPtr = reinterpret_cast < T *>( MPattern.data () );
1717
1704
*PatternPtr = Pattern;
1718
1705
} else {
1719
1706
@@ -1741,54 +1728,30 @@ class __SYCL_EXPORT handler {
1741
1728
// /
1742
1729
// / \param WaitList is a vector of valid SYCL events that need to complete
1743
1730
// / before barrier command can be executed.
1744
- void barrier (const vector_class<event> &WaitList) {
1745
- throwIfActionIsCreated ();
1746
- MCGType = detail::CG::BARRIER_WAITLIST;
1747
- MEventsWaitWithBarrier.resize (WaitList.size ());
1748
- std::transform (
1749
- WaitList.begin (), WaitList.end (), MEventsWaitWithBarrier.begin (),
1750
- [](const event &Event) { return detail::getSyclObjImpl (Event); });
1751
- }
1731
+ void barrier (const vector_class<event> &WaitList);
1752
1732
1753
1733
// / Copies data from one memory region to another, both pointed by
1754
1734
// / USM pointers.
1755
1735
// /
1756
1736
// / \param Dest is a USM pointer to the destination memory.
1757
1737
// / \param Src is a USM pointer to the source memory.
1758
1738
// / \param Count is a number of bytes to copy.
1759
- void memcpy (void *Dest, const void *Src, size_t Count) {
1760
- throwIfActionIsCreated ();
1761
- MSrcPtr = const_cast <void *>(Src);
1762
- MDstPtr = Dest;
1763
- MLength = Count;
1764
- MCGType = detail::CG::COPY_USM;
1765
- }
1739
+ void memcpy (void *Dest, const void *Src, size_t Count);
1766
1740
1767
1741
// / Fills the memory pointed by a USM pointer with the value specified.
1768
1742
// /
1769
1743
// / \param Dest is a USM pointer to the memory to fill.
1770
1744
// / \param Value is a value to be set. Value is cast as an unsigned char.
1771
1745
// / \param Count is a number of bytes to fill.
1772
- void memset (void *Dest, int Value, size_t Count) {
1773
- throwIfActionIsCreated ();
1774
- MDstPtr = Dest;
1775
- MPattern.push_back ((char )Value);
1776
- MLength = Count;
1777
- MCGType = detail::CG::FILL_USM;
1778
- }
1746
+ void memset (void *Dest, int Value, size_t Count);
1779
1747
1780
1748
// / Provides hints to the runtime library that data should be made available
1781
1749
// / on a device earlier than Unified Shared Memory would normally require it
1782
1750
// / to be available.
1783
1751
// /
1784
1752
// / \param Ptr is a USM pointer to the memory to be prefetched to the device.
1785
1753
// / \param Count is a number of bytes to be prefetched.
1786
- void prefetch (const void *Ptr, size_t Count) {
1787
- throwIfActionIsCreated ();
1788
- MDstPtr = const_cast <void *>(Ptr);
1789
- MLength = Count;
1790
- MCGType = detail::CG::PREFETCH_USM;
1791
- }
1754
+ void prefetch (const void *Ptr, size_t Count);
1792
1755
1793
1756
private:
1794
1757
shared_ptr_class<detail::queue_impl> MQueue;
@@ -1830,7 +1793,7 @@ class __SYCL_EXPORT handler {
1830
1793
unique_ptr_class<detail::HostTask> MHostTask;
1831
1794
detail::OSModuleHandle MOSModuleHandle = detail::OSUtil::ExeModuleHandle;
1832
1795
// Storage for a lambda or function when using InteropTasks
1833
- std::unique_ptr <detail::InteropTask> MInteropTask;
1796
+ unique_ptr_class <detail::InteropTask> MInteropTask;
1834
1797
// / The list of events that order this operation.
1835
1798
vector_class<detail::EventImplPtr> MEvents;
1836
1799
// / The list of valid SYCL events that need to complete
0 commit comments