Lines Matching +full:- +full:std

7 #include <algorithm> // std::find_if
8 #include <cstring> // std::memset
31 // GCC implementation for std::hash<T*>. LLVM's libc++ is almost 2x slower because they do all
35 PETSC_NODISCARD std::size_t operator()(const T *ptr) const noexcept in operator ()()
37 return reinterpret_cast<std::size_t>(ptr); in operator ()()
50 std::size_t size = 0; // size of allocation (bytes)
55 constexpr PointerAttributes(PetscMemType, PetscObjectId, std::size_t) noexcept;
63 // PointerAttributes - Public API
66 inline constexpr PointerAttributes::PointerAttributes(PetscMemType mtype_, PetscObjectId id_, std::… in PointerAttributes()
74 PointerAttributes::contains - asks and answers the question, does ptr_begin contain ptr
77 + ptr_begin - pointer to the start of the range to check
78 - ptr - the pointer to query
92 // cannot just store meta-data within the pointer itself (as we can't dereference them). So
95 // Each entry maps pointer -> {
96 // PetscMemType - The memtype of the pointer
97 // PetscObjectId - A unique ID assigned at allocation or registration so auto-dep can
99 // size - The size (in bytes) of the allocation
118 // MemoryMap - Private API
140 // MemoryMap - Public API
144 MemoryMap::search_for - retrieve an iterator to the key-value pair for a pointer in the map
147 + ptr - pointer to search for
148 - must_find - true if an error is raised if the pointer is not found (default: false)
151 Accounts for sub-regions, i.e. if ptr is contained within another pointers region, it returns
152 the iterator to the super-pointers key-value pair.
165 // clang-format off in search_for()
166 it = std::find_if(map.begin(), end_it, [ptr](map_type::const_iterator::reference map_it) { in search_for()
169 // clang-format on in search_for()
183 … host memory", PetscObjectCast(dctx)->id, PetscObjectCast(dctx)->name, dctx->device ? PetscDeviceT… in PetscDeviceCheckCapable_Private()
190 …RegisterMemory_Private(const void *PETSC_RESTRICT ptr, PetscMemType mtype, std::size_t size, Petsc… in PetscDeviceRegisterMemory_Private()
207 …r %p (memtype %s, size %zu) but it appears you have already registered a sub-region of it (pointer… in PetscDeviceRegisterMemory_Private()
211 // clang-format off in PetscDeviceRegisterMemory_Private()
214 std::piecewise_construct, in PetscDeviceRegisterMemory_Private()
215 std::forward_as_tuple(const_cast<MemoryMap::map_type::key_type>(ptr)), in PetscDeviceRegisterMemory_Private()
216 std::forward_as_tuple(mtype, newid, size) in PetscDeviceRegisterMemory_Private()
218 // clang-format on in PetscDeviceRegisterMemory_Private()
222 const auto &old = it->second; in PetscDeviceRegisterMemory_Private()
224 …4_FMT ", which does not match new values: (mtype %s, size %zu, id %" PetscInt64_FMT ")", it->first, in PetscDeviceRegisterMemory_Private()
227 if (id) *id = it->second.id; in PetscDeviceRegisterMemory_Private()
232 PetscDeviceRegisterMemory - Register a pointer for use with device-aware memory system
237 + ptr - The pointer to register
238 . mtype - The `PetscMemType` of the pointer
239 - size - The size (in bytes) of the memory region
245 It's OK to re-register the same `ptr` repeatedly (subsequent registrations do nothing)
255 PetscErrorCode PetscDeviceRegisterMemory(const void *PETSC_RESTRICT ptr, PetscMemType mtype, std::s… in PetscDeviceRegisterMemory()
265 PetscDeviceAllocate_Private - Allocate device-aware memory
267 Not Collective, Asynchronous, Auto-dependency aware
270 + dctx - The `PetscDeviceContext` used to allocate the memory
271 . clear - Whether or not the memory should be zeroed
272 . mtype - The type of memory to allocate
273 . n - The amount (in bytes) to allocate
274 - alignment - The alignment requirement (in bytes) of the allocated pointer
277 . ptr - The pointer to store the result in
283 If the user is unsure about `alignment` -- or unable to compute it -- passing
312 time ->
314 -> dctx - |= CALL =| -\- dctx -->
315 \- ptr ->
325 …vate(PetscDeviceContext dctx, PetscBool clear, PetscMemType mtype, std::size_t n, std::size_t alig… in PetscDeviceAllocate_Private()
331 const auto is_power_of_2 = [](std::size_t num) { return (num & (num - 1)) == 0; }; in PetscDeviceAllocate_Private()
343 if (dctx->ops->memalloc) { in PetscDeviceAllocate_Private()
357 PetscDeviceDeallocate_Private - Free device-aware memory
359 Not Collective, Asynchronous, Auto-dependency aware
362 + dctx - The `PetscDeviceContext` used to free the memory
363 - ptr - The pointer to free
381 time ->
383 -> dctx -/- |= CALL =| - dctx ->
384 -> ptr -/
410 auto &&attr = it->second; in PetscDeviceDeallocate_Private()
411 …ocation of %p (memtype %s, id %" PetscInt64_FMT ", size %zu bytes)", ptr, it->first, PetscMemTypeT… in PetscDeviceDeallocate_Private()
413 auto &&attr = found_it->second; in PetscDeviceDeallocate_Private()
419 if (dctx->ops->memfree) { in PetscDeviceDeallocate_Private()
431 // PetscClangLinter pragma disable: -fdoc-section-header-unknown
433 PetscDeviceMemcpy - Copy memory in a device-aware manner
435 Not Collective, Asynchronous, Auto-dependency aware
438 + dctx - The `PetscDeviceContext` used to copy the memory
439 . dest - The pointer to copy to
440 . src - The pointer to copy from
441 - n - The amount (in bytes) to copy
458 time ->
460 -> dctx - |= CALL =| - dctx ->
461 -> dest --------------------->
462 -> src ---------------------->
470 …(PetscDeviceContext dctx, void *PETSC_RESTRICT dest, const void *PETSC_RESTRICT src, std::size_t n) in PetscDeviceMemcpy()
479 const auto &dest_attr = memory_map.search_for(dest, true)->second; in PetscDeviceMemcpy()
480 const auto &src_attr = memory_map.search_for(src, true)->second; in PetscDeviceMemcpy()
486 if (dctx->ops->memcopy) { in PetscDeviceMemcpy()
494 // REVIEW ME: we might potentially need to sync here if the memory is device-allocated in PetscDeviceMemcpy()
503 // PetscClangLinter pragma disable: -fdoc-section-header-unknown
505 PetscDeviceMemset - Memset device-aware memory
507 Not Collective, Asynchronous, Auto-dependency aware
510 + dctx - The `PetscDeviceContext` used to memset the memory
511 . ptr - The pointer to the memory
512 . v - The value to set
513 - n - The amount (in bytes) to set
532 time ->
534 -> dctx - |= CALL =| - dctx ->
535 -> dest --------------------->
543 PetscErrorCode PetscDeviceMemset(PetscDeviceContext dctx, void *ptr, PetscInt v, std::size_t n) in PetscDeviceMemset()
550 const auto &attr = memory_map.search_for(ptr, true)->second; in PetscDeviceMemset()
553 if (dctx->ops->memset) { in PetscDeviceMemset()
556 // REVIEW ME: we might potentially need to sync here if the memory is device-allocated in PetscDeviceMemset()
559 std::memset(ptr, static_cast<int>(v), n); in PetscDeviceMemset()