Skip to content

Commit

Permalink
Move memoryPool from occa::experimental to occa namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-rowe committed Dec 21, 2023
1 parent ec9d90c commit 6390b2d
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/cpp/17_memory_pool/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int main(int argc, const char **argv) {
occa::json properties;
properties["verbose"] = args["options/verbose"];

occa::experimental::memoryPool memPool = device.createMemoryPool(properties);
occa::memoryPool memPool = device.createMemoryPool(properties);

int alignment = memPool.alignment();

Expand Down
1 change: 1 addition & 0 deletions include/occa.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <occa/c/json.h>
#include <occa/c/kernel.h>
#include <occa/c/memory.h>
#include <occa/c/memoryPool.h>

// Just in case someone wants to run with an older format than C99
#ifndef OCCA_DISABLE_VARIADIC_MACROS
Expand Down
1 change: 0 additions & 1 deletion include/occa/c/experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define OCCA_C_EXPERIMENTAL_HEADER

#include <occa/c/experimental/kernelBuilder.h>
#include <occa/c/experimental/memoryPool.h>

#ifdef OCCA_JIT
# undef OCCA_JIT
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions include/occa/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <occa/core/kernel.hpp>
#include <occa/core/kernelArg.hpp>
#include <occa/core/memory.hpp>
#include <occa/core/memoryPool.hpp>
#include <occa/core/stream.hpp>
#include <occa/core/streamTag.hpp>

Expand Down
3 changes: 2 additions & 1 deletion include/occa/core/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <occa/core/device.hpp>
#include <occa/core/kernel.hpp>
#include <occa/core/memory.hpp>
#include <occa/core/memoryPool.hpp>
#include <occa/core/stream.hpp>
#include <occa/core/streamTag.hpp>

Expand Down Expand Up @@ -44,7 +45,7 @@ namespace occa {

streamTag tagStream();

experimental::memoryPool createMemoryPool(const occa::json &props = occa::json());
memoryPool createMemoryPool(const occa::json &props = occa::json());
//====================================

//---[ Kernel Functions ]-------------
Expand Down
2 changes: 1 addition & 1 deletion include/occa/core/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ namespace occa {
*
* @endDoc
*/
experimental::memoryPool createMemoryPool(const occa::json &props = occa::json());
memoryPool createMemoryPool(const occa::json &props = occa::json());

// |===============================

Expand Down
7 changes: 2 additions & 5 deletions include/occa/core/memoryPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace occa {
class modeDevice_t; class device;
class modeMemoryPool_t;

namespace experimental {

class memoryPool : public gc::ringEntry_t {
friend class occa::modeMemoryPool_t;

Expand Down Expand Up @@ -141,7 +139,7 @@ namespace occa {
*
* @endDoc
*/
bool operator == (const occa::experimental::memoryPool &other) const;
bool operator == (const occa::memoryPool &other) const;

/**
* @startDoc{operator_equals[1]}
Expand All @@ -154,7 +152,7 @@ namespace occa {
*
* @endDoc
*/
bool operator != (const occa::experimental::memoryPool &other) const;
bool operator != (const occa::memoryPool &other) const;

/**
* @startDoc{resize}
Expand Down Expand Up @@ -253,7 +251,6 @@ namespace occa {
void setAlignment(const udim_t alignment);
};

}
}

#include "memoryPool.tpp"
Expand Down
2 changes: 0 additions & 2 deletions include/occa/core/memoryPool.tpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
namespace occa {
namespace experimental {
template <class T>
occa::memory memoryPool::reserve(const dim_t entries) {
return reserve(entries, occa::dtype::get<T>());
}
}
}
2 changes: 1 addition & 1 deletion src/c/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ occaMemory occaTypedWrapMemory(const void *ptr,

//---[ MemoryPool ]---------------------
occaMemoryPool occaCreateMemoryPool(occaJson props) {
occa::experimental::memoryPool memPool;
occa::memoryPool memPool;
if (occa::c::isDefault(props)) {
memPool = occa::createMemoryPool();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/c/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ occaMemoryPool occaDeviceCreateMemoryPool(occaDevice device,
occaJson props) {
occa::device device_ = occa::c::device(device);

occa::experimental::memoryPool memoryPool;
occa::memoryPool memoryPool;

Check warning on line 266 in src/c/device.cpp

View check run for this annotation

Codecov / codecov/patch

src/c/device.cpp#L266

Added line #L266 was not covered by tests
if (occa::c::isDefault(props)) {
memoryPool = device_.createMemoryPool();
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/c/experimental/memoryPool.cpp → src/c/memoryPool.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <occa/internal/c/types.hpp>
#include <occa/c/dtype.h>
#include <occa/c/memory.h>
#include <occa/c/experimental/memoryPool.h>
#include <occa/c/memoryPool.h>

OCCA_START_EXTERN_C

Expand Down Expand Up @@ -57,7 +57,7 @@ occaMemory occaMemoryPoolReserve(occaDevice device,
occaMemory occaMemoryPoolTypedReserve(occaMemoryPool memoryPool,
const occaUDim_t entries,
const occaDtype dtype) {
occa::experimental::memoryPool memoryPool_ = occa::c::memoryPool(memoryPool);
occa::memoryPool memoryPool_ = occa::c::memoryPool(memoryPool);
const occa::dtype_t &dtype_ = occa::c::dtype(dtype);

occa::memory memory = memoryPool_.reserve(entries, dtype_);
Expand Down
2 changes: 1 addition & 1 deletion src/core/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace occa {
return getDevice().tagStream();
}

experimental::memoryPool createMemoryPool(const occa::json &props) {
memoryPool createMemoryPool(const occa::json &props) {
return getDevice().createMemoryPool(props);
}

Expand Down
10 changes: 5 additions & 5 deletions src/occa/internal/c/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ namespace occa {
return oType;
}

occaType newOccaType(occa::experimental::memoryPool memoryPool) {
occaType newOccaType(occa::memoryPool memoryPool) {
occa::modeMemoryPool_t *modeMemoryPool = memoryPool.getModeMemoryPool();
if (!modeMemoryPool) {
return occaUndefined;
Expand Down Expand Up @@ -386,13 +386,13 @@ namespace occa {
return occa::memory((occa::modeMemory_t*) value.value.ptr);
}

occa::experimental::memoryPool memoryPool(occaType value) {
occa::memoryPool memoryPool(occaType value) {
if (occaIsUndefined(value)) {
return occa::experimental::memoryPool();
return occa::memoryPool();
}
OCCA_ERROR("Input is not an occaMemoryPool",
value.type == typeType::memoryPool);
return occa::experimental::memoryPool((occa::modeMemoryPool_t*) value.value.ptr);
return occa::memoryPool((occa::modeMemoryPool_t*) value.value.ptr);
}

occa::stream stream(occaType value) {
Expand Down Expand Up @@ -981,7 +981,7 @@ void occaPrintTypeInfo(occaType value) {
info["type"] = "memoryPool";
info["value"] = (void*) value.value.ptr;

occa::experimental::memoryPool memPool = occa::c::memoryPool(value);
occa::memoryPool memPool = occa::c::memoryPool(value);

Check warning on line 984 in src/occa/internal/c/types.cpp

View check run for this annotation

Codecov / codecov/patch

src/occa/internal/c/types.cpp#L984

Added line #L984 was not covered by tests
if (memPool.isInitialized()) {
info["mode"] = memPool.mode();
info["props"] = memPool.properties();
Expand Down
4 changes: 2 additions & 2 deletions src/occa/internal/c/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace occa {
occaType newOccaType(occa::device device);
occaType newOccaType(occa::kernel kernel);
occaType newOccaType(occa::memory memory);
occaType newOccaType(occa::experimental::memoryPool memoryPool);
occaType newOccaType(occa::memoryPool memoryPool);
occaType newOccaType(occa::stream stream);
occaType newOccaType(occa::streamTag streamTag);

Expand All @@ -118,7 +118,7 @@ namespace occa {
occa::kernel kernel(occaType value);
occa::kernelBuilder kernelBuilder(occaType value);
occa::memory memory(occaType value);
occa::experimental::memoryPool memoryPool(occaType value);
occa::memoryPool memoryPool(occaType value);
occa::stream stream(occaType value);
occa::streamTag streamTag(occaType value);

Expand Down
2 changes: 0 additions & 2 deletions src/occa/internal/core/memoryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace occa {

using experimental::memoryPool;

modeMemoryPool_t::modeMemoryPool_t(modeDevice_t *modeDevice_,
const occa::json &properties_) :
modeBuffer_t(modeDevice_, 0, properties_),
Expand Down
1 change: 0 additions & 1 deletion src/occa/internal/core/memoryPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <set>

namespace occa {
using experimental::memoryPool;

class modeMemoryPool_t : public modeBuffer_t {
public:
Expand Down
1 change: 0 additions & 1 deletion tests/src/c/memoryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <occa.hpp>
#include <occa.h>
#include <occa/c/experimental.h>
#include <occa/internal/c/types.hpp>
#include <occa/internal/utils/testing.hpp>

Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/memoryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void testReserve() {
{"mode", "Serial"}
});

occa::experimental::memoryPool memPool = device.createMemoryPool();
occa::memoryPool memPool = device.createMemoryPool();

/*Set aligment to 5*sizeof(float) bytes*/
memPool.setAlignment(5 * sizeof(float));
Expand Down

0 comments on commit 6390b2d

Please sign in to comment.