Program Listing for File Requirements.h

Return to documentation for file (nvcv_types/include/nvcv/alloc/Requirements.h)

/*
 * SPDX-FileCopyrightText: Copyright (c) 2022 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 NVCV_REQUIREMENTS_H
#define NVCV_REQUIREMENTS_H

#include "../Status.h"

#include <stdint.h>

#ifdef __cplusplus
extern "C"
{
#endif

#define NVCV_MAX_MEM_REQUIREMENTS_LOG2_BLOCK_SIZE (32)

#define NVCV_MAX_MEM_REQUIREMENTS_BLOCK_SIZE (((int64_t)1) << NVCV_MAX_MEM_REQUIREMENTS_LOG2_BLOCK_SIZE)

typedef struct NVCVMemRequirementsRec
{
    int64_t numBlocks[NVCV_MAX_MEM_REQUIREMENTS_LOG2_BLOCK_SIZE];
} NVCVMemRequirements;

typedef struct NVCVRequirementsRec
{
    NVCVMemRequirements cudaMem;       /*< Device memory */
    NVCVMemRequirements hostMem;       /*< Host memory */
    NVCVMemRequirements hostPinnedMem; /*< Host-pinned memory */
} NVCVRequirements;

NVCV_PUBLIC NVCVStatus nvcvRequirementsInit(NVCVRequirements *req);

NVCV_PUBLIC NVCVStatus nvcvRequirementsAdd(NVCVRequirements *reqSum, const NVCVRequirements *req);

NVCV_PUBLIC NVCVStatus nvcvMemRequirementsCalcTotalSizeBytes(const NVCVMemRequirements *memReq, int64_t *sizeBytes);

NVCV_PUBLIC NVCVStatus nvcvMemRequirementsAddBuffer(NVCVMemRequirements *memReq, int64_t bufSize, int64_t bufAlignment);

#ifdef __cplusplus
}
#endif

#endif // NVCV_REQUIREMENTS_H