-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d118e95
commit d318673
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
pluto/src/pluto/memory_resource/StreamMemoryResourceAdaptor.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} |