================================================================================================
| 83 | |
| 84 | // ================================================================================================ |
| 85 | hipError_t hipMallocAsync(void** dev_ptr, size_t size, hipStream_t stream) { |
| 86 | HIP_INIT_API(hipMallocAsync, dev_ptr, size, stream); |
| 87 | if (dev_ptr == nullptr) { |
| 88 | HIP_RETURN(hipErrorInvalidValue); |
| 89 | } |
| 90 | getStreamPerThread(stream); |
| 91 | if (size == 0) { |
| 92 | *dev_ptr = nullptr; |
| 93 | HIP_RETURN(hipSuccess); |
| 94 | } |
| 95 | hip::Stream* s = reinterpret_cast<hip::Stream*>(stream); |
| 96 | auto hip_stream = |
| 97 | (stream == nullptr || stream == hipStreamLegacy) ? hip::getCurrentDevice()->NullStream() : s; |
| 98 | auto device = hip_stream->GetDevice(); |
| 99 | auto mem_pool = device->GetCurrentMemoryPool(); |
| 100 | |
| 101 | // Return error if any stream other than the current stream is in capture mode |
| 102 | if (device->StreamCaptureBlocking()) { |
| 103 | if (s->GetCaptureStatus() != hipStreamCaptureStatusActive) { |
| 104 | return hipErrorStreamCaptureUnsupported; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | STREAM_CAPTURE(hipMallocAsync, stream, reinterpret_cast<hipMemPool_t>(mem_pool), size, dev_ptr); |
| 109 | |
| 110 | *dev_ptr = mem_pool->AllocateMemory(size, hip_stream); |
| 111 | if (*dev_ptr == nullptr) { |
| 112 | HIP_RETURN(hipErrorOutOfMemory); |
| 113 | } |
| 114 | HIP_RETURN(hipSuccess); |
| 115 | } |
| 116 | |
| 117 | // ================================================================================================ |
| 118 | // @note: Runtime needs the new command for MT path, since the app can execute hipFreeAsync() |
nothing calls this directly
no test coverage detected