Skip to content

Commit

Permalink
fixup streammemoryresourceadaptor
Browse files Browse the repository at this point in the history
  • Loading branch information
wdeconinck committed Nov 19, 2024
1 parent d118e95 commit d318673
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pluto/src/pluto/memory_resource/StreamMemoryResourceAdaptor.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* (C) Copyright 2024- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation
* nor does it submit to any jurisdiction.
*/

#include "StreamMemoryResourceAdaptor.h"

#include "pluto/offload/Stream.h"

namespace pluto {

void* StreamMemoryResourceAdaptor::do_allocate(std::size_t bytes, std::size_t alignment) {
if (async_mr_) {
return async_mr_->allocate_async(bytes, alignment, get_current_stream());
}
else {
return mr_->allocate(bytes, alignment);
}
}

void StreamMemoryResourceAdaptor::do_deallocate(void* p, std::size_t bytes, std::size_t alignment) {
if (async_mr_) {
async_mr_->deallocate_async(p, bytes, alignment, get_current_stream());
}
else {
mr_->deallocate(p, bytes, alignment);
}
}

}

0 comments on commit d318673

Please sign in to comment.