Program Listing for File system_resources.hpp
↰ Return to documentation for file (include/holoscan/core/resources/gxf/system_resources.hpp
)
/*
* SPDX-FileCopyrightText: Copyright (c) 2024-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_RESOURCES_GXF_SYSTEM_RESOURCES_HPP
#define HOLOSCAN_CORE_RESOURCES_GXF_SYSTEM_RESOURCES_HPP
#include <yaml-cpp/yaml.h>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include <gxf/std/resources.hpp>
#include "../../component_spec.hpp"
#include "../../gxf/entity_group.hpp"
#include "../../gxf/gxf_resource.hpp"
#include "../../operator.hpp"
namespace holoscan {
class ThreadPool : public gxf::GXFSystemResourceBase {
public:
HOLOSCAN_RESOURCE_FORWARD_ARGS_SUPER(ThreadPool, gxf::GXFSystemResourceBase)
ThreadPool() = default;
ThreadPool(const std::string& name, nvidia::gxf::ThreadPool* component);
const char* gxf_typename() const override { return "nvidia::gxf::ThreadPool"; }
void setup(ComponentSpec& spec) override;
int64_t size() const;
void add(const std::shared_ptr<Operator>& op, bool pin_operator = true);
void add(std::vector<std::shared_ptr<Operator>> ops, bool pin_operator = true);
// The entity group that this thread pool is associated with.
std::shared_ptr<gxf::EntityGroup> entity_group() const { return entity_group_; }
std::vector<std::shared_ptr<Operator>> operators() const { return operators_; }
YAML::Node to_yaml_node() const override;
protected:
friend class Fragment; // allow Fragment::make_thread_pool to set entity_group_
void entity_group(const std::shared_ptr<gxf::EntityGroup>& entity_group) {
entity_group_ = entity_group;
}
private:
Parameter<int64_t> initial_size_;
// Note: The GXF priority parameter is not currently functional, so we don't expose it here.
// Parameter<int64_t> priority_; ///< priority of the thread pool (0=low, 1=medium, 2=high)
std::shared_ptr<gxf::EntityGroup> entity_group_;
std::vector<std::shared_ptr<Operator>> operators_;
};
class GPUDevice : public gxf::GXFSystemResourceBase {
public:
HOLOSCAN_RESOURCE_FORWARD_ARGS_SUPER(GPUDevice, gxf::GXFSystemResourceBase)
GPUDevice() = default;
GPUDevice(const std::string& name, nvidia::gxf::GPUDevice* component);
const char* gxf_typename() const override { return "nvidia::gxf::GPUDevice"; }
void setup(ComponentSpec& spec) override;
int32_t device_id() const;
private:
Parameter<int32_t> dev_id_;
};
} // namespace holoscan
#endif/* HOLOSCAN_CORE_RESOURCES_GXF_SYSTEM_RESOURCES_HPP */