@@ -1829,6 +1829,11 @@ dynamic_parameter_base::dynamic_parameter_base(
1829
1829
: impl(std::make_shared<dynamic_parameter_impl>(
1830
1830
sycl::detail::getSyclObjImpl (Graph), ParamSize, Data)) {}
1831
1831
1832
+ dynamic_parameter_base::dynamic_parameter_base (
1833
+ command_graph<graph_state::modifiable> Graph)
1834
+ : impl(std::make_shared<dynamic_parameter_impl>(
1835
+ sycl::detail::getSyclObjImpl (Graph))) {}
1836
+
1832
1837
void dynamic_parameter_base::updateValue (const void *NewValue, size_t Size ) {
1833
1838
impl->updateValue (NewValue, Size );
1834
1839
}
@@ -1843,6 +1848,20 @@ void dynamic_parameter_base::updateAccessor(
1843
1848
impl->updateAccessor (Acc);
1844
1849
}
1845
1850
1851
+ sycl::detail::LocalAccessorImplPtr
1852
+ dynamic_parameter_base::getLocalAccessor (handler *Handler) {
1853
+ return impl->getLocalAccessor (Handler);
1854
+ }
1855
+
1856
+ void dynamic_parameter_base::registerLocalAccessor (
1857
+ sycl::detail::LocalAccessorBaseHost *LocalAccBaseHost, handler *Handler) {
1858
+ impl->registerLocalAccessor (LocalAccBaseHost, Handler);
1859
+ }
1860
+
1861
+ void dynamic_parameter_base::updateLocalAccessor (range<3 > NewAllocationSize) {
1862
+ impl->updateLocalAccessor (NewAllocationSize);
1863
+ }
1864
+
1846
1865
void dynamic_parameter_impl::updateValue (const raw_kernel_arg *NewRawValue,
1847
1866
size_t Size ) {
1848
1867
// Number of bytes is taken from member of raw_kernel_arg object rather
@@ -1898,6 +1917,53 @@ void dynamic_parameter_impl::updateAccessor(
1898
1917
sizeof (sycl::detail::AccessorBaseHost));
1899
1918
}
1900
1919
1920
+ sycl::detail::LocalAccessorImplPtr
1921
+ dynamic_parameter_impl::getLocalAccessor (handler *Handler) {
1922
+ auto HandlerImpl = sycl::detail::getSyclObjImpl (*Handler);
1923
+ auto FindLocalAcc = MHandlerToLocalAccMap.find (HandlerImpl);
1924
+
1925
+ if (FindLocalAcc != MHandlerToLocalAccMap.end ()) {
1926
+ auto LocalAccImpl = FindLocalAcc->second ;
1927
+ return LocalAccImpl;
1928
+ }
1929
+ return nullptr ;
1930
+ }
1931
+
1932
+ void dynamic_parameter_impl::registerLocalAccessor (
1933
+ sycl::detail::LocalAccessorBaseHost *LocalAccBaseHost, handler *Handler) {
1934
+
1935
+ auto HandlerImpl = sycl::detail::getSyclObjImpl (*Handler);
1936
+ auto LocalAccImpl = sycl::detail::getSyclObjImpl (*LocalAccBaseHost);
1937
+
1938
+ MHandlerToLocalAccMap.insert ({HandlerImpl, LocalAccImpl});
1939
+ }
1940
+
1941
+ void dynamic_parameter_impl::updateLocalAccessor (range<3 > NewAllocationSize) {
1942
+
1943
+ for (auto &[NodeWeak, ArgIndex] : MNodes) {
1944
+ auto NodeShared = NodeWeak.lock ();
1945
+ if (NodeShared) {
1946
+ // We can use the first local accessor in the map since the dimensions
1947
+ // and element type should be identical.
1948
+ auto LocalAccessor = MHandlerToLocalAccMap.begin ()->second ;
1949
+ dynamic_parameter_impl::updateCGLocalAccessor (
1950
+ NodeShared->MCommandGroup , ArgIndex, NewAllocationSize,
1951
+ LocalAccessor->MDims , LocalAccessor->MElemSize );
1952
+ }
1953
+ }
1954
+
1955
+ for (auto &DynCGInfo : MDynCGs) {
1956
+ auto DynCG = DynCGInfo.DynCG .lock ();
1957
+ if (DynCG) {
1958
+ auto &CG = DynCG->MKernels [DynCGInfo.CGIndex ];
1959
+ auto LocalAccessor = MHandlerToLocalAccMap.begin ()->second ;
1960
+ dynamic_parameter_impl::updateCGLocalAccessor (
1961
+ CG, DynCGInfo.ArgIndex , NewAllocationSize,
1962
+ LocalAccessor->MDims , LocalAccessor->MElemSize );
1963
+ }
1964
+ }
1965
+ }
1966
+
1901
1967
void dynamic_parameter_impl::updateCGArgValue (
1902
1968
std::shared_ptr<sycl::detail::CG> CG, int ArgIndex, const void *NewValue,
1903
1969
size_t Size ) {
@@ -1963,6 +2029,28 @@ void dynamic_parameter_impl::updateCGAccessor(
1963
2029
}
1964
2030
}
1965
2031
2032
+ void dynamic_parameter_impl::updateCGLocalAccessor (
2033
+ std::shared_ptr<sycl::detail::CG> CG, int ArgIndex,
2034
+ range<3 > NewAllocationSize,
2035
+ int Dims, int ElemSize) {
2036
+ auto &Args = static_cast <sycl::detail::CGExecKernel *>(CG.get ())->MArgs ;
2037
+
2038
+ for (auto &Arg : Args) {
2039
+ if (Arg.MIndex != ArgIndex) {
2040
+ continue ;
2041
+ }
2042
+ assert (Arg.MType == sycl::detail::kernel_param_kind_t ::kind_std_layout);
2043
+
2044
+ int SizeInBytes = ElemSize;
2045
+ for (int I = 0 ; I < Dims; ++I)
2046
+ SizeInBytes *= NewAllocationSize[I];
2047
+ SizeInBytes = std::max (SizeInBytes, 1 );
2048
+
2049
+ Arg.MSize = SizeInBytes;
2050
+ break ;
2051
+ }
2052
+ }
2053
+
1966
2054
dynamic_command_group_impl::dynamic_command_group_impl (
1967
2055
const command_graph<graph_state::modifiable> &Graph)
1968
2056
: MGraph{sycl::detail::getSyclObjImpl (Graph)}, MActiveCGF(0 ) {}
@@ -2084,6 +2172,7 @@ size_t dynamic_command_group::get_active_index() const {
2084
2172
void dynamic_command_group::set_active_index (size_t Index) {
2085
2173
return impl->setActiveIndex (Index);
2086
2174
}
2175
+
2087
2176
} // namespace experimental
2088
2177
} // namespace oneapi
2089
2178
} // namespace ext
0 commit comments