Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/SetupChaiOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ option(CHAI_ENABLE_RAJA_PLUGIN "Build plugin to set RAJA execution spaces" Off)
option(CHAI_ENABLE_GPU_ERROR_CHECKING "Enable GPU error checking" On)
option(CHAI_ENABLE_MANAGED_PTR "Enable managed_ptr" On)
option(CHAI_DEBUG "Enable Debug Logging." Off)
option(CHAI_ENABLE_ZERO_INITIALIZED_MEMORY "Initialize allocations to 0" Off)
option(CHAI_ENABLE_RAJA_NESTED_TEST "Enable raja-chai-nested-tests, which fails to build on Debug CUDA builds." On)

option(CHAI_ENABLE_TESTS "Enable CHAI tests" On)
Expand Down
5 changes: 5 additions & 0 deletions src/chai/ArrayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ void ArrayManager::allocate(
auto alloc = m_resource_manager.getAllocator(pointer_record->m_allocators[space]);

pointer_record->m_pointers[space] = alloc.allocate(size);

#if CHAI_ENABLE_ZERO_INITIALIZED_MEMORY
m_resource_manager.memset(new_ptr, 0, new_size);
#endif

callback(pointer_record, ACTION_ALLOC, space);

registerPointer(pointer_record, space);
Expand Down
5 changes: 5 additions & 0 deletions src/chai/ArrayManager.inl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ void* ArrayManager::reallocate(void* pointer, size_t elems, PointerRecord* point

if (old_ptr) {
void* new_ptr = m_allocators[space]->allocate(new_size);

#if CHAI_ENABLE_ZERO_INITIALIZED_MEMORY
m_resource_manager.memset(new_ptr, 0, new_size);
#endif

m_resource_manager.copy(new_ptr, old_ptr, num_bytes_to_copy);
m_allocators[space]->deallocate(old_ptr);

Expand Down
1 change: 1 addition & 0 deletions src/chai/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#cmakedefine CHAI_DISABLE_RM
#cmakedefine CHAI_ENABLE_UM
#cmakedefine CHAI_DEBUG
#cmakedefine CHAI_ENABLE_ZERO_INITIALIZED_MEMORY
#cmakedefine CHAI_ENABLE_GPU_ERROR_CHECKING
#cmakedefine CHAI_ENABLE_MANAGED_PTR
#cmakedefine CHAI_ENABLE_RAJA_PLUGIN
Expand Down