2020-02-04 08:45:01 -08:00
|
|
|
/* Copyright (c) 2015-present Advanced Micro Devices, Inc.
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2020-02-04 08:45:01 -08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2020-02-04 08:45:01 -08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2020-02-04 08:45:01 -08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
THE SOFTWARE. */
|
2018-03-02 17:55:48 -05:00
|
|
|
|
|
|
|
|
#include <hip/hip_runtime.h>
|
|
|
|
|
#include "hip_internal.hpp"
|
2018-05-15 16:26:16 -04:00
|
|
|
#include "hip_event.hpp"
|
2018-05-11 11:34:01 -04:00
|
|
|
#include "thread/monitor.hpp"
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2020-05-11 16:35:13 -07:00
|
|
|
static amd::Monitor streamSetLock{"Guards global stream set"};
|
2019-08-09 20:41:13 -04:00
|
|
|
static std::unordered_set<hip::Stream*> streamSet;
|
2018-05-11 11:34:01 -04:00
|
|
|
|
2018-10-24 18:00:42 -04:00
|
|
|
// Internal structure for stream callback handler
|
|
|
|
|
class StreamCallback {
|
|
|
|
|
public:
|
|
|
|
|
StreamCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData,
|
|
|
|
|
amd::Command* command)
|
|
|
|
|
: stream_(stream), callBack_(callback),
|
|
|
|
|
userData_(userData), command_(command) {
|
|
|
|
|
};
|
|
|
|
|
hipStream_t stream_;
|
|
|
|
|
hipStreamCallback_t callBack_;
|
|
|
|
|
void* userData_;
|
|
|
|
|
amd::Command* command_;
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-11 11:34:01 -04:00
|
|
|
namespace hip {
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2020-04-23 16:54:48 -04:00
|
|
|
Stream::Stream(hip::Device* dev, amd::CommandQueue::Priority p,
|
2020-05-15 18:08:26 -04:00
|
|
|
unsigned int f, bool null_stream, const std::vector<uint32_t>& cuMask)
|
2020-04-23 16:54:48 -04:00
|
|
|
: queue_(nullptr), lock_("Stream Callback lock"), device_(dev),
|
2020-05-15 18:08:26 -04:00
|
|
|
priority_(p), flags_(f), null_(null_stream), cuMask_(cuMask) {}
|
2019-08-09 20:41:13 -04:00
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
|
|
|
|
bool Stream::Create() {
|
2019-08-09 20:41:13 -04:00
|
|
|
cl_command_queue_properties properties = CL_QUEUE_PROFILING_ENABLE;
|
2020-04-23 16:54:48 -04:00
|
|
|
queue_ = new amd::HostQueue(*device_->asContext(), *device_->devices()[0], properties,
|
2020-05-15 18:08:26 -04:00
|
|
|
amd::CommandQueue::RealTimeDisabled, priority_, cuMask_);
|
2020-04-29 02:11:37 -04:00
|
|
|
// Create a host queue
|
|
|
|
|
bool result = (queue_ != nullptr) ? queue_->create() : false;
|
|
|
|
|
// Insert just created stream into the list of the blocking queues
|
|
|
|
|
if (result) {
|
2020-05-26 12:54:27 -07:00
|
|
|
amd::ScopedLock lock(streamSetLock);
|
|
|
|
|
streamSet.insert(this);
|
2020-04-29 02:11:37 -04:00
|
|
|
} else {
|
|
|
|
|
Destroy();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2019-08-09 20:41:13 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2020-05-01 09:22:31 -04:00
|
|
|
amd::HostQueue* Stream::asHostQueue(bool skip_alloc) {
|
2020-04-29 02:11:37 -04:00
|
|
|
// Access to the stream object is lock protected, because possible allocation
|
|
|
|
|
amd::ScopedLock l(Lock());
|
2020-04-23 16:54:48 -04:00
|
|
|
if (queue_ == nullptr) {
|
2020-04-29 02:11:37 -04:00
|
|
|
// Create the host queue for the first time
|
2020-05-01 09:22:31 -04:00
|
|
|
if (!skip_alloc) {
|
|
|
|
|
Create();
|
2020-04-23 16:54:48 -04:00
|
|
|
}
|
2019-08-09 20:41:13 -04:00
|
|
|
}
|
2020-04-23 16:54:48 -04:00
|
|
|
return queue_;
|
2019-08-09 20:41:13 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
|
|
|
|
void Stream::Destroy() {
|
2020-04-23 16:54:48 -04:00
|
|
|
if (queue_ != nullptr) {
|
2020-04-29 02:11:37 -04:00
|
|
|
amd::ScopedLock lock(streamSetLock);
|
|
|
|
|
streamSet.erase(this);
|
2020-05-11 16:35:13 -07:00
|
|
|
|
|
|
|
|
queue_->release();
|
|
|
|
|
queue_ = nullptr;
|
2019-08-09 20:41:13 -04:00
|
|
|
}
|
2020-04-29 02:11:37 -04:00
|
|
|
delete this;
|
2019-08-09 20:41:13 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
|
|
|
|
void Stream::Finish() const {
|
2020-04-23 16:54:48 -04:00
|
|
|
if (queue_ != nullptr) {
|
|
|
|
|
queue_->finish();
|
2019-08-09 20:41:13 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2020-04-23 16:54:48 -04:00
|
|
|
int Stream::DeviceId() const {
|
|
|
|
|
return device_->deviceId();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-26 12:54:27 -07:00
|
|
|
void Stream::syncNonBlockingStreams() {
|
|
|
|
|
amd::ScopedLock lock(streamSetLock);
|
|
|
|
|
for (auto& it : streamSet) {
|
|
|
|
|
if (it->Flags() & hipStreamNonBlocking) {
|
|
|
|
|
it->asHostQueue()->finish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-11 11:34:01 -04:00
|
|
|
};
|
2018-03-30 01:06:00 -04:00
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2020-04-23 16:54:48 -04:00
|
|
|
void iHipWaitActiveStreams(amd::HostQueue* blocking_queue, bool wait_null_stream) {
|
2020-04-17 10:42:46 -04:00
|
|
|
amd::Command::EventWaitList eventWaitList;
|
|
|
|
|
{
|
|
|
|
|
amd::ScopedLock lock(streamSetLock);
|
|
|
|
|
|
2020-04-23 16:54:48 -04:00
|
|
|
for (const auto& stream : streamSet) {
|
|
|
|
|
amd::HostQueue* active_queue = stream->asHostQueue();
|
2020-04-17 10:42:46 -04:00
|
|
|
// If it's the current device
|
2020-04-29 02:11:37 -04:00
|
|
|
if ((&active_queue->device() == &blocking_queue->device()) &&
|
2020-05-26 12:54:27 -07:00
|
|
|
// Make sure it's a default stream
|
|
|
|
|
((stream->Flags() & hipStreamNonBlocking) == 0) &&
|
2020-04-17 10:42:46 -04:00
|
|
|
// and it's not the current stream
|
2020-04-23 16:54:48 -04:00
|
|
|
(active_queue != blocking_queue) &&
|
|
|
|
|
// check for a wait on the null stream
|
|
|
|
|
(stream->Null() == wait_null_stream)) {
|
2020-04-29 02:11:37 -04:00
|
|
|
// Get the last valid command
|
2020-04-23 16:54:48 -04:00
|
|
|
amd::Command* command = active_queue->getLastQueuedCommand(true);
|
2020-04-17 10:42:46 -04:00
|
|
|
if ((command != nullptr) &&
|
2020-04-23 16:54:48 -04:00
|
|
|
// Check the current active status
|
2020-04-17 10:42:46 -04:00
|
|
|
(command->status() != CL_COMPLETE)) {
|
|
|
|
|
eventWaitList.push_back(command);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if we have to wait anything
|
|
|
|
|
if (eventWaitList.size() > 0) {
|
|
|
|
|
amd::Command* command = new amd::Marker(*blocking_queue, false, eventWaitList);
|
|
|
|
|
if (command != nullptr) {
|
|
|
|
|
command->enqueue();
|
|
|
|
|
command->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Release all active commands. It's safe after the marker was enqueued
|
|
|
|
|
for (const auto& it : eventWaitList) {
|
|
|
|
|
it->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2019-03-20 12:24:45 -04:00
|
|
|
void CL_CALLBACK ihipStreamCallback(cl_event event, cl_int command_exec_status, void* user_data) {
|
2018-10-24 18:00:42 -04:00
|
|
|
hipError_t status = hipSuccess;
|
|
|
|
|
StreamCallback* cbo = reinterpret_cast<StreamCallback*>(user_data);
|
2020-03-20 13:06:11 -07:00
|
|
|
{
|
2020-04-23 16:54:48 -04:00
|
|
|
amd::ScopedLock lock(reinterpret_cast<hip::Stream*>(cbo->stream_)->Lock());
|
2020-03-20 13:06:11 -07:00
|
|
|
cbo->callBack_(cbo->stream_, status, cbo->userData_);
|
|
|
|
|
}
|
2018-10-24 18:00:42 -04:00
|
|
|
cbo->command_->release();
|
|
|
|
|
delete cbo;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
|
|
|
|
static hipError_t ihipStreamCreate(hipStream_t* stream,
|
2020-05-15 18:08:26 -04:00
|
|
|
unsigned int flags, amd::CommandQueue::Priority priority,
|
|
|
|
|
const std::vector<uint32_t>& cuMask = {}) {
|
|
|
|
|
hip::Stream* hStream = new hip::Stream(hip::getCurrentDevice(), priority, flags, false, cuMask);
|
2018-03-30 01:06:00 -04:00
|
|
|
|
2019-08-09 20:41:13 -04:00
|
|
|
if (hStream == nullptr) {
|
2018-05-09 18:15:41 -04:00
|
|
|
return hipErrorOutOfMemory;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-09 20:41:13 -04:00
|
|
|
*stream = reinterpret_cast<hipStream_t>(hStream);
|
2018-03-30 01:06:00 -04:00
|
|
|
|
2019-11-04 14:44:59 -05:00
|
|
|
ClPrint(amd::LOG_INFO, amd::LOG_API, "ihipStreamCreate: %zx", hStream);
|
2019-08-27 20:26:25 -04:00
|
|
|
|
2018-03-30 01:06:00 -04:00
|
|
|
return hipSuccess;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2018-04-05 15:02:43 -04:00
|
|
|
hipError_t hipStreamCreateWithFlags(hipStream_t *stream, unsigned int flags) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamCreateWithFlags, stream, flags);
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2019-05-01 18:43:47 -04:00
|
|
|
HIP_RETURN(ihipStreamCreate(stream, flags, amd::CommandQueue::Priority::Normal));
|
2018-03-02 17:55:48 -05:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2018-04-05 15:02:43 -04:00
|
|
|
hipError_t hipStreamCreate(hipStream_t *stream) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamCreate, stream);
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2019-05-01 18:43:47 -04:00
|
|
|
HIP_RETURN(ihipStreamCreate(stream, hipStreamDefault, amd::CommandQueue::Priority::Normal));
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2019-05-01 18:43:47 -04:00
|
|
|
hipError_t hipStreamCreateWithPriority(hipStream_t* stream, unsigned int flags, int priority) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamCreateWithPriority, stream, flags, priority);
|
2019-05-01 18:43:47 -04:00
|
|
|
|
|
|
|
|
if (priority > static_cast<int>(amd::CommandQueue::Priority::High)) {
|
|
|
|
|
priority = static_cast<int>(amd::CommandQueue::Priority::High);
|
|
|
|
|
} else if (priority < static_cast<int>(amd::CommandQueue::Priority::Normal)) {
|
|
|
|
|
priority = static_cast<int>(amd::CommandQueue::Priority::Normal);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-28 20:18:16 -04:00
|
|
|
HIP_RETURN(ihipStreamCreate(stream, flags, static_cast<amd::CommandQueue::Priority>(priority)));
|
2019-05-01 18:43:47 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2019-05-01 18:43:47 -04:00
|
|
|
hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPriority) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipDeviceGetStreamPriorityRange, leastPriority, greatestPriority);
|
2019-05-01 18:43:47 -04:00
|
|
|
|
|
|
|
|
if (leastPriority != nullptr) {
|
|
|
|
|
*leastPriority = static_cast<int>(amd::CommandQueue::Priority::Normal);
|
|
|
|
|
}
|
|
|
|
|
if (greatestPriority != nullptr) {
|
|
|
|
|
// Only report one kind of priority for now.
|
|
|
|
|
*greatestPriority = static_cast<int>(amd::CommandQueue::Priority::Normal);
|
|
|
|
|
}
|
2020-05-28 20:18:16 -04:00
|
|
|
HIP_RETURN(hipSuccess);
|
2018-03-02 17:55:48 -05:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2020-04-23 16:54:48 -04:00
|
|
|
hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int* flags) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamGetFlags, stream, flags);
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
if ((flags != nullptr) && (stream != nullptr)) {
|
|
|
|
|
*flags = reinterpret_cast<hip::Stream*>(stream)->Flags();
|
2018-05-08 19:04:35 -04:00
|
|
|
} else {
|
2018-08-14 18:54:13 -04:00
|
|
|
HIP_RETURN(hipErrorInvalidValue);
|
2018-05-08 19:04:35 -04:00
|
|
|
}
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2018-08-14 18:54:13 -04:00
|
|
|
HIP_RETURN(hipSuccess);
|
2018-05-08 19:04:35 -04:00
|
|
|
}
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2018-04-05 15:02:43 -04:00
|
|
|
hipError_t hipStreamSynchronize(hipStream_t stream) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamSynchronize, stream);
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// Wait for the current host queue
|
|
|
|
|
hip::getQueue(stream)->finish();
|
2018-05-01 18:10:09 -04:00
|
|
|
|
2018-08-14 18:54:13 -04:00
|
|
|
HIP_RETURN(hipSuccess);
|
2018-03-02 17:55:48 -05:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2018-04-05 15:02:43 -04:00
|
|
|
hipError_t hipStreamDestroy(hipStream_t stream) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamDestroy, stream);
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2018-05-01 18:10:09 -04:00
|
|
|
if (stream == nullptr) {
|
2019-12-30 16:46:39 -05:00
|
|
|
HIP_RETURN(hipErrorInvalidHandle);
|
2018-05-01 18:10:09 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
reinterpret_cast<hip::Stream*>(stream)->Destroy();
|
2018-03-02 17:55:48 -05:00
|
|
|
|
2018-08-14 18:54:13 -04:00
|
|
|
HIP_RETURN(hipSuccess);
|
2018-03-02 17:55:48 -05:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2018-04-05 15:02:43 -04:00
|
|
|
hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamWaitEvent, stream, event, flags);
|
2018-04-05 15:02:43 -04:00
|
|
|
|
2019-05-28 19:06:58 -04:00
|
|
|
if (event == nullptr) {
|
2019-12-30 16:46:39 -05:00
|
|
|
HIP_RETURN(hipErrorInvalidHandle);
|
2018-05-15 16:26:16 -04:00
|
|
|
}
|
2018-04-05 15:02:43 -04:00
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
amd::HostQueue* queue = hip::getQueue(stream);
|
|
|
|
|
|
2018-05-15 16:26:16 -04:00
|
|
|
hip::Event* e = reinterpret_cast<hip::Event*>(event);
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
HIP_RETURN(e->streamWait(queue, flags));
|
2018-04-05 15:02:43 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2018-04-05 15:02:43 -04:00
|
|
|
hipError_t hipStreamQuery(hipStream_t stream) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamQuery, stream);
|
2018-04-05 15:02:43 -04:00
|
|
|
|
2020-04-23 16:54:48 -04:00
|
|
|
amd::HostQueue* hostQueue = hip::getQueue(stream);
|
2019-07-24 12:05:47 -04:00
|
|
|
|
2020-02-24 13:28:08 -08:00
|
|
|
amd::Command* command = hostQueue->getLastQueuedCommand(true);
|
2019-07-24 12:05:47 -04:00
|
|
|
if (command == nullptr) {
|
2020-04-29 02:11:37 -04:00
|
|
|
// Nothing was submitted to the queue
|
2019-07-24 12:05:47 -04:00
|
|
|
HIP_RETURN(hipSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
amd::Event& event = command->event();
|
2019-08-12 19:16:30 -04:00
|
|
|
if (command->type() != 0) {
|
2019-07-24 12:05:47 -04:00
|
|
|
event.notifyCmdQueue();
|
|
|
|
|
}
|
2020-02-24 13:28:08 -08:00
|
|
|
hipError_t status = (command->status() == CL_COMPLETE) ? hipSuccess : hipErrorNotReady;
|
|
|
|
|
command->release();
|
|
|
|
|
HIP_RETURN(status);
|
2018-04-05 15:02:43 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
// ================================================================================================
|
2018-04-05 15:02:43 -04:00
|
|
|
hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData,
|
|
|
|
|
unsigned int flags) {
|
2019-10-07 11:55:30 -04:00
|
|
|
HIP_INIT_API(hipStreamAddCallback, stream, callback, userData, flags);
|
2018-04-05 15:02:43 -04:00
|
|
|
|
2020-04-29 02:11:37 -04:00
|
|
|
amd::HostQueue* hostQueue = hip::getQueue(stream);
|
2018-10-24 18:00:42 -04:00
|
|
|
amd::Command* command = hostQueue->getLastQueuedCommand(true);
|
2020-03-19 11:11:59 -07:00
|
|
|
if (command == nullptr) {
|
|
|
|
|
amd::Command::EventWaitList eventWaitList;
|
|
|
|
|
command = new amd::Marker(*hostQueue, false, eventWaitList);
|
|
|
|
|
command->enqueue();
|
|
|
|
|
}
|
2018-10-24 18:00:42 -04:00
|
|
|
amd::Event& event = command->event();
|
|
|
|
|
StreamCallback* cbo = new StreamCallback(stream, callback, userData, command);
|
|
|
|
|
|
|
|
|
|
if(!event.setCallback(CL_COMPLETE, ihipStreamCallback, reinterpret_cast<void*>(cbo))) {
|
|
|
|
|
command->release();
|
2019-12-30 16:46:39 -05:00
|
|
|
return hipErrorInvalidHandle;
|
2018-10-24 18:00:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event.notifyCmdQueue();
|
2018-04-05 15:02:43 -04:00
|
|
|
|
2018-09-06 15:21:28 -04:00
|
|
|
HIP_RETURN(hipSuccess);
|
2018-04-05 15:02:43 -04:00
|
|
|
}
|
2020-05-15 18:08:26 -04:00
|
|
|
|
|
|
|
|
// ================================================================================================
|
|
|
|
|
hipError_t hipExtStreamCreateWithCUMask(hipStream_t* stream, uint32_t cuMaskSize,
|
|
|
|
|
const uint32_t* cuMask) {
|
|
|
|
|
HIP_INIT_API(hipExtStreamCreateWithCUMask, stream, cuMaskSize, cuMask);
|
|
|
|
|
|
|
|
|
|
if (stream == nullptr) {
|
|
|
|
|
HIP_RETURN(hipErrorInvalidHandle);
|
|
|
|
|
}
|
|
|
|
|
if (cuMaskSize == 0 || cuMask == nullptr) {
|
|
|
|
|
HIP_RETURN(hipErrorInvalidValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::vector<uint32_t> cuMaskv(cuMask, cuMask + cuMaskSize);
|
|
|
|
|
|
|
|
|
|
HIP_RETURN(ihipStreamCreate(stream, hipStreamDefault, amd::CommandQueue::Priority::Normal, cuMaskv));
|
|
|
|
|
}
|
|
|
|
|
|