Skip to content

Commit

Permalink
Declare memoryPool::reserve specialization for void in header to …
Browse files Browse the repository at this point in the history
…make available in other translation units. (#762)
  • Loading branch information
kris-rowe authored Nov 20, 2024
1 parent 0e177a1 commit 1bb7c22
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/occa/core/memoryPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ namespace occa {
* @endDoc
*/
occa::memory reserve(const dim_t entries,
const dtype_t &dtype);\
const dtype_t &dtype);

/**
* @startDoc{setAlignment}
Expand All @@ -251,6 +251,10 @@ namespace occa {
void setAlignment(const udim_t alignment);
};

// Need to declare this function template specialization
// in the header so it is available in other translation units.
template <>
occa::memory memoryPool::reserve<void>(const dim_t entries);
}

#include "memoryPool.tpp"
Expand Down
14 changes: 14 additions & 0 deletions tests/src/core/memoryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#include <occa/internal/utils/testing.hpp>

void testReserve();
void testVoid();

int main(const int argc, const char **argv) {
testReserve();
testVoid();

return 0;
}
Expand Down Expand Up @@ -165,3 +167,15 @@ void testReserve() {
delete[] test;
delete[] data;
}

void testVoid() {
#define ASSERT_SAME_SIZE(a, b) \
ASSERT_EQ((size_t) (a), (size_t) (b))

occa::device device({{"mode", "Serial"}});
occa::memoryPool memory_pool = device.createMemoryPool();

const int size = 10;
occa::memory memory = memory_pool.reserve(10);
ASSERT_SAME_SIZE(memory.size(), size);
}

0 comments on commit 1bb7c22

Please sign in to comment.