Program Listing for File gpu_resident_deck.hpp
↰ Return to documentation for file (include/holoscan/core/executors/gpu_resident/gpu_resident_deck.hpp)
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HOLOSCAN_CORE_EXECUTORS_GPU_RESIDENT_GPU_RESIDENT_DECK_HPP
#define HOLOSCAN_CORE_EXECUTORS_GPU_RESIDENT_GPU_RESIDENT_DECK_HPP
#include <cuda_runtime.h>
#include <atomic>
#include <future>
#include <memory>
#include "holoscan/utils/cuda/buffer.hpp"
namespace holoscan {
class GPUResidentDeck {
public:
GPUResidentDeck();
~GPUResidentDeck();
std::future<void> launch_cuda_graph(cudaGraphExec_t graph);
void* data_ready_device_address() { return cpu_data_ready_trigger_->device_data(); }
void* result_ready_device_address() { return cpu_result_ready_trigger_->device_data(); }
void* tear_down_device_address() { return cpu_tear_down_trigger_->device_data(); }
void timeout_ms(unsigned long long timeout_ms) { timeout_ms_ = timeout_ms; }
bool result_ready();
void tear_down();
void set_data_ready();
bool is_launched() const;
private:
std::shared_ptr<holoscan::utils::cuda::CudaHostMappedBuffer> cpu_data_ready_trigger_;
std::shared_ptr<holoscan::utils::cuda::CudaHostMappedBuffer> cpu_result_ready_trigger_;
std::shared_ptr<holoscan::utils::cuda::CudaHostMappedBuffer> cpu_tear_down_trigger_;
cudaStream_t execution_stream_;
cudaStream_t status_stream_;
unsigned long long timeout_ms_ = 0;
std::atomic<bool> graph_launched_{false};
};
} // namespace holoscan
#endif// HOLOSCAN_CORE_EXECUTORS_GPU_RESIDENT_GPU_RESIDENT_DECK_HPP