Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare memoryPool::reserve specialization for void in header to make available in other translation units. #762

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
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
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);
}