Skip to content
Merged
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
14 changes: 10 additions & 4 deletions include/af/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,14 @@ namespace af
AFAPI void deviceGC();
/// @}

/// \brief Set the resolution of memory chunks
/// \brief Set the resolution of memory chunks. Works only with the default
/// memory manager - throws if a custom memory manager is set.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

///
/// \ingroup device_func_mem
AFAPI void setMemStepSize(const size_t size);

/// \brief Get the resolution of memory chunks
/// \brief Get the resolution of memory chunks. Works only with the default
/// memory manager - throws if a custom memory manager is set.
///
/// \ingroup device_func_mem
AFAPI size_t getMemStepSize();
Expand Down Expand Up @@ -395,13 +397,17 @@ extern "C" {
AFAPI af_err af_device_gc();

/**
Set the minimum memory chunk size
Set the minimum memory chunk size. Works only with the default
memory manager - returns an error if a custom memory manager is set.

\ingroup device_func_mem
*/
AFAPI af_err af_set_mem_step_size(const size_t step_bytes);

/**
Get the minimum memory chunk size
Get the minimum memory chunk size. Works only with the default
memory manager - returns an error if a custom memory manager is set.

\ingroup device_func_mem
*/
AFAPI af_err af_get_mem_step_size(size_t *step_bytes);
Expand Down
8 changes: 2 additions & 6 deletions test/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <gtest/gtest.h>
#include <testHelpers.hpp>
#include <af/dim4.hpp>
#include <af/event.h>
#include <af/internal.h>
#include <af/memory.h>
#include <af/traits.hpp>
Expand Down Expand Up @@ -711,9 +710,6 @@ af_err unlock_fn(af_memory_manager manager, void *ptr, int userLock) {

af_err user_unlock_fn(af_memory_manager manager, void *ptr) {
auto *payload = getMemoryManagerPayload<E2ETestPayload>(manager);
af_event event;
af_create_event(&event);
af_mark_event(event);
af_err err = unlock_fn(manager, ptr, /* user */ 1);
payload->lockedBytes -= payload->table[ptr];
return err;
Expand Down Expand Up @@ -746,7 +742,7 @@ af_err print_info_fn(af_memory_manager manager, char *c, int b) {

af_err get_memory_pressure_fn(af_memory_manager manager, float *out) {
auto *payload = getMemoryManagerPayload<E2ETestPayload>(manager);
if (payload->totalBytes > payload->maxBytes ||
if (payload->lockedBytes > payload->maxBytes ||
payload->totalBuffers > payload->maxBuffers) {
*out = 1.0;
} else {
Expand All @@ -773,7 +769,7 @@ af_err alloc_fn(af_memory_manager manager, void **ptr,
get_memory_pressure_fn(manager, &pressure);
float threshold;
af_memory_manager_get_memory_pressure_threshold(manager, &threshold);
if (pressure > threshold) { signal_memory_cleanup_fn(manager); }
if (pressure >= threshold) { signal_memory_cleanup_fn(manager); }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file basically reflect the change in #2801 Is that correct ?

af_memory_manager_native_alloc(manager, ptr, size);

Expand Down