Skip to content

Commit

Permalink
trying to make stuff work
Browse files Browse the repository at this point in the history
  • Loading branch information
kab163 committed Dec 15, 2023
1 parent 6781960 commit 7003b1d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ cmake_dependent_option( UMPIRE_ENABLE_BENCHMARKS "Build Umpire benchmarks" On
cmake_dependent_option( UMPIRE_ENABLE_EXAMPLES "Build Umpire examples" On
"ENABLE_EXAMPLES" Off )

cmake_dependent_option( UMPIRE_ENABLE_DOCS "Build Umpire docs" Off
"ENABLE_DOCS" Off )
cmake_dependent_option( UMPIRE_ENABLE_DOCS "Build Umpire docs" On
"ENABLE_DOCS" On )
cmake_dependent_option( UMPIRE_ENABLE_CLANGQUERY "Build Umpire with Clang query" On
"ENABLE_CLANGQUERY" Off )
cmake_dependent_option( UMPIRE_ENABLE_COVERAGE "Build Umpire with Coverage support (with GCC)" On
Expand Down
9 changes: 5 additions & 4 deletions examples/sap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ __global__ void touch_data(double* data, int len)
__global__ void do_sleep()
{
//sleep - works still at 1000, so keeping it at 100k
sleep(1000);
sleep(1000000);
}

__global__ void check_data(double* data, int len)
Expand All @@ -62,7 +62,8 @@ __global__ void touch_data_again(double* data, int len)
int main(int, char**)
{
auto& rm = umpire::ResourceManager::getInstance();
auto pool = rm.makeAllocator<umpire::strategy::StreamAwareQuickPool>("sap-pool", rm.getAllocator("DEVICE"));
//auto pool = rm.makeAllocator<umpire::strategy::StreamAwareQuickPool>("sap-pool", rm.getAllocator("DEVICE"));
auto pool = umpire::strategy::StreamAwareQuickPool("sap-pool", 150, rm.getAllocator("DEVICE"), 32, 32);
int NUM_BLOCKS = NUM_THREADS / BLOCK_SIZE;

cudaStream_t s1, s2;
Expand All @@ -78,7 +79,7 @@ int main(int, char**)
check_data<<<NUM_BLOCKS, BLOCK_SIZE, 0, s1>>>(a, NUM_THREADS);

//deallocate and reallocate a using different streams
pool.deallocate(s1, a);
pool.deallocate(s1, a, NUM_THREADS * sizeof(double));
a = static_cast<double*>(pool.allocate(s2, NUM_THREADS * sizeof(double)));

//with stream s2, use memory in reallocated a in kernel
Expand All @@ -101,7 +102,7 @@ int main(int, char**)
std::cout << "Kernel succeeded! Expected result returned" << std::endl;

//final deallocations
pool.deallocate(s2, a);
pool.deallocate(s2, a, NUM_THREADS * sizeof(double));
rm.deallocate(b);
return 0;
}
5 changes: 4 additions & 1 deletion src/umpire/strategy/StreamAwareQuickPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ StreamAwareQuickPool::~StreamAwareQuickPool()

void* StreamAwareQuickPool::allocate(void* stream, std::size_t bytes)
{
/*
unsigned int size = m_registered_streams.size();
UMPIRE_LOG(Debug, "Size of registered streams vector is: " << size);
Expand All @@ -55,6 +56,7 @@ void* StreamAwareQuickPool::allocate(void* stream, std::size_t bytes)
UMPIRE_LOG(Debug, "I did not find a registered stream so I am adding it to vector.");
m_registered_streams.push_back(stream);
*/
return allocate(bytes);
}

Expand Down Expand Up @@ -165,11 +167,12 @@ void StreamAwareQuickPool::deallocate(void* stream, void* ptr, std::size_t size)
m_registered_dealloc.at(i) = deallocate_has_occurred;
}
}

/*
UMPIRE_ERROR(
runtime_error,
umpire::fmt::format("Invalid deallocate: {} stream has not been allocated yet", stream));
deallocate(ptr, size);
*/
}

void StreamAwareQuickPool::deallocate(void* ptr, std::size_t UMPIRE_UNUSED_ARG(size))
Expand Down
4 changes: 2 additions & 2 deletions src/umpire/strategy/StreamAwareQuickPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class StreamAwareQuickPool : public AllocationStrategy, private mixins::AlignedA

~StreamAwareQuickPool();

StreamAwareQuickPool(const StreamAwareQuickPool&) = delete;
StreamAwareQuickPool(const StreamAwareQuickPool&);

private:
void* allocate(std::size_t bytes);
Expand Down Expand Up @@ -168,7 +168,7 @@ class StreamAwareQuickPool : public AllocationStrategy, private mixins::AlignedA
const std::size_t m_first_minimum_pool_allocation_size;
const std::size_t m_next_minimum_pool_allocation_size;

std::vector<void*> m_registered_streams{0};
std::vector<void*> m_registered_streams{};
std::vector<camp::resources::Event> m_registered_dealloc{};

std::size_t m_total_blocks{0};
Expand Down

0 comments on commit 7003b1d

Please sign in to comment.