Skip to content

Conversation

@Bensuo
Copy link
Contributor

@Bensuo Bensuo commented May 6, 2025

  • Optimize memory use for allocations within a single graph by reusing memory where possible
  • New handler impl member for node dependency access with the CGF
  • New E2E tests for memory reuse
  • Add missing CGType -> string conversion for graph printing alloc and free nodes

@Bensuo Bensuo force-pushed the ben/graph-memory-reuse branch from dec8b75 to cdcec7e Compare May 6, 2025 16:30
@Bensuo Bensuo force-pushed the ben/graph-memory-reuse branch from cdcec7e to 64fef78 Compare May 7, 2025 11:17
@Bensuo Bensuo temporarily deployed to WindowsCILock May 7, 2025 11:18 — with GitHub Actions Inactive
@Bensuo Bensuo temporarily deployed to WindowsCILock May 7, 2025 11:56 — with GitHub Actions Inactive
@Bensuo Bensuo temporarily deployed to WindowsCILock May 7, 2025 11:56 — with GitHub Actions Inactive
- Optimize memory use for allocations within a single graph by reusing memory where possible
- New handler impl member for node dependency access with the CGF
- New E2E tests for memory reuse
- Add design doc information on memory reuse
- Add missing CGType -> string conversion for graph printing alloc and free nodes
@Bensuo Bensuo force-pushed the ben/graph-memory-reuse branch from 64fef78 to c1d9595 Compare May 7, 2025 12:25
@Bensuo Bensuo temporarily deployed to WindowsCILock May 7, 2025 12:25 — with GitHub Actions Inactive
@Bensuo Bensuo temporarily deployed to WindowsCILock May 7, 2025 12:47 — with GitHub Actions Inactive
@Bensuo Bensuo temporarily deployed to WindowsCILock May 7, 2025 12:47 — with GitHub Actions Inactive
@Bensuo Bensuo marked this pull request as ready for review May 7, 2025 15:15
@Bensuo Bensuo requested review from a team as code owners May 7, 2025 15:15
@Bensuo Bensuo requested review from againull and fabiomestre May 7, 2025 15:15
@Bensuo Bensuo temporarily deployed to WindowsCILock May 8, 2025 12:38 — with GitHub Actions Inactive
@Bensuo Bensuo temporarily deployed to WindowsCILock May 8, 2025 13:47 — with GitHub Actions Inactive
@Bensuo Bensuo temporarily deployed to WindowsCILock May 8, 2025 13:47 — with GitHub Actions Inactive
- Fix wording in design doc
- Remove code duplication is async_alloc calls
- Early return from tryReuseExistingAllocation()
- No dep nodes means that we cannot be connected to any free nodes for reuse
@Bensuo Bensuo temporarily deployed to WindowsCILock May 15, 2025 16:14 — with GitHub Actions Inactive
@Bensuo Bensuo temporarily deployed to WindowsCILock May 15, 2025 16:44 — with GitHub Actions Inactive
@Bensuo Bensuo temporarily deployed to WindowsCILock May 15, 2025 16:44 — with GitHub Actions Inactive
@Bensuo
Copy link
Contributor Author

Bensuo commented May 19, 2025

@intel/llvm-reviewers-runtime Could I get a review on this please? The Arc failures on CI look unrelated to this PR.

@againull againull merged commit a722e78 into intel:sycl May 19, 2025
24 of 25 checks passed
@sarnex
Copy link
Contributor

sarnex commented May 20, 2025

@Bensuo @EwanC
This is causing a warning on GCC causing a build fail with -Werror (which we use)

FAILED: tools/sycl/source/CMakeFiles/sycl_object.dir/detail/graph_memory_pool.cpp.o 
ccache /usr/bin/g++ -DCL_TARGET_OPENCL_VERSION=300 -DSYCL2020_DISABLE_DEPRECATION_WARNINGS -DSYCL_EXT_JIT_ENABLE -DXPTI_ENABLE_INSTRUMENTATION -DXPTI_STATIC_LIBRARY -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__DPCPP_ENABLE_UNFINISHED_KHR_EXTENSIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__SYCL_INTERNAL_API -I/__w/llvm/llvm/build/tools/sycl/source -I/__w/llvm/llvm/src/sycl/source -I/__w/llvm/llvm/build/include -I/__w/llvm/llvm/src/xpti/include -I/__w/llvm/llvm/src/sycl/include -I/__w/llvm/llvm/build/_deps/boost_unordered-src/include -I/__w/llvm/llvm/build/_deps/boost_assert-src/include -I/__w/llvm/llvm/build/_deps/boost_config-src/include -I/__w/llvm/llvm/build/_deps/boost_container_hash-src/include -I/__w/llvm/llvm/build/_deps/boost_core-src/include -I/__w/llvm/llvm/build/_deps/boost_describe-src/include -I/__w/llvm/llvm/build/_deps/boost_mp11-src/include -I/__w/llvm/llvm/build/_deps/boost_predef-src/include -I/__w/llvm/llvm/build/_deps/boost_static_assert-src/include -I/__w/llvm/llvm/build/_deps/boost_throw_exception-src/include -I/__w/llvm/llvm/src/sycl-jit/common/include -I/__w/llvm/llvm/src/sycl-jit/jit-compiler/include -I/__w/llvm/llvm/src/unified-runtime/include -I/__w/llvm/llvm/build/_deps/opencl-headers-src -isystem /__w/llvm/llvm/src/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wextra -Werror -O3 -DNDEBUG -UNDEBUG -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wno-psabi -std=c++17 -MD -MT tools/sycl/source/CMakeFiles/sycl_object.dir/detail/graph_memory_pool.cpp.o -MF tools/sycl/source/CMakeFiles/sycl_object.dir/detail/graph_memory_pool.cpp.o.d -o tools/sycl/source/CMakeFiles/sycl_object.dir/detail/graph_memory_pool.cpp.o -c /__w/llvm/llvm/src/sycl/source/detail/graph_memory_pool.cpp
/__w/llvm/llvm/src/sycl/source/detail/graph_memory_pool.cpp: In member function 'std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info> sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::tryReuseExistingAllocation(size_t, sycl::_V1::usm::alloc, bool, const std::vector<std::shared_ptr<sycl::_V1::ext::oneapi::experimental::detail::node_impl> >&)':
/__w/llvm/llvm/src/sycl/source/detail/graph_memory_pool.cpp:130:29: error: '((std::__weak_count<__gnu_cxx::_S_atomic>*)((char*)&AllocInfo + offsetof(std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>,std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>::<unnamed>.std::_Optional_base<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, false, false>::_M_payload.std::_Optional_payload<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, false, false, false>::<unnamed>.std::_Optional_payload<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, true, false, false>::<unnamed>.std::_Optional_payload_base<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>::_M_payload)))[7].std::__weak_count<__gnu_cxx::_S_atomic>::_M_pi' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  130 |   std::optional<alloc_info> AllocInfo = {};
      |                             ^~~~~~~~~
/__w/llvm/llvm/src/sycl/source/detail/graph_memory_pool.cpp:130:29: error: '((std::__weak_ptr<sycl::_V1::ext::oneapi::experimental::detail::node_impl, __gnu_cxx::_S_atomic>*)((char*)&AllocInfo + offsetof(std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>,std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>::<unnamed>.std::_Optional_base<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, false, false>::_M_payload.std::_Optional_payload<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, false, false, false>::<unnamed>.std::_Optional_payload<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, true, false, false>::<unnamed>.std::_Optional_payload_base<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>::_M_payload)))[3].std::__weak_ptr<sycl::_V1::ext::oneapi::experimental::detail::node_impl, __gnu_cxx::_S_atomic>::_M_ptr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1plus: all warnings being treated as errors
[4160/5103] Building CXX object tools/sycl/source/CMakeFiles/sycl_object.dir/detail/scheduler/scheduler.cpp.o
[4161/5103] Building CXX object tools/sycl/source/CMakeFiles/sycl_object.dir/stream.cpp.o
[4162/5103] Building CXX object tools/sycl/source/CMakeFiles/sycl-preview_object.dir/detail/graph_memory_pool.cpp.o
FAILED: tools/sycl/source/CMakeFiles/sycl-preview_object.dir/detail/graph_memory_pool.cpp.o 
ccache /usr/bin/g++ -DCL_TARGET_OPENCL_VERSION=300 -DSYCL2020_DISABLE_DEPRECATION_WARNINGS -DSYCL_EXT_JIT_ENABLE -DXPTI_ENABLE_INSTRUMENTATION -DXPTI_STATIC_LIBRARY -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__DPCPP_ENABLE_UNFINISHED_KHR_EXTENSIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__SYCL_INTERNAL_API -I/__w/llvm/llvm/build/tools/sycl/source -I/__w/llvm/llvm/src/sycl/source -I/__w/llvm/llvm/build/include -I/__w/llvm/llvm/src/xpti/include -I/__w/llvm/llvm/src/sycl/include -I/__w/llvm/llvm/build/_deps/boost_unordered-src/include -I/__w/llvm/llvm/build/_deps/boost_assert-src/include -I/__w/llvm/llvm/build/_deps/boost_config-src/include -I/__w/llvm/llvm/build/_deps/boost_container_hash-src/include -I/__w/llvm/llvm/build/_deps/boost_core-src/include -I/__w/llvm/llvm/build/_deps/boost_describe-src/include -I/__w/llvm/llvm/build/_deps/boost_mp11-src/include -I/__w/llvm/llvm/build/_deps/boost_predef-src/include -I/__w/llvm/llvm/build/_deps/boost_static_assert-src/include -I/__w/llvm/llvm/build/_deps/boost_throw_exception-src/include -I/__w/llvm/llvm/src/sycl-jit/common/include -I/__w/llvm/llvm/src/sycl-jit/jit-compiler/include -I/__w/llvm/llvm/src/unified-runtime/include -I/__w/llvm/llvm/build/_deps/opencl-headers-src -isystem /__w/llvm/llvm/src/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wextra -Werror -O3 -DNDEBUG -UNDEBUG -D__INTEL_PREVIEW_BREAKING_CHANGES -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wno-psabi -std=c++17 -MD -MT tools/sycl/source/CMakeFiles/sycl-preview_object.dir/detail/graph_memory_pool.cpp.o -MF tools/sycl/source/CMakeFiles/sycl-preview_object.dir/detail/graph_memory_pool.cpp.o.d -o tools/sycl/source/CMakeFiles/sycl-preview_object.dir/detail/graph_memory_pool.cpp.o -c /__w/llvm/llvm/src/sycl/source/detail/graph_memory_pool.cpp
/__w/llvm/llvm/src/sycl/source/detail/graph_memory_pool.cpp: In member function 'std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info> sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::tryReuseExistingAllocation(size_t, sycl::_V1::usm::alloc, bool, const std::vector<std::shared_ptr<sycl::_V1::ext::oneapi::experimental::detail::node_impl> >&)':
/__w/llvm/llvm/src/sycl/source/detail/graph_memory_pool.cpp:130:29: error: '((std::__weak_count<__gnu_cxx::_S_atomic>*)((char*)&AllocInfo + offsetof(std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>,std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>::<unnamed>.std::_Optional_base<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, false, false>::_M_payload.std::_Optional_payload<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, false, false, false>::<unnamed>.std::_Optional_payload<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, true, false, false>::<unnamed>.std::_Optional_payload_base<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>::_M_payload)))[7].std::__weak_count<__gnu_cxx::_S_atomic>::_M_pi' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  130 |   std::optional<alloc_info> AllocInfo = {};
      |                             ^~~~~~~~~
/__w/llvm/llvm/src/sycl/source/detail/graph_memory_pool.cpp:130:29: error: '((std::__weak_ptr<sycl::_V1::ext::oneapi::experimental::detail::node_impl, __gnu_cxx::_S_atomic>*)((char*)&AllocInfo + offsetof(std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>,std::optional<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>::<unnamed>.std::_Optional_base<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, false, false>::_M_payload.std::_Optional_payload<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, false, false, false>::<unnamed>.std::_Optional_payload<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info, true, false, false>::<unnamed>.std::_Optional_payload_base<sycl::_V1::ext::oneapi::experimental::detail::graph_mem_pool::alloc_info>::_M_payload)))[3].std::__weak_ptr<sycl::_V1::ext::oneapi::experimental::detail::node_impl, __gnu_cxx::_S_atomic>::_M_ptr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1plus: all warnings being treated as errors

https://github.com/intel/llvm/actions/runs/15128095339/job/42523770858

To me it looks like a bogus warning but I'm not an expert in this code. Can someone take a look and work around the warning if it is bogus? Thanks

@Bensuo
Copy link
Contributor Author

Bensuo commented May 21, 2025

@Bensuo @EwanC This is causing a warning on GCC causing a build fail with -Werror (which we use)

https://github.com/intel/llvm/actions/runs/15128095339/job/42523770858

To me it looks like a bogus warning but I'm not an expert in this code. Can someone take a look and work around the warning if it is bogus? Thanks

I think this is bogus yeah, there is other similar initialization in the runtime that isn't getting flagged on GCC 11.4, and the error doesn't show up in 12.3. I've reworked the code so it's not initialized outside and then assigned to in the lambda (and fixed a few small issues I saw at the same time) and that seems fine now: #18583

@sarnex
Copy link
Contributor

sarnex commented May 21, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants