Instructions to use fuuuzzy/F5-TTS-pt-br with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- F5-TTS
How to use fuuuzzy/F5-TTS-pt-br with F5-TTS:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .venv/lib/python3.11/site-packages/certifi/__pycache__/core.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/certifi/cacert.pem +0 -0
- .venv/lib/python3.11/site-packages/certifi/core.py +83 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/__init__.py +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/__init__.py +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/builtin_types.h +64 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/channel_descriptor.h +597 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/common_functions.h +65 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cooperative_groups.h +1743 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cooperative_groups/details/async.h +452 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cooperative_groups/memcpy_async.h +62 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cooperative_groups/reduce.h +63 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuComplex.h +348 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda.h +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaEGL.h +662 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaEGLTypedefs.h +96 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaGL.h +608 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaGLTypedefs.h +123 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaProfilerTypedefs.h +78 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaTypedefs.h +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaVDPAU.h +282 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaVDPAUTypedefs.h +90 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_awbarrier.h +280 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_awbarrier_helpers.h +365 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_awbarrier_primitives.h +109 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_bf16.h +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_bf16.hpp +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_device_runtime_api.h +914 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_egl_interop.h +645 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp16.h +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp16.hpp +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp4.h +357 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp4.hpp +953 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp6.h +362 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp6.hpp +1549 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp8.h +475 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp8.hpp +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_gl_interop.h +514 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_occupancy.h +2094 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_pipeline.h +224 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_pipeline_helpers.h +373 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_pipeline_primitives.h +148 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_runtime.h +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_runtime_api.h +0 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_surface_types.h +76 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_texture_types.h +76 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_vdpau_interop.h +201 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudart_platform.h +57 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/device_atomic_functions.h +193 -0
- .venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/device_atomic_functions.hpp +254 -0
.venv/lib/python3.11/site-packages/certifi/__pycache__/core.cpython-311.pyc
ADDED
|
Binary file (2.39 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/certifi/cacert.pem
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.11/site-packages/certifi/core.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
certifi.py
|
| 3 |
+
~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
This module returns the installation location of cacert.pem or its contents.
|
| 6 |
+
"""
|
| 7 |
+
import sys
|
| 8 |
+
import atexit
|
| 9 |
+
|
| 10 |
+
def exit_cacert_ctx() -> None:
|
| 11 |
+
_CACERT_CTX.__exit__(None, None, None) # type: ignore[union-attr]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
if sys.version_info >= (3, 11):
|
| 15 |
+
|
| 16 |
+
from importlib.resources import as_file, files
|
| 17 |
+
|
| 18 |
+
_CACERT_CTX = None
|
| 19 |
+
_CACERT_PATH = None
|
| 20 |
+
|
| 21 |
+
def where() -> str:
|
| 22 |
+
# This is slightly terrible, but we want to delay extracting the file
|
| 23 |
+
# in cases where we're inside of a zipimport situation until someone
|
| 24 |
+
# actually calls where(), but we don't want to re-extract the file
|
| 25 |
+
# on every call of where(), so we'll do it once then store it in a
|
| 26 |
+
# global variable.
|
| 27 |
+
global _CACERT_CTX
|
| 28 |
+
global _CACERT_PATH
|
| 29 |
+
if _CACERT_PATH is None:
|
| 30 |
+
# This is slightly janky, the importlib.resources API wants you to
|
| 31 |
+
# manage the cleanup of this file, so it doesn't actually return a
|
| 32 |
+
# path, it returns a context manager that will give you the path
|
| 33 |
+
# when you enter it and will do any cleanup when you leave it. In
|
| 34 |
+
# the common case of not needing a temporary file, it will just
|
| 35 |
+
# return the file system location and the __exit__() is a no-op.
|
| 36 |
+
#
|
| 37 |
+
# We also have to hold onto the actual context manager, because
|
| 38 |
+
# it will do the cleanup whenever it gets garbage collected, so
|
| 39 |
+
# we will also store that at the global level as well.
|
| 40 |
+
_CACERT_CTX = as_file(files("certifi").joinpath("cacert.pem"))
|
| 41 |
+
_CACERT_PATH = str(_CACERT_CTX.__enter__())
|
| 42 |
+
atexit.register(exit_cacert_ctx)
|
| 43 |
+
|
| 44 |
+
return _CACERT_PATH
|
| 45 |
+
|
| 46 |
+
def contents() -> str:
|
| 47 |
+
return files("certifi").joinpath("cacert.pem").read_text(encoding="ascii")
|
| 48 |
+
|
| 49 |
+
else:
|
| 50 |
+
|
| 51 |
+
from importlib.resources import path as get_path, read_text
|
| 52 |
+
|
| 53 |
+
_CACERT_CTX = None
|
| 54 |
+
_CACERT_PATH = None
|
| 55 |
+
|
| 56 |
+
def where() -> str:
|
| 57 |
+
# This is slightly terrible, but we want to delay extracting the
|
| 58 |
+
# file in cases where we're inside of a zipimport situation until
|
| 59 |
+
# someone actually calls where(), but we don't want to re-extract
|
| 60 |
+
# the file on every call of where(), so we'll do it once then store
|
| 61 |
+
# it in a global variable.
|
| 62 |
+
global _CACERT_CTX
|
| 63 |
+
global _CACERT_PATH
|
| 64 |
+
if _CACERT_PATH is None:
|
| 65 |
+
# This is slightly janky, the importlib.resources API wants you
|
| 66 |
+
# to manage the cleanup of this file, so it doesn't actually
|
| 67 |
+
# return a path, it returns a context manager that will give
|
| 68 |
+
# you the path when you enter it and will do any cleanup when
|
| 69 |
+
# you leave it. In the common case of not needing a temporary
|
| 70 |
+
# file, it will just return the file system location and the
|
| 71 |
+
# __exit__() is a no-op.
|
| 72 |
+
#
|
| 73 |
+
# We also have to hold onto the actual context manager, because
|
| 74 |
+
# it will do the cleanup whenever it gets garbage collected, so
|
| 75 |
+
# we will also store that at the global level as well.
|
| 76 |
+
_CACERT_CTX = get_path("certifi", "cacert.pem")
|
| 77 |
+
_CACERT_PATH = str(_CACERT_CTX.__enter__())
|
| 78 |
+
atexit.register(exit_cacert_ctx)
|
| 79 |
+
|
| 80 |
+
return _CACERT_PATH
|
| 81 |
+
|
| 82 |
+
def contents() -> str:
|
| 83 |
+
return read_text("certifi", "cacert.pem", encoding="ascii")
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/__init__.py
ADDED
|
File without changes
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/__init__.py
ADDED
|
File without changes
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/builtin_types.h
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
/*******************************************************************************
|
| 51 |
+
* *
|
| 52 |
+
* *
|
| 53 |
+
* *
|
| 54 |
+
*******************************************************************************/
|
| 55 |
+
|
| 56 |
+
#include "device_types.h"
|
| 57 |
+
#if !defined(__CUDACC_RTC__)
|
| 58 |
+
#define EXCLUDE_FROM_RTC
|
| 59 |
+
#include "driver_types.h"
|
| 60 |
+
#undef EXCLUDE_FROM_RTC
|
| 61 |
+
#endif /* !__CUDACC_RTC__ */
|
| 62 |
+
#include "surface_types.h"
|
| 63 |
+
#include "texture_types.h"
|
| 64 |
+
#include "vector_types.h"
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/channel_descriptor.h
ADDED
|
@@ -0,0 +1,597 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CHANNEL_DESCRIPTOR_H__)
|
| 51 |
+
#define __CHANNEL_DESCRIPTOR_H__
|
| 52 |
+
|
| 53 |
+
#if defined(__cplusplus)
|
| 54 |
+
|
| 55 |
+
/*******************************************************************************
|
| 56 |
+
* *
|
| 57 |
+
* *
|
| 58 |
+
* *
|
| 59 |
+
*******************************************************************************/
|
| 60 |
+
|
| 61 |
+
#include "cuda_runtime_api.h"
|
| 62 |
+
|
| 63 |
+
/*******************************************************************************
|
| 64 |
+
* *
|
| 65 |
+
* *
|
| 66 |
+
* *
|
| 67 |
+
*******************************************************************************/
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* \addtogroup CUDART_HIGHLEVEL
|
| 71 |
+
*
|
| 72 |
+
* @{
|
| 73 |
+
*/
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* \brief \hl Returns a channel descriptor using the specified format
|
| 77 |
+
*
|
| 78 |
+
* Returns a channel descriptor with format \p f and number of bits of each
|
| 79 |
+
* component \p x, \p y, \p z, and \p w. The ::cudaChannelFormatDesc is
|
| 80 |
+
* defined as:
|
| 81 |
+
* \code
|
| 82 |
+
struct cudaChannelFormatDesc {
|
| 83 |
+
int x, y, z, w;
|
| 84 |
+
enum cudaChannelFormatKind f;
|
| 85 |
+
};
|
| 86 |
+
* \endcode
|
| 87 |
+
*
|
| 88 |
+
* where ::cudaChannelFormatKind is one of ::cudaChannelFormatKindSigned,
|
| 89 |
+
* ::cudaChannelFormatKindUnsigned, cudaChannelFormatKindFloat,
|
| 90 |
+
* ::cudaChannelFormatKindSignedNormalized8X1, ::cudaChannelFormatKindSignedNormalized8X2,
|
| 91 |
+
* ::cudaChannelFormatKindSignedNormalized8X4,
|
| 92 |
+
* ::cudaChannelFormatKindUnsignedNormalized8X1, ::cudaChannelFormatKindUnsignedNormalized8X2,
|
| 93 |
+
* ::cudaChannelFormatKindUnsignedNormalized8X4,
|
| 94 |
+
* ::cudaChannelFormatKindSignedNormalized16X1, ::cudaChannelFormatKindSignedNormalized16X2,
|
| 95 |
+
* ::cudaChannelFormatKindSignedNormalized16X4,
|
| 96 |
+
* ::cudaChannelFormatKindUnsignedNormalized16X1, ::cudaChannelFormatKindUnsignedNormalized16X2,
|
| 97 |
+
* ::cudaChannelFormatKindUnsignedNormalized16X4,
|
| 98 |
+
* ::cudaChannelFormatKindUnsignedNormalized1010102
|
| 99 |
+
* or ::cudaChannelFormatKindNV12.
|
| 100 |
+
*
|
| 101 |
+
* The format is specified by the template specialization.
|
| 102 |
+
*
|
| 103 |
+
* The template function specializes for the following scalar types:
|
| 104 |
+
* char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, and float.
|
| 105 |
+
* The template function specializes for the following vector types:
|
| 106 |
+
* char{1|2|4}, uchar{1|2|4}, short{1|2|4}, ushort{1|2|4}, int{1|2|4}, uint{1|2|4}, long{1|2|4}, ulong{1|2|4}, float{1|2|4}.
|
| 107 |
+
* The template function specializes for following cudaChannelFormatKind enum values:
|
| 108 |
+
* ::cudaChannelFormatKind{Uns|S}ignedNormalized{8|16}X{1|2|4},
|
| 109 |
+
* ::cudaChannelFormatKindUnsignedNormalized1010102
|
| 110 |
+
* and ::cudaChannelFormatKindNV12.
|
| 111 |
+
*
|
| 112 |
+
* Invoking the function on a type without a specialization defaults to creating a channel format of kind ::cudaChannelFormatKindNone
|
| 113 |
+
*
|
| 114 |
+
* \return
|
| 115 |
+
* Channel descriptor with format \p f
|
| 116 |
+
*
|
| 117 |
+
* \sa \ref ::cudaCreateChannelDesc(int,int,int,int,cudaChannelFormatKind) "cudaCreateChannelDesc (Low level)",
|
| 118 |
+
* ::cudaGetChannelDesc,
|
| 119 |
+
*/
|
| 120 |
+
template<class T> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc(void)
|
| 121 |
+
{
|
| 122 |
+
return cudaCreateChannelDesc(0, 0, 0, 0, cudaChannelFormatKindNone);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
static __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDescHalf(void)
|
| 126 |
+
{
|
| 127 |
+
int e = (int)sizeof(unsigned short) * 8;
|
| 128 |
+
|
| 129 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindFloat);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
static __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDescHalf1(void)
|
| 133 |
+
{
|
| 134 |
+
int e = (int)sizeof(unsigned short) * 8;
|
| 135 |
+
|
| 136 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindFloat);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
static __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDescHalf2(void)
|
| 140 |
+
{
|
| 141 |
+
int e = (int)sizeof(unsigned short) * 8;
|
| 142 |
+
|
| 143 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindFloat);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
static __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDescHalf4(void)
|
| 147 |
+
{
|
| 148 |
+
int e = (int)sizeof(unsigned short) * 8;
|
| 149 |
+
|
| 150 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindFloat);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<char>(void)
|
| 154 |
+
{
|
| 155 |
+
int e = (int)sizeof(char) * 8;
|
| 156 |
+
|
| 157 |
+
#if defined(_CHAR_UNSIGNED) || defined(__CHAR_UNSIGNED__)
|
| 158 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 159 |
+
#else /* _CHAR_UNSIGNED || __CHAR_UNSIGNED__ */
|
| 160 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 161 |
+
#endif /* _CHAR_UNSIGNED || __CHAR_UNSIGNED__ */
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<signed char>(void)
|
| 165 |
+
{
|
| 166 |
+
int e = (int)sizeof(signed char) * 8;
|
| 167 |
+
|
| 168 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<unsigned char>(void)
|
| 172 |
+
{
|
| 173 |
+
int e = (int)sizeof(unsigned char) * 8;
|
| 174 |
+
|
| 175 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<char1>(void)
|
| 179 |
+
{
|
| 180 |
+
int e = (int)sizeof(signed char) * 8;
|
| 181 |
+
|
| 182 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<uchar1>(void)
|
| 186 |
+
{
|
| 187 |
+
int e = (int)sizeof(unsigned char) * 8;
|
| 188 |
+
|
| 189 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<char2>(void)
|
| 193 |
+
{
|
| 194 |
+
int e = (int)sizeof(signed char) * 8;
|
| 195 |
+
|
| 196 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindSigned);
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<uchar2>(void)
|
| 200 |
+
{
|
| 201 |
+
int e = (int)sizeof(unsigned char) * 8;
|
| 202 |
+
|
| 203 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindUnsigned);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<char4>(void)
|
| 207 |
+
{
|
| 208 |
+
int e = (int)sizeof(signed char) * 8;
|
| 209 |
+
|
| 210 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindSigned);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<uchar4>(void)
|
| 214 |
+
{
|
| 215 |
+
int e = (int)sizeof(unsigned char) * 8;
|
| 216 |
+
|
| 217 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindUnsigned);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<short>(void)
|
| 221 |
+
{
|
| 222 |
+
int e = (int)sizeof(short) * 8;
|
| 223 |
+
|
| 224 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<unsigned short>(void)
|
| 228 |
+
{
|
| 229 |
+
int e = (int)sizeof(unsigned short) * 8;
|
| 230 |
+
|
| 231 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<short1>(void)
|
| 235 |
+
{
|
| 236 |
+
int e = (int)sizeof(short) * 8;
|
| 237 |
+
|
| 238 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<ushort1>(void)
|
| 242 |
+
{
|
| 243 |
+
int e = (int)sizeof(unsigned short) * 8;
|
| 244 |
+
|
| 245 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<short2>(void)
|
| 249 |
+
{
|
| 250 |
+
int e = (int)sizeof(short) * 8;
|
| 251 |
+
|
| 252 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindSigned);
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<ushort2>(void)
|
| 256 |
+
{
|
| 257 |
+
int e = (int)sizeof(unsigned short) * 8;
|
| 258 |
+
|
| 259 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindUnsigned);
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<short4>(void)
|
| 263 |
+
{
|
| 264 |
+
int e = (int)sizeof(short) * 8;
|
| 265 |
+
|
| 266 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindSigned);
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<ushort4>(void)
|
| 270 |
+
{
|
| 271 |
+
int e = (int)sizeof(unsigned short) * 8;
|
| 272 |
+
|
| 273 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindUnsigned);
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<int>(void)
|
| 277 |
+
{
|
| 278 |
+
int e = (int)sizeof(int) * 8;
|
| 279 |
+
|
| 280 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<unsigned int>(void)
|
| 284 |
+
{
|
| 285 |
+
int e = (int)sizeof(unsigned int) * 8;
|
| 286 |
+
|
| 287 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<int1>(void)
|
| 291 |
+
{
|
| 292 |
+
int e = (int)sizeof(int) * 8;
|
| 293 |
+
|
| 294 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<uint1>(void)
|
| 298 |
+
{
|
| 299 |
+
int e = (int)sizeof(unsigned int) * 8;
|
| 300 |
+
|
| 301 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<int2>(void)
|
| 305 |
+
{
|
| 306 |
+
int e = (int)sizeof(int) * 8;
|
| 307 |
+
|
| 308 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindSigned);
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<uint2>(void)
|
| 312 |
+
{
|
| 313 |
+
int e = (int)sizeof(unsigned int) * 8;
|
| 314 |
+
|
| 315 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindUnsigned);
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<int4>(void)
|
| 319 |
+
{
|
| 320 |
+
int e = (int)sizeof(int) * 8;
|
| 321 |
+
|
| 322 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindSigned);
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<uint4>(void)
|
| 326 |
+
{
|
| 327 |
+
int e = (int)sizeof(unsigned int) * 8;
|
| 328 |
+
|
| 329 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindUnsigned);
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
#if !defined(__LP64__)
|
| 333 |
+
|
| 334 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<long>(void)
|
| 335 |
+
{
|
| 336 |
+
int e = (int)sizeof(long) * 8;
|
| 337 |
+
|
| 338 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<unsigned long>(void)
|
| 342 |
+
{
|
| 343 |
+
int e = (int)sizeof(unsigned long) * 8;
|
| 344 |
+
|
| 345 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<long1>(void)
|
| 349 |
+
{
|
| 350 |
+
int e = (int)sizeof(long) * 8;
|
| 351 |
+
|
| 352 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindSigned);
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<ulong1>(void)
|
| 356 |
+
{
|
| 357 |
+
int e = (int)sizeof(unsigned long) * 8;
|
| 358 |
+
|
| 359 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindUnsigned);
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<long2>(void)
|
| 363 |
+
{
|
| 364 |
+
int e = (int)sizeof(long) * 8;
|
| 365 |
+
|
| 366 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindSigned);
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<ulong2>(void)
|
| 370 |
+
{
|
| 371 |
+
int e = (int)sizeof(unsigned long) * 8;
|
| 372 |
+
|
| 373 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindUnsigned);
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<long4>(void)
|
| 377 |
+
{
|
| 378 |
+
int e = (int)sizeof(long) * 8;
|
| 379 |
+
|
| 380 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindSigned);
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<ulong4>(void)
|
| 384 |
+
{
|
| 385 |
+
int e = (int)sizeof(unsigned long) * 8;
|
| 386 |
+
|
| 387 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindUnsigned);
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
#endif /* !__LP64__ */
|
| 391 |
+
|
| 392 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<float>(void)
|
| 393 |
+
{
|
| 394 |
+
int e = (int)sizeof(float) * 8;
|
| 395 |
+
|
| 396 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindFloat);
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<float1>(void)
|
| 400 |
+
{
|
| 401 |
+
int e = (int)sizeof(float) * 8;
|
| 402 |
+
|
| 403 |
+
return cudaCreateChannelDesc(e, 0, 0, 0, cudaChannelFormatKindFloat);
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<float2>(void)
|
| 407 |
+
{
|
| 408 |
+
int e = (int)sizeof(float) * 8;
|
| 409 |
+
|
| 410 |
+
return cudaCreateChannelDesc(e, e, 0, 0, cudaChannelFormatKindFloat);
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<float4>(void)
|
| 414 |
+
{
|
| 415 |
+
int e = (int)sizeof(float) * 8;
|
| 416 |
+
|
| 417 |
+
return cudaCreateChannelDesc(e, e, e, e, cudaChannelFormatKindFloat);
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
static __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDescNV12(void)
|
| 421 |
+
{
|
| 422 |
+
int e = (int)sizeof(char) * 8;
|
| 423 |
+
|
| 424 |
+
return cudaCreateChannelDesc(e, e, e, 0, cudaChannelFormatKindNV12);
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
template<cudaChannelFormatKind> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc(void)
|
| 428 |
+
{
|
| 429 |
+
return cudaCreateChannelDesc(0, 0, 0, 0, cudaChannelFormatKindNone);
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
/* Signed 8-bit normalized integer formats */
|
| 433 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X1>(void)
|
| 434 |
+
{
|
| 435 |
+
return cudaCreateChannelDesc(8, 0, 0, 0, cudaChannelFormatKindSignedNormalized8X1);
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X2>(void)
|
| 439 |
+
{
|
| 440 |
+
return cudaCreateChannelDesc(8, 8, 0, 0, cudaChannelFormatKindSignedNormalized8X2);
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X4>(void)
|
| 444 |
+
{
|
| 445 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindSignedNormalized8X4);
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
/* Unsigned 8-bit normalized integer formats */
|
| 449 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X1>(void)
|
| 450 |
+
{
|
| 451 |
+
return cudaCreateChannelDesc(8, 0, 0, 0, cudaChannelFormatKindUnsignedNormalized8X1);
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X2>(void)
|
| 455 |
+
{
|
| 456 |
+
return cudaCreateChannelDesc(8, 8, 0, 0, cudaChannelFormatKindUnsignedNormalized8X2);
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X4>(void)
|
| 460 |
+
{
|
| 461 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedNormalized8X4);
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
/* Signed 16-bit normalized integer formats */
|
| 465 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X1>(void)
|
| 466 |
+
{
|
| 467 |
+
return cudaCreateChannelDesc(16, 0, 0, 0, cudaChannelFormatKindSignedNormalized16X1);
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X2>(void)
|
| 471 |
+
{
|
| 472 |
+
return cudaCreateChannelDesc(16, 16, 0, 0, cudaChannelFormatKindSignedNormalized16X2);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X4>(void)
|
| 476 |
+
{
|
| 477 |
+
return cudaCreateChannelDesc(16, 16, 16, 16, cudaChannelFormatKindSignedNormalized16X4);
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
/* Unsigned 16-bit normalized integer formats */
|
| 481 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X1>(void)
|
| 482 |
+
{
|
| 483 |
+
return cudaCreateChannelDesc(16, 0, 0, 0, cudaChannelFormatKindUnsignedNormalized16X1);
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X2>(void)
|
| 487 |
+
{
|
| 488 |
+
return cudaCreateChannelDesc(16, 16, 0, 0, cudaChannelFormatKindUnsignedNormalized16X2);
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X4>(void)
|
| 492 |
+
{
|
| 493 |
+
return cudaCreateChannelDesc(16, 16, 16, 16, cudaChannelFormatKindUnsignedNormalized16X4);
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
/* NV12 format */
|
| 497 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindNV12>(void)
|
| 498 |
+
{
|
| 499 |
+
return cudaCreateChannelDesc(8, 8, 8, 0, cudaChannelFormatKindNV12);
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
/* Int101010 format */
|
| 503 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized1010102>(void)
|
| 504 |
+
{
|
| 505 |
+
return cudaCreateChannelDesc(10, 10, 10, 2, cudaChannelFormatKindUnsignedNormalized1010102);
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
/* BC1 format */
|
| 509 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed1>(void)
|
| 510 |
+
{
|
| 511 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed1);
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
/* BC1sRGB format */
|
| 515 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed1SRGB>(void)
|
| 516 |
+
{
|
| 517 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed1SRGB);
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
/* BC2 format */
|
| 521 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed2>(void)
|
| 522 |
+
{
|
| 523 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed2);
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
/* BC2sRGB format */
|
| 527 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed2SRGB>(void)
|
| 528 |
+
{
|
| 529 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed2SRGB);
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
/* BC3 format */
|
| 533 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed3>(void)
|
| 534 |
+
{
|
| 535 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed3);
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
/* BC3sRGB format */
|
| 539 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed3SRGB>(void)
|
| 540 |
+
{
|
| 541 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed3SRGB);
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
/* BC4 unsigned format */
|
| 545 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed4>(void)
|
| 546 |
+
{
|
| 547 |
+
return cudaCreateChannelDesc(8, 0, 0, 0, cudaChannelFormatKindUnsignedBlockCompressed4);
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
/* BC4 signed format */
|
| 551 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed4>(void)
|
| 552 |
+
{
|
| 553 |
+
return cudaCreateChannelDesc(8, 0, 0, 0, cudaChannelFormatKindSignedBlockCompressed4);
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
/* BC5 unsigned format */
|
| 557 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed5>(void)
|
| 558 |
+
{
|
| 559 |
+
return cudaCreateChannelDesc(8, 8, 0, 0, cudaChannelFormatKindUnsignedBlockCompressed5);
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
/* BC5 signed format */
|
| 563 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed5>(void)
|
| 564 |
+
{
|
| 565 |
+
return cudaCreateChannelDesc(8, 8, 0, 0, cudaChannelFormatKindSignedBlockCompressed5);
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
/* BC6H unsigned format */
|
| 569 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed6H>(void)
|
| 570 |
+
{
|
| 571 |
+
return cudaCreateChannelDesc(16, 16, 16, 0, cudaChannelFormatKindUnsignedBlockCompressed6H);
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
/* BC6H signed format */
|
| 575 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed6H>(void)
|
| 576 |
+
{
|
| 577 |
+
return cudaCreateChannelDesc(16, 16, 16, 0, cudaChannelFormatKindSignedBlockCompressed6H);
|
| 578 |
+
}
|
| 579 |
+
|
| 580 |
+
/* BC7 format */
|
| 581 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed7>(void)
|
| 582 |
+
{
|
| 583 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed7);
|
| 584 |
+
}
|
| 585 |
+
|
| 586 |
+
/* BC7sRGB format */
|
| 587 |
+
template<> __inline__ __host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed7SRGB>(void)
|
| 588 |
+
{
|
| 589 |
+
return cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsignedBlockCompressed7SRGB);
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
#endif /* __cplusplus */
|
| 593 |
+
|
| 594 |
+
/** @} */
|
| 595 |
+
/** @} */ /* END CUDART_TEXTURE_HL */
|
| 596 |
+
|
| 597 |
+
#endif /* !__CHANNEL_DESCRIPTOR_H__ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/common_functions.h
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2018 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__)
|
| 51 |
+
#if defined(_MSC_VER)
|
| 52 |
+
#pragma message("common_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release. Please use cuda_runtime_api.h or cuda_runtime.h instead.")
|
| 53 |
+
#else
|
| 54 |
+
#warning "common_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release. Please use cuda_runtime_api.h or cuda_runtime.h instead."
|
| 55 |
+
#endif
|
| 56 |
+
#define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
|
| 57 |
+
#define __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_COMMON_FUNCTIONS_H_WRAPPER__
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
#include "crt/common_functions.h"
|
| 61 |
+
|
| 62 |
+
#if defined(__UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_COMMON_FUNCTIONS_H_WRAPPER__)
|
| 63 |
+
#undef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
|
| 64 |
+
#undef __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_COMMON_FUNCTIONS_H_WRAPPER__
|
| 65 |
+
#endif
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cooperative_groups.h
ADDED
|
@@ -0,0 +1,1743 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef _COOPERATIVE_GROUPS_H_
|
| 51 |
+
#define _COOPERATIVE_GROUPS_H_
|
| 52 |
+
|
| 53 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 54 |
+
|
| 55 |
+
#include "cooperative_groups/details/info.h"
|
| 56 |
+
#include "cooperative_groups/details/driver_abi.h"
|
| 57 |
+
#include "cooperative_groups/details/helpers.h"
|
| 58 |
+
#include "cooperative_groups/details/memory.h"
|
| 59 |
+
|
| 60 |
+
#if defined(_CG_HAS_STL_ATOMICS)
|
| 61 |
+
#include <cuda/atomic>
|
| 62 |
+
#define _CG_THREAD_SCOPE(scope) _CG_STATIC_CONST_DECL cuda::thread_scope thread_scope = scope;
|
| 63 |
+
#else
|
| 64 |
+
#define _CG_THREAD_SCOPE(scope)
|
| 65 |
+
#endif
|
| 66 |
+
|
| 67 |
+
_CG_BEGIN_NAMESPACE
|
| 68 |
+
|
| 69 |
+
namespace details {
|
| 70 |
+
_CG_CONST_DECL unsigned int coalesced_group_id = 1;
|
| 71 |
+
_CG_CONST_DECL unsigned int multi_grid_group_id = 2;
|
| 72 |
+
_CG_CONST_DECL unsigned int grid_group_id = 3;
|
| 73 |
+
_CG_CONST_DECL unsigned int thread_block_id = 4;
|
| 74 |
+
_CG_CONST_DECL unsigned int multi_tile_group_id = 5;
|
| 75 |
+
_CG_CONST_DECL unsigned int cluster_group_id = 6;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* class thread_group;
|
| 80 |
+
*
|
| 81 |
+
* Generic thread group type, into which all groups are convertible.
|
| 82 |
+
* It acts as a container for all storage necessary for the derived groups,
|
| 83 |
+
* and will dispatch the API calls to the correct derived group. This means
|
| 84 |
+
* that all derived groups must implement the same interface as thread_group.
|
| 85 |
+
*/
|
| 86 |
+
class thread_group
|
| 87 |
+
{
|
| 88 |
+
protected:
|
| 89 |
+
struct group_data {
|
| 90 |
+
unsigned int _unused : 1;
|
| 91 |
+
unsigned int type : 7, : 0;
|
| 92 |
+
};
|
| 93 |
+
|
| 94 |
+
struct gg_data {
|
| 95 |
+
details::grid_workspace *gridWs;
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
#if defined(_CG_CPP11_FEATURES) && defined(_CG_ABI_EXPERIMENTAL)
|
| 99 |
+
struct mg_data {
|
| 100 |
+
unsigned long long _unused : 1;
|
| 101 |
+
unsigned long long type : 7;
|
| 102 |
+
unsigned long long handle : 56;
|
| 103 |
+
const details::multi_grid::multi_grid_functions *functions;
|
| 104 |
+
};
|
| 105 |
+
#endif
|
| 106 |
+
|
| 107 |
+
struct tg_data {
|
| 108 |
+
unsigned int is_tiled : 1;
|
| 109 |
+
unsigned int type : 7;
|
| 110 |
+
unsigned int size : 24;
|
| 111 |
+
// packed to 4b
|
| 112 |
+
unsigned int metaGroupSize : 16;
|
| 113 |
+
unsigned int metaGroupRank : 16;
|
| 114 |
+
// packed to 8b
|
| 115 |
+
unsigned int mask;
|
| 116 |
+
// packed to 12b
|
| 117 |
+
unsigned int _res;
|
| 118 |
+
};
|
| 119 |
+
|
| 120 |
+
friend _CG_QUALIFIER thread_group tiled_partition(const thread_group& parent, unsigned int tilesz);
|
| 121 |
+
friend class thread_block;
|
| 122 |
+
|
| 123 |
+
union __align__(8) {
|
| 124 |
+
group_data group;
|
| 125 |
+
tg_data coalesced;
|
| 126 |
+
gg_data grid;
|
| 127 |
+
#if defined(_CG_CPP11_FEATURES) && defined(_CG_ABI_EXPERIMENTAL)
|
| 128 |
+
mg_data multi_grid;
|
| 129 |
+
#endif
|
| 130 |
+
} _data;
|
| 131 |
+
|
| 132 |
+
_CG_QUALIFIER thread_group operator=(const thread_group& src);
|
| 133 |
+
|
| 134 |
+
_CG_QUALIFIER thread_group(unsigned int type) {
|
| 135 |
+
_data.group.type = type;
|
| 136 |
+
_data.group._unused = false;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
#ifdef _CG_CPP11_FEATURES
|
| 140 |
+
static_assert(sizeof(tg_data) <= 16, "Failed size check");
|
| 141 |
+
static_assert(sizeof(gg_data) <= 16, "Failed size check");
|
| 142 |
+
# ifdef _CG_ABI_EXPERIMENTAL
|
| 143 |
+
static_assert(sizeof(mg_data) <= 16, "Failed size check");
|
| 144 |
+
# endif
|
| 145 |
+
#endif
|
| 146 |
+
|
| 147 |
+
public:
|
| 148 |
+
_CG_THREAD_SCOPE(cuda::thread_scope::thread_scope_device)
|
| 149 |
+
|
| 150 |
+
_CG_QUALIFIER unsigned long long size() const;
|
| 151 |
+
_CG_QUALIFIER unsigned long long num_threads() const;
|
| 152 |
+
_CG_QUALIFIER unsigned long long thread_rank() const;
|
| 153 |
+
_CG_QUALIFIER void sync() const;
|
| 154 |
+
_CG_QUALIFIER unsigned int get_type() const {
|
| 155 |
+
return _data.group.type;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
};
|
| 159 |
+
|
| 160 |
+
template <unsigned int TyId>
|
| 161 |
+
struct thread_group_base : public thread_group {
|
| 162 |
+
_CG_QUALIFIER thread_group_base() : thread_group(TyId) {}
|
| 163 |
+
_CG_STATIC_CONST_DECL unsigned int id = TyId;
|
| 164 |
+
};
|
| 165 |
+
|
| 166 |
+
#if defined(_CG_HAS_MULTI_GRID_GROUP)
|
| 167 |
+
|
| 168 |
+
/**
|
| 169 |
+
* class multi_grid_group;
|
| 170 |
+
*
|
| 171 |
+
* Threads within this this group are guaranteed to be co-resident on the
|
| 172 |
+
* same system, on multiple devices within the same launched kernels.
|
| 173 |
+
* To use this group, the kernel must have been launched with
|
| 174 |
+
* cuLaunchCooperativeKernelMultiDevice (or the CUDA Runtime equivalent),
|
| 175 |
+
* and the device must support it (queryable device attribute).
|
| 176 |
+
*
|
| 177 |
+
* Constructed via this_multi_grid();
|
| 178 |
+
*/
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
# if defined(_CG_CPP11_FEATURES) && defined(_CG_ABI_EXPERIMENTAL)
|
| 182 |
+
class multi_grid_group;
|
| 183 |
+
|
| 184 |
+
// Multi grid group requires these functions to be templated to prevent ptxas from trying to use CG syscalls
|
| 185 |
+
template <typename = void>
|
| 186 |
+
__device__ _CG_DEPRECATED multi_grid_group this_multi_grid();
|
| 187 |
+
|
| 188 |
+
class multi_grid_group : public thread_group_base<details::multi_grid_group_id>
|
| 189 |
+
{
|
| 190 |
+
private:
|
| 191 |
+
template <typename = void>
|
| 192 |
+
_CG_QUALIFIER multi_grid_group() {
|
| 193 |
+
_data.multi_grid.functions = details::multi_grid::load_grid_intrinsics();
|
| 194 |
+
_data.multi_grid.handle = _data.multi_grid.functions->get_intrinsic_handle();
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
friend multi_grid_group this_multi_grid<void>();
|
| 198 |
+
|
| 199 |
+
public:
|
| 200 |
+
_CG_THREAD_SCOPE(cuda::thread_scope::thread_scope_system)
|
| 201 |
+
|
| 202 |
+
_CG_QUALIFIER bool is_valid() const {
|
| 203 |
+
return (_data.multi_grid.handle != 0);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
_CG_QUALIFIER void sync() const {
|
| 207 |
+
if (!is_valid()) {
|
| 208 |
+
_CG_ABORT();
|
| 209 |
+
}
|
| 210 |
+
_data.multi_grid.functions->sync(_data.multi_grid.handle);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
_CG_QUALIFIER unsigned long long num_threads() const {
|
| 214 |
+
_CG_ASSERT(is_valid());
|
| 215 |
+
return _data.multi_grid.functions->size(_data.multi_grid.handle);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
_CG_QUALIFIER unsigned long long size() const {
|
| 219 |
+
return num_threads();
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
_CG_QUALIFIER unsigned long long thread_rank() const {
|
| 223 |
+
_CG_ASSERT(is_valid());
|
| 224 |
+
return _data.multi_grid.functions->thread_rank(_data.multi_grid.handle);
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
_CG_QUALIFIER unsigned int grid_rank() const {
|
| 228 |
+
_CG_ASSERT(is_valid());
|
| 229 |
+
return (_data.multi_grid.functions->grid_rank(_data.multi_grid.handle));
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
_CG_QUALIFIER unsigned int num_grids() const {
|
| 233 |
+
_CG_ASSERT(is_valid());
|
| 234 |
+
return (_data.multi_grid.functions->num_grids(_data.multi_grid.handle));
|
| 235 |
+
}
|
| 236 |
+
};
|
| 237 |
+
# else
|
| 238 |
+
class multi_grid_group
|
| 239 |
+
{
|
| 240 |
+
private:
|
| 241 |
+
unsigned long long _handle;
|
| 242 |
+
unsigned int _size;
|
| 243 |
+
unsigned int _rank;
|
| 244 |
+
|
| 245 |
+
friend _CG_QUALIFIER multi_grid_group this_multi_grid();
|
| 246 |
+
|
| 247 |
+
_CG_QUALIFIER multi_grid_group() {
|
| 248 |
+
_handle = details::multi_grid::get_intrinsic_handle();
|
| 249 |
+
_size = details::multi_grid::size(_handle);
|
| 250 |
+
_rank = details::multi_grid::thread_rank(_handle);
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
public:
|
| 254 |
+
_CG_THREAD_SCOPE(cuda::thread_scope::thread_scope_system)
|
| 255 |
+
|
| 256 |
+
_CG_QUALIFIER _CG_DEPRECATED bool is_valid() const {
|
| 257 |
+
return (_handle != 0);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
_CG_QUALIFIER _CG_DEPRECATED void sync() const {
|
| 261 |
+
if (!is_valid()) {
|
| 262 |
+
_CG_ABORT();
|
| 263 |
+
}
|
| 264 |
+
details::multi_grid::sync(_handle);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
_CG_QUALIFIER _CG_DEPRECATED unsigned long long num_threads() const {
|
| 268 |
+
_CG_ASSERT(is_valid());
|
| 269 |
+
return _size;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
_CG_QUALIFIER _CG_DEPRECATED unsigned long long size() const {
|
| 273 |
+
return num_threads();
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
_CG_QUALIFIER _CG_DEPRECATED unsigned long long thread_rank() const {
|
| 277 |
+
_CG_ASSERT(is_valid());
|
| 278 |
+
return _rank;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
_CG_QUALIFIER _CG_DEPRECATED unsigned int grid_rank() const {
|
| 282 |
+
_CG_ASSERT(is_valid());
|
| 283 |
+
return (details::multi_grid::grid_rank(_handle));
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
_CG_QUALIFIER _CG_DEPRECATED unsigned int num_grids() const {
|
| 287 |
+
_CG_ASSERT(is_valid());
|
| 288 |
+
return (details::multi_grid::num_grids(_handle));
|
| 289 |
+
}
|
| 290 |
+
};
|
| 291 |
+
# endif
|
| 292 |
+
|
| 293 |
+
/**
|
| 294 |
+
* multi_grid_group this_multi_grid()
|
| 295 |
+
*
|
| 296 |
+
* Constructs a multi_grid_group
|
| 297 |
+
*/
|
| 298 |
+
# if defined(_CG_CPP11_FEATURES) && defined(_CG_ABI_EXPERIMENTAL)
|
| 299 |
+
template <typename>
|
| 300 |
+
__device__
|
| 301 |
+
#else
|
| 302 |
+
_CG_QUALIFIER
|
| 303 |
+
# endif
|
| 304 |
+
_CG_DEPRECATED
|
| 305 |
+
multi_grid_group this_multi_grid()
|
| 306 |
+
{
|
| 307 |
+
return multi_grid_group();
|
| 308 |
+
}
|
| 309 |
+
#endif
|
| 310 |
+
|
| 311 |
+
/**
|
| 312 |
+
* class grid_group;
|
| 313 |
+
*
|
| 314 |
+
* Threads within this this group are guaranteed to be co-resident on the
|
| 315 |
+
* same device within the same launched kernel. To use this group, the kernel
|
| 316 |
+
* must have been launched with cuLaunchCooperativeKernel (or the CUDA Runtime equivalent),
|
| 317 |
+
* and the device must support it (queryable device attribute).
|
| 318 |
+
*
|
| 319 |
+
* Constructed via this_grid();
|
| 320 |
+
*/
|
| 321 |
+
class grid_group : public thread_group_base<details::grid_group_id>
|
| 322 |
+
{
|
| 323 |
+
_CG_STATIC_CONST_DECL unsigned int _group_id = details::grid_group_id;
|
| 324 |
+
friend _CG_QUALIFIER grid_group this_grid();
|
| 325 |
+
|
| 326 |
+
private:
|
| 327 |
+
_CG_QUALIFIER grid_group(details::grid_workspace *gridWs) {
|
| 328 |
+
_data.grid.gridWs = gridWs;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
public:
|
| 332 |
+
_CG_THREAD_SCOPE(cuda::thread_scope::thread_scope_device)
|
| 333 |
+
|
| 334 |
+
_CG_QUALIFIER bool is_valid() const {
|
| 335 |
+
return (_data.grid.gridWs != NULL);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
_CG_QUALIFIER void sync() const {
|
| 339 |
+
if (!is_valid()) {
|
| 340 |
+
_CG_ABORT();
|
| 341 |
+
}
|
| 342 |
+
details::grid::sync(&_data.grid.gridWs->barrier);
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
#if defined(_CG_CPP11_FEATURES)
|
| 346 |
+
using arrival_token = unsigned int;
|
| 347 |
+
|
| 348 |
+
_CG_QUALIFIER arrival_token barrier_arrive() const {
|
| 349 |
+
if (!is_valid()) {
|
| 350 |
+
_CG_ABORT();
|
| 351 |
+
}
|
| 352 |
+
return details::grid::barrier_arrive(&_data.grid.gridWs->barrier);
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
_CG_QUALIFIER void barrier_wait(arrival_token&& token) const {
|
| 356 |
+
details::grid::barrier_wait(token, &_data.grid.gridWs->barrier);
|
| 357 |
+
}
|
| 358 |
+
#endif
|
| 359 |
+
|
| 360 |
+
_CG_STATIC_QUALIFIER unsigned long long size() {
|
| 361 |
+
return details::grid::size();
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
_CG_STATIC_QUALIFIER dim3 group_dim() {
|
| 365 |
+
return details::grid::grid_dim();
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
_CG_STATIC_QUALIFIER dim3 dim_threads() {
|
| 369 |
+
return details::grid::dim_threads();
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
_CG_STATIC_QUALIFIER unsigned long long num_threads() {
|
| 373 |
+
return details::grid::num_threads();
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
_CG_STATIC_QUALIFIER dim3 thread_index() {
|
| 377 |
+
return details::grid::thread_index();
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
_CG_STATIC_QUALIFIER unsigned long long thread_rank() {
|
| 381 |
+
return details::grid::thread_rank();
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
_CG_STATIC_QUALIFIER dim3 dim_blocks() {
|
| 385 |
+
return details::grid::dim_blocks();
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
_CG_STATIC_QUALIFIER unsigned long long num_blocks() {
|
| 389 |
+
return details::grid::num_blocks();
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
_CG_STATIC_QUALIFIER dim3 block_index() {
|
| 393 |
+
return details::grid::block_index();
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
_CG_STATIC_QUALIFIER unsigned long long block_rank() {
|
| 397 |
+
return details::grid::block_rank();
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
# if defined(_CG_HAS_CLUSTER_GROUP)
|
| 401 |
+
_CG_STATIC_QUALIFIER dim3 dim_clusters() {
|
| 402 |
+
return details::grid::dim_clusters();
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
_CG_STATIC_QUALIFIER unsigned long long num_clusters() {
|
| 406 |
+
return details::grid::num_clusters();
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
_CG_STATIC_QUALIFIER dim3 cluster_index() {
|
| 410 |
+
return details::grid::cluster_index();
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
_CG_STATIC_QUALIFIER unsigned long long cluster_rank() {
|
| 414 |
+
return details::grid::cluster_rank();
|
| 415 |
+
}
|
| 416 |
+
# endif
|
| 417 |
+
};
|
| 418 |
+
|
| 419 |
+
_CG_QUALIFIER grid_group this_grid() {
|
| 420 |
+
// Load a workspace from the driver
|
| 421 |
+
grid_group gg(details::get_grid_workspace());
|
| 422 |
+
#ifdef _CG_DEBUG
|
| 423 |
+
// *all* threads must be available to synchronize
|
| 424 |
+
gg.sync();
|
| 425 |
+
#endif // _CG_DEBUG
|
| 426 |
+
return gg;
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
#if defined(_CG_HAS_CLUSTER_GROUP)
|
| 430 |
+
/**
|
| 431 |
+
* class cluster_group
|
| 432 |
+
*
|
| 433 |
+
* Every GPU kernel is executed by a grid of thread blocks. A grid can be evenly
|
| 434 |
+
* divided along all dimensions to form groups of blocks, each group of which is
|
| 435 |
+
* a block cluster. Clustered grids are subject to various restrictions and
|
| 436 |
+
* limitations. Primarily, a cluster consists of at most 8 blocks by default
|
| 437 |
+
* (although the user is allowed to opt-in to non-standard sizes,) and clustered
|
| 438 |
+
* grids are subject to additional occupancy limitations due to per-cluster
|
| 439 |
+
* hardware resource consumption. In exchange, a block cluster is guaranteed to
|
| 440 |
+
* be a cooperative group, with access to all cooperative group capabilities, as
|
| 441 |
+
* well as cluster specific capabilities and accelerations. A cluster_group
|
| 442 |
+
* represents a block cluster.
|
| 443 |
+
*
|
| 444 |
+
* Constructed via this_cluster_group();
|
| 445 |
+
*/
|
| 446 |
+
class cluster_group : public thread_group_base<details::cluster_group_id>
|
| 447 |
+
{
|
| 448 |
+
// Friends
|
| 449 |
+
friend _CG_QUALIFIER cluster_group this_cluster();
|
| 450 |
+
|
| 451 |
+
// Disable constructor
|
| 452 |
+
_CG_QUALIFIER cluster_group()
|
| 453 |
+
{
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
public:
|
| 457 |
+
//_CG_THREAD_SCOPE(cuda::thread_scope::thread_scope_cluster)
|
| 458 |
+
|
| 459 |
+
using arrival_token = struct {};
|
| 460 |
+
|
| 461 |
+
// Functionality exposed by the group
|
| 462 |
+
_CG_STATIC_QUALIFIER void sync()
|
| 463 |
+
{
|
| 464 |
+
return details::cluster::sync();
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
_CG_STATIC_QUALIFIER arrival_token barrier_arrive()
|
| 468 |
+
{
|
| 469 |
+
details::cluster::barrier_arrive();
|
| 470 |
+
return arrival_token();
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
_CG_STATIC_QUALIFIER void barrier_wait()
|
| 474 |
+
{
|
| 475 |
+
return details::cluster::barrier_wait();
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
_CG_STATIC_QUALIFIER void barrier_wait(arrival_token&&)
|
| 479 |
+
{
|
| 480 |
+
return details::cluster::barrier_wait();
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
_CG_STATIC_QUALIFIER unsigned int query_shared_rank(const void *addr)
|
| 484 |
+
{
|
| 485 |
+
return details::cluster::query_shared_rank(addr);
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
template <typename T>
|
| 489 |
+
_CG_STATIC_QUALIFIER T* map_shared_rank(T *addr, int rank)
|
| 490 |
+
{
|
| 491 |
+
return details::cluster::map_shared_rank(addr, rank);
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
_CG_STATIC_QUALIFIER dim3 block_index()
|
| 495 |
+
{
|
| 496 |
+
return details::cluster::block_index();
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
_CG_STATIC_QUALIFIER unsigned int block_rank()
|
| 500 |
+
{
|
| 501 |
+
return details::cluster::block_rank();
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
_CG_STATIC_QUALIFIER dim3 thread_index()
|
| 505 |
+
{
|
| 506 |
+
return details::cluster::thread_index();
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
_CG_STATIC_QUALIFIER unsigned int thread_rank()
|
| 510 |
+
{
|
| 511 |
+
return details::cluster::thread_rank();
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
_CG_STATIC_QUALIFIER dim3 dim_blocks()
|
| 515 |
+
{
|
| 516 |
+
return details::cluster::dim_blocks();
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
_CG_STATIC_QUALIFIER unsigned int num_blocks()
|
| 520 |
+
{
|
| 521 |
+
return details::cluster::num_blocks();
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
_CG_STATIC_QUALIFIER dim3 dim_threads()
|
| 525 |
+
{
|
| 526 |
+
return details::cluster::dim_threads();
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
_CG_STATIC_QUALIFIER unsigned int num_threads()
|
| 530 |
+
{
|
| 531 |
+
return details::cluster::num_threads();
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
// Legacy aliases
|
| 535 |
+
_CG_STATIC_QUALIFIER unsigned int size()
|
| 536 |
+
{
|
| 537 |
+
return num_threads();
|
| 538 |
+
}
|
| 539 |
+
};
|
| 540 |
+
|
| 541 |
+
/*
|
| 542 |
+
* cluster_group this_cluster()
|
| 543 |
+
*
|
| 544 |
+
* Constructs a cluster_group
|
| 545 |
+
*/
|
| 546 |
+
_CG_QUALIFIER cluster_group this_cluster()
|
| 547 |
+
{
|
| 548 |
+
cluster_group cg;
|
| 549 |
+
#ifdef _CG_DEBUG
|
| 550 |
+
cg.sync();
|
| 551 |
+
#endif
|
| 552 |
+
return cg;
|
| 553 |
+
}
|
| 554 |
+
#endif
|
| 555 |
+
|
| 556 |
+
#if defined(_CG_CPP11_FEATURES)
|
| 557 |
+
class thread_block;
|
| 558 |
+
template <unsigned int MaxBlockSize>
|
| 559 |
+
_CG_QUALIFIER thread_block this_thread_block(block_tile_memory<MaxBlockSize>& scratch);
|
| 560 |
+
#endif
|
| 561 |
+
|
| 562 |
+
/**
|
| 563 |
+
* class thread_block
|
| 564 |
+
*
|
| 565 |
+
* Every GPU kernel is executed by a grid of thread blocks, and threads within
|
| 566 |
+
* each block are guaranteed to reside on the same streaming multiprocessor.
|
| 567 |
+
* A thread_block represents a thread block whose dimensions are not known until runtime.
|
| 568 |
+
*
|
| 569 |
+
* Constructed via this_thread_block();
|
| 570 |
+
*/
|
| 571 |
+
class thread_block : public thread_group_base<details::thread_block_id>
|
| 572 |
+
{
|
| 573 |
+
// Friends
|
| 574 |
+
friend _CG_QUALIFIER thread_block this_thread_block();
|
| 575 |
+
friend _CG_QUALIFIER thread_group tiled_partition(const thread_group& parent, unsigned int tilesz);
|
| 576 |
+
friend _CG_QUALIFIER thread_group tiled_partition(const thread_block& parent, unsigned int tilesz);
|
| 577 |
+
|
| 578 |
+
#if defined(_CG_CPP11_FEATURES)
|
| 579 |
+
template <unsigned int MaxBlockSize>
|
| 580 |
+
friend _CG_QUALIFIER thread_block this_thread_block(block_tile_memory<MaxBlockSize>& scratch);
|
| 581 |
+
template <unsigned int Size>
|
| 582 |
+
friend class __static_size_multi_warp_tile_base;
|
| 583 |
+
|
| 584 |
+
details::multi_warp_scratch* const tile_memory;
|
| 585 |
+
|
| 586 |
+
template <unsigned int MaxBlockSize>
|
| 587 |
+
_CG_QUALIFIER thread_block(block_tile_memory<MaxBlockSize>& scratch) :
|
| 588 |
+
tile_memory(details::get_scratch_ptr(&scratch)) {
|
| 589 |
+
#ifdef _CG_DEBUG
|
| 590 |
+
if (num_threads() > MaxBlockSize) {
|
| 591 |
+
details::abort();
|
| 592 |
+
}
|
| 593 |
+
#endif
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
#if defined(_CG_USER_PROVIDED_SHARED_MEMORY)
|
| 597 |
+
#define _CG_SKIP_BARRIER_INIT_TARGET NV_NO_TARGET
|
| 598 |
+
#else
|
| 599 |
+
#define _CG_SKIP_BARRIER_INIT_TARGET NV_PROVIDES_SM_80
|
| 600 |
+
#endif
|
| 601 |
+
NV_IF_ELSE_TARGET(
|
| 602 |
+
_CG_SKIP_BARRIER_INIT_TARGET,
|
| 603 |
+
// skip if clause
|
| 604 |
+
,
|
| 605 |
+
(tile_memory->init_barriers(thread_rank());
|
| 606 |
+
sync();)
|
| 607 |
+
)
|
| 608 |
+
}
|
| 609 |
+
#endif
|
| 610 |
+
#undef _CG_SKIP_BARRIER_INIT_TARGET
|
| 611 |
+
|
| 612 |
+
// Disable constructor
|
| 613 |
+
_CG_QUALIFIER thread_block()
|
| 614 |
+
#if defined(_CG_CPP11_FEATURES)
|
| 615 |
+
: tile_memory(details::get_scratch_ptr(NULL))
|
| 616 |
+
#endif
|
| 617 |
+
{ }
|
| 618 |
+
|
| 619 |
+
// Internal Use
|
| 620 |
+
_CG_QUALIFIER thread_group _get_tiled_threads(unsigned int tilesz) const {
|
| 621 |
+
const bool pow2_tilesz = ((tilesz & (tilesz - 1)) == 0);
|
| 622 |
+
|
| 623 |
+
// Invalid, immediately fail
|
| 624 |
+
if (tilesz == 0 || (tilesz > 32) || !pow2_tilesz) {
|
| 625 |
+
details::abort();
|
| 626 |
+
return (thread_block());
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
unsigned int mask;
|
| 630 |
+
unsigned int base_offset = thread_rank() & (~(tilesz - 1));
|
| 631 |
+
unsigned int masklength = min((unsigned int)size() - base_offset, tilesz);
|
| 632 |
+
|
| 633 |
+
mask = (unsigned int)(-1) >> (32 - masklength);
|
| 634 |
+
mask <<= (details::laneid() & ~(tilesz - 1));
|
| 635 |
+
thread_group tile = thread_group(details::coalesced_group_id);
|
| 636 |
+
tile._data.coalesced.mask = mask;
|
| 637 |
+
tile._data.coalesced.size = __popc(mask);
|
| 638 |
+
tile._data.coalesced.metaGroupSize = (details::cta::size() + tilesz - 1) / tilesz;
|
| 639 |
+
tile._data.coalesced.metaGroupRank = details::cta::thread_rank() / tilesz;
|
| 640 |
+
tile._data.coalesced.is_tiled = true;
|
| 641 |
+
return (tile);
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
public:
|
| 645 |
+
_CG_STATIC_CONST_DECL unsigned int _group_id = details::thread_block_id;
|
| 646 |
+
_CG_THREAD_SCOPE(cuda::thread_scope::thread_scope_block)
|
| 647 |
+
|
| 648 |
+
_CG_STATIC_QUALIFIER void sync() {
|
| 649 |
+
details::cta::sync();
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
#if defined(_CG_CPP11_FEATURES)
|
| 653 |
+
struct arrival_token {};
|
| 654 |
+
|
| 655 |
+
_CG_QUALIFIER arrival_token barrier_arrive() const {
|
| 656 |
+
return arrival_token();
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
_CG_QUALIFIER void barrier_wait(arrival_token&&) const {
|
| 660 |
+
details::cta::sync();
|
| 661 |
+
}
|
| 662 |
+
#endif
|
| 663 |
+
|
| 664 |
+
_CG_STATIC_QUALIFIER unsigned int size() {
|
| 665 |
+
return details::cta::size();
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
_CG_STATIC_QUALIFIER unsigned int thread_rank() {
|
| 669 |
+
return details::cta::thread_rank();
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
// Additional functionality exposed by the group
|
| 673 |
+
_CG_STATIC_QUALIFIER dim3 group_index() {
|
| 674 |
+
return details::cta::group_index();
|
| 675 |
+
}
|
| 676 |
+
|
| 677 |
+
_CG_STATIC_QUALIFIER dim3 thread_index() {
|
| 678 |
+
return details::cta::thread_index();
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
_CG_STATIC_QUALIFIER dim3 group_dim() {
|
| 682 |
+
return details::cta::block_dim();
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
_CG_STATIC_QUALIFIER dim3 dim_threads() {
|
| 686 |
+
return details::cta::dim_threads();
|
| 687 |
+
}
|
| 688 |
+
|
| 689 |
+
_CG_STATIC_QUALIFIER unsigned int num_threads() {
|
| 690 |
+
return details::cta::num_threads();
|
| 691 |
+
}
|
| 692 |
+
|
| 693 |
+
};
|
| 694 |
+
|
| 695 |
+
/**
|
| 696 |
+
* thread_block this_thread_block()
|
| 697 |
+
*
|
| 698 |
+
* Constructs a thread_block group
|
| 699 |
+
*/
|
| 700 |
+
_CG_QUALIFIER thread_block this_thread_block()
|
| 701 |
+
{
|
| 702 |
+
return (thread_block());
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
#if defined(_CG_CPP11_FEATURES)
|
| 706 |
+
template <unsigned int MaxBlockSize>
|
| 707 |
+
_CG_QUALIFIER thread_block this_thread_block(block_tile_memory<MaxBlockSize>& scratch) {
|
| 708 |
+
return (thread_block(scratch));
|
| 709 |
+
}
|
| 710 |
+
#endif
|
| 711 |
+
|
| 712 |
+
/**
|
| 713 |
+
* class coalesced_group
|
| 714 |
+
*
|
| 715 |
+
* A group representing the current set of converged threads in a warp.
|
| 716 |
+
* The size of the group is not guaranteed and it may return a group of
|
| 717 |
+
* only one thread (itself).
|
| 718 |
+
*
|
| 719 |
+
* This group exposes warp-synchronous builtins.
|
| 720 |
+
* Constructed via coalesced_threads();
|
| 721 |
+
*/
|
| 722 |
+
class coalesced_group : public thread_group_base<details::coalesced_group_id>
|
| 723 |
+
{
|
| 724 |
+
private:
|
| 725 |
+
friend _CG_QUALIFIER coalesced_group coalesced_threads();
|
| 726 |
+
friend _CG_QUALIFIER thread_group tiled_partition(const thread_group& parent, unsigned int tilesz);
|
| 727 |
+
friend _CG_QUALIFIER coalesced_group tiled_partition(const coalesced_group& parent, unsigned int tilesz);
|
| 728 |
+
friend class details::_coalesced_group_data_access;
|
| 729 |
+
|
| 730 |
+
_CG_QUALIFIER unsigned int _packLanes(unsigned laneMask) const {
|
| 731 |
+
unsigned int member_pack = 0;
|
| 732 |
+
unsigned int member_rank = 0;
|
| 733 |
+
for (int bit_idx = 0; bit_idx < 32; bit_idx++) {
|
| 734 |
+
unsigned int lane_bit = _data.coalesced.mask & (1 << bit_idx);
|
| 735 |
+
if (lane_bit) {
|
| 736 |
+
if (laneMask & lane_bit)
|
| 737 |
+
member_pack |= 1 << member_rank;
|
| 738 |
+
member_rank++;
|
| 739 |
+
}
|
| 740 |
+
}
|
| 741 |
+
return (member_pack);
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
// Internal Use
|
| 745 |
+
_CG_QUALIFIER coalesced_group _get_tiled_threads(unsigned int tilesz) const {
|
| 746 |
+
const bool pow2_tilesz = ((tilesz & (tilesz - 1)) == 0);
|
| 747 |
+
|
| 748 |
+
// Invalid, immediately fail
|
| 749 |
+
if (tilesz == 0 || (tilesz > 32) || !pow2_tilesz) {
|
| 750 |
+
details::abort();
|
| 751 |
+
return (coalesced_group(0));
|
| 752 |
+
}
|
| 753 |
+
if (size() <= tilesz) {
|
| 754 |
+
return (*this);
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
if ((_data.coalesced.is_tiled == true) && pow2_tilesz) {
|
| 758 |
+
unsigned int base_offset = (thread_rank() & (~(tilesz - 1)));
|
| 759 |
+
unsigned int masklength = min((unsigned int)size() - base_offset, tilesz);
|
| 760 |
+
unsigned int mask = (unsigned int)(-1) >> (32 - masklength);
|
| 761 |
+
|
| 762 |
+
mask <<= (details::laneid() & ~(tilesz - 1));
|
| 763 |
+
coalesced_group coalesced_tile = coalesced_group(mask);
|
| 764 |
+
coalesced_tile._data.coalesced.metaGroupSize = size() / tilesz;
|
| 765 |
+
coalesced_tile._data.coalesced.metaGroupRank = thread_rank() / tilesz;
|
| 766 |
+
coalesced_tile._data.coalesced.is_tiled = true;
|
| 767 |
+
return (coalesced_tile);
|
| 768 |
+
}
|
| 769 |
+
else if ((_data.coalesced.is_tiled == false) && pow2_tilesz) {
|
| 770 |
+
unsigned int mask = 0;
|
| 771 |
+
unsigned int member_rank = 0;
|
| 772 |
+
int seen_lanes = (thread_rank() / tilesz) * tilesz;
|
| 773 |
+
for (unsigned int bit_idx = 0; bit_idx < 32; bit_idx++) {
|
| 774 |
+
unsigned int lane_bit = _data.coalesced.mask & (1 << bit_idx);
|
| 775 |
+
if (lane_bit) {
|
| 776 |
+
if (seen_lanes <= 0 && member_rank < tilesz) {
|
| 777 |
+
mask |= lane_bit;
|
| 778 |
+
member_rank++;
|
| 779 |
+
}
|
| 780 |
+
seen_lanes--;
|
| 781 |
+
}
|
| 782 |
+
}
|
| 783 |
+
coalesced_group coalesced_tile = coalesced_group(mask);
|
| 784 |
+
// Override parent with the size of this group
|
| 785 |
+
coalesced_tile._data.coalesced.metaGroupSize = (size() + tilesz - 1) / tilesz;
|
| 786 |
+
coalesced_tile._data.coalesced.metaGroupRank = thread_rank() / tilesz;
|
| 787 |
+
return coalesced_tile;
|
| 788 |
+
}
|
| 789 |
+
else {
|
| 790 |
+
// None in _CG_VERSION 1000
|
| 791 |
+
details::abort();
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
return (coalesced_group(0));
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
protected:
|
| 798 |
+
_CG_QUALIFIER coalesced_group(unsigned int mask) {
|
| 799 |
+
_data.coalesced.mask = mask;
|
| 800 |
+
_data.coalesced.size = __popc(mask);
|
| 801 |
+
_data.coalesced.metaGroupRank = 0;
|
| 802 |
+
_data.coalesced.metaGroupSize = 1;
|
| 803 |
+
_data.coalesced.is_tiled = false;
|
| 804 |
+
}
|
| 805 |
+
|
| 806 |
+
_CG_QUALIFIER unsigned int get_mask() const {
|
| 807 |
+
return (_data.coalesced.mask);
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
public:
|
| 811 |
+
_CG_STATIC_CONST_DECL unsigned int _group_id = details::coalesced_group_id;
|
| 812 |
+
_CG_THREAD_SCOPE(cuda::thread_scope::thread_scope_block)
|
| 813 |
+
|
| 814 |
+
_CG_QUALIFIER unsigned int num_threads() const {
|
| 815 |
+
return _data.coalesced.size;
|
| 816 |
+
}
|
| 817 |
+
|
| 818 |
+
_CG_QUALIFIER unsigned int size() const {
|
| 819 |
+
return num_threads();
|
| 820 |
+
}
|
| 821 |
+
|
| 822 |
+
_CG_QUALIFIER unsigned int thread_rank() const {
|
| 823 |
+
return (__popc(_data.coalesced.mask & details::lanemask32_lt()));
|
| 824 |
+
}
|
| 825 |
+
|
| 826 |
+
// Rank of this group in the upper level of the hierarchy
|
| 827 |
+
_CG_QUALIFIER unsigned int meta_group_rank() const {
|
| 828 |
+
return _data.coalesced.metaGroupRank;
|
| 829 |
+
}
|
| 830 |
+
|
| 831 |
+
// Total num partitions created out of all CTAs when the group was created
|
| 832 |
+
_CG_QUALIFIER unsigned int meta_group_size() const {
|
| 833 |
+
return _data.coalesced.metaGroupSize;
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
_CG_QUALIFIER void sync() const {
|
| 837 |
+
__syncwarp(_data.coalesced.mask);
|
| 838 |
+
}
|
| 839 |
+
|
| 840 |
+
#ifdef _CG_CPP11_FEATURES
|
| 841 |
+
template <typename TyElem, typename TyRet = details::remove_qual<TyElem>>
|
| 842 |
+
_CG_QUALIFIER TyRet shfl(TyElem&& elem, int srcRank) const {
|
| 843 |
+
unsigned int lane = (srcRank == 0) ? __ffs(_data.coalesced.mask) - 1 :
|
| 844 |
+
(size() == 32) ? srcRank : __fns(_data.coalesced.mask, 0, (srcRank + 1));
|
| 845 |
+
|
| 846 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl(
|
| 847 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), _data.coalesced.mask, lane, 32);
|
| 848 |
+
}
|
| 849 |
+
|
| 850 |
+
template <typename TyElem, typename TyRet = details::remove_qual<TyElem>>
|
| 851 |
+
_CG_QUALIFIER TyRet shfl_down(TyElem&& elem, unsigned int delta) const {
|
| 852 |
+
if (size() == 32) {
|
| 853 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl_down(
|
| 854 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), 0xFFFFFFFF, delta, 32);
|
| 855 |
+
}
|
| 856 |
+
|
| 857 |
+
unsigned int lane = __fns(_data.coalesced.mask, details::laneid(), delta + 1);
|
| 858 |
+
|
| 859 |
+
if (lane >= 32)
|
| 860 |
+
lane = details::laneid();
|
| 861 |
+
|
| 862 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl(
|
| 863 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), _data.coalesced.mask, lane, 32);
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
template <typename TyElem, typename TyRet = details::remove_qual<TyElem>>
|
| 867 |
+
_CG_QUALIFIER TyRet shfl_up(TyElem&& elem, int delta) const {
|
| 868 |
+
if (size() == 32) {
|
| 869 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl_up(
|
| 870 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), 0xFFFFFFFF, delta, 32);
|
| 871 |
+
}
|
| 872 |
+
|
| 873 |
+
unsigned lane = __fns(_data.coalesced.mask, details::laneid(), -(delta + 1));
|
| 874 |
+
if (lane >= 32)
|
| 875 |
+
lane = details::laneid();
|
| 876 |
+
|
| 877 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl(
|
| 878 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), _data.coalesced.mask, lane, 32);
|
| 879 |
+
}
|
| 880 |
+
#else
|
| 881 |
+
template <typename TyIntegral>
|
| 882 |
+
_CG_QUALIFIER TyIntegral shfl(TyIntegral var, unsigned int src_rank) const {
|
| 883 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 884 |
+
unsigned int lane = (src_rank == 0) ? __ffs(_data.coalesced.mask) - 1 :
|
| 885 |
+
(size() == 32) ? src_rank : __fns(_data.coalesced.mask, 0, (src_rank + 1));
|
| 886 |
+
return (__shfl_sync(_data.coalesced.mask, var, lane, 32));
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
+
template <typename TyIntegral>
|
| 890 |
+
_CG_QUALIFIER TyIntegral shfl_up(TyIntegral var, int delta) const {
|
| 891 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 892 |
+
if (size() == 32) {
|
| 893 |
+
return (__shfl_up_sync(0xFFFFFFFF, var, delta, 32));
|
| 894 |
+
}
|
| 895 |
+
unsigned lane = __fns(_data.coalesced.mask, details::laneid(), -(delta + 1));
|
| 896 |
+
if (lane >= 32) lane = details::laneid();
|
| 897 |
+
return (__shfl_sync(_data.coalesced.mask, var, lane, 32));
|
| 898 |
+
}
|
| 899 |
+
|
| 900 |
+
template <typename TyIntegral>
|
| 901 |
+
_CG_QUALIFIER TyIntegral shfl_down(TyIntegral var, int delta) const {
|
| 902 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 903 |
+
if (size() == 32) {
|
| 904 |
+
return (__shfl_down_sync(0xFFFFFFFF, var, delta, 32));
|
| 905 |
+
}
|
| 906 |
+
unsigned int lane = __fns(_data.coalesced.mask, details::laneid(), delta + 1);
|
| 907 |
+
if (lane >= 32) lane = details::laneid();
|
| 908 |
+
return (__shfl_sync(_data.coalesced.mask, var, lane, 32));
|
| 909 |
+
}
|
| 910 |
+
#endif
|
| 911 |
+
|
| 912 |
+
_CG_QUALIFIER int any(int predicate) const {
|
| 913 |
+
return (__ballot_sync(_data.coalesced.mask, predicate) != 0);
|
| 914 |
+
}
|
| 915 |
+
_CG_QUALIFIER int all(int predicate) const {
|
| 916 |
+
return (__ballot_sync(_data.coalesced.mask, predicate) == _data.coalesced.mask);
|
| 917 |
+
}
|
| 918 |
+
_CG_QUALIFIER unsigned int ballot(int predicate) const {
|
| 919 |
+
if (size() == 32) {
|
| 920 |
+
return (__ballot_sync(0xFFFFFFFF, predicate));
|
| 921 |
+
}
|
| 922 |
+
unsigned int lane_ballot = __ballot_sync(_data.coalesced.mask, predicate);
|
| 923 |
+
return (_packLanes(lane_ballot));
|
| 924 |
+
}
|
| 925 |
+
|
| 926 |
+
#ifdef _CG_HAS_MATCH_COLLECTIVE
|
| 927 |
+
|
| 928 |
+
template <typename TyIntegral>
|
| 929 |
+
_CG_QUALIFIER unsigned int match_any(TyIntegral val) const {
|
| 930 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 931 |
+
if (size() == 32) {
|
| 932 |
+
return (__match_any_sync(0xFFFFFFFF, val));
|
| 933 |
+
}
|
| 934 |
+
unsigned int lane_match = __match_any_sync(_data.coalesced.mask, val);
|
| 935 |
+
return (_packLanes(lane_match));
|
| 936 |
+
}
|
| 937 |
+
|
| 938 |
+
template <typename TyIntegral>
|
| 939 |
+
_CG_QUALIFIER unsigned int match_all(TyIntegral val, int &pred) const {
|
| 940 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 941 |
+
if (size() == 32) {
|
| 942 |
+
return (__match_all_sync(0xFFFFFFFF, val, &pred));
|
| 943 |
+
}
|
| 944 |
+
unsigned int lane_match = __match_all_sync(_data.coalesced.mask, val, &pred);
|
| 945 |
+
return (_packLanes(lane_match));
|
| 946 |
+
}
|
| 947 |
+
|
| 948 |
+
#endif /* !_CG_HAS_MATCH_COLLECTIVE */
|
| 949 |
+
|
| 950 |
+
};
|
| 951 |
+
|
| 952 |
+
_CG_QUALIFIER coalesced_group coalesced_threads()
|
| 953 |
+
{
|
| 954 |
+
return (coalesced_group(__activemask()));
|
| 955 |
+
}
|
| 956 |
+
|
| 957 |
+
namespace details {
|
| 958 |
+
template <unsigned int Size> struct verify_thread_block_tile_size;
|
| 959 |
+
template <> struct verify_thread_block_tile_size<32> { typedef void OK; };
|
| 960 |
+
template <> struct verify_thread_block_tile_size<16> { typedef void OK; };
|
| 961 |
+
template <> struct verify_thread_block_tile_size<8> { typedef void OK; };
|
| 962 |
+
template <> struct verify_thread_block_tile_size<4> { typedef void OK; };
|
| 963 |
+
template <> struct verify_thread_block_tile_size<2> { typedef void OK; };
|
| 964 |
+
template <> struct verify_thread_block_tile_size<1> { typedef void OK; };
|
| 965 |
+
|
| 966 |
+
#ifdef _CG_CPP11_FEATURES
|
| 967 |
+
template <unsigned int Size>
|
| 968 |
+
using _is_power_of_2 = _CG_STL_NAMESPACE::integral_constant<bool, (Size & (Size - 1)) == 0>;
|
| 969 |
+
|
| 970 |
+
template <unsigned int Size>
|
| 971 |
+
using _is_single_warp = _CG_STL_NAMESPACE::integral_constant<bool, Size <= 32>;
|
| 972 |
+
template <unsigned int Size>
|
| 973 |
+
using _is_multi_warp =
|
| 974 |
+
_CG_STL_NAMESPACE::integral_constant<bool, (Size > 32) && (Size <= 1024)>;
|
| 975 |
+
|
| 976 |
+
template <unsigned int Size>
|
| 977 |
+
using _is_valid_single_warp_tile =
|
| 978 |
+
_CG_STL_NAMESPACE::integral_constant<bool, _is_power_of_2<Size>::value && _is_single_warp<Size>::value>;
|
| 979 |
+
template <unsigned int Size>
|
| 980 |
+
using _is_valid_multi_warp_tile =
|
| 981 |
+
_CG_STL_NAMESPACE::integral_constant<bool, _is_power_of_2<Size>::value && _is_multi_warp<Size>::value>;
|
| 982 |
+
#else
|
| 983 |
+
template <unsigned int Size>
|
| 984 |
+
struct _is_multi_warp {
|
| 985 |
+
static const bool value = false;
|
| 986 |
+
};
|
| 987 |
+
#endif
|
| 988 |
+
}
|
| 989 |
+
|
| 990 |
+
template <unsigned int Size>
|
| 991 |
+
class __static_size_tile_base
|
| 992 |
+
{
|
| 993 |
+
protected:
|
| 994 |
+
_CG_STATIC_CONST_DECL unsigned int numThreads = Size;
|
| 995 |
+
|
| 996 |
+
public:
|
| 997 |
+
_CG_THREAD_SCOPE(cuda::thread_scope::thread_scope_block)
|
| 998 |
+
|
| 999 |
+
// Rank of thread within tile
|
| 1000 |
+
_CG_STATIC_QUALIFIER unsigned int thread_rank() {
|
| 1001 |
+
return (details::cta::thread_rank() & (numThreads - 1));
|
| 1002 |
+
}
|
| 1003 |
+
|
| 1004 |
+
// Number of threads within tile
|
| 1005 |
+
_CG_STATIC_CONSTEXPR_QUALIFIER unsigned int num_threads() {
|
| 1006 |
+
return numThreads;
|
| 1007 |
+
}
|
| 1008 |
+
|
| 1009 |
+
_CG_STATIC_CONSTEXPR_QUALIFIER unsigned int size() {
|
| 1010 |
+
return num_threads();
|
| 1011 |
+
}
|
| 1012 |
+
};
|
| 1013 |
+
|
| 1014 |
+
template <unsigned int Size>
|
| 1015 |
+
class __static_size_thread_block_tile_base : public __static_size_tile_base<Size>
|
| 1016 |
+
{
|
| 1017 |
+
friend class details::_coalesced_group_data_access;
|
| 1018 |
+
typedef details::tile::tile_helpers<Size> th;
|
| 1019 |
+
|
| 1020 |
+
#ifdef _CG_CPP11_FEATURES
|
| 1021 |
+
static_assert(details::_is_valid_single_warp_tile<Size>::value, "Size must be one of 1/2/4/8/16/32");
|
| 1022 |
+
#else
|
| 1023 |
+
typedef typename details::verify_thread_block_tile_size<Size>::OK valid;
|
| 1024 |
+
#endif
|
| 1025 |
+
using __static_size_tile_base<Size>::numThreads;
|
| 1026 |
+
_CG_STATIC_CONST_DECL unsigned int fullMask = 0xFFFFFFFF;
|
| 1027 |
+
|
| 1028 |
+
protected:
|
| 1029 |
+
_CG_STATIC_QUALIFIER unsigned int build_mask() {
|
| 1030 |
+
unsigned int mask = fullMask;
|
| 1031 |
+
if (numThreads != 32) {
|
| 1032 |
+
// [0,31] representing the current active thread in the warp
|
| 1033 |
+
unsigned int laneId = details::laneid();
|
| 1034 |
+
// shift mask according to the partition it belongs to
|
| 1035 |
+
mask = th::tileMask << (laneId & ~(th::laneMask));
|
| 1036 |
+
}
|
| 1037 |
+
return (mask);
|
| 1038 |
+
}
|
| 1039 |
+
|
| 1040 |
+
public:
|
| 1041 |
+
_CG_STATIC_CONST_DECL unsigned int _group_id = details::coalesced_group_id;
|
| 1042 |
+
|
| 1043 |
+
_CG_STATIC_QUALIFIER void sync() {
|
| 1044 |
+
__syncwarp(build_mask());
|
| 1045 |
+
}
|
| 1046 |
+
|
| 1047 |
+
#ifdef _CG_CPP11_FEATURES
|
| 1048 |
+
// PTX supported collectives
|
| 1049 |
+
template <typename TyElem, typename TyRet = details::remove_qual<TyElem>>
|
| 1050 |
+
_CG_QUALIFIER TyRet shfl(TyElem&& elem, int srcRank) const {
|
| 1051 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl(
|
| 1052 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), build_mask(), srcRank, numThreads);
|
| 1053 |
+
}
|
| 1054 |
+
|
| 1055 |
+
template <typename TyElem, typename TyRet = details::remove_qual<TyElem>>
|
| 1056 |
+
_CG_QUALIFIER TyRet shfl_down(TyElem&& elem, unsigned int delta) const {
|
| 1057 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl_down(
|
| 1058 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), build_mask(), delta, numThreads);
|
| 1059 |
+
}
|
| 1060 |
+
|
| 1061 |
+
template <typename TyElem, typename TyRet = details::remove_qual<TyElem>>
|
| 1062 |
+
_CG_QUALIFIER TyRet shfl_up(TyElem&& elem, unsigned int delta) const {
|
| 1063 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl_up(
|
| 1064 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), build_mask(), delta, numThreads);
|
| 1065 |
+
}
|
| 1066 |
+
|
| 1067 |
+
template <typename TyElem, typename TyRet = details::remove_qual<TyElem>>
|
| 1068 |
+
_CG_QUALIFIER TyRet shfl_xor(TyElem&& elem, unsigned int laneMask) const {
|
| 1069 |
+
return details::tile::shuffle_dispatch<TyElem>::shfl_xor(
|
| 1070 |
+
_CG_STL_NAMESPACE::forward<TyElem>(elem), build_mask(), laneMask, numThreads);
|
| 1071 |
+
}
|
| 1072 |
+
#else
|
| 1073 |
+
template <typename TyIntegral>
|
| 1074 |
+
_CG_QUALIFIER TyIntegral shfl(TyIntegral var, int srcRank) const {
|
| 1075 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 1076 |
+
return (__shfl_sync(build_mask(), var, srcRank, numThreads));
|
| 1077 |
+
}
|
| 1078 |
+
|
| 1079 |
+
template <typename TyIntegral>
|
| 1080 |
+
_CG_QUALIFIER TyIntegral shfl_down(TyIntegral var, unsigned int delta) const {
|
| 1081 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 1082 |
+
return (__shfl_down_sync(build_mask(), var, delta, numThreads));
|
| 1083 |
+
}
|
| 1084 |
+
|
| 1085 |
+
template <typename TyIntegral>
|
| 1086 |
+
_CG_QUALIFIER TyIntegral shfl_up(TyIntegral var, unsigned int delta) const {
|
| 1087 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 1088 |
+
return (__shfl_up_sync(build_mask(), var, delta, numThreads));
|
| 1089 |
+
}
|
| 1090 |
+
|
| 1091 |
+
template <typename TyIntegral>
|
| 1092 |
+
_CG_QUALIFIER TyIntegral shfl_xor(TyIntegral var, unsigned int laneMask) const {
|
| 1093 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 1094 |
+
return (__shfl_xor_sync(build_mask(), var, laneMask, numThreads));
|
| 1095 |
+
}
|
| 1096 |
+
#endif //_CG_CPP11_FEATURES
|
| 1097 |
+
|
| 1098 |
+
_CG_QUALIFIER int any(int predicate) const {
|
| 1099 |
+
unsigned int lane_ballot = __ballot_sync(build_mask(), predicate);
|
| 1100 |
+
return (lane_ballot != 0);
|
| 1101 |
+
}
|
| 1102 |
+
_CG_QUALIFIER int all(int predicate) const {
|
| 1103 |
+
unsigned int lane_ballot = __ballot_sync(build_mask(), predicate);
|
| 1104 |
+
return (lane_ballot == build_mask());
|
| 1105 |
+
}
|
| 1106 |
+
_CG_QUALIFIER unsigned int ballot(int predicate) const {
|
| 1107 |
+
unsigned int lane_ballot = __ballot_sync(build_mask(), predicate);
|
| 1108 |
+
return (lane_ballot >> (details::laneid() & (~(th::laneMask))));
|
| 1109 |
+
}
|
| 1110 |
+
|
| 1111 |
+
#ifdef _CG_HAS_MATCH_COLLECTIVE
|
| 1112 |
+
template <typename TyIntegral>
|
| 1113 |
+
_CG_QUALIFIER unsigned int match_any(TyIntegral val) const {
|
| 1114 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 1115 |
+
unsigned int lane_match = __match_any_sync(build_mask(), val);
|
| 1116 |
+
return (lane_match >> (details::laneid() & (~(th::laneMask))));
|
| 1117 |
+
}
|
| 1118 |
+
|
| 1119 |
+
template <typename TyIntegral>
|
| 1120 |
+
_CG_QUALIFIER unsigned int match_all(TyIntegral val, int &pred) const {
|
| 1121 |
+
details::assert_if_not_arithmetic<TyIntegral>();
|
| 1122 |
+
unsigned int lane_match = __match_all_sync(build_mask(), val, &pred);
|
| 1123 |
+
return (lane_match >> (details::laneid() & (~(th::laneMask))));
|
| 1124 |
+
}
|
| 1125 |
+
#endif
|
| 1126 |
+
|
| 1127 |
+
};
|
| 1128 |
+
|
| 1129 |
+
template <unsigned int Size, typename ParentT>
|
| 1130 |
+
class __static_parent_thread_block_tile_base
|
| 1131 |
+
{
|
| 1132 |
+
public:
|
| 1133 |
+
// Rank of this group in the upper level of the hierarchy
|
| 1134 |
+
_CG_STATIC_QUALIFIER unsigned int meta_group_rank() {
|
| 1135 |
+
return ParentT::thread_rank() / Size;
|
| 1136 |
+
}
|
| 1137 |
+
|
| 1138 |
+
// Total num partitions created out of all CTAs when the group was created
|
| 1139 |
+
_CG_STATIC_QUALIFIER unsigned int meta_group_size() {
|
| 1140 |
+
return (ParentT::size() + Size - 1) / Size;
|
| 1141 |
+
}
|
| 1142 |
+
};
|
| 1143 |
+
|
| 1144 |
+
/**
|
| 1145 |
+
* class thread_block_tile<unsigned int Size, ParentT = void>
|
| 1146 |
+
*
|
| 1147 |
+
* Statically-sized group type, representing one tile of a thread block.
|
| 1148 |
+
* The only specializations currently supported are those with native
|
| 1149 |
+
* hardware support (1/2/4/8/16/32)
|
| 1150 |
+
*
|
| 1151 |
+
* This group exposes warp-synchronous builtins.
|
| 1152 |
+
* Can only be constructed via tiled_partition<Size>(ParentT&)
|
| 1153 |
+
*/
|
| 1154 |
+
|
| 1155 |
+
template <unsigned int Size, typename ParentT = void>
|
| 1156 |
+
class __single_warp_thread_block_tile :
|
| 1157 |
+
public __static_size_thread_block_tile_base<Size>,
|
| 1158 |
+
public __static_parent_thread_block_tile_base<Size, ParentT>
|
| 1159 |
+
{
|
| 1160 |
+
typedef __static_parent_thread_block_tile_base<Size, ParentT> staticParentBaseT;
|
| 1161 |
+
friend class details::_coalesced_group_data_access;
|
| 1162 |
+
|
| 1163 |
+
protected:
|
| 1164 |
+
_CG_QUALIFIER __single_warp_thread_block_tile() { };
|
| 1165 |
+
_CG_QUALIFIER __single_warp_thread_block_tile(unsigned int, unsigned int) { };
|
| 1166 |
+
|
| 1167 |
+
_CG_STATIC_QUALIFIER unsigned int get_mask() {
|
| 1168 |
+
return __static_size_thread_block_tile_base<Size>::build_mask();
|
| 1169 |
+
}
|
| 1170 |
+
};
|
| 1171 |
+
|
| 1172 |
+
template <unsigned int Size>
|
| 1173 |
+
class __single_warp_thread_block_tile<Size, void> :
|
| 1174 |
+
public __static_size_thread_block_tile_base<Size>,
|
| 1175 |
+
public thread_group_base<details::coalesced_group_id>
|
| 1176 |
+
{
|
| 1177 |
+
_CG_STATIC_CONST_DECL unsigned int numThreads = Size;
|
| 1178 |
+
|
| 1179 |
+
template <unsigned int, typename ParentT> friend class __single_warp_thread_block_tile;
|
| 1180 |
+
friend class details::_coalesced_group_data_access;
|
| 1181 |
+
|
| 1182 |
+
typedef __static_size_thread_block_tile_base<numThreads> staticSizeBaseT;
|
| 1183 |
+
|
| 1184 |
+
protected:
|
| 1185 |
+
_CG_QUALIFIER __single_warp_thread_block_tile(unsigned int meta_group_rank = 0, unsigned int meta_group_size = 1) {
|
| 1186 |
+
_data.coalesced.mask = staticSizeBaseT::build_mask();
|
| 1187 |
+
_data.coalesced.size = numThreads;
|
| 1188 |
+
_data.coalesced.metaGroupRank = meta_group_rank;
|
| 1189 |
+
_data.coalesced.metaGroupSize = meta_group_size;
|
| 1190 |
+
_data.coalesced.is_tiled = true;
|
| 1191 |
+
}
|
| 1192 |
+
|
| 1193 |
+
_CG_QUALIFIER unsigned int get_mask() const {
|
| 1194 |
+
return (_data.coalesced.mask);
|
| 1195 |
+
}
|
| 1196 |
+
|
| 1197 |
+
public:
|
| 1198 |
+
using staticSizeBaseT::sync;
|
| 1199 |
+
using staticSizeBaseT::size;
|
| 1200 |
+
using staticSizeBaseT::num_threads;
|
| 1201 |
+
using staticSizeBaseT::thread_rank;
|
| 1202 |
+
|
| 1203 |
+
_CG_QUALIFIER unsigned int meta_group_rank() const {
|
| 1204 |
+
return _data.coalesced.metaGroupRank;
|
| 1205 |
+
}
|
| 1206 |
+
|
| 1207 |
+
_CG_QUALIFIER unsigned int meta_group_size() const {
|
| 1208 |
+
return _data.coalesced.metaGroupSize;
|
| 1209 |
+
}
|
| 1210 |
+
};
|
| 1211 |
+
|
| 1212 |
+
/**
|
| 1213 |
+
* Outer level API calls
|
| 1214 |
+
* void sync(GroupT) - see <group_type>.sync()
|
| 1215 |
+
* void thread_rank(GroupT) - see <group_type>.thread_rank()
|
| 1216 |
+
* void group_size(GroupT) - see <group_type>.size()
|
| 1217 |
+
*/
|
| 1218 |
+
template <class GroupT>
|
| 1219 |
+
_CG_QUALIFIER void sync(GroupT const &g)
|
| 1220 |
+
{
|
| 1221 |
+
g.sync();
|
| 1222 |
+
}
|
| 1223 |
+
|
| 1224 |
+
// TODO: Use a static dispatch to determine appropriate return type
|
| 1225 |
+
// C++03 is stuck with unsigned long long for now
|
| 1226 |
+
#ifdef _CG_CPP11_FEATURES
|
| 1227 |
+
template <class GroupT>
|
| 1228 |
+
_CG_QUALIFIER auto thread_rank(GroupT const& g) -> decltype(g.thread_rank()) {
|
| 1229 |
+
return g.thread_rank();
|
| 1230 |
+
}
|
| 1231 |
+
|
| 1232 |
+
|
| 1233 |
+
template <class GroupT>
|
| 1234 |
+
_CG_QUALIFIER auto group_size(GroupT const &g) -> decltype(g.num_threads()) {
|
| 1235 |
+
return g.num_threads();
|
| 1236 |
+
}
|
| 1237 |
+
#else
|
| 1238 |
+
template <class GroupT>
|
| 1239 |
+
_CG_QUALIFIER unsigned long long thread_rank(GroupT const& g) {
|
| 1240 |
+
return static_cast<unsigned long long>(g.thread_rank());
|
| 1241 |
+
}
|
| 1242 |
+
|
| 1243 |
+
|
| 1244 |
+
template <class GroupT>
|
| 1245 |
+
_CG_QUALIFIER unsigned long long group_size(GroupT const &g) {
|
| 1246 |
+
return static_cast<unsigned long long>(g.num_threads());
|
| 1247 |
+
}
|
| 1248 |
+
#endif
|
| 1249 |
+
|
| 1250 |
+
|
| 1251 |
+
/**
|
| 1252 |
+
* tiled_partition
|
| 1253 |
+
*
|
| 1254 |
+
* The tiled_partition(parent, tilesz) method is a collective operation that
|
| 1255 |
+
* partitions the parent group into a one-dimensional, row-major, tiling of subgroups.
|
| 1256 |
+
*
|
| 1257 |
+
* A total of ((size(parent)+tilesz-1)/tilesz) subgroups will
|
| 1258 |
+
* be created where threads having identical k = (thread_rank(parent)/tilesz)
|
| 1259 |
+
* will be members of the same subgroup.
|
| 1260 |
+
*
|
| 1261 |
+
* The implementation may cause the calling thread to wait until all the members
|
| 1262 |
+
* of the parent group have invoked the operation before resuming execution.
|
| 1263 |
+
*
|
| 1264 |
+
* Functionality is limited to power-of-two sized subgorup instances of at most
|
| 1265 |
+
* 32 threads. Only thread_block, thread_block_tile<>, and their subgroups can be
|
| 1266 |
+
* tiled_partition() in _CG_VERSION 1000.
|
| 1267 |
+
*/
|
| 1268 |
+
_CG_QUALIFIER thread_group tiled_partition(const thread_group& parent, unsigned int tilesz)
|
| 1269 |
+
{
|
| 1270 |
+
if (parent.get_type() == details::coalesced_group_id) {
|
| 1271 |
+
const coalesced_group *_cg = static_cast<const coalesced_group*>(&parent);
|
| 1272 |
+
return _cg->_get_tiled_threads(tilesz);
|
| 1273 |
+
}
|
| 1274 |
+
else {
|
| 1275 |
+
const thread_block *_tb = static_cast<const thread_block*>(&parent);
|
| 1276 |
+
return _tb->_get_tiled_threads(tilesz);
|
| 1277 |
+
}
|
| 1278 |
+
}
|
| 1279 |
+
|
| 1280 |
+
// Thread block type overload: returns a basic thread_group for now (may be specialized later)
|
| 1281 |
+
_CG_QUALIFIER thread_group tiled_partition(const thread_block& parent, unsigned int tilesz)
|
| 1282 |
+
{
|
| 1283 |
+
return (parent._get_tiled_threads(tilesz));
|
| 1284 |
+
}
|
| 1285 |
+
|
| 1286 |
+
// Coalesced group type overload: retains its ability to stay coalesced
|
| 1287 |
+
_CG_QUALIFIER coalesced_group tiled_partition(const coalesced_group& parent, unsigned int tilesz)
|
| 1288 |
+
{
|
| 1289 |
+
return (parent._get_tiled_threads(tilesz));
|
| 1290 |
+
}
|
| 1291 |
+
|
| 1292 |
+
namespace details {
|
| 1293 |
+
template <unsigned int Size, typename ParentT>
|
| 1294 |
+
class internal_thread_block_tile : public __single_warp_thread_block_tile<Size, ParentT> {};
|
| 1295 |
+
|
| 1296 |
+
template <unsigned int Size, typename ParentT>
|
| 1297 |
+
_CG_QUALIFIER internal_thread_block_tile<Size, ParentT> tiled_partition_internal() {
|
| 1298 |
+
return internal_thread_block_tile<Size, ParentT>();
|
| 1299 |
+
}
|
| 1300 |
+
|
| 1301 |
+
template <typename TyVal, typename GroupT, typename WarpLambda, typename InterWarpLambda>
|
| 1302 |
+
_CG_QUALIFIER TyVal multi_warp_collectives_helper(
|
| 1303 |
+
const GroupT& group,
|
| 1304 |
+
WarpLambda warp_lambda,
|
| 1305 |
+
InterWarpLambda inter_warp_lambda) {
|
| 1306 |
+
return group.template collectives_scheme<TyVal>(warp_lambda, inter_warp_lambda);
|
| 1307 |
+
}
|
| 1308 |
+
|
| 1309 |
+
template <typename T, typename GroupT>
|
| 1310 |
+
_CG_QUALIFIER T* multi_warp_scratch_location_getter(const GroupT& group, unsigned int warp_id) {
|
| 1311 |
+
return group.template get_scratch_location<T>(warp_id);
|
| 1312 |
+
}
|
| 1313 |
+
|
| 1314 |
+
template <typename GroupT>
|
| 1315 |
+
_CG_QUALIFIER details::barrier_t* multi_warp_sync_location_getter(const GroupT& group) {
|
| 1316 |
+
return group.get_sync_location();
|
| 1317 |
+
}
|
| 1318 |
+
|
| 1319 |
+
}
|
| 1320 |
+
/**
|
| 1321 |
+
* tiled_partition<tilesz>
|
| 1322 |
+
*
|
| 1323 |
+
* The tiled_partition<tilesz>(parent) method is a collective operation that
|
| 1324 |
+
* partitions the parent group into a one-dimensional, row-major, tiling of subgroups.
|
| 1325 |
+
*
|
| 1326 |
+
* A total of ((size(parent)/tilesz) subgroups will be created,
|
| 1327 |
+
* therefore the parent group size must be evenly divisible by the tilesz.
|
| 1328 |
+
* The allow parent groups are thread_block or thread_block_tile<size>.
|
| 1329 |
+
*
|
| 1330 |
+
* The implementation may cause the calling thread to wait until all the members
|
| 1331 |
+
* of the parent group have invoked the operation before resuming execution.
|
| 1332 |
+
*
|
| 1333 |
+
* Functionality is limited to native hardware sizes, 1/2/4/8/16/32.
|
| 1334 |
+
* The size(parent) must be greater than the template Size parameter
|
| 1335 |
+
* otherwise the results are undefined.
|
| 1336 |
+
*/
|
| 1337 |
+
|
| 1338 |
+
#if defined(_CG_CPP11_FEATURES)
|
| 1339 |
+
template <unsigned int Size>
|
| 1340 |
+
class __static_size_multi_warp_tile_base : public __static_size_tile_base<Size>
|
| 1341 |
+
{
|
| 1342 |
+
static_assert(details::_is_valid_multi_warp_tile<Size>::value, "Size must be one of 64/128/256/512");
|
| 1343 |
+
|
| 1344 |
+
template <typename TyVal, typename GroupT, typename WarpLambda, typename InterWarpLambda>
|
| 1345 |
+
friend __device__ TyVal details::multi_warp_collectives_helper(
|
| 1346 |
+
const GroupT& group,
|
| 1347 |
+
WarpLambda warp_lambda,
|
| 1348 |
+
InterWarpLambda inter_warp_lambda);
|
| 1349 |
+
template <typename T, typename GroupT>
|
| 1350 |
+
friend __device__ T* details::multi_warp_scratch_location_getter(const GroupT& group, unsigned int warp_id);
|
| 1351 |
+
template <typename GroupT>
|
| 1352 |
+
friend __device__ details::barrier_t* details::multi_warp_sync_location_getter(const GroupT& group);
|
| 1353 |
+
template <unsigned int OtherSize>
|
| 1354 |
+
friend class __static_size_multi_warp_tile_base;
|
| 1355 |
+
using WarpType = details::internal_thread_block_tile<32, __static_size_multi_warp_tile_base<Size>>;
|
| 1356 |
+
using ThisType = __static_size_multi_warp_tile_base<Size>;
|
| 1357 |
+
_CG_STATIC_CONST_DECL int numWarps = Size / 32;
|
| 1358 |
+
|
| 1359 |
+
protected:
|
| 1360 |
+
details::multi_warp_scratch* const tile_memory;
|
| 1361 |
+
|
| 1362 |
+
template <typename GroupT>
|
| 1363 |
+
_CG_QUALIFIER __static_size_multi_warp_tile_base(const GroupT& g) : tile_memory(g.tile_memory) {
|
| 1364 |
+
#if !defined(_CG_USER_PROVIDED_SHARED_MEMORY)
|
| 1365 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80,
|
| 1366 |
+
details::sync_warps_reset(get_sync_location(), details::cta::thread_rank());
|
| 1367 |
+
g.sync();
|
| 1368 |
+
)
|
| 1369 |
+
#endif
|
| 1370 |
+
}
|
| 1371 |
+
|
| 1372 |
+
|
| 1373 |
+
private:
|
| 1374 |
+
_CG_QUALIFIER details::barrier_t* get_sync_location() const {
|
| 1375 |
+
// Different group sizes use different barriers, all groups of a given size share one barrier.
|
| 1376 |
+
unsigned int sync_id = details::log2(Size / 64);
|
| 1377 |
+
return &tile_memory->barriers[sync_id];
|
| 1378 |
+
}
|
| 1379 |
+
|
| 1380 |
+
template <typename T>
|
| 1381 |
+
_CG_QUALIFIER T* get_scratch_location(unsigned int warp_id) const {
|
| 1382 |
+
unsigned int scratch_id = (details::cta::thread_rank() - thread_rank()) / 32 + warp_id;
|
| 1383 |
+
return reinterpret_cast<T*>(&tile_memory->communication_memory[scratch_id]);
|
| 1384 |
+
}
|
| 1385 |
+
|
| 1386 |
+
template <typename T>
|
| 1387 |
+
_CG_QUALIFIER T* get_scratch_location() const {
|
| 1388 |
+
unsigned int scratch_id = details::cta::thread_rank() / 32;
|
| 1389 |
+
return reinterpret_cast<T*>(&tile_memory->communication_memory[scratch_id]);
|
| 1390 |
+
}
|
| 1391 |
+
|
| 1392 |
+
template <typename TyVal>
|
| 1393 |
+
_CG_QUALIFIER TyVal shfl_impl(TyVal val, unsigned int src) const {
|
| 1394 |
+
unsigned int src_warp = src / 32;
|
| 1395 |
+
auto warp = details::tiled_partition_internal<32, ThisType>();
|
| 1396 |
+
details::barrier_t* sync_location = get_sync_location();
|
| 1397 |
+
|
| 1398 |
+
// Get warp slot of the source threads warp.
|
| 1399 |
+
TyVal* warp_scratch_location = get_scratch_location<TyVal>(src_warp);
|
| 1400 |
+
|
| 1401 |
+
if (warp.meta_group_rank() == src_warp) {
|
| 1402 |
+
warp.sync();
|
| 1403 |
+
// Put shuffled value into my warp slot and let my warp arrive at the barrier.
|
| 1404 |
+
if (thread_rank() == src) {
|
| 1405 |
+
*warp_scratch_location = val;
|
| 1406 |
+
}
|
| 1407 |
+
details::sync_warps_arrive(sync_location, details::cta::thread_rank(), numWarps);
|
| 1408 |
+
TyVal result = *warp_scratch_location;
|
| 1409 |
+
details::sync_warps_wait(sync_location, details::cta::thread_rank());
|
| 1410 |
+
return result;
|
| 1411 |
+
}
|
| 1412 |
+
else {
|
| 1413 |
+
// Wait for the source warp to arrive on the barrier.
|
| 1414 |
+
details::sync_warps_wait_for_specific_warp(sync_location,
|
| 1415 |
+
(details::cta::thread_rank() / 32 - warp.meta_group_rank() + src_warp));
|
| 1416 |
+
TyVal result = *warp_scratch_location;
|
| 1417 |
+
details::sync_warps(sync_location, details::cta::thread_rank(), numWarps);
|
| 1418 |
+
return result;
|
| 1419 |
+
}
|
| 1420 |
+
}
|
| 1421 |
+
|
| 1422 |
+
template <typename TyVal, typename WarpLambda, typename InterWarpLambda>
|
| 1423 |
+
_CG_QUALIFIER TyVal collectives_scheme(const WarpLambda& warp_lambda, const InterWarpLambda& inter_warp_lambda) const {
|
| 1424 |
+
static_assert(sizeof(TyVal) <= details::multi_warp_scratch::communication_size,
|
| 1425 |
+
"Collectives with tiles larger than 32 threads are limited to types smaller then 8 bytes");
|
| 1426 |
+
auto warp = details::tiled_partition_internal<32, ThisType>();
|
| 1427 |
+
details::barrier_t* sync_location = get_sync_location();
|
| 1428 |
+
TyVal* warp_scratch_location = get_scratch_location<TyVal>();
|
| 1429 |
+
|
| 1430 |
+
warp_lambda(warp, warp_scratch_location);
|
| 1431 |
+
|
| 1432 |
+
if (details::sync_warps_last_releases(sync_location, details::cta::thread_rank(), numWarps)) {
|
| 1433 |
+
auto subwarp = details::tiled_partition_internal<numWarps, decltype(warp)>();
|
| 1434 |
+
if (subwarp.meta_group_rank() == 0) {
|
| 1435 |
+
TyVal* thread_scratch_location = get_scratch_location<TyVal>(subwarp.thread_rank());
|
| 1436 |
+
inter_warp_lambda(subwarp, thread_scratch_location);
|
| 1437 |
+
}
|
| 1438 |
+
warp.sync();
|
| 1439 |
+
details::sync_warps_release(sync_location, warp.thread_rank() == 0, details::cta::thread_rank(), numWarps);
|
| 1440 |
+
}
|
| 1441 |
+
TyVal result = *warp_scratch_location;
|
| 1442 |
+
return result;
|
| 1443 |
+
}
|
| 1444 |
+
|
| 1445 |
+
public:
|
| 1446 |
+
_CG_STATIC_CONST_DECL unsigned int _group_id = details::multi_tile_group_id;
|
| 1447 |
+
|
| 1448 |
+
using __static_size_tile_base<Size>::thread_rank;
|
| 1449 |
+
|
| 1450 |
+
template <typename TyVal>
|
| 1451 |
+
_CG_QUALIFIER TyVal shfl(TyVal val, unsigned int src) const {
|
| 1452 |
+
static_assert(sizeof(TyVal) <= details::multi_warp_scratch::communication_size,
|
| 1453 |
+
"Collectives with tiles larger than 32 threads are limited to types smaller then 8 bytes");
|
| 1454 |
+
return shfl_impl(val, src);
|
| 1455 |
+
}
|
| 1456 |
+
|
| 1457 |
+
_CG_QUALIFIER void sync() const {
|
| 1458 |
+
details::sync_warps(get_sync_location(), details::cta::thread_rank(), numWarps);
|
| 1459 |
+
}
|
| 1460 |
+
|
| 1461 |
+
_CG_QUALIFIER int any(int predicate) const {
|
| 1462 |
+
auto warp_lambda = [=] (WarpType& warp, int* warp_scratch_location) {
|
| 1463 |
+
*warp_scratch_location = __any_sync(0xFFFFFFFF, predicate);
|
| 1464 |
+
};
|
| 1465 |
+
auto inter_warp_lambda =
|
| 1466 |
+
[] (details::internal_thread_block_tile<numWarps, WarpType>& subwarp, int* thread_scratch_location) {
|
| 1467 |
+
*thread_scratch_location = __any_sync(0xFFFFFFFFU >> (32 - numWarps), *thread_scratch_location);
|
| 1468 |
+
};
|
| 1469 |
+
return collectives_scheme<int>(warp_lambda, inter_warp_lambda);
|
| 1470 |
+
}
|
| 1471 |
+
|
| 1472 |
+
_CG_QUALIFIER int all(int predicate) const {
|
| 1473 |
+
auto warp_lambda = [=] (WarpType& warp, int* warp_scratch_location) {
|
| 1474 |
+
*warp_scratch_location = __all_sync(0xFFFFFFFF, predicate);
|
| 1475 |
+
};
|
| 1476 |
+
auto inter_warp_lambda =
|
| 1477 |
+
[] (details::internal_thread_block_tile<numWarps, WarpType>& subwarp, int* thread_scratch_location) {
|
| 1478 |
+
*thread_scratch_location = __all_sync(0xFFFFFFFFU >> (32 - numWarps), *thread_scratch_location);
|
| 1479 |
+
};
|
| 1480 |
+
return collectives_scheme<int>(warp_lambda, inter_warp_lambda);
|
| 1481 |
+
}
|
| 1482 |
+
};
|
| 1483 |
+
|
| 1484 |
+
|
| 1485 |
+
template <unsigned int Size, typename ParentT = void>
|
| 1486 |
+
class __multi_warp_thread_block_tile :
|
| 1487 |
+
public __static_size_multi_warp_tile_base<Size>,
|
| 1488 |
+
public __static_parent_thread_block_tile_base<Size, ParentT>
|
| 1489 |
+
{
|
| 1490 |
+
typedef __static_parent_thread_block_tile_base<Size, ParentT> staticParentBaseT;
|
| 1491 |
+
typedef __static_size_multi_warp_tile_base<Size> staticTileBaseT;
|
| 1492 |
+
protected:
|
| 1493 |
+
_CG_QUALIFIER __multi_warp_thread_block_tile(const ParentT& g) :
|
| 1494 |
+
__static_size_multi_warp_tile_base<Size>(g) {}
|
| 1495 |
+
};
|
| 1496 |
+
|
| 1497 |
+
template <unsigned int Size>
|
| 1498 |
+
class __multi_warp_thread_block_tile<Size, void> : public __static_size_multi_warp_tile_base<Size>
|
| 1499 |
+
{
|
| 1500 |
+
const unsigned int metaGroupRank;
|
| 1501 |
+
const unsigned int metaGroupSize;
|
| 1502 |
+
|
| 1503 |
+
protected:
|
| 1504 |
+
template <unsigned int OtherSize, typename ParentT>
|
| 1505 |
+
_CG_QUALIFIER __multi_warp_thread_block_tile(const __multi_warp_thread_block_tile<OtherSize, ParentT>& g) :
|
| 1506 |
+
__static_size_multi_warp_tile_base<Size>(g), metaGroupRank(g.meta_group_rank()), metaGroupSize(g.meta_group_size()) {}
|
| 1507 |
+
|
| 1508 |
+
public:
|
| 1509 |
+
_CG_QUALIFIER unsigned int meta_group_rank() const {
|
| 1510 |
+
return metaGroupRank;
|
| 1511 |
+
}
|
| 1512 |
+
|
| 1513 |
+
_CG_QUALIFIER unsigned int meta_group_size() const {
|
| 1514 |
+
return metaGroupSize;
|
| 1515 |
+
}
|
| 1516 |
+
};
|
| 1517 |
+
#endif
|
| 1518 |
+
|
| 1519 |
+
template <unsigned int Size, typename ParentT = void>
|
| 1520 |
+
class thread_block_tile;
|
| 1521 |
+
|
| 1522 |
+
namespace details {
|
| 1523 |
+
template <unsigned int Size, typename ParentT, bool IsMultiWarp>
|
| 1524 |
+
class thread_block_tile_impl;
|
| 1525 |
+
|
| 1526 |
+
template <unsigned int Size, typename ParentT>
|
| 1527 |
+
class thread_block_tile_impl<Size, ParentT, false>: public __single_warp_thread_block_tile<Size, ParentT>
|
| 1528 |
+
{
|
| 1529 |
+
protected:
|
| 1530 |
+
template <unsigned int OtherSize, typename OtherParentT, bool OtherIsMultiWarp>
|
| 1531 |
+
_CG_QUALIFIER thread_block_tile_impl(const thread_block_tile_impl<OtherSize, OtherParentT, OtherIsMultiWarp>& g) :
|
| 1532 |
+
__single_warp_thread_block_tile<Size, ParentT>(g.meta_group_rank(), g.meta_group_size()) {}
|
| 1533 |
+
|
| 1534 |
+
_CG_QUALIFIER thread_block_tile_impl(const thread_block& g) :
|
| 1535 |
+
__single_warp_thread_block_tile<Size, ParentT>() {}
|
| 1536 |
+
};
|
| 1537 |
+
|
| 1538 |
+
#if defined(_CG_CPP11_FEATURES)
|
| 1539 |
+
template <unsigned int Size, typename ParentT>
|
| 1540 |
+
class thread_block_tile_impl<Size, ParentT, true> : public __multi_warp_thread_block_tile<Size, ParentT>
|
| 1541 |
+
{
|
| 1542 |
+
protected:
|
| 1543 |
+
template <typename GroupT>
|
| 1544 |
+
_CG_QUALIFIER thread_block_tile_impl(const GroupT& g) :
|
| 1545 |
+
__multi_warp_thread_block_tile<Size, ParentT>(g) {}
|
| 1546 |
+
};
|
| 1547 |
+
#else
|
| 1548 |
+
template <unsigned int Size, typename ParentT>
|
| 1549 |
+
class thread_block_tile_impl<Size, ParentT, true>
|
| 1550 |
+
{
|
| 1551 |
+
protected:
|
| 1552 |
+
template <typename GroupT>
|
| 1553 |
+
_CG_QUALIFIER thread_block_tile_impl(const GroupT& g) {}
|
| 1554 |
+
};
|
| 1555 |
+
#endif
|
| 1556 |
+
}
|
| 1557 |
+
|
| 1558 |
+
template <unsigned int Size, typename ParentT>
|
| 1559 |
+
class thread_block_tile : public details::thread_block_tile_impl<Size, ParentT, details::_is_multi_warp<Size>::value>
|
| 1560 |
+
{
|
| 1561 |
+
friend _CG_QUALIFIER thread_block_tile<1, void> this_thread();
|
| 1562 |
+
|
| 1563 |
+
protected:
|
| 1564 |
+
_CG_QUALIFIER thread_block_tile(const ParentT& g) :
|
| 1565 |
+
details::thread_block_tile_impl<Size, ParentT, details::_is_multi_warp<Size>::value>(g) {}
|
| 1566 |
+
|
| 1567 |
+
public:
|
| 1568 |
+
_CG_QUALIFIER operator thread_block_tile<Size, void>() const {
|
| 1569 |
+
return thread_block_tile<Size, void>(*this);
|
| 1570 |
+
}
|
| 1571 |
+
};
|
| 1572 |
+
|
| 1573 |
+
template <unsigned int Size>
|
| 1574 |
+
class thread_block_tile<Size, void> : public details::thread_block_tile_impl<Size, void, details::_is_multi_warp<Size>::value>
|
| 1575 |
+
{
|
| 1576 |
+
template <unsigned int, typename ParentT>
|
| 1577 |
+
friend class thread_block_tile;
|
| 1578 |
+
|
| 1579 |
+
protected:
|
| 1580 |
+
template <unsigned int OtherSize, typename OtherParentT>
|
| 1581 |
+
_CG_QUALIFIER thread_block_tile(const thread_block_tile<OtherSize, OtherParentT>& g) :
|
| 1582 |
+
details::thread_block_tile_impl<Size, void, details::_is_multi_warp<Size>::value>(g) {}
|
| 1583 |
+
|
| 1584 |
+
public:
|
| 1585 |
+
template <typename ParentT>
|
| 1586 |
+
_CG_QUALIFIER thread_block_tile(const thread_block_tile<Size, ParentT>& g) :
|
| 1587 |
+
details::thread_block_tile_impl<Size, void, details::_is_multi_warp<Size>::value>(g) {}
|
| 1588 |
+
};
|
| 1589 |
+
|
| 1590 |
+
namespace details {
|
| 1591 |
+
template <unsigned int Size, typename ParentT>
|
| 1592 |
+
struct tiled_partition_impl;
|
| 1593 |
+
|
| 1594 |
+
template <unsigned int Size>
|
| 1595 |
+
struct tiled_partition_impl<Size, thread_block> : public thread_block_tile<Size, thread_block> {
|
| 1596 |
+
_CG_QUALIFIER tiled_partition_impl(const thread_block& g) :
|
| 1597 |
+
thread_block_tile<Size, thread_block>(g) {}
|
| 1598 |
+
};
|
| 1599 |
+
|
| 1600 |
+
// ParentT = static thread_block_tile<ParentSize, GrandParent> specialization
|
| 1601 |
+
template <unsigned int Size, unsigned int ParentSize, typename GrandParent>
|
| 1602 |
+
struct tiled_partition_impl<Size, thread_block_tile<ParentSize, GrandParent> > :
|
| 1603 |
+
public thread_block_tile<Size, thread_block_tile<ParentSize, GrandParent> > {
|
| 1604 |
+
#ifdef _CG_CPP11_FEATURES
|
| 1605 |
+
static_assert(Size < ParentSize, "Tile size bigger or equal to the parent group size");
|
| 1606 |
+
#endif
|
| 1607 |
+
_CG_QUALIFIER tiled_partition_impl(const thread_block_tile<ParentSize, GrandParent>& g) :
|
| 1608 |
+
thread_block_tile<Size, thread_block_tile<ParentSize, GrandParent> >(g) {}
|
| 1609 |
+
};
|
| 1610 |
+
|
| 1611 |
+
}
|
| 1612 |
+
|
| 1613 |
+
template <unsigned int Size, typename ParentT>
|
| 1614 |
+
_CG_QUALIFIER thread_block_tile<Size, ParentT> tiled_partition(const ParentT& g)
|
| 1615 |
+
{
|
| 1616 |
+
return details::tiled_partition_impl<Size, ParentT>(g);
|
| 1617 |
+
}
|
| 1618 |
+
|
| 1619 |
+
/**
|
| 1620 |
+
* thread_group this_thread()
|
| 1621 |
+
*
|
| 1622 |
+
* Constructs a generic thread_group containing only the calling thread
|
| 1623 |
+
*/
|
| 1624 |
+
_CG_QUALIFIER thread_block_tile<1, void> this_thread()
|
| 1625 |
+
{
|
| 1626 |
+
// Make thread_block_tile<1, thread_block> parent of the returned group, so it will have its
|
| 1627 |
+
// meta group rank and size set to 0 and 1 respectively.
|
| 1628 |
+
return thread_block_tile<1, thread_block_tile<1, thread_block> >(this_thread_block());
|
| 1629 |
+
}
|
| 1630 |
+
|
| 1631 |
+
/**
|
| 1632 |
+
* <group_type>.sync()
|
| 1633 |
+
*
|
| 1634 |
+
* Executes a barrier across the group
|
| 1635 |
+
*
|
| 1636 |
+
* Implements both a compiler fence and an architectural fence to prevent,
|
| 1637 |
+
* memory reordering around the barrier.
|
| 1638 |
+
*/
|
| 1639 |
+
_CG_QUALIFIER void thread_group::sync() const
|
| 1640 |
+
{
|
| 1641 |
+
switch (_data.group.type) {
|
| 1642 |
+
case details::coalesced_group_id:
|
| 1643 |
+
cooperative_groups::sync(*static_cast<const coalesced_group*>(this));
|
| 1644 |
+
break;
|
| 1645 |
+
case details::thread_block_id:
|
| 1646 |
+
cooperative_groups::sync(*static_cast<const thread_block*>(this));
|
| 1647 |
+
break;
|
| 1648 |
+
case details::grid_group_id:
|
| 1649 |
+
cooperative_groups::sync(*static_cast<const grid_group*>(this));
|
| 1650 |
+
break;
|
| 1651 |
+
#if defined(_CG_HAS_MULTI_GRID_GROUP) && defined(_CG_CPP11_FEATURES) && defined(_CG_ABI_EXPERIMENTAL)
|
| 1652 |
+
case details::multi_grid_group_id:
|
| 1653 |
+
cooperative_groups::sync(*static_cast<const multi_grid_group*>(this));
|
| 1654 |
+
break;
|
| 1655 |
+
#endif
|
| 1656 |
+
#if defined(_CG_HAS_CLUSTER_GROUP)
|
| 1657 |
+
case details::cluster_group_id:
|
| 1658 |
+
cooperative_groups::sync(*static_cast<const cluster_group*>(this));
|
| 1659 |
+
break;
|
| 1660 |
+
#endif
|
| 1661 |
+
default:
|
| 1662 |
+
break;
|
| 1663 |
+
}
|
| 1664 |
+
}
|
| 1665 |
+
|
| 1666 |
+
/**
|
| 1667 |
+
* <group_type>.size()
|
| 1668 |
+
*
|
| 1669 |
+
* Returns the total number of threads in the group.
|
| 1670 |
+
*/
|
| 1671 |
+
_CG_QUALIFIER unsigned long long thread_group::size() const
|
| 1672 |
+
{
|
| 1673 |
+
unsigned long long size = 0;
|
| 1674 |
+
switch (_data.group.type) {
|
| 1675 |
+
case details::coalesced_group_id:
|
| 1676 |
+
size = cooperative_groups::group_size(*static_cast<const coalesced_group*>(this));
|
| 1677 |
+
break;
|
| 1678 |
+
case details::thread_block_id:
|
| 1679 |
+
size = cooperative_groups::group_size(*static_cast<const thread_block*>(this));
|
| 1680 |
+
break;
|
| 1681 |
+
case details::grid_group_id:
|
| 1682 |
+
size = cooperative_groups::group_size(*static_cast<const grid_group*>(this));
|
| 1683 |
+
break;
|
| 1684 |
+
#if defined(_CG_HAS_MULTI_GRID_GROUP) && defined(_CG_CPP11_FEATURES) && defined(_CG_ABI_EXPERIMENTAL)
|
| 1685 |
+
case details::multi_grid_group_id:
|
| 1686 |
+
size = cooperative_groups::group_size(*static_cast<const multi_grid_group*>(this));
|
| 1687 |
+
break;
|
| 1688 |
+
#endif
|
| 1689 |
+
#if defined(_CG_HAS_CLUSTER_GROUP)
|
| 1690 |
+
case details::cluster_group_id:
|
| 1691 |
+
size = cooperative_groups::group_size(*static_cast<const cluster_group*>(this));
|
| 1692 |
+
break;
|
| 1693 |
+
#endif
|
| 1694 |
+
default:
|
| 1695 |
+
break;
|
| 1696 |
+
}
|
| 1697 |
+
return size;
|
| 1698 |
+
}
|
| 1699 |
+
|
| 1700 |
+
/**
|
| 1701 |
+
* <group_type>.thread_rank()
|
| 1702 |
+
*
|
| 1703 |
+
* Returns the linearized rank of the calling thread along the interval [0, size()).
|
| 1704 |
+
*/
|
| 1705 |
+
_CG_QUALIFIER unsigned long long thread_group::thread_rank() const
|
| 1706 |
+
{
|
| 1707 |
+
unsigned long long rank = 0;
|
| 1708 |
+
switch (_data.group.type) {
|
| 1709 |
+
case details::coalesced_group_id:
|
| 1710 |
+
rank = cooperative_groups::thread_rank(*static_cast<const coalesced_group*>(this));
|
| 1711 |
+
break;
|
| 1712 |
+
case details::thread_block_id:
|
| 1713 |
+
rank = cooperative_groups::thread_rank(*static_cast<const thread_block*>(this));
|
| 1714 |
+
break;
|
| 1715 |
+
case details::grid_group_id:
|
| 1716 |
+
rank = cooperative_groups::thread_rank(*static_cast<const grid_group*>(this));
|
| 1717 |
+
break;
|
| 1718 |
+
#if defined(_CG_HAS_MULTI_GRID_GROUP) && defined(_CG_CPP11_FEATURES) && defined(_CG_ABI_EXPERIMENTAL)
|
| 1719 |
+
case details::multi_grid_group_id:
|
| 1720 |
+
rank = cooperative_groups::thread_rank(*static_cast<const multi_grid_group*>(this));
|
| 1721 |
+
break;
|
| 1722 |
+
#endif
|
| 1723 |
+
#if defined(_CG_HAS_CLUSTER_GROUP)
|
| 1724 |
+
case details::cluster_group_id:
|
| 1725 |
+
rank = cooperative_groups::thread_rank(*static_cast<const cluster_group*>(this));
|
| 1726 |
+
break;
|
| 1727 |
+
#endif
|
| 1728 |
+
default:
|
| 1729 |
+
break;
|
| 1730 |
+
}
|
| 1731 |
+
return rank;
|
| 1732 |
+
}
|
| 1733 |
+
|
| 1734 |
+
_CG_END_NAMESPACE
|
| 1735 |
+
|
| 1736 |
+
#include <cooperative_groups/details/partitioning.h>
|
| 1737 |
+
#if (!defined(_MSC_VER) || defined(_WIN64))
|
| 1738 |
+
# include <cooperative_groups/details/invoke.h>
|
| 1739 |
+
#endif
|
| 1740 |
+
|
| 1741 |
+
# endif /* ! (__cplusplus, __CUDACC__) */
|
| 1742 |
+
|
| 1743 |
+
#endif /* !_COOPERATIVE_GROUPS_H_ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cooperative_groups/details/async.h
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 1993-2016 NVIDIA Corporation. All rights reserved.
|
| 2 |
+
*
|
| 3 |
+
* NOTICE TO LICENSEE:
|
| 4 |
+
*
|
| 5 |
+
* The source code and/or documentation ("Licensed Deliverables") are
|
| 6 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* The Licensed Deliverables contained herein are PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and are being provided under the terms and
|
| 11 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 12 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 13 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 14 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 15 |
+
* of the Licensed Deliverables to any third party without the express
|
| 16 |
+
* written consent of NVIDIA is prohibited.
|
| 17 |
+
*
|
| 18 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 19 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 20 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
|
| 21 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 22 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 23 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 24 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 25 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 26 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 27 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 28 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 29 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 30 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 31 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 32 |
+
*
|
| 33 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 34 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 35 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 36 |
+
* computer software documentation" as such terms are used in 48
|
| 37 |
+
* C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
|
| 38 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 39 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 40 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 41 |
+
* only those rights set forth herein.
|
| 42 |
+
*
|
| 43 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 44 |
+
* software must include, in the user documentation and internal
|
| 45 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 46 |
+
* Users Notice.
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
#ifndef _CG_ASYNC_H
|
| 50 |
+
#define _CG_ASYNC_H
|
| 51 |
+
|
| 52 |
+
#include "helpers.h"
|
| 53 |
+
#include "info.h"
|
| 54 |
+
|
| 55 |
+
#include <cuda_pipeline.h>
|
| 56 |
+
|
| 57 |
+
_CG_BEGIN_NAMESPACE
|
| 58 |
+
|
| 59 |
+
namespace details {
|
| 60 |
+
// Groups supported by memcpy_async
|
| 61 |
+
template <class TyGroup>
|
| 62 |
+
struct _async_copy_group_supported : public _CG_STL_NAMESPACE::false_type {};
|
| 63 |
+
|
| 64 |
+
template <unsigned int Sz, typename TyPar>
|
| 65 |
+
struct _async_copy_group_supported<cooperative_groups::thread_block_tile<Sz, TyPar>>
|
| 66 |
+
: public _CG_STL_NAMESPACE::true_type {};
|
| 67 |
+
template <>
|
| 68 |
+
struct _async_copy_group_supported<cooperative_groups::coalesced_group> : public _CG_STL_NAMESPACE::true_type {};
|
| 69 |
+
template <>
|
| 70 |
+
struct _async_copy_group_supported<cooperative_groups::thread_block> : public _CG_STL_NAMESPACE::true_type {};
|
| 71 |
+
|
| 72 |
+
template <class TyGroup>
|
| 73 |
+
using async_copy_group_supported = _async_copy_group_supported<details::remove_qual<TyGroup>>;
|
| 74 |
+
|
| 75 |
+
// Groups that require optimization
|
| 76 |
+
template <class TyGroup>
|
| 77 |
+
struct _async_copy_optimize_tile : public _CG_STL_NAMESPACE::false_type {};
|
| 78 |
+
|
| 79 |
+
template <typename TyPar>
|
| 80 |
+
struct _async_copy_optimize_tile<cooperative_groups::thread_block_tile<1, TyPar>>
|
| 81 |
+
: public _CG_STL_NAMESPACE::false_type {};
|
| 82 |
+
|
| 83 |
+
template <unsigned int Sz, typename TyPar>
|
| 84 |
+
struct _async_copy_optimize_tile<cooperative_groups::thread_block_tile<Sz, TyPar>>
|
| 85 |
+
: public _CG_STL_NAMESPACE::true_type {};
|
| 86 |
+
|
| 87 |
+
template <class TyGroup>
|
| 88 |
+
using async_copy_optimize_tile = _async_copy_optimize_tile<details::remove_qual<TyGroup>>;
|
| 89 |
+
|
| 90 |
+
// SFINAE helpers for tile optimizations
|
| 91 |
+
template <class TyGroup>
|
| 92 |
+
using enable_tile_optimization =
|
| 93 |
+
typename _CG_STL_NAMESPACE::enable_if<async_copy_optimize_tile<TyGroup>::value, void *>::type;
|
| 94 |
+
|
| 95 |
+
template <class TyGroup>
|
| 96 |
+
using disable_tile_optimization =
|
| 97 |
+
typename _CG_STL_NAMESPACE::enable_if<!async_copy_optimize_tile<TyGroup>::value, void *>::type;
|
| 98 |
+
|
| 99 |
+
// Segment for punning to aligned types
|
| 100 |
+
template <unsigned int N>
|
| 101 |
+
struct _Segment {
|
| 102 |
+
int _seg[N];
|
| 103 |
+
};
|
| 104 |
+
|
| 105 |
+
// Trivial layout guaranteed-aligned copy-async compatible segments
|
| 106 |
+
template <unsigned int N>
|
| 107 |
+
struct Segment;
|
| 108 |
+
template <>
|
| 109 |
+
struct __align__(4) Segment<1> : public _Segment<1>{};
|
| 110 |
+
template <>
|
| 111 |
+
struct __align__(8) Segment<2> : public _Segment<2>{};
|
| 112 |
+
template <>
|
| 113 |
+
struct __align__(16) Segment<4> : public _Segment<4>{};
|
| 114 |
+
|
| 115 |
+
// Interleaved element by element copies from source to dest
|
| 116 |
+
template <typename TyGroup, typename TyElem>
|
| 117 |
+
_CG_STATIC_QUALIFIER void inline_copy(TyGroup &group, TyElem *__restrict__ dst, const TyElem *__restrict__ src,
|
| 118 |
+
size_t count) {
|
| 119 |
+
const unsigned int rank = group.thread_rank();
|
| 120 |
+
const unsigned int stride = group.size();
|
| 121 |
+
|
| 122 |
+
for (size_t idx = rank; idx < count; idx += stride) {
|
| 123 |
+
dst[idx] = src[idx];
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
template <typename TyGroup, typename TyElem, enable_tile_optimization<TyGroup> = nullptr>
|
| 128 |
+
_CG_STATIC_QUALIFIER void accelerated_async_copy(TyGroup &group, TyElem *__restrict__ dst,
|
| 129 |
+
const TyElem *__restrict__ src, size_t count) {
|
| 130 |
+
static_assert(async_copy_group_supported<TyGroup>::value,
|
| 131 |
+
"Async copy is only supported for groups that represent private shared memory");
|
| 132 |
+
|
| 133 |
+
if (count == 0) {
|
| 134 |
+
return;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
const bool dstIsNotShared = !__isShared(dst);
|
| 138 |
+
const bool srcIsNotGlobal = !__isGlobal(src);
|
| 139 |
+
|
| 140 |
+
if (dstIsNotShared || srcIsNotGlobal) {
|
| 141 |
+
inline_copy(group, dst, src, count);
|
| 142 |
+
return;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
const unsigned int stride = group.size();
|
| 146 |
+
const unsigned int rank = group.thread_rank();
|
| 147 |
+
// Efficient copies require warps to operate on the same amount of work at each step.
|
| 148 |
+
// remainders are handled in a separate stage to prevent branching
|
| 149 |
+
const unsigned int subWarpMask = (stride - 1);
|
| 150 |
+
const unsigned int subwarpCopies = (subWarpMask & (unsigned int)count);
|
| 151 |
+
const unsigned int maxSubwarpRank = min(rank, subwarpCopies - 1);
|
| 152 |
+
|
| 153 |
+
const size_t warpCopies = (count & (~subWarpMask));
|
| 154 |
+
|
| 155 |
+
for (size_t idx = 0; idx < warpCopies; idx += stride) {
|
| 156 |
+
size_t _srcIdx = rank + idx;
|
| 157 |
+
size_t _dstIdx = rank + idx;
|
| 158 |
+
__pipeline_memcpy_async(dst + _dstIdx, src + _srcIdx, sizeof(TyElem));
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
if (subwarpCopies) {
|
| 162 |
+
size_t _srcIdx = warpCopies + maxSubwarpRank;
|
| 163 |
+
size_t _dstIdx = warpCopies + maxSubwarpRank;
|
| 164 |
+
__pipeline_memcpy_async(dst + _dstIdx, src + _srcIdx, sizeof(TyElem));
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
template <typename TyGroup, typename TyElem, disable_tile_optimization<TyGroup> = nullptr>
|
| 169 |
+
_CG_STATIC_QUALIFIER void accelerated_async_copy(TyGroup &group, TyElem *__restrict__ dst,
|
| 170 |
+
const TyElem *__restrict__ src, size_t count) {
|
| 171 |
+
static_assert(async_copy_group_supported<TyGroup>::value,
|
| 172 |
+
"Async copy is only supported for groups that represent private shared memory");
|
| 173 |
+
|
| 174 |
+
const bool dstIsNotShared = !__isShared(dst);
|
| 175 |
+
const bool srcIsNotGlobal = !__isGlobal(src);
|
| 176 |
+
|
| 177 |
+
if (dstIsNotShared || srcIsNotGlobal) {
|
| 178 |
+
inline_copy(group, dst, src, count);
|
| 179 |
+
return;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
unsigned int stride = group.size();
|
| 183 |
+
unsigned int rank = group.thread_rank();
|
| 184 |
+
|
| 185 |
+
for (size_t idx = rank; idx < count; idx += stride) {
|
| 186 |
+
size_t _srcIdx = idx;
|
| 187 |
+
size_t _dstIdx = idx;
|
| 188 |
+
__pipeline_memcpy_async(dst + _dstIdx, src + _srcIdx, sizeof(TyElem));
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
// Determine best possible alignment given an input and initial conditions
|
| 193 |
+
// Attempts to generate as little code as possible, most likely should only be used with 1 and 2 byte alignments
|
| 194 |
+
template <unsigned int MinAlignment, unsigned int MaxAlignment>
|
| 195 |
+
_CG_STATIC_QUALIFIER uint32_t find_best_alignment(void *__restrict__ dst, const void *__restrict__ src) {
|
| 196 |
+
// Narrowing conversion intentional
|
| 197 |
+
uint32_t base1 = (uint32_t) reinterpret_cast<uintptr_t>(src);
|
| 198 |
+
uint32_t base2 = (uint32_t) reinterpret_cast<uintptr_t>(dst);
|
| 199 |
+
|
| 200 |
+
uint32_t diff = ((base1) ^ (base2)) & (MaxAlignment - 1);
|
| 201 |
+
|
| 202 |
+
// range [MaxAlignment, alignof(elem)], step: x >> 1
|
| 203 |
+
// over range of possible alignments, choose best available out of range
|
| 204 |
+
uint32_t out = MaxAlignment;
|
| 205 |
+
#pragma unroll
|
| 206 |
+
for (uint32_t alignment = (MaxAlignment >> 1); alignment >= MinAlignment; alignment >>= 1) {
|
| 207 |
+
if (alignment & diff)
|
| 208 |
+
out = alignment;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
return out;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
// Determine best possible alignment given an input and initial conditions
|
| 215 |
+
// Attempts to generate as little code as possible, most likely should only be used with 1 and 2 byte alignments
|
| 216 |
+
template <typename TyType, typename TyGroup>
|
| 217 |
+
_CG_STATIC_QUALIFIER void copy_like(const TyGroup &group, void *__restrict__ _dst, const void *__restrict__ _src,
|
| 218 |
+
size_t count) {
|
| 219 |
+
const char *src = reinterpret_cast<const char *>(_src);
|
| 220 |
+
char *dst = reinterpret_cast<char *>(_dst);
|
| 221 |
+
|
| 222 |
+
constexpr uint32_t targetAlignment = (uint32_t)alignof(TyType);
|
| 223 |
+
|
| 224 |
+
uint32_t base = (uint32_t) reinterpret_cast<uintptr_t>(src);
|
| 225 |
+
uint32_t alignOffset = ((~base) + 1) & (targetAlignment - 1);
|
| 226 |
+
|
| 227 |
+
inline_copy(group, dst, src, alignOffset);
|
| 228 |
+
count -= alignOffset;
|
| 229 |
+
src += alignOffset;
|
| 230 |
+
dst += alignOffset;
|
| 231 |
+
|
| 232 |
+
// Copy using the best available alignment, async_copy expects n-datums, not bytes
|
| 233 |
+
size_t asyncCount = count / sizeof(TyType);
|
| 234 |
+
accelerated_async_copy(group, reinterpret_cast<TyType *>(dst), reinterpret_cast<const TyType *>(src), asyncCount);
|
| 235 |
+
asyncCount *= sizeof(TyType);
|
| 236 |
+
|
| 237 |
+
count -= asyncCount;
|
| 238 |
+
src += asyncCount;
|
| 239 |
+
dst += asyncCount;
|
| 240 |
+
inline_copy(group, dst, src, count);
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
// We must determine alignment and manually align src/dst ourselves
|
| 244 |
+
template <size_t AlignHint>
|
| 245 |
+
struct _memcpy_async_align_dispatch {
|
| 246 |
+
template <typename TyGroup>
|
| 247 |
+
_CG_STATIC_QUALIFIER void copy(TyGroup &group, void *__restrict__ dst, const void *__restrict__ src, size_t count) {
|
| 248 |
+
uint32_t alignment = find_best_alignment<AlignHint, 16>(dst, src);
|
| 249 |
+
|
| 250 |
+
// Avoid copying the extra bytes if desired copy count is smaller
|
| 251 |
+
alignment = count < alignment ? AlignHint : alignment;
|
| 252 |
+
|
| 253 |
+
switch (alignment) {
|
| 254 |
+
default:
|
| 255 |
+
case 1:
|
| 256 |
+
inline_copy(group, reinterpret_cast<char *>(dst), reinterpret_cast<const char *>(src), count);
|
| 257 |
+
break;
|
| 258 |
+
case 2:
|
| 259 |
+
inline_copy(group, reinterpret_cast<short *>(dst), reinterpret_cast<const short *>(src), count >> 1);
|
| 260 |
+
break;
|
| 261 |
+
case 4:
|
| 262 |
+
copy_like<Segment<1>>(group, dst, src, count);
|
| 263 |
+
break;
|
| 264 |
+
case 8:
|
| 265 |
+
copy_like<Segment<2>>(group, dst, src, count);
|
| 266 |
+
break;
|
| 267 |
+
case 16:
|
| 268 |
+
copy_like<Segment<4>>(group, dst, src, count);
|
| 269 |
+
break;
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
};
|
| 273 |
+
|
| 274 |
+
// Specialization for 4 byte alignments
|
| 275 |
+
template <>
|
| 276 |
+
struct _memcpy_async_align_dispatch<4> {
|
| 277 |
+
template <typename TyGroup>
|
| 278 |
+
_CG_STATIC_QUALIFIER void copy(TyGroup &group, void *__restrict__ _dst, const void *__restrict__ _src,
|
| 279 |
+
size_t count) {
|
| 280 |
+
const Segment<1> *src = reinterpret_cast<const Segment<1> *>(_src);
|
| 281 |
+
Segment<1> *dst = reinterpret_cast<Segment<1> *>(_dst);
|
| 282 |
+
|
| 283 |
+
// Dispatch straight to aligned LDGSTS calls
|
| 284 |
+
accelerated_async_copy(group, dst, src, count / sizeof(*dst));
|
| 285 |
+
}
|
| 286 |
+
};
|
| 287 |
+
|
| 288 |
+
// Specialization for 8 byte alignments
|
| 289 |
+
template <>
|
| 290 |
+
struct _memcpy_async_align_dispatch<8> {
|
| 291 |
+
template <typename TyGroup>
|
| 292 |
+
_CG_STATIC_QUALIFIER void copy(TyGroup &group, void *__restrict__ _dst, const void *__restrict__ _src,
|
| 293 |
+
size_t count) {
|
| 294 |
+
const Segment<2> *src = reinterpret_cast<const Segment<2> *>(_src);
|
| 295 |
+
Segment<2> *dst = reinterpret_cast<Segment<2> *>(_dst);
|
| 296 |
+
|
| 297 |
+
// Dispatch straight to aligned LDGSTS calls
|
| 298 |
+
accelerated_async_copy(group, dst, src, count / sizeof(*dst));
|
| 299 |
+
}
|
| 300 |
+
};
|
| 301 |
+
|
| 302 |
+
// Alignments over 16 are truncated to 16 and bypass alignment
|
| 303 |
+
// This is the highest performing memcpy available
|
| 304 |
+
template <>
|
| 305 |
+
struct _memcpy_async_align_dispatch<16> {
|
| 306 |
+
template <typename TyGroup>
|
| 307 |
+
_CG_STATIC_QUALIFIER void copy(TyGroup &group, void *__restrict__ _dst, const void *__restrict__ _src,
|
| 308 |
+
size_t count) {
|
| 309 |
+
const Segment<4> *src = reinterpret_cast<const Segment<4> *>(_src);
|
| 310 |
+
Segment<4> *dst = reinterpret_cast<Segment<4> *>(_dst);
|
| 311 |
+
|
| 312 |
+
// Dispatch straight to aligned LDGSTS calls
|
| 313 |
+
accelerated_async_copy(group, dst, src, count / sizeof(*dst));
|
| 314 |
+
}
|
| 315 |
+
};
|
| 316 |
+
|
| 317 |
+
// byte-wide API
|
| 318 |
+
template <size_t Alignment, class TyGroup>
|
| 319 |
+
_CG_STATIC_QUALIFIER void _memcpy_async_dispatch_to_aligned_copy(const TyGroup &group, void *__restrict__ _dst,
|
| 320 |
+
const void *__restrict__ _src, size_t count) {
|
| 321 |
+
static_assert(!(Alignment & (Alignment - 1)), "Known static alignment dispatch must be a power of 2");
|
| 322 |
+
details::_memcpy_async_align_dispatch<Alignment>::copy(group, _dst, _src, count);
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
// Internal dispatch APIs
|
| 326 |
+
// These deduce the alignments and sizes necessary to invoke the underlying copy engine
|
| 327 |
+
template <typename Ty>
|
| 328 |
+
using is_void = _CG_STL_NAMESPACE::is_same<Ty, void>;
|
| 329 |
+
|
| 330 |
+
template <typename Ty>
|
| 331 |
+
using enable_if_not_void = typename _CG_STL_NAMESPACE::enable_if<!is_void<Ty>::value, void *>::type;
|
| 332 |
+
|
| 333 |
+
template <typename Ty>
|
| 334 |
+
using enable_if_void = typename _CG_STL_NAMESPACE::enable_if<is_void<Ty>::value, void *>::type;
|
| 335 |
+
|
| 336 |
+
template <typename Ty>
|
| 337 |
+
using enable_if_integral =
|
| 338 |
+
typename _CG_STL_NAMESPACE::enable_if<_CG_STL_NAMESPACE::is_integral<Ty>::value, void *>::type;
|
| 339 |
+
|
| 340 |
+
// byte-wide API using aligned_sized_t
|
| 341 |
+
template <class TyGroup, template <size_t> typename Alignment, size_t Hint>
|
| 342 |
+
_CG_STATIC_QUALIFIER void _memcpy_async_bytes(const TyGroup &group, void *__restrict__ _dst,
|
| 343 |
+
const void *__restrict__ _src, const Alignment<Hint> &count) {
|
| 344 |
+
constexpr size_t _align = (Hint > 16) ? 16 : Hint;
|
| 345 |
+
|
| 346 |
+
details::_memcpy_async_dispatch_to_aligned_copy<_align>(group, _dst, _src, (size_t)count);
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
// byte-wide API using type for aligment
|
| 350 |
+
template <class TyGroup, typename TyElem, typename TySize, size_t Hint = alignof(TyElem),
|
| 351 |
+
enable_if_not_void<TyElem> = nullptr, enable_if_integral<TySize> = nullptr>
|
| 352 |
+
_CG_STATIC_QUALIFIER void _memcpy_async_bytes(const TyGroup &group, TyElem *__restrict__ _dst,
|
| 353 |
+
const TyElem *__restrict__ _src, const TySize& count) {
|
| 354 |
+
constexpr size_t _align = (Hint > 16) ? 16 : Hint;
|
| 355 |
+
|
| 356 |
+
details::_memcpy_async_dispatch_to_aligned_copy<_align>(group, _dst, _src, count);
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
// byte-wide API with full alignment deduction required
|
| 360 |
+
template <class TyGroup, typename TyElem, typename TySize, enable_if_void<TyElem> = nullptr,
|
| 361 |
+
enable_if_integral<TySize> = nullptr>
|
| 362 |
+
_CG_STATIC_QUALIFIER void _memcpy_async_bytes(const TyGroup &group, TyElem *__restrict__ _dst,
|
| 363 |
+
const TyElem *__restrict__ _src, const TySize& count) {
|
| 364 |
+
details::_memcpy_async_dispatch_to_aligned_copy<1>(group, _dst, _src, count);
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
// 1d-datum API
|
| 368 |
+
template <class TyGroup, typename TyElem, size_t Hint = alignof(TyElem)>
|
| 369 |
+
_CG_STATIC_QUALIFIER void _memcpy_async_datum(const TyGroup &group, TyElem *__restrict__ dst, const size_t dstCount,
|
| 370 |
+
const TyElem *__restrict__ src, const size_t srcCount) {
|
| 371 |
+
constexpr unsigned int _align = Hint;
|
| 372 |
+
const size_t totalCount = min(dstCount, srcCount) * sizeof(TyElem);
|
| 373 |
+
|
| 374 |
+
details::_memcpy_async_dispatch_to_aligned_copy<_align>(group, dst, src, totalCount);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
// 1d-datum API using aligned_size_t
|
| 378 |
+
template <class TyGroup, typename TyElem, template <size_t> typename Alignment, size_t Hint>
|
| 379 |
+
_CG_STATIC_QUALIFIER void _memcpy_async_datum(const TyGroup &group, TyElem *__restrict__ dst, const Alignment<Hint> &dstCount,
|
| 380 |
+
const TyElem *__restrict__ src, const Alignment<Hint> &srcCount) {
|
| 381 |
+
constexpr unsigned int _align = Hint;
|
| 382 |
+
const size_t totalCount = min((size_t)dstCount, (size_t)srcCount) * sizeof(TyElem);
|
| 383 |
+
|
| 384 |
+
details::_memcpy_async_dispatch_to_aligned_copy<_align>(group, dst, src, totalCount);
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
} // namespace details
|
| 388 |
+
|
| 389 |
+
/*
|
| 390 |
+
* Group submit batch of async-copy to cover contiguous 1D array
|
| 391 |
+
* and commit that batch to eventually wait for completion.
|
| 392 |
+
*/
|
| 393 |
+
template <class TyGroup, typename TyElem, typename TySizeT>
|
| 394 |
+
_CG_STATIC_QUALIFIER void memcpy_async(const TyGroup &group, TyElem *__restrict__ _dst, const TyElem *__restrict__ _src,
|
| 395 |
+
const TySizeT &count) {
|
| 396 |
+
details::_memcpy_async_bytes(group, _dst, _src, count);
|
| 397 |
+
__pipeline_commit();
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
/*
|
| 401 |
+
* Group submit batch of async-copy to cover contiguous 1D array
|
| 402 |
+
* and commit that batch to eventually wait for completion.
|
| 403 |
+
* Object counts are in datum sized chunks, not bytes.
|
| 404 |
+
*/
|
| 405 |
+
template <class TyGroup, class TyElem, typename DstLayout, typename SrcLayout>
|
| 406 |
+
_CG_STATIC_QUALIFIER void memcpy_async(const TyGroup &group, TyElem *__restrict__ dst, const DstLayout &dstLayout,
|
| 407 |
+
const TyElem *__restrict__ src, const SrcLayout &srcLayout) {
|
| 408 |
+
details::_memcpy_async_datum(group, dst, dstLayout, src, srcLayout);
|
| 409 |
+
__pipeline_commit();
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/* Group wait for prior Nth stage of memcpy_async to complete. */
|
| 413 |
+
template <unsigned int Stage, class TyGroup>
|
| 414 |
+
_CG_STATIC_QUALIFIER void wait_prior(const TyGroup &group) {
|
| 415 |
+
__pipeline_wait_prior(Stage);
|
| 416 |
+
group.sync();
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
/* Group wait all previously submitted memcpy_async to complete. */
|
| 420 |
+
template <class TyGroup>
|
| 421 |
+
_CG_STATIC_QUALIFIER void wait(const TyGroup &group) {
|
| 422 |
+
__pipeline_wait_prior(0);
|
| 423 |
+
group.sync();
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
/***************** CG APIs including pipeline are deprecated *****************/
|
| 427 |
+
|
| 428 |
+
/* Group submit batch of async-copy to cover of contiguous 1D array
|
| 429 |
+
to a pipeline and commit the batch*/
|
| 430 |
+
template <class TyGroup, class TyElem>
|
| 431 |
+
_CG_DEPRECATED _CG_STATIC_QUALIFIER void memcpy_async(TyGroup &group, TyElem *dst, size_t dstCount, const TyElem *src, size_t srcCount,
|
| 432 |
+
nvcuda::experimental::pipeline &pipe) {
|
| 433 |
+
details::_memcpy_async_datum(group, dst, dstCount, src, srcCount);
|
| 434 |
+
pipe.commit();
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
/* Group wait for prior Nth stage of memcpy_async to complete. */
|
| 438 |
+
template <unsigned int Stage, class TyGroup>
|
| 439 |
+
_CG_DEPRECATED _CG_STATIC_QUALIFIER void wait_prior(TyGroup &group, nvcuda::experimental::pipeline &pipe) {
|
| 440 |
+
pipe.wait_prior<Stage>();
|
| 441 |
+
group.sync();
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
/* Group wait for stage-S of memcpy_async to complete. */
|
| 445 |
+
template <class TyGroup>
|
| 446 |
+
_CG_DEPRECATED _CG_STATIC_QUALIFIER void wait(TyGroup &group, nvcuda::experimental::pipeline &pipe, size_t stage) {
|
| 447 |
+
pipe.wait(stage);
|
| 448 |
+
group.sync();
|
| 449 |
+
}
|
| 450 |
+
_CG_END_NAMESPACE
|
| 451 |
+
|
| 452 |
+
#endif // _CG_ASYNC_H
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cooperative_groups/memcpy_async.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 1993-2016 NVIDIA Corporation. All rights reserved.
|
| 2 |
+
*
|
| 3 |
+
* NOTICE TO LICENSEE:
|
| 4 |
+
*
|
| 5 |
+
* The source code and/or documentation ("Licensed Deliverables") are
|
| 6 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* The Licensed Deliverables contained herein are PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and are being provided under the terms and
|
| 11 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 12 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 13 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 14 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 15 |
+
* of the Licensed Deliverables to any third party without the express
|
| 16 |
+
* written consent of NVIDIA is prohibited.
|
| 17 |
+
*
|
| 18 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 19 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 20 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
|
| 21 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 22 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 23 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 24 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 25 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 26 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 27 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 28 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 29 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 30 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 31 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 32 |
+
*
|
| 33 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 34 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 35 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 36 |
+
* computer software documentation" as such terms are used in 48
|
| 37 |
+
* C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
|
| 38 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 39 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 40 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 41 |
+
* only those rights set forth herein.
|
| 42 |
+
*
|
| 43 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 44 |
+
* software must include, in the user documentation and internal
|
| 45 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 46 |
+
* Users Notice.
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
#ifndef _COOPERATIVE_GROUPS_MEMCPY_ASYNC
|
| 50 |
+
#define _COOPERATIVE_GROUPS_MEMCPY_ASYNC
|
| 51 |
+
|
| 52 |
+
#include "../cooperative_groups.h"
|
| 53 |
+
#include "details/info.h"
|
| 54 |
+
|
| 55 |
+
#ifdef _CG_CPP11_FEATURES
|
| 56 |
+
# include "details/async.h"
|
| 57 |
+
#else
|
| 58 |
+
# error This file requires compiler support for the ISO C++ 2011 standard. This support must be enabled with the \
|
| 59 |
+
-std=c++11 compiler option.
|
| 60 |
+
#endif
|
| 61 |
+
|
| 62 |
+
#endif // _COOPERATIVE_GROUPS_MEMCPY_ASYNC
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cooperative_groups/reduce.h
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 1993-2016 NVIDIA Corporation. All rights reserved.
|
| 2 |
+
*
|
| 3 |
+
* NOTICE TO LICENSEE:
|
| 4 |
+
*
|
| 5 |
+
* The source code and/or documentation ("Licensed Deliverables") are
|
| 6 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* The Licensed Deliverables contained herein are PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and are being provided under the terms and
|
| 11 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 12 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 13 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 14 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 15 |
+
* of the Licensed Deliverables to any third party without the express
|
| 16 |
+
* written consent of NVIDIA is prohibited.
|
| 17 |
+
*
|
| 18 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 19 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 20 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
|
| 21 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 22 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 23 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 24 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 25 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 26 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 27 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 28 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 29 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 30 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 31 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 32 |
+
*
|
| 33 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 34 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 35 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 36 |
+
* computer software documentation" as such terms are used in 48
|
| 37 |
+
* C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
|
| 38 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 39 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 40 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 41 |
+
* only those rights set forth herein.
|
| 42 |
+
*
|
| 43 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 44 |
+
* software must include, in the user documentation and internal
|
| 45 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 46 |
+
* Users Notice.
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
#ifndef _COOPERATIVE_GROUPS_REDUCE_H
|
| 50 |
+
#define _COOPERATIVE_GROUPS_REDUCE_H
|
| 51 |
+
|
| 52 |
+
#include "../cooperative_groups.h"
|
| 53 |
+
#include "details/info.h"
|
| 54 |
+
|
| 55 |
+
#ifdef _CG_CPP11_FEATURES
|
| 56 |
+
# include "details/reduce.h"
|
| 57 |
+
#else
|
| 58 |
+
# error This file requires compiler support for the ISO C++ 2011 standard. This support must be enabled with the \
|
| 59 |
+
-std=c++11 compiler option.
|
| 60 |
+
#endif
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
#endif //_COOPERATIVE_GROUPS_REDUCE_H
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuComplex.h
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(CU_COMPLEX_H_)
|
| 51 |
+
#define CU_COMPLEX_H_
|
| 52 |
+
|
| 53 |
+
#if !defined(__CUDACC_RTC__)
|
| 54 |
+
#if defined(__GNUC__)
|
| 55 |
+
#if defined(__clang__) || (!defined(__PGIC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)))
|
| 56 |
+
#pragma GCC diagnostic ignored "-Wunused-function"
|
| 57 |
+
#endif
|
| 58 |
+
#endif
|
| 59 |
+
#endif
|
| 60 |
+
|
| 61 |
+
/* When trying to include C header file in C++ Code extern "C" is required
|
| 62 |
+
* But the Standard QNX headers already have ifdef extern in them when compiling C++ Code
|
| 63 |
+
* extern "C" cannot be nested
|
| 64 |
+
* Hence keep the header out of extern "C" block
|
| 65 |
+
*/
|
| 66 |
+
|
| 67 |
+
#if !defined(__CUDACC__)
|
| 68 |
+
#include <math.h> /* import fabsf, sqrt */
|
| 69 |
+
#endif /* !defined(__CUDACC__) */
|
| 70 |
+
|
| 71 |
+
#if defined(__cplusplus)
|
| 72 |
+
extern "C" {
|
| 73 |
+
#endif /* __cplusplus */
|
| 74 |
+
|
| 75 |
+
#include "vector_types.h"
|
| 76 |
+
|
| 77 |
+
typedef float2 cuFloatComplex;
|
| 78 |
+
|
| 79 |
+
__host__ __device__ static __inline__ float cuCrealf (cuFloatComplex x)
|
| 80 |
+
{
|
| 81 |
+
return x.x;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
__host__ __device__ static __inline__ float cuCimagf (cuFloatComplex x)
|
| 85 |
+
{
|
| 86 |
+
return x.y;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
__host__ __device__ static __inline__ cuFloatComplex make_cuFloatComplex
|
| 90 |
+
(float r, float i)
|
| 91 |
+
{
|
| 92 |
+
cuFloatComplex res;
|
| 93 |
+
res.x = r;
|
| 94 |
+
res.y = i;
|
| 95 |
+
return res;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
__host__ __device__ static __inline__ cuFloatComplex cuConjf (cuFloatComplex x)
|
| 99 |
+
{
|
| 100 |
+
return make_cuFloatComplex (cuCrealf(x), -cuCimagf(x));
|
| 101 |
+
}
|
| 102 |
+
__host__ __device__ static __inline__ cuFloatComplex cuCaddf (cuFloatComplex x,
|
| 103 |
+
cuFloatComplex y)
|
| 104 |
+
{
|
| 105 |
+
return make_cuFloatComplex (cuCrealf(x) + cuCrealf(y),
|
| 106 |
+
cuCimagf(x) + cuCimagf(y));
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
__host__ __device__ static __inline__ cuFloatComplex cuCsubf (cuFloatComplex x,
|
| 110 |
+
cuFloatComplex y)
|
| 111 |
+
{
|
| 112 |
+
return make_cuFloatComplex (cuCrealf(x) - cuCrealf(y),
|
| 113 |
+
cuCimagf(x) - cuCimagf(y));
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/* This implementation could suffer from intermediate overflow even though
|
| 117 |
+
* the final result would be in range. However, various implementations do
|
| 118 |
+
* not guard against this (presumably to avoid losing performance), so we
|
| 119 |
+
* don't do it either to stay competitive.
|
| 120 |
+
*/
|
| 121 |
+
__host__ __device__ static __inline__ cuFloatComplex cuCmulf (cuFloatComplex x,
|
| 122 |
+
cuFloatComplex y)
|
| 123 |
+
{
|
| 124 |
+
cuFloatComplex prod;
|
| 125 |
+
prod = make_cuFloatComplex ((cuCrealf(x) * cuCrealf(y)) -
|
| 126 |
+
(cuCimagf(x) * cuCimagf(y)),
|
| 127 |
+
(cuCrealf(x) * cuCimagf(y)) +
|
| 128 |
+
(cuCimagf(x) * cuCrealf(y)));
|
| 129 |
+
return prod;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
/* This implementation guards against intermediate underflow and overflow
|
| 133 |
+
* by scaling. Such guarded implementations are usually the default for
|
| 134 |
+
* complex library implementations, with some also offering an unguarded,
|
| 135 |
+
* faster version.
|
| 136 |
+
*/
|
| 137 |
+
__host__ __device__ static __inline__ cuFloatComplex cuCdivf (cuFloatComplex x,
|
| 138 |
+
cuFloatComplex y)
|
| 139 |
+
{
|
| 140 |
+
cuFloatComplex quot;
|
| 141 |
+
float s = fabsf(cuCrealf(y)) + fabsf(cuCimagf(y));
|
| 142 |
+
float oos = 1.0f / s;
|
| 143 |
+
float ars = cuCrealf(x) * oos;
|
| 144 |
+
float ais = cuCimagf(x) * oos;
|
| 145 |
+
float brs = cuCrealf(y) * oos;
|
| 146 |
+
float bis = cuCimagf(y) * oos;
|
| 147 |
+
s = (brs * brs) + (bis * bis);
|
| 148 |
+
oos = 1.0f / s;
|
| 149 |
+
quot = make_cuFloatComplex (((ars * brs) + (ais * bis)) * oos,
|
| 150 |
+
((ais * brs) - (ars * bis)) * oos);
|
| 151 |
+
return quot;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/*
|
| 155 |
+
* We would like to call hypotf(), but it's not available on all platforms.
|
| 156 |
+
* This discrete implementation guards against intermediate underflow and
|
| 157 |
+
* overflow by scaling. Otherwise we would lose half the exponent range.
|
| 158 |
+
* There are various ways of doing guarded computation. For now chose the
|
| 159 |
+
* simplest and fastest solution, however this may suffer from inaccuracies
|
| 160 |
+
* if sqrt and division are not IEEE compliant.
|
| 161 |
+
*/
|
| 162 |
+
__host__ __device__ static __inline__ float cuCabsf (cuFloatComplex x)
|
| 163 |
+
{
|
| 164 |
+
float a = cuCrealf(x);
|
| 165 |
+
float b = cuCimagf(x);
|
| 166 |
+
float v, w, t;
|
| 167 |
+
a = fabsf(a);
|
| 168 |
+
b = fabsf(b);
|
| 169 |
+
if (a > b) {
|
| 170 |
+
v = a;
|
| 171 |
+
w = b;
|
| 172 |
+
} else {
|
| 173 |
+
v = b;
|
| 174 |
+
w = a;
|
| 175 |
+
}
|
| 176 |
+
t = w / v;
|
| 177 |
+
t = 1.0f + t * t;
|
| 178 |
+
t = v * sqrtf(t);
|
| 179 |
+
if ((v == 0.0f) || (v > 3.402823466e38f) || (w > 3.402823466e38f)) {
|
| 180 |
+
t = v + w;
|
| 181 |
+
}
|
| 182 |
+
return t;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/* Double precision */
|
| 186 |
+
typedef double2 cuDoubleComplex;
|
| 187 |
+
|
| 188 |
+
__host__ __device__ static __inline__ double cuCreal (cuDoubleComplex x)
|
| 189 |
+
{
|
| 190 |
+
return x.x;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
__host__ __device__ static __inline__ double cuCimag (cuDoubleComplex x)
|
| 194 |
+
{
|
| 195 |
+
return x.y;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
__host__ __device__ static __inline__ cuDoubleComplex make_cuDoubleComplex
|
| 199 |
+
(double r, double i)
|
| 200 |
+
{
|
| 201 |
+
cuDoubleComplex res;
|
| 202 |
+
res.x = r;
|
| 203 |
+
res.y = i;
|
| 204 |
+
return res;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
__host__ __device__ static __inline__ cuDoubleComplex cuConj(cuDoubleComplex x)
|
| 208 |
+
{
|
| 209 |
+
return make_cuDoubleComplex (cuCreal(x), -cuCimag(x));
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
__host__ __device__ static __inline__ cuDoubleComplex cuCadd(cuDoubleComplex x,
|
| 213 |
+
cuDoubleComplex y)
|
| 214 |
+
{
|
| 215 |
+
return make_cuDoubleComplex (cuCreal(x) + cuCreal(y),
|
| 216 |
+
cuCimag(x) + cuCimag(y));
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
__host__ __device__ static __inline__ cuDoubleComplex cuCsub(cuDoubleComplex x,
|
| 220 |
+
cuDoubleComplex y)
|
| 221 |
+
{
|
| 222 |
+
return make_cuDoubleComplex (cuCreal(x) - cuCreal(y),
|
| 223 |
+
cuCimag(x) - cuCimag(y));
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
/* This implementation could suffer from intermediate overflow even though
|
| 227 |
+
* the final result would be in range. However, various implementations do
|
| 228 |
+
* not guard against this (presumably to avoid losing performance), so we
|
| 229 |
+
* don't do it either to stay competitive.
|
| 230 |
+
*/
|
| 231 |
+
__host__ __device__ static __inline__ cuDoubleComplex cuCmul(cuDoubleComplex x,
|
| 232 |
+
cuDoubleComplex y)
|
| 233 |
+
{
|
| 234 |
+
cuDoubleComplex prod;
|
| 235 |
+
prod = make_cuDoubleComplex ((cuCreal(x) * cuCreal(y)) -
|
| 236 |
+
(cuCimag(x) * cuCimag(y)),
|
| 237 |
+
(cuCreal(x) * cuCimag(y)) +
|
| 238 |
+
(cuCimag(x) * cuCreal(y)));
|
| 239 |
+
return prod;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/* This implementation guards against intermediate underflow and overflow
|
| 243 |
+
* by scaling. Such guarded implementations are usually the default for
|
| 244 |
+
* complex library implementations, with some also offering an unguarded,
|
| 245 |
+
* faster version.
|
| 246 |
+
*/
|
| 247 |
+
__host__ __device__ static __inline__ cuDoubleComplex cuCdiv(cuDoubleComplex x,
|
| 248 |
+
cuDoubleComplex y)
|
| 249 |
+
{
|
| 250 |
+
cuDoubleComplex quot;
|
| 251 |
+
double s = (fabs(cuCreal(y))) + (fabs(cuCimag(y)));
|
| 252 |
+
double oos = 1.0 / s;
|
| 253 |
+
double ars = cuCreal(x) * oos;
|
| 254 |
+
double ais = cuCimag(x) * oos;
|
| 255 |
+
double brs = cuCreal(y) * oos;
|
| 256 |
+
double bis = cuCimag(y) * oos;
|
| 257 |
+
s = (brs * brs) + (bis * bis);
|
| 258 |
+
oos = 1.0 / s;
|
| 259 |
+
quot = make_cuDoubleComplex (((ars * brs) + (ais * bis)) * oos,
|
| 260 |
+
((ais * brs) - (ars * bis)) * oos);
|
| 261 |
+
return quot;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
/* This implementation guards against intermediate underflow and overflow
|
| 265 |
+
* by scaling. Otherwise we would lose half the exponent range. There are
|
| 266 |
+
* various ways of doing guarded computation. For now chose the simplest
|
| 267 |
+
* and fastest solution, however this may suffer from inaccuracies if sqrt
|
| 268 |
+
* and division are not IEEE compliant.
|
| 269 |
+
*/
|
| 270 |
+
__host__ __device__ static __inline__ double cuCabs (cuDoubleComplex x)
|
| 271 |
+
{
|
| 272 |
+
double a = cuCreal(x);
|
| 273 |
+
double b = cuCimag(x);
|
| 274 |
+
double v, w, t;
|
| 275 |
+
a = fabs(a);
|
| 276 |
+
b = fabs(b);
|
| 277 |
+
if (a > b) {
|
| 278 |
+
v = a;
|
| 279 |
+
w = b;
|
| 280 |
+
} else {
|
| 281 |
+
v = b;
|
| 282 |
+
w = a;
|
| 283 |
+
}
|
| 284 |
+
t = w / v;
|
| 285 |
+
t = 1.0 + t * t;
|
| 286 |
+
t = v * sqrt(t);
|
| 287 |
+
if ((v == 0.0) ||
|
| 288 |
+
(v > 1.79769313486231570e+308) || (w > 1.79769313486231570e+308)) {
|
| 289 |
+
t = v + w;
|
| 290 |
+
}
|
| 291 |
+
return t;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
#if defined(__cplusplus)
|
| 295 |
+
}
|
| 296 |
+
#endif /* __cplusplus */
|
| 297 |
+
|
| 298 |
+
/* aliases */
|
| 299 |
+
typedef cuFloatComplex cuComplex;
|
| 300 |
+
__host__ __device__ static __inline__ cuComplex make_cuComplex (float x,
|
| 301 |
+
float y)
|
| 302 |
+
{
|
| 303 |
+
return make_cuFloatComplex (x, y);
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
/* float-to-double promotion */
|
| 307 |
+
__host__ __device__ static __inline__ cuDoubleComplex cuComplexFloatToDouble
|
| 308 |
+
(cuFloatComplex c)
|
| 309 |
+
{
|
| 310 |
+
return make_cuDoubleComplex ((double)cuCrealf(c), (double)cuCimagf(c));
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
__host__ __device__ static __inline__ cuFloatComplex cuComplexDoubleToFloat
|
| 314 |
+
(cuDoubleComplex c)
|
| 315 |
+
{
|
| 316 |
+
return make_cuFloatComplex ((float)cuCreal(c), (float)cuCimag(c));
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
__host__ __device__ static __inline__ cuComplex cuCfmaf( cuComplex x, cuComplex y, cuComplex d)
|
| 321 |
+
{
|
| 322 |
+
float real_res;
|
| 323 |
+
float imag_res;
|
| 324 |
+
|
| 325 |
+
real_res = (cuCrealf(x) * cuCrealf(y)) + cuCrealf(d);
|
| 326 |
+
imag_res = (cuCrealf(x) * cuCimagf(y)) + cuCimagf(d);
|
| 327 |
+
|
| 328 |
+
real_res = -(cuCimagf(x) * cuCimagf(y)) + real_res;
|
| 329 |
+
imag_res = (cuCimagf(x) * cuCrealf(y)) + imag_res;
|
| 330 |
+
|
| 331 |
+
return make_cuComplex(real_res, imag_res);
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
__host__ __device__ static __inline__ cuDoubleComplex cuCfma( cuDoubleComplex x, cuDoubleComplex y, cuDoubleComplex d)
|
| 335 |
+
{
|
| 336 |
+
double real_res;
|
| 337 |
+
double imag_res;
|
| 338 |
+
|
| 339 |
+
real_res = (cuCreal(x) * cuCreal(y)) + cuCreal(d);
|
| 340 |
+
imag_res = (cuCreal(x) * cuCimag(y)) + cuCimag(d);
|
| 341 |
+
|
| 342 |
+
real_res = -(cuCimag(x) * cuCimag(y)) + real_res;
|
| 343 |
+
imag_res = (cuCimag(x) * cuCreal(y)) + imag_res;
|
| 344 |
+
|
| 345 |
+
return make_cuDoubleComplex(real_res, imag_res);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
#endif /* !defined(CU_COMPLEX_H_) */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaEGL.h
ADDED
|
@@ -0,0 +1,662 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef CUDAEGL_H
|
| 51 |
+
#define CUDAEGL_H
|
| 52 |
+
|
| 53 |
+
#include "cuda.h"
|
| 54 |
+
#include "EGL/egl.h"
|
| 55 |
+
#include "EGL/eglext.h"
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
#ifdef CUDA_FORCE_API_VERSION
|
| 59 |
+
#error "CUDA_FORCE_API_VERSION is no longer supported."
|
| 60 |
+
#endif
|
| 61 |
+
|
| 62 |
+
#ifdef __cplusplus
|
| 63 |
+
extern "C" {
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* \addtogroup CUDA_TYPES
|
| 68 |
+
* @{
|
| 69 |
+
*/
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Maximum number of planes per frame
|
| 73 |
+
*/
|
| 74 |
+
#define MAX_PLANES 3
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* CUDA EglFrame type - array or pointer
|
| 78 |
+
*/
|
| 79 |
+
typedef enum CUeglFrameType_enum {
|
| 80 |
+
CU_EGL_FRAME_TYPE_ARRAY = 0, /**< Frame type CUDA array */
|
| 81 |
+
CU_EGL_FRAME_TYPE_PITCH = 1, /**< Frame type pointer */
|
| 82 |
+
} CUeglFrameType;
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Indicates that timeout for ::cuEGLStreamConsumerAcquireFrame is infinite.
|
| 86 |
+
*/
|
| 87 |
+
#define CUDA_EGL_INFINITE_TIMEOUT 0xFFFFFFFF
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Resource location flags- sysmem or vidmem
|
| 91 |
+
*
|
| 92 |
+
* For CUDA context on iGPU, since video and system memory are equivalent -
|
| 93 |
+
* these flags will not have an effect on the execution.
|
| 94 |
+
*
|
| 95 |
+
* For CUDA context on dGPU, applications can use the flag ::CUeglResourceLocationFlags
|
| 96 |
+
* to give a hint about the desired location.
|
| 97 |
+
*
|
| 98 |
+
* ::CU_EGL_RESOURCE_LOCATION_SYSMEM - the frame data is made resident on the system memory
|
| 99 |
+
* to be accessed by CUDA.
|
| 100 |
+
*
|
| 101 |
+
* ::CU_EGL_RESOURCE_LOCATION_VIDMEM - the frame data is made resident on the dedicated
|
| 102 |
+
* video memory to be accessed by CUDA.
|
| 103 |
+
*
|
| 104 |
+
* There may be an additional latency due to new allocation and data migration,
|
| 105 |
+
* if the frame is produced on a different memory.
|
| 106 |
+
|
| 107 |
+
*/
|
| 108 |
+
typedef enum CUeglResourceLocationFlags_enum {
|
| 109 |
+
CU_EGL_RESOURCE_LOCATION_SYSMEM = 0x00, /**< Resource location sysmem */
|
| 110 |
+
CU_EGL_RESOURCE_LOCATION_VIDMEM = 0x01 /**< Resource location vidmem */
|
| 111 |
+
} CUeglResourceLocationFlags;
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* CUDA EGL Color Format - The different planar and multiplanar formats currently supported for CUDA_EGL interops.
|
| 115 |
+
* Three channel formats are currently not supported for ::CU_EGL_FRAME_TYPE_ARRAY
|
| 116 |
+
*/
|
| 117 |
+
typedef enum CUeglColorFormat_enum {
|
| 118 |
+
CU_EGL_COLOR_FORMAT_YUV420_PLANAR = 0x00, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 119 |
+
CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR = 0x01, /**< Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV420Planar. */
|
| 120 |
+
CU_EGL_COLOR_FORMAT_YUV422_PLANAR = 0x02, /**< Y, U, V each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 121 |
+
CU_EGL_COLOR_FORMAT_YUV422_SEMIPLANAR = 0x03, /**< Y, UV in two surfaces with VU byte ordering, width, height ratio same as YUV422Planar. */
|
| 122 |
+
CU_EGL_COLOR_FORMAT_RGB = 0x04, /**< R/G/B three channels in one surface with BGR byte ordering. Only pitch linear format supported. */
|
| 123 |
+
CU_EGL_COLOR_FORMAT_BGR = 0x05, /**< R/G/B three channels in one surface with RGB byte ordering. Only pitch linear format supported. */
|
| 124 |
+
CU_EGL_COLOR_FORMAT_ARGB = 0x06, /**< R/G/B/A four channels in one surface with BGRA byte ordering. */
|
| 125 |
+
CU_EGL_COLOR_FORMAT_RGBA = 0x07, /**< R/G/B/A four channels in one surface with ABGR byte ordering. */
|
| 126 |
+
CU_EGL_COLOR_FORMAT_L = 0x08, /**< single luminance channel in one surface. */
|
| 127 |
+
CU_EGL_COLOR_FORMAT_R = 0x09, /**< single color channel in one surface. */
|
| 128 |
+
CU_EGL_COLOR_FORMAT_YUV444_PLANAR = 0x0A, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height. */
|
| 129 |
+
CU_EGL_COLOR_FORMAT_YUV444_SEMIPLANAR = 0x0B, /**< Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV444Planar. */
|
| 130 |
+
CU_EGL_COLOR_FORMAT_YUYV_422 = 0x0C, /**< Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 131 |
+
CU_EGL_COLOR_FORMAT_UYVY_422 = 0x0D, /**< Y, U, V in one surface, interleaved as YUYV in one channel. */
|
| 132 |
+
CU_EGL_COLOR_FORMAT_ABGR = 0x0E, /**< R/G/B/A four channels in one surface with RGBA byte ordering. */
|
| 133 |
+
CU_EGL_COLOR_FORMAT_BGRA = 0x0F, /**< R/G/B/A four channels in one surface with ARGB byte ordering. */
|
| 134 |
+
CU_EGL_COLOR_FORMAT_A = 0x10, /**< Alpha color format - one channel in one surface. */
|
| 135 |
+
CU_EGL_COLOR_FORMAT_RG = 0x11, /**< R/G color format - two channels in one surface with GR byte ordering */
|
| 136 |
+
CU_EGL_COLOR_FORMAT_AYUV = 0x12, /**< Y, U, V, A four channels in one surface, interleaved as VUYA. */
|
| 137 |
+
CU_EGL_COLOR_FORMAT_YVU444_SEMIPLANAR = 0x13, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 138 |
+
CU_EGL_COLOR_FORMAT_YVU422_SEMIPLANAR = 0x14, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 139 |
+
CU_EGL_COLOR_FORMAT_YVU420_SEMIPLANAR = 0x15, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 140 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_444_SEMIPLANAR = 0x16, /**< Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 141 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_420_SEMIPLANAR = 0x17, /**< Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 142 |
+
CU_EGL_COLOR_FORMAT_Y12V12U12_444_SEMIPLANAR = 0x18, /**< Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 143 |
+
CU_EGL_COLOR_FORMAT_Y12V12U12_420_SEMIPLANAR = 0x19, /**< Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 144 |
+
CU_EGL_COLOR_FORMAT_VYUY_ER = 0x1A, /**< Extended Range Y, U, V in one surface, interleaved as YVYU in one channel. */
|
| 145 |
+
CU_EGL_COLOR_FORMAT_UYVY_ER = 0x1B, /**< Extended Range Y, U, V in one surface, interleaved as YUYV in one channel. */
|
| 146 |
+
CU_EGL_COLOR_FORMAT_YUYV_ER = 0x1C, /**< Extended Range Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 147 |
+
CU_EGL_COLOR_FORMAT_YVYU_ER = 0x1D, /**< Extended Range Y, U, V in one surface, interleaved as VYUY in one channel. */
|
| 148 |
+
CU_EGL_COLOR_FORMAT_YUV_ER = 0x1E, /**< Extended Range Y, U, V three channels in one surface, interleaved as VUY. Only pitch linear format supported. */
|
| 149 |
+
CU_EGL_COLOR_FORMAT_YUVA_ER = 0x1F, /**< Extended Range Y, U, V, A four channels in one surface, interleaved as AVUY. */
|
| 150 |
+
CU_EGL_COLOR_FORMAT_AYUV_ER = 0x20, /**< Extended Range Y, U, V, A four channels in one surface, interleaved as VUYA. */
|
| 151 |
+
CU_EGL_COLOR_FORMAT_YUV444_PLANAR_ER = 0x21, /**< Extended Range Y, U, V in three surfaces, U/V width = Y width, U/V height = Y height. */
|
| 152 |
+
CU_EGL_COLOR_FORMAT_YUV422_PLANAR_ER = 0x22, /**< Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 153 |
+
CU_EGL_COLOR_FORMAT_YUV420_PLANAR_ER = 0x23, /**< Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 154 |
+
CU_EGL_COLOR_FORMAT_YUV444_SEMIPLANAR_ER = 0x24, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 155 |
+
CU_EGL_COLOR_FORMAT_YUV422_SEMIPLANAR_ER = 0x25, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 156 |
+
CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR_ER = 0x26, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 157 |
+
CU_EGL_COLOR_FORMAT_YVU444_PLANAR_ER = 0x27, /**< Extended Range Y, V, U in three surfaces, U/V width = Y width, U/V height = Y height. */
|
| 158 |
+
CU_EGL_COLOR_FORMAT_YVU422_PLANAR_ER = 0x28, /**< Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 159 |
+
CU_EGL_COLOR_FORMAT_YVU420_PLANAR_ER = 0x29, /**< Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 160 |
+
CU_EGL_COLOR_FORMAT_YVU444_SEMIPLANAR_ER = 0x2A, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 161 |
+
CU_EGL_COLOR_FORMAT_YVU422_SEMIPLANAR_ER = 0x2B, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 162 |
+
CU_EGL_COLOR_FORMAT_YVU420_SEMIPLANAR_ER = 0x2C, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 163 |
+
CU_EGL_COLOR_FORMAT_BAYER_RGGB = 0x2D, /**< Bayer format - one channel in one surface with interleaved RGGB ordering. */
|
| 164 |
+
CU_EGL_COLOR_FORMAT_BAYER_BGGR = 0x2E, /**< Bayer format - one channel in one surface with interleaved BGGR ordering. */
|
| 165 |
+
CU_EGL_COLOR_FORMAT_BAYER_GRBG = 0x2F, /**< Bayer format - one channel in one surface with interleaved GRBG ordering. */
|
| 166 |
+
CU_EGL_COLOR_FORMAT_BAYER_GBRG = 0x30, /**< Bayer format - one channel in one surface with interleaved GBRG ordering. */
|
| 167 |
+
CU_EGL_COLOR_FORMAT_BAYER10_RGGB = 0x31, /**< Bayer10 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 168 |
+
CU_EGL_COLOR_FORMAT_BAYER10_BGGR = 0x32, /**< Bayer10 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 169 |
+
CU_EGL_COLOR_FORMAT_BAYER10_GRBG = 0x33, /**< Bayer10 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 170 |
+
CU_EGL_COLOR_FORMAT_BAYER10_GBRG = 0x34, /**< Bayer10 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 171 |
+
CU_EGL_COLOR_FORMAT_BAYER12_RGGB = 0x35, /**< Bayer12 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 172 |
+
CU_EGL_COLOR_FORMAT_BAYER12_BGGR = 0x36, /**< Bayer12 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 173 |
+
CU_EGL_COLOR_FORMAT_BAYER12_GRBG = 0x37, /**< Bayer12 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 174 |
+
CU_EGL_COLOR_FORMAT_BAYER12_GBRG = 0x38, /**< Bayer12 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 175 |
+
CU_EGL_COLOR_FORMAT_BAYER14_RGGB = 0x39, /**< Bayer14 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
|
| 176 |
+
CU_EGL_COLOR_FORMAT_BAYER14_BGGR = 0x3A, /**< Bayer14 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
|
| 177 |
+
CU_EGL_COLOR_FORMAT_BAYER14_GRBG = 0x3B, /**< Bayer14 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
|
| 178 |
+
CU_EGL_COLOR_FORMAT_BAYER14_GBRG = 0x3C, /**< Bayer14 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
|
| 179 |
+
CU_EGL_COLOR_FORMAT_BAYER20_RGGB = 0x3D, /**< Bayer20 format - one channel in one surface with interleaved RGGB ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
|
| 180 |
+
CU_EGL_COLOR_FORMAT_BAYER20_BGGR = 0x3E, /**< Bayer20 format - one channel in one surface with interleaved BGGR ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
|
| 181 |
+
CU_EGL_COLOR_FORMAT_BAYER20_GRBG = 0x3F, /**< Bayer20 format - one channel in one surface with interleaved GRBG ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
|
| 182 |
+
CU_EGL_COLOR_FORMAT_BAYER20_GBRG = 0x40, /**< Bayer20 format - one channel in one surface with interleaved GBRG ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
|
| 183 |
+
CU_EGL_COLOR_FORMAT_YVU444_PLANAR = 0x41, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height. */
|
| 184 |
+
CU_EGL_COLOR_FORMAT_YVU422_PLANAR = 0x42, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 185 |
+
CU_EGL_COLOR_FORMAT_YVU420_PLANAR = 0x43, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 186 |
+
CU_EGL_COLOR_FORMAT_BAYER_ISP_RGGB = 0x44, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved RGGB ordering and mapped to opaque integer datatype. */
|
| 187 |
+
CU_EGL_COLOR_FORMAT_BAYER_ISP_BGGR = 0x45, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved BGGR ordering and mapped to opaque integer datatype. */
|
| 188 |
+
CU_EGL_COLOR_FORMAT_BAYER_ISP_GRBG = 0x46, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GRBG ordering and mapped to opaque integer datatype. */
|
| 189 |
+
CU_EGL_COLOR_FORMAT_BAYER_ISP_GBRG = 0x47, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GBRG ordering and mapped to opaque integer datatype. */
|
| 190 |
+
CU_EGL_COLOR_FORMAT_BAYER_BCCR = 0x48, /**< Bayer format - one channel in one surface with interleaved BCCR ordering. */
|
| 191 |
+
CU_EGL_COLOR_FORMAT_BAYER_RCCB = 0x49, /**< Bayer format - one channel in one surface with interleaved RCCB ordering. */
|
| 192 |
+
CU_EGL_COLOR_FORMAT_BAYER_CRBC = 0x4A, /**< Bayer format - one channel in one surface with interleaved CRBC ordering. */
|
| 193 |
+
CU_EGL_COLOR_FORMAT_BAYER_CBRC = 0x4B, /**< Bayer format - one channel in one surface with interleaved CBRC ordering. */
|
| 194 |
+
CU_EGL_COLOR_FORMAT_BAYER10_CCCC = 0x4C, /**< Bayer10 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 195 |
+
CU_EGL_COLOR_FORMAT_BAYER12_BCCR = 0x4D, /**< Bayer12 format - one channel in one surface with interleaved BCCR ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 196 |
+
CU_EGL_COLOR_FORMAT_BAYER12_RCCB = 0x4E, /**< Bayer12 format - one channel in one surface with interleaved RCCB ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 197 |
+
CU_EGL_COLOR_FORMAT_BAYER12_CRBC = 0x4F, /**< Bayer12 format - one channel in one surface with interleaved CRBC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 198 |
+
CU_EGL_COLOR_FORMAT_BAYER12_CBRC = 0x50, /**< Bayer12 format - one channel in one surface with interleaved CBRC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 199 |
+
CU_EGL_COLOR_FORMAT_BAYER12_CCCC = 0x51, /**< Bayer12 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 200 |
+
CU_EGL_COLOR_FORMAT_Y = 0x52, /**< Color format for single Y plane. */
|
| 201 |
+
CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR_2020 = 0x53, /**< Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 202 |
+
CU_EGL_COLOR_FORMAT_YVU420_SEMIPLANAR_2020 = 0x54, /**< Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 203 |
+
CU_EGL_COLOR_FORMAT_YUV420_PLANAR_2020 = 0x55, /**< Y, U, V each in a separate surface, U/V width = 1/2 Y width, U/V height= 1/2 Y height. */
|
| 204 |
+
CU_EGL_COLOR_FORMAT_YVU420_PLANAR_2020 = 0x56, /**< Y, V, U each in a separate surface, U/V width = 1/2 Y width, U/V height
|
| 205 |
+
= 1/2 Y height. */
|
| 206 |
+
CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR_709 = 0x57, /**< Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 207 |
+
CU_EGL_COLOR_FORMAT_YVU420_SEMIPLANAR_709 = 0x58, /**< Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 208 |
+
CU_EGL_COLOR_FORMAT_YUV420_PLANAR_709 = 0x59, /**< Y, U, V each in a separate surface, U/V width = 1/2 Y width, U/V height
|
| 209 |
+
= 1/2 Y height. */
|
| 210 |
+
CU_EGL_COLOR_FORMAT_YVU420_PLANAR_709 = 0x5A, /**< Y, V, U each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 211 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_420_SEMIPLANAR_709 = 0x5B, /**< Y10, V10U10 in two surfaces (VU as one surface), U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 212 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_420_SEMIPLANAR_2020 = 0x5C, /**< Y10, V10U10 in two surfaces (VU as one surface), U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 213 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_422_SEMIPLANAR_2020 = 0x5D, /**< Y10, V10U10 in two surfaces(VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
|
| 214 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_422_SEMIPLANAR = 0x5E, /**< Y10, V10U10 in two surfaces(VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
|
| 215 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_422_SEMIPLANAR_709 = 0x5F, /**< Y10, V10U10 in two surfaces(VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
|
| 216 |
+
CU_EGL_COLOR_FORMAT_Y_ER = 0x60, /**< Extended Range Color format for single Y plane. */
|
| 217 |
+
CU_EGL_COLOR_FORMAT_Y_709_ER = 0x61, /**< Extended Range Color format for single Y plane. */
|
| 218 |
+
CU_EGL_COLOR_FORMAT_Y10_ER = 0x62, /**< Extended Range Color format for single Y10 plane. */
|
| 219 |
+
CU_EGL_COLOR_FORMAT_Y10_709_ER = 0x63, /**< Extended Range Color format for single Y10 plane. */
|
| 220 |
+
CU_EGL_COLOR_FORMAT_Y12_ER = 0x64, /**< Extended Range Color format for single Y12 plane. */
|
| 221 |
+
CU_EGL_COLOR_FORMAT_Y12_709_ER = 0x65, /**< Extended Range Color format for single Y12 plane. */
|
| 222 |
+
CU_EGL_COLOR_FORMAT_YUVA = 0x66, /**< Y, U, V, A four channels in one surface, interleaved as AVUY. */
|
| 223 |
+
CU_EGL_COLOR_FORMAT_YUV = 0x67, /**< Y, U, V three channels in one surface, interleaved as VUY. Only pitch linear format supported. */
|
| 224 |
+
CU_EGL_COLOR_FORMAT_YVYU = 0x68, /**< Y, U, V in one surface, interleaved as YVYU in one channel. */
|
| 225 |
+
CU_EGL_COLOR_FORMAT_VYUY = 0x69, /**< Y, U, V in one surface, interleaved as VYUY in one channel. */
|
| 226 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_420_SEMIPLANAR_ER = 0x6A, /**< Extended Range Y10, V10U10 in two surfaces(VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 227 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_420_SEMIPLANAR_709_ER = 0x6B, /**< Extended Range Y10, V10U10 in two surfaces(VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 228 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_444_SEMIPLANAR_ER = 0x6C, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
|
| 229 |
+
CU_EGL_COLOR_FORMAT_Y10V10U10_444_SEMIPLANAR_709_ER = 0x6D, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
|
| 230 |
+
CU_EGL_COLOR_FORMAT_Y12V12U12_420_SEMIPLANAR_ER = 0x6E, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 231 |
+
CU_EGL_COLOR_FORMAT_Y12V12U12_420_SEMIPLANAR_709_ER = 0x6F, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 232 |
+
CU_EGL_COLOR_FORMAT_Y12V12U12_444_SEMIPLANAR_ER = 0x70, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
|
| 233 |
+
CU_EGL_COLOR_FORMAT_Y12V12U12_444_SEMIPLANAR_709_ER = 0x71, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
|
| 234 |
+
CU_EGL_COLOR_FORMAT_UYVY_709 = 0x72, /**< Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 235 |
+
CU_EGL_COLOR_FORMAT_UYVY_709_ER = 0x73, /**< Extended Range Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 236 |
+
CU_EGL_COLOR_FORMAT_UYVY_2020 = 0x74, /**< Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 237 |
+
CU_EGL_COLOR_FORMAT_MAX
|
| 238 |
+
} CUeglColorFormat;
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* CUDA EGLFrame structure Descriptor - structure defining one frame of EGL.
|
| 242 |
+
*
|
| 243 |
+
* Each frame may contain one or more planes depending on whether the surface * is Multiplanar or not.
|
| 244 |
+
*/
|
| 245 |
+
typedef struct CUeglFrame_st {
|
| 246 |
+
union {
|
| 247 |
+
CUarray pArray[MAX_PLANES]; /**< Array of CUarray corresponding to each plane*/
|
| 248 |
+
void* pPitch[MAX_PLANES]; /**< Array of Pointers corresponding to each plane*/
|
| 249 |
+
} frame;
|
| 250 |
+
unsigned int width; /**< Width of first plane */
|
| 251 |
+
unsigned int height; /**< Height of first plane */
|
| 252 |
+
unsigned int depth; /**< Depth of first plane */
|
| 253 |
+
unsigned int pitch; /**< Pitch of first plane */
|
| 254 |
+
unsigned int planeCount; /**< Number of planes */
|
| 255 |
+
unsigned int numChannels; /**< Number of channels for the plane */
|
| 256 |
+
CUeglFrameType frameType; /**< Array or Pitch */
|
| 257 |
+
CUeglColorFormat eglColorFormat; /**< CUDA EGL Color Format*/
|
| 258 |
+
CUarray_format cuFormat; /**< CUDA Array Format*/
|
| 259 |
+
} CUeglFrame_v1;
|
| 260 |
+
typedef CUeglFrame_v1 CUeglFrame;
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
* CUDA EGLSream Connection
|
| 264 |
+
*/
|
| 265 |
+
typedef struct CUeglStreamConnection_st* CUeglStreamConnection;
|
| 266 |
+
|
| 267 |
+
/** @} */ /* END CUDA_TYPES */
|
| 268 |
+
|
| 269 |
+
/**
|
| 270 |
+
* \file cudaEGL.h
|
| 271 |
+
* \brief Header file for the EGL interoperability functions of the
|
| 272 |
+
* low-level CUDA driver application programming interface.
|
| 273 |
+
*/
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* \defgroup CUDA_EGL EGL Interoperability
|
| 277 |
+
* \ingroup CUDA_DRIVER
|
| 278 |
+
*
|
| 279 |
+
* ___MANBRIEF___ EGL interoperability functions of the low-level CUDA
|
| 280 |
+
* driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
|
| 281 |
+
*
|
| 282 |
+
* This section describes the EGL interoperability functions of the
|
| 283 |
+
* low-level CUDA driver application programming interface.
|
| 284 |
+
*
|
| 285 |
+
* @{
|
| 286 |
+
*/
|
| 287 |
+
|
| 288 |
+
/**
|
| 289 |
+
* \brief Registers an EGL image
|
| 290 |
+
*
|
| 291 |
+
* Registers the EGLImageKHR specified by \p image for access by
|
| 292 |
+
* CUDA. A handle to the registered object is returned as \p pCudaResource.
|
| 293 |
+
* Additional Mapping/Unmapping is not required for the registered resource and
|
| 294 |
+
* ::cuGraphicsResourceGetMappedEglFrame can be directly called on the \p pCudaResource.
|
| 295 |
+
*
|
| 296 |
+
* The application will be responsible for synchronizing access to shared objects.
|
| 297 |
+
* The application must ensure that any pending operation which access the objects have completed
|
| 298 |
+
* before passing control to CUDA. This may be accomplished by issuing and waiting for
|
| 299 |
+
* glFinish command on all GLcontexts (for OpenGL and likewise for other APIs).
|
| 300 |
+
* The application will be also responsible for ensuring that any pending operation on the
|
| 301 |
+
* registered CUDA resource has completed prior to executing subsequent commands in other APIs
|
| 302 |
+
* accesing the same memory objects.
|
| 303 |
+
* This can be accomplished by calling cuCtxSynchronize or cuEventSynchronize (preferably).
|
| 304 |
+
*
|
| 305 |
+
* The surface's intended usage is specified using \p flags, as follows:
|
| 306 |
+
*
|
| 307 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE: Specifies no hints about how this
|
| 308 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 309 |
+
* read from and written to by CUDA. This is the default value.
|
| 310 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY: Specifies that CUDA
|
| 311 |
+
* will not write to this resource.
|
| 312 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD: Specifies that
|
| 313 |
+
* CUDA will not read from this resource and will write over the
|
| 314 |
+
* entire contents of the resource, so none of the data previously
|
| 315 |
+
* stored in the resource will be preserved.
|
| 316 |
+
*
|
| 317 |
+
* The EGLImageKHR is an object which can be used to create EGLImage target resource. It is defined as a void pointer.
|
| 318 |
+
* typedef void* EGLImageKHR
|
| 319 |
+
*
|
| 320 |
+
* \param pCudaResource - Pointer to the returned object handle
|
| 321 |
+
* \param image - An EGLImageKHR image which can be used to create target resource.
|
| 322 |
+
* \param flags - Map flags
|
| 323 |
+
*
|
| 324 |
+
* \return
|
| 325 |
+
* ::CUDA_SUCCESS,
|
| 326 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 327 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 328 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 329 |
+
*
|
| 330 |
+
* \sa ::cuGraphicsEGLRegisterImage, ::cuGraphicsUnregisterResource,
|
| 331 |
+
* ::cuGraphicsResourceSetMapFlags, ::cuGraphicsMapResources,
|
| 332 |
+
* ::cuGraphicsUnmapResources,
|
| 333 |
+
* ::cudaGraphicsEGLRegisterImage
|
| 334 |
+
*/
|
| 335 |
+
CUresult CUDAAPI cuGraphicsEGLRegisterImage(CUgraphicsResource *pCudaResource, EGLImageKHR image, unsigned int flags);
|
| 336 |
+
|
| 337 |
+
/**
|
| 338 |
+
* \brief Connect CUDA to EGLStream as a consumer.
|
| 339 |
+
*
|
| 340 |
+
* Connect CUDA as a consumer to EGLStreamKHR specified by \p stream.
|
| 341 |
+
*
|
| 342 |
+
* The EGLStreamKHR is an EGL object that transfers a sequence of image frames from one
|
| 343 |
+
* API to another.
|
| 344 |
+
*
|
| 345 |
+
* \param conn - Pointer to the returned connection handle
|
| 346 |
+
* \param stream - EGLStreamKHR handle
|
| 347 |
+
*
|
| 348 |
+
* \return
|
| 349 |
+
* ::CUDA_SUCCESS,
|
| 350 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 351 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 352 |
+
*
|
| 353 |
+
* \sa ::cuEGLStreamConsumerConnect, ::cuEGLStreamConsumerDisconnect,
|
| 354 |
+
* ::cuEGLStreamConsumerAcquireFrame, ::cuEGLStreamConsumerReleaseFrame,
|
| 355 |
+
* ::cudaEGLStreamConsumerConnect
|
| 356 |
+
*/
|
| 357 |
+
CUresult CUDAAPI cuEGLStreamConsumerConnect(CUeglStreamConnection *conn, EGLStreamKHR stream);
|
| 358 |
+
|
| 359 |
+
/**
|
| 360 |
+
* \brief Connect CUDA to EGLStream as a consumer with given flags.
|
| 361 |
+
*
|
| 362 |
+
* Connect CUDA as a consumer to EGLStreamKHR specified by \p stream with specified \p flags defined by CUeglResourceLocationFlags.
|
| 363 |
+
*
|
| 364 |
+
* The flags specify whether the consumer wants to access frames from system memory or video memory.
|
| 365 |
+
* Default is ::CU_EGL_RESOURCE_LOCATION_VIDMEM.
|
| 366 |
+
*
|
| 367 |
+
* \param conn - Pointer to the returned connection handle
|
| 368 |
+
* \param stream - EGLStreamKHR handle
|
| 369 |
+
* \param flags - Flags denote intended location - system or video.
|
| 370 |
+
*
|
| 371 |
+
* \return
|
| 372 |
+
* ::CUDA_SUCCESS,
|
| 373 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 374 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 375 |
+
*
|
| 376 |
+
* \sa ::cuEGLStreamConsumerConnect, ::cuEGLStreamConsumerDisconnect,
|
| 377 |
+
* ::cuEGLStreamConsumerAcquireFrame, ::cuEGLStreamConsumerReleaseFrame,
|
| 378 |
+
* ::cudaEGLStreamConsumerConnectWithFlags
|
| 379 |
+
*/
|
| 380 |
+
|
| 381 |
+
CUresult CUDAAPI cuEGLStreamConsumerConnectWithFlags(CUeglStreamConnection *conn, EGLStreamKHR stream, unsigned int flags);
|
| 382 |
+
|
| 383 |
+
/**
|
| 384 |
+
* \brief Disconnect CUDA as a consumer to EGLStream .
|
| 385 |
+
*
|
| 386 |
+
* Disconnect CUDA as a consumer to EGLStreamKHR.
|
| 387 |
+
*
|
| 388 |
+
* \param conn - Conection to disconnect.
|
| 389 |
+
*
|
| 390 |
+
* \return
|
| 391 |
+
* ::CUDA_SUCCESS,
|
| 392 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 393 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 394 |
+
*
|
| 395 |
+
* \sa ::cuEGLStreamConsumerConnect, ::cuEGLStreamConsumerDisconnect,
|
| 396 |
+
* ::cuEGLStreamConsumerAcquireFrame, ::cuEGLStreamConsumerReleaseFrame,
|
| 397 |
+
* ::cudaEGLStreamConsumerDisconnect
|
| 398 |
+
*/
|
| 399 |
+
CUresult CUDAAPI cuEGLStreamConsumerDisconnect(CUeglStreamConnection *conn);
|
| 400 |
+
|
| 401 |
+
/**
|
| 402 |
+
* \brief Acquire an image frame from the EGLStream with CUDA as a consumer.
|
| 403 |
+
*
|
| 404 |
+
* Acquire an image frame from EGLStreamKHR. This API can also acquire an old frame presented
|
| 405 |
+
* by the producer unless explicitly disabled by setting EGL_SUPPORT_REUSE_NV flag to EGL_FALSE
|
| 406 |
+
* during stream initialization. By default, EGLStream is created with this flag set to EGL_TRUE.
|
| 407 |
+
* ::cuGraphicsResourceGetMappedEglFrame can be called on \p pCudaResource to get
|
| 408 |
+
* ::CUeglFrame.
|
| 409 |
+
*
|
| 410 |
+
* \param conn - Connection on which to acquire
|
| 411 |
+
* \param pCudaResource - CUDA resource on which the stream frame will be mapped for use.
|
| 412 |
+
* \param pStream - CUDA stream for synchronization and any data migrations
|
| 413 |
+
* implied by ::CUeglResourceLocationFlags.
|
| 414 |
+
* \param timeout - Desired timeout in usec for a new frame to be acquired.
|
| 415 |
+
* If set as ::CUDA_EGL_INFINITE_TIMEOUT, acquire waits infinitely.
|
| 416 |
+
* After timeout occurs CUDA consumer tries to acquire an old frame
|
| 417 |
+
* if available and EGL_SUPPORT_REUSE_NV flag is set.
|
| 418 |
+
*
|
| 419 |
+
* \return
|
| 420 |
+
* ::CUDA_SUCCESS,
|
| 421 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 422 |
+
* ::CUDA_ERROR_LAUNCH_TIMEOUT,
|
| 423 |
+
*
|
| 424 |
+
* \sa ::cuEGLStreamConsumerConnect, ::cuEGLStreamConsumerDisconnect,
|
| 425 |
+
* ::cuEGLStreamConsumerAcquireFrame, ::cuEGLStreamConsumerReleaseFrame,
|
| 426 |
+
* ::cudaEGLStreamConsumerAcquireFrame
|
| 427 |
+
*/
|
| 428 |
+
CUresult CUDAAPI cuEGLStreamConsumerAcquireFrame(CUeglStreamConnection *conn,
|
| 429 |
+
CUgraphicsResource *pCudaResource, CUstream *pStream, unsigned int timeout);
|
| 430 |
+
/**
|
| 431 |
+
* \brief Releases the last frame acquired from the EGLStream.
|
| 432 |
+
*
|
| 433 |
+
* Release the acquired image frame specified by \p pCudaResource to EGLStreamKHR.
|
| 434 |
+
* If EGL_SUPPORT_REUSE_NV flag is set to EGL_TRUE, at the time of EGL creation
|
| 435 |
+
* this API doesn't release the last frame acquired on the EGLStream.
|
| 436 |
+
* By default, EGLStream is created with this flag set to EGL_TRUE.
|
| 437 |
+
*
|
| 438 |
+
* \param conn - Connection on which to release
|
| 439 |
+
* \param pCudaResource - CUDA resource whose corresponding frame is to be released
|
| 440 |
+
* \param pStream - CUDA stream on which release will be done.
|
| 441 |
+
*
|
| 442 |
+
* \return
|
| 443 |
+
* ::CUDA_SUCCESS,
|
| 444 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 445 |
+
*
|
| 446 |
+
* \sa ::cuEGLStreamConsumerConnect, ::cuEGLStreamConsumerDisconnect,
|
| 447 |
+
* ::cuEGLStreamConsumerAcquireFrame, ::cuEGLStreamConsumerReleaseFrame,
|
| 448 |
+
* ::cudaEGLStreamConsumerReleaseFrame
|
| 449 |
+
*/
|
| 450 |
+
CUresult CUDAAPI cuEGLStreamConsumerReleaseFrame(CUeglStreamConnection *conn,
|
| 451 |
+
CUgraphicsResource pCudaResource, CUstream *pStream);
|
| 452 |
+
|
| 453 |
+
/**
|
| 454 |
+
* \brief Connect CUDA to EGLStream as a producer.
|
| 455 |
+
*
|
| 456 |
+
* Connect CUDA as a producer to EGLStreamKHR specified by \p stream.
|
| 457 |
+
*
|
| 458 |
+
* The EGLStreamKHR is an EGL object that transfers a sequence of image frames from one
|
| 459 |
+
* API to another.
|
| 460 |
+
*
|
| 461 |
+
* \param conn - Pointer to the returned connection handle
|
| 462 |
+
* \param stream - EGLStreamKHR handle
|
| 463 |
+
* \param width - width of the image to be submitted to the stream
|
| 464 |
+
* \param height - height of the image to be submitted to the stream
|
| 465 |
+
*
|
| 466 |
+
* \return
|
| 467 |
+
* ::CUDA_SUCCESS,
|
| 468 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 469 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 470 |
+
*
|
| 471 |
+
* \sa ::cuEGLStreamProducerConnect, ::cuEGLStreamProducerDisconnect,
|
| 472 |
+
* ::cuEGLStreamProducerPresentFrame,
|
| 473 |
+
* ::cudaEGLStreamProducerConnect
|
| 474 |
+
*/
|
| 475 |
+
CUresult CUDAAPI cuEGLStreamProducerConnect(CUeglStreamConnection *conn, EGLStreamKHR stream,
|
| 476 |
+
EGLint width, EGLint height);
|
| 477 |
+
|
| 478 |
+
/**
|
| 479 |
+
* \brief Disconnect CUDA as a producer to EGLStream .
|
| 480 |
+
*
|
| 481 |
+
* Disconnect CUDA as a producer to EGLStreamKHR.
|
| 482 |
+
*
|
| 483 |
+
* \param conn - Conection to disconnect.
|
| 484 |
+
*
|
| 485 |
+
* \return
|
| 486 |
+
* ::CUDA_SUCCESS,
|
| 487 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 488 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 489 |
+
*
|
| 490 |
+
* \sa ::cuEGLStreamProducerConnect, ::cuEGLStreamProducerDisconnect,
|
| 491 |
+
* ::cuEGLStreamProducerPresentFrame,
|
| 492 |
+
* ::cudaEGLStreamProducerDisconnect
|
| 493 |
+
*/
|
| 494 |
+
CUresult CUDAAPI cuEGLStreamProducerDisconnect(CUeglStreamConnection *conn);
|
| 495 |
+
|
| 496 |
+
/**
|
| 497 |
+
* \brief Present a CUDA eglFrame to the EGLStream with CUDA as a producer.
|
| 498 |
+
*
|
| 499 |
+
* When a frame is presented by the producer, it gets associated with the EGLStream
|
| 500 |
+
* and thus it is illegal to free the frame before the producer is disconnected.
|
| 501 |
+
* If a frame is freed and reused it may lead to undefined behavior.
|
| 502 |
+
*
|
| 503 |
+
* If producer and consumer are on different GPUs (iGPU and dGPU) then frametype
|
| 504 |
+
* ::CU_EGL_FRAME_TYPE_ARRAY is not supported. ::CU_EGL_FRAME_TYPE_PITCH can be used for
|
| 505 |
+
* such cross-device applications.
|
| 506 |
+
*
|
| 507 |
+
* The ::CUeglFrame is defined as:
|
| 508 |
+
* \code
|
| 509 |
+
* typedef struct CUeglFrame_st {
|
| 510 |
+
* union {
|
| 511 |
+
* CUarray pArray[MAX_PLANES];
|
| 512 |
+
* void* pPitch[MAX_PLANES];
|
| 513 |
+
* } frame;
|
| 514 |
+
* unsigned int width;
|
| 515 |
+
* unsigned int height;
|
| 516 |
+
* unsigned int depth;
|
| 517 |
+
* unsigned int pitch;
|
| 518 |
+
* unsigned int planeCount;
|
| 519 |
+
* unsigned int numChannels;
|
| 520 |
+
* CUeglFrameType frameType;
|
| 521 |
+
* CUeglColorFormat eglColorFormat;
|
| 522 |
+
* CUarray_format cuFormat;
|
| 523 |
+
* } CUeglFrame;
|
| 524 |
+
* \endcode
|
| 525 |
+
*
|
| 526 |
+
* For ::CUeglFrame of type ::CU_EGL_FRAME_TYPE_PITCH, the application may present sub-region of a memory
|
| 527 |
+
* allocation. In that case, the pitched pointer will specify the start address of the sub-region in
|
| 528 |
+
* the allocation and corresponding ::CUeglFrame fields will specify the dimensions of the sub-region.
|
| 529 |
+
*
|
| 530 |
+
* \param conn - Connection on which to present the CUDA array
|
| 531 |
+
* \param eglframe - CUDA Eglstream Proucer Frame handle to be sent to the consumer over EglStream.
|
| 532 |
+
* \param pStream - CUDA stream on which to present the frame.
|
| 533 |
+
*
|
| 534 |
+
* \return
|
| 535 |
+
* ::CUDA_SUCCESS,
|
| 536 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 537 |
+
*
|
| 538 |
+
* \sa ::cuEGLStreamProducerConnect, ::cuEGLStreamProducerDisconnect,
|
| 539 |
+
* ::cuEGLStreamProducerReturnFrame,
|
| 540 |
+
* ::cudaEGLStreamProducerPresentFrame
|
| 541 |
+
*/
|
| 542 |
+
CUresult CUDAAPI cuEGLStreamProducerPresentFrame(CUeglStreamConnection *conn,
|
| 543 |
+
CUeglFrame eglframe, CUstream *pStream);
|
| 544 |
+
|
| 545 |
+
/**
|
| 546 |
+
* \brief Return the CUDA eglFrame to the EGLStream released by the consumer.
|
| 547 |
+
*
|
| 548 |
+
* This API can potentially return CUDA_ERROR_LAUNCH_TIMEOUT if the consumer has not
|
| 549 |
+
* returned a frame to EGL stream. If timeout is returned the application can retry.
|
| 550 |
+
*
|
| 551 |
+
* \param conn - Connection on which to return
|
| 552 |
+
* \param eglframe - CUDA Eglstream Proucer Frame handle returned from the consumer over EglStream.
|
| 553 |
+
* \param pStream - CUDA stream on which to return the frame.
|
| 554 |
+
*
|
| 555 |
+
* \return
|
| 556 |
+
* ::CUDA_SUCCESS,
|
| 557 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 558 |
+
* ::CUDA_ERROR_LAUNCH_TIMEOUT
|
| 559 |
+
*
|
| 560 |
+
* \sa ::cuEGLStreamProducerConnect, ::cuEGLStreamProducerDisconnect,
|
| 561 |
+
* ::cuEGLStreamProducerPresentFrame,
|
| 562 |
+
* ::cudaEGLStreamProducerReturnFrame
|
| 563 |
+
*/
|
| 564 |
+
CUresult CUDAAPI cuEGLStreamProducerReturnFrame(CUeglStreamConnection *conn,
|
| 565 |
+
CUeglFrame *eglframe, CUstream *pStream);
|
| 566 |
+
|
| 567 |
+
/**
|
| 568 |
+
* \brief Get an eglFrame through which to access a registered EGL graphics resource.
|
| 569 |
+
*
|
| 570 |
+
* Returns in \p *eglFrame an eglFrame pointer through which the registered graphics resource
|
| 571 |
+
* \p resource may be accessed.
|
| 572 |
+
* This API can only be called for registered EGL graphics resources.
|
| 573 |
+
*
|
| 574 |
+
* The ::CUeglFrame is defined as:
|
| 575 |
+
* \code
|
| 576 |
+
* typedef struct CUeglFrame_st {
|
| 577 |
+
* union {
|
| 578 |
+
* CUarray pArray[MAX_PLANES];
|
| 579 |
+
* void* pPitch[MAX_PLANES];
|
| 580 |
+
* } frame;
|
| 581 |
+
* unsigned int width;
|
| 582 |
+
* unsigned int height;
|
| 583 |
+
* unsigned int depth;
|
| 584 |
+
* unsigned int pitch;
|
| 585 |
+
* unsigned int planeCount;
|
| 586 |
+
* unsigned int numChannels;
|
| 587 |
+
* CUeglFrameType frameType;
|
| 588 |
+
* CUeglColorFormat eglColorFormat;
|
| 589 |
+
* CUarray_format cuFormat;
|
| 590 |
+
* } CUeglFrame;
|
| 591 |
+
* \endcode
|
| 592 |
+
*
|
| 593 |
+
* If \p resource is not registered then ::CUDA_ERROR_NOT_MAPPED is returned.
|
| 594 |
+
* *
|
| 595 |
+
* \param eglFrame - Returned eglFrame.
|
| 596 |
+
* \param resource - Registered resource to access.
|
| 597 |
+
* \param index - Index for cubemap surfaces.
|
| 598 |
+
* \param mipLevel - Mipmap level for the subresource to access.
|
| 599 |
+
*
|
| 600 |
+
* \return
|
| 601 |
+
* ::CUDA_SUCCESS,
|
| 602 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 603 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 604 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 605 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 606 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 607 |
+
* ::CUDA_ERROR_NOT_MAPPED
|
| 608 |
+
*
|
| 609 |
+
* \sa
|
| 610 |
+
* ::cuGraphicsMapResources,
|
| 611 |
+
* ::cuGraphicsSubResourceGetMappedArray,
|
| 612 |
+
* ::cuGraphicsResourceGetMappedPointer,
|
| 613 |
+
* ::cudaGraphicsResourceGetMappedEglFrame
|
| 614 |
+
*/
|
| 615 |
+
CUresult CUDAAPI cuGraphicsResourceGetMappedEglFrame(CUeglFrame* eglFrame, CUgraphicsResource resource, unsigned int index, unsigned int mipLevel);
|
| 616 |
+
|
| 617 |
+
/**
|
| 618 |
+
* \brief Creates an event from EGLSync object
|
| 619 |
+
*
|
| 620 |
+
* Creates an event *phEvent from an EGLSyncKHR eglSync with the flags specified
|
| 621 |
+
* via \p flags. Valid flags include:
|
| 622 |
+
* - ::CU_EVENT_DEFAULT: Default event creation flag.
|
| 623 |
+
* - ::CU_EVENT_BLOCKING_SYNC: Specifies that the created event should use blocking
|
| 624 |
+
* synchronization. A CPU thread that uses ::cuEventSynchronize() to wait on
|
| 625 |
+
* an event created with this flag will block until the event has actually
|
| 626 |
+
* been completed.
|
| 627 |
+
*
|
| 628 |
+
* Once the \p eglSync gets destroyed, ::cuEventDestroy is the only API
|
| 629 |
+
* that can be invoked on the event.
|
| 630 |
+
*
|
| 631 |
+
* ::cuEventRecord and TimingData are not supported for events created from EGLSync.
|
| 632 |
+
*
|
| 633 |
+
* The EGLSyncKHR is an opaque handle to an EGL sync object.
|
| 634 |
+
* typedef void* EGLSyncKHR
|
| 635 |
+
*
|
| 636 |
+
* \param phEvent - Returns newly created event
|
| 637 |
+
* \param eglSync - Opaque handle to EGLSync object
|
| 638 |
+
* \param flags - Event creation flags
|
| 639 |
+
*
|
| 640 |
+
* \return
|
| 641 |
+
* ::CUDA_SUCCESS,
|
| 642 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 643 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 644 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 645 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 646 |
+
* ::CUDA_ERROR_OUT_OF_MEMORY
|
| 647 |
+
*
|
| 648 |
+
* \sa
|
| 649 |
+
* ::cuEventQuery,
|
| 650 |
+
* ::cuEventSynchronize,
|
| 651 |
+
* ::cuEventDestroy
|
| 652 |
+
*/
|
| 653 |
+
CUresult CUDAAPI cuEventCreateFromEGLSync(CUevent *phEvent, EGLSyncKHR eglSync, unsigned int flags);
|
| 654 |
+
|
| 655 |
+
/** @} */ /* END CUDA_EGL */
|
| 656 |
+
|
| 657 |
+
#ifdef __cplusplus
|
| 658 |
+
};
|
| 659 |
+
#endif
|
| 660 |
+
|
| 661 |
+
#endif
|
| 662 |
+
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaEGLTypedefs.h
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2020-2021 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef CUDAEGLTYPEDEFS_H
|
| 51 |
+
#define CUDAEGLTYPEDEFS_H
|
| 52 |
+
|
| 53 |
+
#include <cudaEGL.h>
|
| 54 |
+
|
| 55 |
+
#ifdef __cplusplus
|
| 56 |
+
extern "C" {
|
| 57 |
+
#endif // __cplusplus
|
| 58 |
+
|
| 59 |
+
/*
|
| 60 |
+
* Macros for the latest version for each driver function in cudaEGL.h
|
| 61 |
+
*/
|
| 62 |
+
#define PFN_cuGraphicsEGLRegisterImage PFN_cuGraphicsEGLRegisterImage_v7000
|
| 63 |
+
#define PFN_cuEGLStreamConsumerConnect PFN_cuEGLStreamConsumerConnect_v7000
|
| 64 |
+
#define PFN_cuEGLStreamConsumerConnectWithFlags PFN_cuEGLStreamConsumerConnectWithFlags_v8000
|
| 65 |
+
#define PFN_cuEGLStreamConsumerDisconnect PFN_cuEGLStreamConsumerDisconnect_v7000
|
| 66 |
+
#define PFN_cuEGLStreamConsumerAcquireFrame PFN_cuEGLStreamConsumerAcquireFrame_v7000
|
| 67 |
+
#define PFN_cuEGLStreamConsumerReleaseFrame PFN_cuEGLStreamConsumerReleaseFrame_v7000
|
| 68 |
+
#define PFN_cuEGLStreamProducerConnect PFN_cuEGLStreamProducerConnect_v7000
|
| 69 |
+
#define PFN_cuEGLStreamProducerDisconnect PFN_cuEGLStreamProducerDisconnect_v7000
|
| 70 |
+
#define PFN_cuEGLStreamProducerPresentFrame PFN_cuEGLStreamProducerPresentFrame_v7000
|
| 71 |
+
#define PFN_cuEGLStreamProducerReturnFrame PFN_cuEGLStreamProducerReturnFrame_v7000
|
| 72 |
+
#define PFN_cuGraphicsResourceGetMappedEglFrame PFN_cuGraphicsResourceGetMappedEglFrame_v7000
|
| 73 |
+
#define PFN_cuEventCreateFromEGLSync PFN_cuEventCreateFromEGLSync_v9000
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Type definitions for functions defined in cudaEGL.h
|
| 78 |
+
*/
|
| 79 |
+
typedef CUresult (CUDAAPI *PFN_cuGraphicsEGLRegisterImage_v7000)(CUgraphicsResource CUDAAPI *pCudaResource, EGLImageKHR image, unsigned int flags);
|
| 80 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerConnect_v7000)(CUeglStreamConnection CUDAAPI *conn, EGLStreamKHR stream);
|
| 81 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerConnectWithFlags_v8000)(CUeglStreamConnection CUDAAPI *conn, EGLStreamKHR stream, unsigned int flags);
|
| 82 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerDisconnect_v7000)(CUeglStreamConnection CUDAAPI *conn);
|
| 83 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerAcquireFrame_v7000)(CUeglStreamConnection CUDAAPI *conn, CUgraphicsResource CUDAAPI *pCudaResource, CUstream CUDAAPI *pStream, unsigned int timeout);
|
| 84 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamConsumerReleaseFrame_v7000)(CUeglStreamConnection CUDAAPI *conn, CUgraphicsResource pCudaResource, CUstream CUDAAPI *pStream);
|
| 85 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamProducerConnect_v7000)(CUeglStreamConnection CUDAAPI *conn, EGLStreamKHR stream, EGLint width, EGLint height);
|
| 86 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamProducerDisconnect_v7000)(CUeglStreamConnection CUDAAPI *conn);
|
| 87 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamProducerPresentFrame_v7000)(CUeglStreamConnection CUDAAPI *conn, CUeglFrame_v1 eglframe, CUstream CUDAAPI *pStream);
|
| 88 |
+
typedef CUresult (CUDAAPI *PFN_cuEGLStreamProducerReturnFrame_v7000)(CUeglStreamConnection CUDAAPI *conn, CUeglFrame_v1 CUDAAPI *eglframe, CUstream CUDAAPI *pStream);
|
| 89 |
+
typedef CUresult (CUDAAPI *PFN_cuGraphicsResourceGetMappedEglFrame_v7000)(CUeglFrame_v1 CUDAAPI *eglFrame, CUgraphicsResource resource, unsigned int index, unsigned int mipLevel);
|
| 90 |
+
typedef CUresult (CUDAAPI *PFN_cuEventCreateFromEGLSync_v9000)(CUevent CUDAAPI *phEvent, EGLSyncKHR eglSync, unsigned int flags);
|
| 91 |
+
|
| 92 |
+
#ifdef __cplusplus
|
| 93 |
+
}
|
| 94 |
+
#endif // __cplusplus
|
| 95 |
+
|
| 96 |
+
#endif // file guard
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaGL.h
ADDED
|
@@ -0,0 +1,608 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef CUDAGL_H
|
| 51 |
+
#define CUDAGL_H
|
| 52 |
+
|
| 53 |
+
#include <cuda.h>
|
| 54 |
+
#include <GL/gl.h>
|
| 55 |
+
|
| 56 |
+
#if defined(__CUDA_API_VERSION_INTERNAL) || defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
|
| 57 |
+
#define __CUDA_DEPRECATED
|
| 58 |
+
#elif defined(_MSC_VER)
|
| 59 |
+
#define __CUDA_DEPRECATED __declspec(deprecated)
|
| 60 |
+
#elif defined(__GNUC__)
|
| 61 |
+
#define __CUDA_DEPRECATED __attribute__((deprecated))
|
| 62 |
+
#else
|
| 63 |
+
#define __CUDA_DEPRECATED
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
#ifdef CUDA_FORCE_API_VERSION
|
| 67 |
+
#error "CUDA_FORCE_API_VERSION is no longer supported."
|
| 68 |
+
#endif
|
| 69 |
+
|
| 70 |
+
#if defined(__CUDA_API_VERSION_INTERNAL) || defined(CUDA_API_PER_THREAD_DEFAULT_STREAM)
|
| 71 |
+
#define __CUDA_API_PER_THREAD_DEFAULT_STREAM
|
| 72 |
+
#define __CUDA_API_PTDS(api) api ## _ptds
|
| 73 |
+
#define __CUDA_API_PTSZ(api) api ## _ptsz
|
| 74 |
+
#else
|
| 75 |
+
#define __CUDA_API_PTDS(api) api
|
| 76 |
+
#define __CUDA_API_PTSZ(api) api
|
| 77 |
+
#endif
|
| 78 |
+
|
| 79 |
+
#define cuGLCtxCreate cuGLCtxCreate_v2
|
| 80 |
+
#define cuGLMapBufferObject __CUDA_API_PTDS(cuGLMapBufferObject_v2)
|
| 81 |
+
#define cuGLMapBufferObjectAsync __CUDA_API_PTSZ(cuGLMapBufferObjectAsync_v2)
|
| 82 |
+
#define cuGLGetDevices cuGLGetDevices_v2
|
| 83 |
+
|
| 84 |
+
#ifdef __cplusplus
|
| 85 |
+
extern "C" {
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* \file cudaGL.h
|
| 90 |
+
* \brief Header file for the OpenGL interoperability functions of the
|
| 91 |
+
* low-level CUDA driver application programming interface.
|
| 92 |
+
*/
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* \defgroup CUDA_GL OpenGL Interoperability
|
| 96 |
+
* \ingroup CUDA_DRIVER
|
| 97 |
+
*
|
| 98 |
+
* ___MANBRIEF___ OpenGL interoperability functions of the low-level CUDA
|
| 99 |
+
* driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
|
| 100 |
+
*
|
| 101 |
+
* This section describes the OpenGL interoperability functions of the
|
| 102 |
+
* low-level CUDA driver application programming interface. Note that mapping
|
| 103 |
+
* of OpenGL resources is performed with the graphics API agnostic, resource
|
| 104 |
+
* mapping interface described in \ref CUDA_GRAPHICS "Graphics Interoperability".
|
| 105 |
+
*
|
| 106 |
+
* @{
|
| 107 |
+
*/
|
| 108 |
+
|
| 109 |
+
#if defined(_WIN32)
|
| 110 |
+
#if !defined(WGL_NV_gpu_affinity)
|
| 111 |
+
typedef void* HGPUNV;
|
| 112 |
+
#endif
|
| 113 |
+
#endif /* _WIN32 */
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* \brief Registers an OpenGL buffer object
|
| 117 |
+
*
|
| 118 |
+
* Registers the buffer object specified by \p buffer for access by
|
| 119 |
+
* CUDA. A handle to the registered object is returned as \p
|
| 120 |
+
* pCudaResource. The register flags \p Flags specify the intended usage,
|
| 121 |
+
* as follows:
|
| 122 |
+
*
|
| 123 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_NONE: Specifies no hints about how this
|
| 124 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 125 |
+
* read from and written to by CUDA. This is the default value.
|
| 126 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY: Specifies that CUDA
|
| 127 |
+
* will not write to this resource.
|
| 128 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD: Specifies that
|
| 129 |
+
* CUDA will not read from this resource and will write over the
|
| 130 |
+
* entire contents of the resource, so none of the data previously
|
| 131 |
+
* stored in the resource will be preserved.
|
| 132 |
+
*
|
| 133 |
+
* \param pCudaResource - Pointer to the returned object handle
|
| 134 |
+
* \param buffer - name of buffer object to be registered
|
| 135 |
+
* \param Flags - Register flags
|
| 136 |
+
*
|
| 137 |
+
* \return
|
| 138 |
+
* ::CUDA_SUCCESS,
|
| 139 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 140 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 141 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 142 |
+
* ::CUDA_ERROR_OPERATING_SYSTEM
|
| 143 |
+
* \notefnerr
|
| 144 |
+
*
|
| 145 |
+
* \sa
|
| 146 |
+
* ::cuGraphicsUnregisterResource,
|
| 147 |
+
* ::cuGraphicsMapResources,
|
| 148 |
+
* ::cuGraphicsResourceGetMappedPointer,
|
| 149 |
+
* ::cudaGraphicsGLRegisterBuffer
|
| 150 |
+
*/
|
| 151 |
+
CUresult CUDAAPI cuGraphicsGLRegisterBuffer(CUgraphicsResource *pCudaResource, GLuint buffer, unsigned int Flags);
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* \brief Register an OpenGL texture or renderbuffer object
|
| 155 |
+
*
|
| 156 |
+
* Registers the texture or renderbuffer object specified by \p image for access by CUDA.
|
| 157 |
+
* A handle to the registered object is returned as \p pCudaResource.
|
| 158 |
+
*
|
| 159 |
+
* \p target must match the type of the object, and must be one of ::GL_TEXTURE_2D,
|
| 160 |
+
* ::GL_TEXTURE_RECTANGLE, ::GL_TEXTURE_CUBE_MAP, ::GL_TEXTURE_3D, ::GL_TEXTURE_2D_ARRAY,
|
| 161 |
+
* or ::GL_RENDERBUFFER.
|
| 162 |
+
*
|
| 163 |
+
* The register flags \p Flags specify the intended usage, as follows:
|
| 164 |
+
*
|
| 165 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_NONE: Specifies no hints about how this
|
| 166 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 167 |
+
* read from and written to by CUDA. This is the default value.
|
| 168 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY: Specifies that CUDA
|
| 169 |
+
* will not write to this resource.
|
| 170 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD: Specifies that
|
| 171 |
+
* CUDA will not read from this resource and will write over the
|
| 172 |
+
* entire contents of the resource, so none of the data previously
|
| 173 |
+
* stored in the resource will be preserved.
|
| 174 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST: Specifies that CUDA will
|
| 175 |
+
* bind this resource to a surface reference.
|
| 176 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER: Specifies that CUDA will perform
|
| 177 |
+
* texture gather operations on this resource.
|
| 178 |
+
*
|
| 179 |
+
* The following image formats are supported. For brevity's sake, the list is abbreviated.
|
| 180 |
+
* For ex., {GL_R, GL_RG} X {8, 16} would expand to the following 4 formats
|
| 181 |
+
* {GL_R8, GL_R16, GL_RG8, GL_RG16} :
|
| 182 |
+
* - GL_RED, GL_RG, GL_RGBA, GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY
|
| 183 |
+
* - {GL_R, GL_RG, GL_RGBA} X {8, 16, 16F, 32F, 8UI, 16UI, 32UI, 8I, 16I, 32I}
|
| 184 |
+
* - {GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY} X
|
| 185 |
+
* {8, 16, 16F_ARB, 32F_ARB, 8UI_EXT, 16UI_EXT, 32UI_EXT, 8I_EXT, 16I_EXT, 32I_EXT}
|
| 186 |
+
*
|
| 187 |
+
* The following image classes are currently disallowed:
|
| 188 |
+
* - Textures with borders
|
| 189 |
+
* - Multisampled renderbuffers
|
| 190 |
+
*
|
| 191 |
+
* \param pCudaResource - Pointer to the returned object handle
|
| 192 |
+
* \param image - name of texture or renderbuffer object to be registered
|
| 193 |
+
* \param target - Identifies the type of object specified by \p image
|
| 194 |
+
* \param Flags - Register flags
|
| 195 |
+
*
|
| 196 |
+
* \return
|
| 197 |
+
* ::CUDA_SUCCESS,
|
| 198 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 199 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 200 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 201 |
+
* ::CUDA_ERROR_OPERATING_SYSTEM
|
| 202 |
+
* \notefnerr
|
| 203 |
+
*
|
| 204 |
+
* \sa
|
| 205 |
+
* ::cuGraphicsUnregisterResource,
|
| 206 |
+
* ::cuGraphicsMapResources,
|
| 207 |
+
* ::cuGraphicsSubResourceGetMappedArray,
|
| 208 |
+
* ::cudaGraphicsGLRegisterImage
|
| 209 |
+
*/
|
| 210 |
+
CUresult CUDAAPI cuGraphicsGLRegisterImage(CUgraphicsResource *pCudaResource, GLuint image, GLenum target, unsigned int Flags);
|
| 211 |
+
|
| 212 |
+
#ifdef _WIN32
|
| 213 |
+
/**
|
| 214 |
+
* \brief Gets the CUDA device associated with hGpu
|
| 215 |
+
*
|
| 216 |
+
* Returns in \p *pDevice the CUDA device associated with a \p hGpu, if
|
| 217 |
+
* applicable.
|
| 218 |
+
*
|
| 219 |
+
* \param pDevice - Device associated with hGpu
|
| 220 |
+
* \param hGpu - Handle to a GPU, as queried via ::WGL_NV_gpu_affinity()
|
| 221 |
+
*
|
| 222 |
+
* \return
|
| 223 |
+
* ::CUDA_SUCCESS,
|
| 224 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 225 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 226 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 227 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 228 |
+
* \notefnerr
|
| 229 |
+
*
|
| 230 |
+
* \sa ::cuGLMapBufferObject,
|
| 231 |
+
* ::cuGLRegisterBufferObject, ::cuGLUnmapBufferObject,
|
| 232 |
+
* ::cuGLUnregisterBufferObject, ::cuGLUnmapBufferObjectAsync,
|
| 233 |
+
* ::cuGLSetBufferObjectMapFlags,
|
| 234 |
+
* ::cudaWGLGetDevice
|
| 235 |
+
*/
|
| 236 |
+
CUresult CUDAAPI cuWGLGetDevice(CUdevice *pDevice, HGPUNV hGpu);
|
| 237 |
+
#endif /* _WIN32 */
|
| 238 |
+
|
| 239 |
+
/**
|
| 240 |
+
* CUDA devices corresponding to an OpenGL device
|
| 241 |
+
*/
|
| 242 |
+
typedef enum CUGLDeviceList_enum {
|
| 243 |
+
CU_GL_DEVICE_LIST_ALL = 0x01, /**< The CUDA devices for all GPUs used by the current OpenGL context */
|
| 244 |
+
CU_GL_DEVICE_LIST_CURRENT_FRAME = 0x02, /**< The CUDA devices for the GPUs used by the current OpenGL context in its currently rendering frame */
|
| 245 |
+
CU_GL_DEVICE_LIST_NEXT_FRAME = 0x03, /**< The CUDA devices for the GPUs to be used by the current OpenGL context in the next frame */
|
| 246 |
+
} CUGLDeviceList;
|
| 247 |
+
|
| 248 |
+
/**
|
| 249 |
+
* \brief Gets the CUDA devices associated with the current OpenGL context
|
| 250 |
+
*
|
| 251 |
+
* Returns in \p *pCudaDeviceCount the number of CUDA-compatible devices
|
| 252 |
+
* corresponding to the current OpenGL context. Also returns in \p *pCudaDevices
|
| 253 |
+
* at most cudaDeviceCount of the CUDA-compatible devices corresponding to
|
| 254 |
+
* the current OpenGL context. If any of the GPUs being used by the current OpenGL
|
| 255 |
+
* context are not CUDA capable then the call will return CUDA_ERROR_NO_DEVICE.
|
| 256 |
+
*
|
| 257 |
+
* The \p deviceList argument may be any of the following:
|
| 258 |
+
* - ::CU_GL_DEVICE_LIST_ALL: Query all devices used by the current OpenGL context.
|
| 259 |
+
* - ::CU_GL_DEVICE_LIST_CURRENT_FRAME: Query the devices used by the current OpenGL context to
|
| 260 |
+
* render the current frame (in SLI).
|
| 261 |
+
* - ::CU_GL_DEVICE_LIST_NEXT_FRAME: Query the devices used by the current OpenGL context to
|
| 262 |
+
* render the next frame (in SLI). Note that this is a prediction, it can't be guaranteed that
|
| 263 |
+
* this is correct in all cases.
|
| 264 |
+
*
|
| 265 |
+
* \param pCudaDeviceCount - Returned number of CUDA devices.
|
| 266 |
+
* \param pCudaDevices - Returned CUDA devices.
|
| 267 |
+
* \param cudaDeviceCount - The size of the output device array pCudaDevices.
|
| 268 |
+
* \param deviceList - The set of devices to return.
|
| 269 |
+
*
|
| 270 |
+
* \return
|
| 271 |
+
* ::CUDA_SUCCESS,
|
| 272 |
+
* ::CUDA_ERROR_NO_DEVICE,
|
| 273 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 274 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 275 |
+
* ::CUDA_ERROR_INVALID_GRAPHICS_CONTEXT,
|
| 276 |
+
* ::CUDA_ERROR_OPERATING_SYSTEM
|
| 277 |
+
*
|
| 278 |
+
* \notefnerr
|
| 279 |
+
*
|
| 280 |
+
* \sa
|
| 281 |
+
* ::cuWGLGetDevice,
|
| 282 |
+
* ::cudaGLGetDevices
|
| 283 |
+
*/
|
| 284 |
+
CUresult CUDAAPI cuGLGetDevices(unsigned int *pCudaDeviceCount, CUdevice *pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
|
| 285 |
+
|
| 286 |
+
/**
|
| 287 |
+
* \defgroup CUDA_GL_DEPRECATED OpenGL Interoperability [DEPRECATED]
|
| 288 |
+
*
|
| 289 |
+
* ___MANBRIEF___ deprecated OpenGL interoperability functions of the low-level
|
| 290 |
+
* CUDA driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
|
| 291 |
+
*
|
| 292 |
+
* This section describes deprecated OpenGL interoperability functionality.
|
| 293 |
+
*
|
| 294 |
+
* @{
|
| 295 |
+
*/
|
| 296 |
+
|
| 297 |
+
/** Flags to map or unmap a resource */
|
| 298 |
+
typedef enum CUGLmap_flags_enum {
|
| 299 |
+
CU_GL_MAP_RESOURCE_FLAGS_NONE = 0x00,
|
| 300 |
+
CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01,
|
| 301 |
+
CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02,
|
| 302 |
+
} CUGLmap_flags;
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* \brief Create a CUDA context for interoperability with OpenGL
|
| 306 |
+
*
|
| 307 |
+
* \deprecated This function is deprecated as of Cuda 5.0.
|
| 308 |
+
*
|
| 309 |
+
* This function is deprecated and should no longer be used. It is
|
| 310 |
+
* no longer necessary to associate a CUDA context with an OpenGL
|
| 311 |
+
* context in order to achieve maximum interoperability performance.
|
| 312 |
+
*
|
| 313 |
+
* \param pCtx - Returned CUDA context
|
| 314 |
+
* \param Flags - Options for CUDA context creation
|
| 315 |
+
* \param device - Device on which to create the context
|
| 316 |
+
*
|
| 317 |
+
* \return
|
| 318 |
+
* ::CUDA_SUCCESS,
|
| 319 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 320 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 321 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 322 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 323 |
+
* ::CUDA_ERROR_OUT_OF_MEMORY
|
| 324 |
+
* \notefnerr
|
| 325 |
+
*
|
| 326 |
+
* \sa ::cuCtxCreate, ::cuGLInit, ::cuGLMapBufferObject,
|
| 327 |
+
* ::cuGLRegisterBufferObject, ::cuGLUnmapBufferObject,
|
| 328 |
+
* ::cuGLUnregisterBufferObject, ::cuGLMapBufferObjectAsync,
|
| 329 |
+
* ::cuGLUnmapBufferObjectAsync, ::cuGLSetBufferObjectMapFlags,
|
| 330 |
+
* ::cuWGLGetDevice
|
| 331 |
+
*/
|
| 332 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLCtxCreate(CUcontext *pCtx, unsigned int Flags, CUdevice device );
|
| 333 |
+
|
| 334 |
+
/**
|
| 335 |
+
* \brief Initializes OpenGL interoperability
|
| 336 |
+
*
|
| 337 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 338 |
+
*
|
| 339 |
+
* Initializes OpenGL interoperability. This function is deprecated
|
| 340 |
+
* and calling it is no longer required. It may fail if the needed
|
| 341 |
+
* OpenGL driver facilities are not available.
|
| 342 |
+
*
|
| 343 |
+
* \return
|
| 344 |
+
* ::CUDA_SUCCESS,
|
| 345 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 346 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 347 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 348 |
+
* ::CUDA_ERROR_UNKNOWN
|
| 349 |
+
* \notefnerr
|
| 350 |
+
*
|
| 351 |
+
* \sa ::cuGLMapBufferObject,
|
| 352 |
+
* ::cuGLRegisterBufferObject, ::cuGLUnmapBufferObject,
|
| 353 |
+
* ::cuGLUnregisterBufferObject, ::cuGLMapBufferObjectAsync,
|
| 354 |
+
* ::cuGLUnmapBufferObjectAsync, ::cuGLSetBufferObjectMapFlags,
|
| 355 |
+
* ::cuWGLGetDevice
|
| 356 |
+
*/
|
| 357 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLInit(void);
|
| 358 |
+
|
| 359 |
+
/**
|
| 360 |
+
* \brief Registers an OpenGL buffer object
|
| 361 |
+
*
|
| 362 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 363 |
+
*
|
| 364 |
+
* Registers the buffer object specified by \p buffer for access by
|
| 365 |
+
* CUDA. This function must be called before CUDA can map the buffer
|
| 366 |
+
* object. There must be a valid OpenGL context bound to the current
|
| 367 |
+
* thread when this function is called, and the buffer name is
|
| 368 |
+
* resolved by that context.
|
| 369 |
+
*
|
| 370 |
+
* \param buffer - The name of the buffer object to register.
|
| 371 |
+
*
|
| 372 |
+
* \return
|
| 373 |
+
* ::CUDA_SUCCESS,
|
| 374 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 375 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 376 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 377 |
+
* ::CUDA_ERROR_ALREADY_MAPPED
|
| 378 |
+
* \notefnerr
|
| 379 |
+
*
|
| 380 |
+
* \sa ::cuGraphicsGLRegisterBuffer
|
| 381 |
+
*/
|
| 382 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLRegisterBufferObject(GLuint buffer);
|
| 383 |
+
|
| 384 |
+
/**
|
| 385 |
+
* \brief Maps an OpenGL buffer object
|
| 386 |
+
*
|
| 387 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 388 |
+
*
|
| 389 |
+
* Maps the buffer object specified by \p buffer into the address space of the
|
| 390 |
+
* current CUDA context and returns in \p *dptr and \p *size the base pointer
|
| 391 |
+
* and size of the resulting mapping.
|
| 392 |
+
*
|
| 393 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 394 |
+
* when this function is called. This must be the same context, or a
|
| 395 |
+
* member of the same shareGroup, as the context that was bound when
|
| 396 |
+
* the buffer was registered.
|
| 397 |
+
*
|
| 398 |
+
* All streams in the current CUDA context are synchronized with the
|
| 399 |
+
* current GL context.
|
| 400 |
+
*
|
| 401 |
+
* \param dptr - Returned mapped base pointer
|
| 402 |
+
* \param size - Returned size of mapping
|
| 403 |
+
* \param buffer - The name of the buffer object to map
|
| 404 |
+
*
|
| 405 |
+
* \return
|
| 406 |
+
* ::CUDA_SUCCESS,
|
| 407 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 408 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 409 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 410 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 411 |
+
* ::CUDA_ERROR_MAP_FAILED
|
| 412 |
+
* \notefnerr
|
| 413 |
+
*
|
| 414 |
+
* \sa ::cuGraphicsMapResources
|
| 415 |
+
*/
|
| 416 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLMapBufferObject(CUdeviceptr *dptr, size_t *size, GLuint buffer);
|
| 417 |
+
|
| 418 |
+
/**
|
| 419 |
+
* \brief Unmaps an OpenGL buffer object
|
| 420 |
+
*
|
| 421 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 422 |
+
*
|
| 423 |
+
* Unmaps the buffer object specified by \p buffer for access by CUDA.
|
| 424 |
+
*
|
| 425 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 426 |
+
* when this function is called. This must be the same context, or a
|
| 427 |
+
* member of the same shareGroup, as the context that was bound when
|
| 428 |
+
* the buffer was registered.
|
| 429 |
+
*
|
| 430 |
+
* All streams in the current CUDA context are synchronized with the
|
| 431 |
+
* current GL context.
|
| 432 |
+
*
|
| 433 |
+
* \param buffer - Buffer object to unmap
|
| 434 |
+
*
|
| 435 |
+
* \return
|
| 436 |
+
* ::CUDA_SUCCESS,
|
| 437 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 438 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 439 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 440 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 441 |
+
* \notefnerr
|
| 442 |
+
*
|
| 443 |
+
* \sa ::cuGraphicsUnmapResources
|
| 444 |
+
*/
|
| 445 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLUnmapBufferObject(GLuint buffer);
|
| 446 |
+
|
| 447 |
+
/**
|
| 448 |
+
* \brief Unregister an OpenGL buffer object
|
| 449 |
+
*
|
| 450 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 451 |
+
*
|
| 452 |
+
* Unregisters the buffer object specified by \p buffer. This
|
| 453 |
+
* releases any resources associated with the registered buffer.
|
| 454 |
+
* After this call, the buffer may no longer be mapped for access by
|
| 455 |
+
* CUDA.
|
| 456 |
+
*
|
| 457 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 458 |
+
* when this function is called. This must be the same context, or a
|
| 459 |
+
* member of the same shareGroup, as the context that was bound when
|
| 460 |
+
* the buffer was registered.
|
| 461 |
+
*
|
| 462 |
+
* \param buffer - Name of the buffer object to unregister
|
| 463 |
+
*
|
| 464 |
+
* \return
|
| 465 |
+
* ::CUDA_SUCCESS,
|
| 466 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 467 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 468 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 469 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 470 |
+
* \notefnerr
|
| 471 |
+
*
|
| 472 |
+
* \sa ::cuGraphicsUnregisterResource
|
| 473 |
+
*/
|
| 474 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLUnregisterBufferObject(GLuint buffer);
|
| 475 |
+
|
| 476 |
+
/**
|
| 477 |
+
* \brief Set the map flags for an OpenGL buffer object
|
| 478 |
+
*
|
| 479 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 480 |
+
*
|
| 481 |
+
* Sets the map flags for the buffer object specified by \p buffer.
|
| 482 |
+
*
|
| 483 |
+
* Changes to \p Flags will take effect the next time \p buffer is mapped.
|
| 484 |
+
* The \p Flags argument may be any of the following:
|
| 485 |
+
* - ::CU_GL_MAP_RESOURCE_FLAGS_NONE: Specifies no hints about how this
|
| 486 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 487 |
+
* read from and written to by CUDA kernels. This is the default value.
|
| 488 |
+
* - ::CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY: Specifies that CUDA kernels which
|
| 489 |
+
* access this resource will not write to this resource.
|
| 490 |
+
* - ::CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD: Specifies that CUDA kernels
|
| 491 |
+
* which access this resource will not read from this resource and will
|
| 492 |
+
* write over the entire contents of the resource, so none of the data
|
| 493 |
+
* previously stored in the resource will be preserved.
|
| 494 |
+
*
|
| 495 |
+
* If \p buffer has not been registered for use with CUDA, then
|
| 496 |
+
* ::CUDA_ERROR_INVALID_HANDLE is returned. If \p buffer is presently
|
| 497 |
+
* mapped for access by CUDA, then ::CUDA_ERROR_ALREADY_MAPPED is returned.
|
| 498 |
+
*
|
| 499 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 500 |
+
* when this function is called. This must be the same context, or a
|
| 501 |
+
* member of the same shareGroup, as the context that was bound when
|
| 502 |
+
* the buffer was registered.
|
| 503 |
+
*
|
| 504 |
+
* \param buffer - Buffer object to unmap
|
| 505 |
+
* \param Flags - Map flags
|
| 506 |
+
*
|
| 507 |
+
* \return
|
| 508 |
+
* ::CUDA_SUCCESS,
|
| 509 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 510 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 511 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 512 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 513 |
+
* \notefnerr
|
| 514 |
+
*
|
| 515 |
+
* \sa ::cuGraphicsResourceSetMapFlags
|
| 516 |
+
*/
|
| 517 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLSetBufferObjectMapFlags(GLuint buffer, unsigned int Flags);
|
| 518 |
+
|
| 519 |
+
/**
|
| 520 |
+
* \brief Maps an OpenGL buffer object
|
| 521 |
+
*
|
| 522 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 523 |
+
*
|
| 524 |
+
* Maps the buffer object specified by \p buffer into the address space of the
|
| 525 |
+
* current CUDA context and returns in \p *dptr and \p *size the base pointer
|
| 526 |
+
* and size of the resulting mapping.
|
| 527 |
+
*
|
| 528 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 529 |
+
* when this function is called. This must be the same context, or a
|
| 530 |
+
* member of the same shareGroup, as the context that was bound when
|
| 531 |
+
* the buffer was registered.
|
| 532 |
+
*
|
| 533 |
+
* Stream \p hStream in the current CUDA context is synchronized with
|
| 534 |
+
* the current GL context.
|
| 535 |
+
*
|
| 536 |
+
* \param dptr - Returned mapped base pointer
|
| 537 |
+
* \param size - Returned size of mapping
|
| 538 |
+
* \param buffer - The name of the buffer object to map
|
| 539 |
+
* \param hStream - Stream to synchronize
|
| 540 |
+
*
|
| 541 |
+
* \return
|
| 542 |
+
* ::CUDA_SUCCESS,
|
| 543 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 544 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 545 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 546 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 547 |
+
* ::CUDA_ERROR_MAP_FAILED
|
| 548 |
+
* \notefnerr
|
| 549 |
+
*
|
| 550 |
+
* \sa ::cuGraphicsMapResources
|
| 551 |
+
*/
|
| 552 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLMapBufferObjectAsync(CUdeviceptr *dptr, size_t *size, GLuint buffer, CUstream hStream);
|
| 553 |
+
|
| 554 |
+
/**
|
| 555 |
+
* \brief Unmaps an OpenGL buffer object
|
| 556 |
+
*
|
| 557 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 558 |
+
*
|
| 559 |
+
* Unmaps the buffer object specified by \p buffer for access by CUDA.
|
| 560 |
+
*
|
| 561 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 562 |
+
* when this function is called. This must be the same context, or a
|
| 563 |
+
* member of the same shareGroup, as the context that was bound when
|
| 564 |
+
* the buffer was registered.
|
| 565 |
+
*
|
| 566 |
+
* Stream \p hStream in the current CUDA context is synchronized with
|
| 567 |
+
* the current GL context.
|
| 568 |
+
*
|
| 569 |
+
* \param buffer - Name of the buffer object to unmap
|
| 570 |
+
* \param hStream - Stream to synchronize
|
| 571 |
+
*
|
| 572 |
+
* \return
|
| 573 |
+
* ::CUDA_SUCCESS,
|
| 574 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 575 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 576 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 577 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 578 |
+
* \notefnerr
|
| 579 |
+
*
|
| 580 |
+
* \sa ::cuGraphicsUnmapResources
|
| 581 |
+
*/
|
| 582 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLUnmapBufferObjectAsync(GLuint buffer, CUstream hStream);
|
| 583 |
+
|
| 584 |
+
/** @} */ /* END CUDA_GL_DEPRECATED */
|
| 585 |
+
/** @} */ /* END CUDA_GL */
|
| 586 |
+
|
| 587 |
+
|
| 588 |
+
#if defined(__CUDA_API_VERSION_INTERNAL)
|
| 589 |
+
#undef cuGLCtxCreate
|
| 590 |
+
#undef cuGLMapBufferObject
|
| 591 |
+
#undef cuGLMapBufferObjectAsync
|
| 592 |
+
#undef cuGLGetDevices
|
| 593 |
+
|
| 594 |
+
CUresult CUDAAPI cuGLGetDevices(unsigned int *pCudaDeviceCount, CUdevice *pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
|
| 595 |
+
CUresult CUDAAPI cuGLMapBufferObject_v2(CUdeviceptr *dptr, size_t *size, GLuint buffer);
|
| 596 |
+
CUresult CUDAAPI cuGLMapBufferObjectAsync_v2(CUdeviceptr *dptr, size_t *size, GLuint buffer, CUstream hStream);
|
| 597 |
+
CUresult CUDAAPI cuGLCtxCreate(CUcontext *pCtx, unsigned int Flags, CUdevice device );
|
| 598 |
+
CUresult CUDAAPI cuGLMapBufferObject(CUdeviceptr_v1 *dptr, unsigned int *size, GLuint buffer);
|
| 599 |
+
CUresult CUDAAPI cuGLMapBufferObjectAsync(CUdeviceptr_v1 *dptr, unsigned int *size, GLuint buffer, CUstream hStream);
|
| 600 |
+
#endif /* __CUDA_API_VERSION_INTERNAL */
|
| 601 |
+
|
| 602 |
+
#ifdef __cplusplus
|
| 603 |
+
};
|
| 604 |
+
#endif
|
| 605 |
+
|
| 606 |
+
#undef __CUDA_DEPRECATED
|
| 607 |
+
|
| 608 |
+
#endif
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaGLTypedefs.h
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2020-2021 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef CUDAGLTYPEDEFS_H
|
| 51 |
+
#define CUDAGLTYPEDEFS_H
|
| 52 |
+
|
| 53 |
+
// Dependent includes for cudagl.h
|
| 54 |
+
#include <GL/gl.h>
|
| 55 |
+
|
| 56 |
+
#include <cudaGL.h>
|
| 57 |
+
|
| 58 |
+
#if defined(CUDA_API_PER_THREAD_DEFAULT_STREAM)
|
| 59 |
+
#define __API_TYPEDEF_PTDS(api, default_version, ptds_version) api ## _v ## ptds_version ## _ptds
|
| 60 |
+
#define __API_TYPEDEF_PTSZ(api, default_version, ptds_version) api ## _v ## ptds_version ## _ptsz
|
| 61 |
+
#else
|
| 62 |
+
#define __API_TYPEDEF_PTDS(api, default_version, ptds_version) api ## _v ## default_version
|
| 63 |
+
#define __API_TYPEDEF_PTSZ(api, default_version, ptds_version) api ## _v ## default_version
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
#ifdef __cplusplus
|
| 67 |
+
extern "C" {
|
| 68 |
+
#endif // __cplusplus
|
| 69 |
+
|
| 70 |
+
/*
|
| 71 |
+
* Macros for the latest version for each driver function in cudaGL.h
|
| 72 |
+
*/
|
| 73 |
+
#define PFN_cuGraphicsGLRegisterBuffer PFN_cuGraphicsGLRegisterBuffer_v3000
|
| 74 |
+
#define PFN_cuGraphicsGLRegisterImage PFN_cuGraphicsGLRegisterImage_v3000
|
| 75 |
+
#define PFN_cuWGLGetDevice PFN_cuWGLGetDevice_v2020
|
| 76 |
+
#define PFN_cuGLGetDevices PFN_cuGLGetDevices_v6050
|
| 77 |
+
#define PFN_cuGLCtxCreate PFN_cuGLCtxCreate_v3020
|
| 78 |
+
#define PFN_cuGLInit PFN_cuGLInit_v2000
|
| 79 |
+
#define PFN_cuGLRegisterBufferObject PFN_cuGLRegisterBufferObject_v2000
|
| 80 |
+
#define PFN_cuGLMapBufferObject __API_TYPEDEF_PTDS(PFN_cuGLMapBufferObject, 3020, 7000)
|
| 81 |
+
#define PFN_cuGLUnmapBufferObject PFN_cuGLUnmapBufferObject_v2000
|
| 82 |
+
#define PFN_cuGLUnregisterBufferObject PFN_cuGLUnregisterBufferObject_v2000
|
| 83 |
+
#define PFN_cuGLSetBufferObjectMapFlags PFN_cuGLSetBufferObjectMapFlags_v2030
|
| 84 |
+
#define PFN_cuGLMapBufferObjectAsync __API_TYPEDEF_PTSZ(PFN_cuGLMapBufferObjectAsync, 3020, 7000)
|
| 85 |
+
#define PFN_cuGLUnmapBufferObjectAsync PFN_cuGLUnmapBufferObjectAsync_v2030
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Type definitions for functions defined in cudaGL.h
|
| 90 |
+
*/
|
| 91 |
+
typedef CUresult (CUDAAPI *PFN_cuGraphicsGLRegisterBuffer_v3000)(CUgraphicsResource *pCudaResource, GLuint buffer, unsigned int Flags);
|
| 92 |
+
typedef CUresult (CUDAAPI *PFN_cuGraphicsGLRegisterImage_v3000)(CUgraphicsResource *pCudaResource, GLuint image, GLenum target, unsigned int Flags);
|
| 93 |
+
#ifdef _WIN32
|
| 94 |
+
typedef CUresult (CUDAAPI *PFN_cuWGLGetDevice_v2020)(CUdevice_v1 *pDevice, HGPUNV hGpu);
|
| 95 |
+
#endif
|
| 96 |
+
typedef CUresult (CUDAAPI *PFN_cuGLGetDevices_v6050)(unsigned int *pCudaDeviceCount, CUdevice_v1 *pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
|
| 97 |
+
typedef CUresult (CUDAAPI *PFN_cuGLCtxCreate_v3020)(CUcontext *pCtx, unsigned int Flags, CUdevice_v1 device);
|
| 98 |
+
typedef CUresult (CUDAAPI *PFN_cuGLInit_v2000)(void);
|
| 99 |
+
typedef CUresult (CUDAAPI *PFN_cuGLRegisterBufferObject_v2000)(GLuint buffer);
|
| 100 |
+
typedef CUresult (CUDAAPI *PFN_cuGLMapBufferObject_v7000_ptds)(CUdeviceptr_v2 *dptr, size_t *size, GLuint buffer);
|
| 101 |
+
typedef CUresult (CUDAAPI *PFN_cuGLUnmapBufferObject_v2000)(GLuint buffer);
|
| 102 |
+
typedef CUresult (CUDAAPI *PFN_cuGLUnregisterBufferObject_v2000)(GLuint buffer);
|
| 103 |
+
typedef CUresult (CUDAAPI *PFN_cuGLSetBufferObjectMapFlags_v2030)(GLuint buffer, unsigned int Flags);
|
| 104 |
+
typedef CUresult (CUDAAPI *PFN_cuGLMapBufferObjectAsync_v7000_ptsz)(CUdeviceptr_v2 *dptr, size_t *size, GLuint buffer, CUstream hStream);
|
| 105 |
+
typedef CUresult (CUDAAPI *PFN_cuGLUnmapBufferObjectAsync_v2030)(GLuint buffer, CUstream hStream);
|
| 106 |
+
typedef CUresult (CUDAAPI *PFN_cuGLMapBufferObject_v3020)(CUdeviceptr_v2 *dptr, size_t *size, GLuint buffer);
|
| 107 |
+
typedef CUresult (CUDAAPI *PFN_cuGLMapBufferObjectAsync_v3020)(CUdeviceptr_v2 *dptr, size_t *size, GLuint buffer, CUstream hStream);
|
| 108 |
+
|
| 109 |
+
/*
|
| 110 |
+
* Type definitions for older versioned functions in cuda.h
|
| 111 |
+
*/
|
| 112 |
+
#if defined(__CUDA_API_VERSION_INTERNAL)
|
| 113 |
+
typedef CUresult (CUDAAPI *PFN_cuGLGetDevices_v4010)(unsigned int *pCudaDeviceCount, CUdevice_v1 *pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
|
| 114 |
+
typedef CUresult (CUDAAPI *PFN_cuGLMapBufferObject_v2000)(CUdeviceptr_v1 *dptr, unsigned int *size, GLuint buffer);
|
| 115 |
+
typedef CUresult (CUDAAPI *PFN_cuGLMapBufferObjectAsync_v2030)(CUdeviceptr_v1 *dptr, unsigned int *size, GLuint buffer, CUstream hStream);
|
| 116 |
+
typedef CUresult (CUDAAPI *PFN_cuGLCtxCreate_v2000)(CUcontext *pCtx, unsigned int Flags, CUdevice_v1 device);
|
| 117 |
+
#endif
|
| 118 |
+
|
| 119 |
+
#ifdef __cplusplus
|
| 120 |
+
}
|
| 121 |
+
#endif // __cplusplus
|
| 122 |
+
|
| 123 |
+
#endif // file guard
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaProfilerTypedefs.h
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2020-2021 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef CUDAPROFILERTYPEDEFS_H
|
| 51 |
+
#define CUDAPROFILERTYPEDEFS_H
|
| 52 |
+
|
| 53 |
+
#include <cudaProfiler.h>
|
| 54 |
+
|
| 55 |
+
#ifdef __cplusplus
|
| 56 |
+
extern "C" {
|
| 57 |
+
#endif // __cplusplus
|
| 58 |
+
|
| 59 |
+
/*
|
| 60 |
+
* Macros for the latest version for each driver function in cudaProfiler.h
|
| 61 |
+
*/
|
| 62 |
+
#define PFN_cuProfilerInitialize PFN_cuProfilerInitialize_v4000
|
| 63 |
+
#define PFN_cuProfilerStart PFN_cuProfilerStart_v4000
|
| 64 |
+
#define PFN_cuProfilerStop PFN_cuProfilerStop_v4000
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Type definitions for functions defined in cudaProfiler.h
|
| 69 |
+
*/
|
| 70 |
+
typedef CUresult (CUDAAPI *PFN_cuProfilerInitialize_v4000)(const char *configFile, const char *outputFile, CUoutput_mode outputMode);
|
| 71 |
+
typedef CUresult (CUDAAPI *PFN_cuProfilerStart_v4000)(void);
|
| 72 |
+
typedef CUresult (CUDAAPI *PFN_cuProfilerStop_v4000)(void);
|
| 73 |
+
|
| 74 |
+
#ifdef __cplusplus
|
| 75 |
+
}
|
| 76 |
+
#endif // __cplusplus
|
| 77 |
+
|
| 78 |
+
#endif // file guard
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaTypedefs.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaVDPAU.h
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2010-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef CUDAVDPAU_H
|
| 51 |
+
#define CUDAVDPAU_H
|
| 52 |
+
|
| 53 |
+
#ifdef CUDA_FORCE_API_VERSION
|
| 54 |
+
#error "CUDA_FORCE_API_VERSION is no longer supported."
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
#define cuVDPAUCtxCreate cuVDPAUCtxCreate_v2
|
| 58 |
+
|
| 59 |
+
#ifdef __cplusplus
|
| 60 |
+
extern "C" {
|
| 61 |
+
#endif
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* \defgroup CUDA_VDPAU VDPAU Interoperability
|
| 65 |
+
* \ingroup CUDA_DRIVER
|
| 66 |
+
*
|
| 67 |
+
* ___MANBRIEF___ VDPAU interoperability functions of the low-level CUDA driver
|
| 68 |
+
* API (___CURRENT_FILE___) ___ENDMANBRIEF___
|
| 69 |
+
*
|
| 70 |
+
* This section describes the VDPAU interoperability functions of the
|
| 71 |
+
* low-level CUDA driver application programming interface.
|
| 72 |
+
*
|
| 73 |
+
* @{
|
| 74 |
+
*/
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* \brief Gets the CUDA device associated with a VDPAU device
|
| 78 |
+
*
|
| 79 |
+
* Returns in \p *pDevice the CUDA device associated with a \p vdpDevice, if
|
| 80 |
+
* applicable.
|
| 81 |
+
*
|
| 82 |
+
* \param pDevice - Device associated with vdpDevice
|
| 83 |
+
* \param vdpDevice - A VdpDevice handle
|
| 84 |
+
* \param vdpGetProcAddress - VDPAU's VdpGetProcAddress function pointer
|
| 85 |
+
*
|
| 86 |
+
* \return
|
| 87 |
+
* ::CUDA_SUCCESS,
|
| 88 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 89 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 90 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 91 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 92 |
+
* \notefnerr
|
| 93 |
+
*
|
| 94 |
+
* \sa ::cuCtxCreate, ::cuVDPAUCtxCreate, ::cuGraphicsVDPAURegisterVideoSurface,
|
| 95 |
+
* ::cuGraphicsVDPAURegisterOutputSurface, ::cuGraphicsUnregisterResource,
|
| 96 |
+
* ::cuGraphicsResourceSetMapFlags, ::cuGraphicsMapResources,
|
| 97 |
+
* ::cuGraphicsUnmapResources, ::cuGraphicsSubResourceGetMappedArray,
|
| 98 |
+
* ::cudaVDPAUGetDevice
|
| 99 |
+
*/
|
| 100 |
+
CUresult CUDAAPI cuVDPAUGetDevice(CUdevice *pDevice, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* \brief Create a CUDA context for interoperability with VDPAU
|
| 104 |
+
*
|
| 105 |
+
* Creates a new CUDA context, initializes VDPAU interoperability, and
|
| 106 |
+
* associates the CUDA context with the calling thread. It must be called
|
| 107 |
+
* before performing any other VDPAU interoperability operations. It may fail
|
| 108 |
+
* if the needed VDPAU driver facilities are not available. For usage of the
|
| 109 |
+
* \p flags parameter, see ::cuCtxCreate().
|
| 110 |
+
*
|
| 111 |
+
* \param pCtx - Returned CUDA context
|
| 112 |
+
* \param flags - Options for CUDA context creation
|
| 113 |
+
* \param device - Device on which to create the context
|
| 114 |
+
* \param vdpDevice - The VdpDevice to interop with
|
| 115 |
+
* \param vdpGetProcAddress - VDPAU's VdpGetProcAddress function pointer
|
| 116 |
+
*
|
| 117 |
+
* \return
|
| 118 |
+
* ::CUDA_SUCCESS,
|
| 119 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 120 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 121 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 122 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 123 |
+
* ::CUDA_ERROR_OUT_OF_MEMORY
|
| 124 |
+
* \notefnerr
|
| 125 |
+
*
|
| 126 |
+
* \sa ::cuCtxCreate, ::cuGraphicsVDPAURegisterVideoSurface,
|
| 127 |
+
* ::cuGraphicsVDPAURegisterOutputSurface, ::cuGraphicsUnregisterResource,
|
| 128 |
+
* ::cuGraphicsResourceSetMapFlags, ::cuGraphicsMapResources,
|
| 129 |
+
* ::cuGraphicsUnmapResources, ::cuGraphicsSubResourceGetMappedArray,
|
| 130 |
+
* ::cuVDPAUGetDevice
|
| 131 |
+
*/
|
| 132 |
+
CUresult CUDAAPI cuVDPAUCtxCreate(CUcontext *pCtx, unsigned int flags, CUdevice device, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* \brief Registers a VDPAU VdpVideoSurface object
|
| 136 |
+
*
|
| 137 |
+
* Registers the VdpVideoSurface specified by \p vdpSurface for access by
|
| 138 |
+
* CUDA. A handle to the registered object is returned as \p pCudaResource.
|
| 139 |
+
* The surface's intended usage is specified using \p flags, as follows:
|
| 140 |
+
*
|
| 141 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE: Specifies no hints about how this
|
| 142 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 143 |
+
* read from and written to by CUDA. This is the default value.
|
| 144 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY: Specifies that CUDA
|
| 145 |
+
* will not write to this resource.
|
| 146 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD: Specifies that
|
| 147 |
+
* CUDA will not read from this resource and will write over the
|
| 148 |
+
* entire contents of the resource, so none of the data previously
|
| 149 |
+
* stored in the resource will be preserved.
|
| 150 |
+
*
|
| 151 |
+
* The VdpVideoSurface is presented as an array of subresources that may be
|
| 152 |
+
* accessed using pointers returned by ::cuGraphicsSubResourceGetMappedArray.
|
| 153 |
+
* The exact number of valid \p arrayIndex values depends on the VDPAU surface
|
| 154 |
+
* format. The mapping is shown in the table below. \p mipLevel must be 0.
|
| 155 |
+
*
|
| 156 |
+
* \htmlonly
|
| 157 |
+
* <table>
|
| 158 |
+
* <tr><th>VdpChromaType </th><th>arrayIndex</th><th>Size </th><th>Format</th><th>Content </th></tr>
|
| 159 |
+
* <tr><td rowspan="4" valign="top">VDP_CHROMA_TYPE_420</td><td>0 </td><td>w x h/2</td><td>R8 </td><td>Top-field luma </td></tr>
|
| 160 |
+
* <tr> <td>1 </td><td>w x h/2</td><td>R8 </td><td>Bottom-field luma </td></tr>
|
| 161 |
+
* <tr> <td>2 </td><td>w/2 x h/4</td><td>R8G8 </td><td>Top-field chroma </td></tr>
|
| 162 |
+
* <tr> <td>3 </td><td>w/2 x h/4</td><td>R8G8 </td><td>Bottom-field chroma</td></tr>
|
| 163 |
+
* <tr><td rowspan="4" valign="top">VDP_CHROMA_TYPE_422</td><td>0 </td><td>w x h/2</td><td>R8 </td><td>Top-field luma </td></tr>
|
| 164 |
+
* <tr> <td>1 </td><td>w x h/2</td><td>R8 </td><td>Bottom-field luma </td></tr>
|
| 165 |
+
* <tr> <td>2 </td><td>w/2 x h/2</td><td>R8G8 </td><td>Top-field chroma </td></tr>
|
| 166 |
+
* <tr> <td>3 </td><td>w/2 x h/2</td><td>R8G8 </td><td>Bottom-field chroma</td></tr>
|
| 167 |
+
* </table>
|
| 168 |
+
* \endhtmlonly
|
| 169 |
+
*
|
| 170 |
+
* \latexonly
|
| 171 |
+
* \begin{tabular}{|l|l|l|l|l|}
|
| 172 |
+
* \hline
|
| 173 |
+
* VdpChromaType & arrayIndex & Size & Format & Content \\
|
| 174 |
+
* \hline
|
| 175 |
+
* VDP\_CHROMA\_TYPE\_420 & 0 & w x h/2 & R8 & Top-field luma \\
|
| 176 |
+
* & 1 & w x h/2 & R8 & Bottom-field luma \\
|
| 177 |
+
* & 2 & w/2 x h/4 & R8G8 & Top-field chroma \\
|
| 178 |
+
* & 3 & w/2 x h/4 & R8G8 & Bottom-field chroma \\
|
| 179 |
+
* \hline
|
| 180 |
+
* VDP\_CHROMA\_TYPE\_422 & 0 & w x h/2 & R8 & Top-field luma \\
|
| 181 |
+
* & 1 & w x h/2 & R8 & Bottom-field luma \\
|
| 182 |
+
* & 2 & w/2 x h/2 & R8G8 & Top-field chroma \\
|
| 183 |
+
* & 3 & w/2 x h/2 & R8G8 & Bottom-field chroma \\
|
| 184 |
+
* \hline
|
| 185 |
+
* \end{tabular}
|
| 186 |
+
* \endlatexonly
|
| 187 |
+
*
|
| 188 |
+
* \param pCudaResource - Pointer to the returned object handle
|
| 189 |
+
* \param vdpSurface - The VdpVideoSurface to be registered
|
| 190 |
+
* \param flags - Map flags
|
| 191 |
+
*
|
| 192 |
+
* \return
|
| 193 |
+
* ::CUDA_SUCCESS,
|
| 194 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 195 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 196 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 197 |
+
* \notefnerr
|
| 198 |
+
*
|
| 199 |
+
* \sa ::cuCtxCreate, ::cuVDPAUCtxCreate,
|
| 200 |
+
* ::cuGraphicsVDPAURegisterOutputSurface, ::cuGraphicsUnregisterResource,
|
| 201 |
+
* ::cuGraphicsResourceSetMapFlags, ::cuGraphicsMapResources,
|
| 202 |
+
* ::cuGraphicsUnmapResources, ::cuGraphicsSubResourceGetMappedArray,
|
| 203 |
+
* ::cuVDPAUGetDevice,
|
| 204 |
+
* ::cudaGraphicsVDPAURegisterVideoSurface
|
| 205 |
+
*/
|
| 206 |
+
CUresult CUDAAPI cuGraphicsVDPAURegisterVideoSurface(CUgraphicsResource *pCudaResource, VdpVideoSurface vdpSurface, unsigned int flags);
|
| 207 |
+
|
| 208 |
+
/**
|
| 209 |
+
* \brief Registers a VDPAU VdpOutputSurface object
|
| 210 |
+
*
|
| 211 |
+
* Registers the VdpOutputSurface specified by \p vdpSurface for access by
|
| 212 |
+
* CUDA. A handle to the registered object is returned as \p pCudaResource.
|
| 213 |
+
* The surface's intended usage is specified using \p flags, as follows:
|
| 214 |
+
*
|
| 215 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE: Specifies no hints about how this
|
| 216 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 217 |
+
* read from and written to by CUDA. This is the default value.
|
| 218 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY: Specifies that CUDA
|
| 219 |
+
* will not write to this resource.
|
| 220 |
+
* - ::CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD: Specifies that
|
| 221 |
+
* CUDA will not read from this resource and will write over the
|
| 222 |
+
* entire contents of the resource, so none of the data previously
|
| 223 |
+
* stored in the resource will be preserved.
|
| 224 |
+
*
|
| 225 |
+
* The VdpOutputSurface is presented as an array of subresources that may be
|
| 226 |
+
* accessed using pointers returned by ::cuGraphicsSubResourceGetMappedArray.
|
| 227 |
+
* The exact number of valid \p arrayIndex values depends on the VDPAU surface
|
| 228 |
+
* format. The mapping is shown in the table below. \p mipLevel must be 0.
|
| 229 |
+
*
|
| 230 |
+
* \htmlonly
|
| 231 |
+
* <table>
|
| 232 |
+
* <tr><th>VdpRGBAFormat </th><th>arrayIndex</th><th>Size </th><th>Format </th><th>Content </th></tr>
|
| 233 |
+
* <tr><td>VDP_RGBA_FORMAT_B8G8R8A8 </td><td>0 </td><td>w x h</td><td>ARGB8 </td><td>Entire surface</td></tr>
|
| 234 |
+
* <tr><td>VDP_RGBA_FORMAT_R10G10B10A2</td><td>0 </td><td>w x h</td><td>A2BGR10</td><td>Entire surface</td></tr>
|
| 235 |
+
* </table>
|
| 236 |
+
* \endhtmlonly
|
| 237 |
+
*
|
| 238 |
+
* \latexonly
|
| 239 |
+
* \begin{tabular}{|l|l|l|l|l|}
|
| 240 |
+
* \hline
|
| 241 |
+
* VdpRGBAFormat & arrayIndex & Size & Format & Content \\
|
| 242 |
+
* \hline
|
| 243 |
+
* VDP\_RGBA\_FORMAT\_B8G8R8A8 & 0 & w x h & ARGB8 & Entire surface \\
|
| 244 |
+
* VDP\_RGBA\_FORMAT\_R10G10B10A2 & 0 & w x h & A2BGR10 & Entire surface \\
|
| 245 |
+
* \hline
|
| 246 |
+
* \end{tabular}
|
| 247 |
+
* \endlatexonly
|
| 248 |
+
*
|
| 249 |
+
* \param pCudaResource - Pointer to the returned object handle
|
| 250 |
+
* \param vdpSurface - The VdpOutputSurface to be registered
|
| 251 |
+
* \param flags - Map flags
|
| 252 |
+
*
|
| 253 |
+
* \return
|
| 254 |
+
* ::CUDA_SUCCESS,
|
| 255 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 256 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 257 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 258 |
+
* \notefnerr
|
| 259 |
+
*
|
| 260 |
+
* \sa ::cuCtxCreate, ::cuVDPAUCtxCreate,
|
| 261 |
+
* ::cuGraphicsVDPAURegisterVideoSurface, ::cuGraphicsUnregisterResource,
|
| 262 |
+
* ::cuGraphicsResourceSetMapFlags, ::cuGraphicsMapResources,
|
| 263 |
+
* ::cuGraphicsUnmapResources, ::cuGraphicsSubResourceGetMappedArray,
|
| 264 |
+
* ::cuVDPAUGetDevice,
|
| 265 |
+
* ::cudaGraphicsVDPAURegisterOutputSurface
|
| 266 |
+
*/
|
| 267 |
+
CUresult CUDAAPI cuGraphicsVDPAURegisterOutputSurface(CUgraphicsResource *pCudaResource, VdpOutputSurface vdpSurface, unsigned int flags);
|
| 268 |
+
|
| 269 |
+
/** @} */ /* END CUDA_VDPAU */
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
#if defined(__CUDA_API_VERSION_INTERNAL)
|
| 273 |
+
#undef cuVDPAUCtxCreate
|
| 274 |
+
|
| 275 |
+
CUresult CUDAAPI cuVDPAUCtxCreate(CUcontext *pCtx, unsigned int flags, CUdevice device, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
|
| 276 |
+
#endif /* __CUDA_API_VERSION_INTERNAL */
|
| 277 |
+
|
| 278 |
+
#ifdef __cplusplus
|
| 279 |
+
};
|
| 280 |
+
#endif
|
| 281 |
+
|
| 282 |
+
#endif
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaVDPAUTypedefs.h
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2020-2021 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef CUDAVDPAUTYPEDEFS_H
|
| 51 |
+
#define CUDAVDPAUTYPEDEFS_H
|
| 52 |
+
|
| 53 |
+
// Dependent includes for cudavdpau.h
|
| 54 |
+
#include <vdpau/vdpau.h>
|
| 55 |
+
|
| 56 |
+
#include <cudaVDPAU.h>
|
| 57 |
+
|
| 58 |
+
#ifdef __cplusplus
|
| 59 |
+
extern "C" {
|
| 60 |
+
#endif // __cplusplus
|
| 61 |
+
|
| 62 |
+
/*
|
| 63 |
+
* Macros for the latest version for each driver function in cudaVDPAU.h
|
| 64 |
+
*/
|
| 65 |
+
#define PFN_cuVDPAUGetDevice PFN_cuVDPAUGetDevice_v3010
|
| 66 |
+
#define PFN_cuVDPAUCtxCreate PFN_cuVDPAUCtxCreate_v3020
|
| 67 |
+
#define PFN_cuGraphicsVDPAURegisterVideoSurface PFN_cuGraphicsVDPAURegisterVideoSurface_v3010
|
| 68 |
+
#define PFN_cuGraphicsVDPAURegisterOutputSurface PFN_cuGraphicsVDPAURegisterOutputSurface_v3010
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Type definitions for functions defined in cudaVDPAU.h
|
| 73 |
+
*/
|
| 74 |
+
typedef CUresult (CUDAAPI *PFN_cuVDPAUGetDevice_v3010)(CUdevice_v1 *pDevice, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
|
| 75 |
+
typedef CUresult (CUDAAPI *PFN_cuVDPAUCtxCreate_v3020)(CUcontext *pCtx, unsigned int flags, CUdevice_v1 device, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
|
| 76 |
+
typedef CUresult (CUDAAPI *PFN_cuGraphicsVDPAURegisterVideoSurface_v3010)(CUgraphicsResource *pCudaResource, VdpVideoSurface vdpSurface, unsigned int flags);
|
| 77 |
+
typedef CUresult (CUDAAPI *PFN_cuGraphicsVDPAURegisterOutputSurface_v3010)(CUgraphicsResource *pCudaResource, VdpOutputSurface vdpSurface, unsigned int flags);
|
| 78 |
+
|
| 79 |
+
/*
|
| 80 |
+
* Type definitions for older versioned functions in cudaVDPAU.h
|
| 81 |
+
*/
|
| 82 |
+
#if defined(__CUDA_API_VERSION_INTERNAL)
|
| 83 |
+
typedef CUresult (CUDAAPI *PFN_cuVDPAUCtxCreate_v3010)(CUcontext *pCtx, unsigned int flags, CUdevice_v1 device, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
|
| 84 |
+
#endif
|
| 85 |
+
|
| 86 |
+
#ifdef __cplusplus
|
| 87 |
+
}
|
| 88 |
+
#endif // __cplusplus
|
| 89 |
+
|
| 90 |
+
#endif // file guard
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_awbarrier.h
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef _CUDA_AWBARRIER_H_
|
| 51 |
+
# define _CUDA_AWBARRIER_H_
|
| 52 |
+
|
| 53 |
+
# include "cuda_awbarrier_primitives.h"
|
| 54 |
+
|
| 55 |
+
# if !defined(_CUDA_AWBARRIER_SM_TARGET)
|
| 56 |
+
# error This file requires compute capability 7.0 or greater.
|
| 57 |
+
# endif
|
| 58 |
+
|
| 59 |
+
# if !defined(_CUDA_AWBARRIER_CPLUSPLUS_11_OR_LATER)
|
| 60 |
+
# error This file requires compiler support for the ISO C++ 2011 standard. This support must be enabled with the \
|
| 61 |
+
-std=c++11 compiler option.
|
| 62 |
+
# endif
|
| 63 |
+
|
| 64 |
+
_CUDA_AWBARRIER_BEGIN_NAMESPACE
|
| 65 |
+
|
| 66 |
+
class awbarrier {
|
| 67 |
+
public:
|
| 68 |
+
class arrival_token {
|
| 69 |
+
public:
|
| 70 |
+
arrival_token() = default;
|
| 71 |
+
~arrival_token() = default;
|
| 72 |
+
_CUDA_AWBARRIER_QUALIFIER uint32_t pending_count() const;
|
| 73 |
+
private:
|
| 74 |
+
_CUDA_AWBARRIER_QUALIFIER arrival_token(uint64_t token);
|
| 75 |
+
uint64_t token;
|
| 76 |
+
friend awbarrier;
|
| 77 |
+
};
|
| 78 |
+
awbarrier() = default;
|
| 79 |
+
awbarrier(const awbarrier&) = delete;
|
| 80 |
+
awbarrier& operator=(const awbarrier&) = delete;
|
| 81 |
+
~awbarrier() = default;
|
| 82 |
+
|
| 83 |
+
_CUDA_AWBARRIER_QUALIFIER arrival_token arrive();
|
| 84 |
+
_CUDA_AWBARRIER_QUALIFIER arrival_token arrive_and_drop();
|
| 85 |
+
_CUDA_AWBARRIER_QUALIFIER bool timed_wait(arrival_token token, uint32_t hint_cycles);
|
| 86 |
+
_CUDA_AWBARRIER_QUALIFIER bool timed_wait_parity(bool phase, uint32_t hint_cycles);
|
| 87 |
+
_CUDA_AWBARRIER_QUALIFIER void wait(arrival_token token);
|
| 88 |
+
_CUDA_AWBARRIER_QUALIFIER void arrive_and_wait();
|
| 89 |
+
_CUDA_AWBARRIER_QUALIFIER bool try_wait(arrival_token token, uint32_t maxSleepNanosec);
|
| 90 |
+
_CUDA_AWBARRIER_QUALIFIER bool try_wait_parity(bool phase, uint32_t maxSleepNanosec);
|
| 91 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER __host__ constexpr uint32_t max();
|
| 92 |
+
|
| 93 |
+
private:
|
| 94 |
+
uint64_t barrier;
|
| 95 |
+
friend _CUDA_AWBARRIER_QUALIFIER void init(awbarrier* barrier, uint32_t expected_count);
|
| 96 |
+
friend _CUDA_AWBARRIER_QUALIFIER void inval(awbarrier* barrier);
|
| 97 |
+
friend class pipeline;
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 101 |
+
uint32_t awbarrier::arrival_token::pending_count() const
|
| 102 |
+
{
|
| 103 |
+
const uint32_t pending_count = _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_token_pending_count(this->token);
|
| 104 |
+
#if (__CUDA_ARCH__ >= 900)
|
| 105 |
+
return pending_count;
|
| 106 |
+
#else
|
| 107 |
+
return (pending_count >> 15);
|
| 108 |
+
#endif
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 112 |
+
awbarrier::arrival_token::arrival_token(uint64_t token)
|
| 113 |
+
: token(token)
|
| 114 |
+
{
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 118 |
+
void init(awbarrier* barrier, uint32_t expected_count)
|
| 119 |
+
{
|
| 120 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 121 |
+
_CUDA_AWBARRIER_ASSERT(expected_count > 0 && expected_count <= _CUDA_AWBARRIER_MAX_COUNT);
|
| 122 |
+
|
| 123 |
+
#if (__CUDA_ARCH__ >= 900)
|
| 124 |
+
const uint32_t init_count = expected_count;
|
| 125 |
+
#else
|
| 126 |
+
const uint32_t init_count = (expected_count << 15) + expected_count;
|
| 127 |
+
#endif
|
| 128 |
+
|
| 129 |
+
_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_init(&barrier->barrier, init_count);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 133 |
+
void inval(awbarrier* barrier)
|
| 134 |
+
{
|
| 135 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 136 |
+
|
| 137 |
+
_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_inval(&barrier->barrier);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 141 |
+
awbarrier::arrival_token awbarrier::arrive()
|
| 142 |
+
{
|
| 143 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
|
| 144 |
+
|
| 145 |
+
#if (__CUDA_ARCH__ < 900)
|
| 146 |
+
const uint32_t arrive_count = 1 << 15;
|
| 147 |
+
const uint64_t token = _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop_no_complete<false>(&this->barrier, arrive_count);
|
| 148 |
+
(void)
|
| 149 |
+
#else
|
| 150 |
+
const uint64_t token =
|
| 151 |
+
#endif
|
| 152 |
+
_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop<false>(&this->barrier);
|
| 153 |
+
|
| 154 |
+
return arrival_token(token);
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 158 |
+
awbarrier::arrival_token awbarrier::arrive_and_drop()
|
| 159 |
+
{
|
| 160 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
|
| 161 |
+
|
| 162 |
+
#if (__CUDA_ARCH__ < 900)
|
| 163 |
+
const uint32_t arrive_count = 1 << 15;
|
| 164 |
+
const uint64_t token = _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop_no_complete<true>(&this->barrier, arrive_count);
|
| 165 |
+
(void)
|
| 166 |
+
#else
|
| 167 |
+
const uint64_t token =
|
| 168 |
+
#endif
|
| 169 |
+
_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop<true>(&this->barrier);
|
| 170 |
+
|
| 171 |
+
return arrival_token(token);
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 175 |
+
bool awbarrier::timed_wait(arrival_token token, uint32_t hint_cycles)
|
| 176 |
+
{
|
| 177 |
+
constexpr uint64_t max_busy_wait_cycles = 1024;
|
| 178 |
+
constexpr uint32_t max_sleep_ns = 1 << 20;
|
| 179 |
+
|
| 180 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
|
| 181 |
+
|
| 182 |
+
if (_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait(&this->barrier, token.token)) {
|
| 183 |
+
return true;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
uint64_t start_cycles = clock64();
|
| 187 |
+
uint64_t elapsed_cycles = 0;
|
| 188 |
+
uint32_t sleep_ns = 32;
|
| 189 |
+
while (elapsed_cycles < hint_cycles) {
|
| 190 |
+
if (_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait(&this->barrier, token.token)) {
|
| 191 |
+
return true;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
if (elapsed_cycles > max_busy_wait_cycles) {
|
| 195 |
+
__nanosleep(sleep_ns);
|
| 196 |
+
if (sleep_ns < max_sleep_ns) {
|
| 197 |
+
sleep_ns *= 2;
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
elapsed_cycles = clock64() - start_cycles;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
return false;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 208 |
+
bool awbarrier::timed_wait_parity(bool phase, uint32_t hint_cycles)
|
| 209 |
+
{
|
| 210 |
+
constexpr uint64_t max_busy_wait_cycles = 1024;
|
| 211 |
+
constexpr uint32_t max_sleep_ns = 1 << 20;
|
| 212 |
+
|
| 213 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
|
| 214 |
+
|
| 215 |
+
if (_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait_parity(&this->barrier, phase)) {
|
| 216 |
+
return true;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
uint64_t start_cycles = clock64();
|
| 220 |
+
uint64_t elapsed_cycles = 0;
|
| 221 |
+
uint32_t sleep_ns = 32;
|
| 222 |
+
while (elapsed_cycles < hint_cycles) {
|
| 223 |
+
if (_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait_parity(&this->barrier, phase)) {
|
| 224 |
+
return true;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
if (elapsed_cycles > max_busy_wait_cycles) {
|
| 228 |
+
__nanosleep(sleep_ns);
|
| 229 |
+
if (sleep_ns < max_sleep_ns) {
|
| 230 |
+
sleep_ns *= 2;
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
elapsed_cycles = clock64() - start_cycles;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
return false;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 241 |
+
bool awbarrier::try_wait(arrival_token token, uint32_t maxSleepNanosec)
|
| 242 |
+
{
|
| 243 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
|
| 244 |
+
|
| 245 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_try_wait(&this->barrier, token.token, maxSleepNanosec);
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 249 |
+
bool awbarrier::try_wait_parity(bool phase, uint32_t maxSleepNanosec)
|
| 250 |
+
{
|
| 251 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
|
| 252 |
+
|
| 253 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_try_wait_parity(&this->barrier, phase, maxSleepNanosec);
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 257 |
+
void awbarrier::wait(arrival_token token)
|
| 258 |
+
{
|
| 259 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
|
| 260 |
+
|
| 261 |
+
while (!timed_wait(token, ~0u));
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
_CUDA_AWBARRIER_QUALIFIER
|
| 265 |
+
void awbarrier::arrive_and_wait()
|
| 266 |
+
{
|
| 267 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(&this->barrier));
|
| 268 |
+
|
| 269 |
+
this->wait(this->arrive());
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
_CUDA_AWBARRIER_QUALIFIER __host__
|
| 273 |
+
constexpr uint32_t awbarrier::max()
|
| 274 |
+
{
|
| 275 |
+
return _CUDA_AWBARRIER_MAX_COUNT;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
_CUDA_AWBARRIER_END_NAMESPACE
|
| 279 |
+
|
| 280 |
+
#endif /* !_CUDA_AWBARRIER_H_ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_awbarrier_helpers.h
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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O LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef _CUDA_AWBARRIER_HELPERS_H_
|
| 51 |
+
#define _CUDA_AWBARRIER_HELPERS_H_
|
| 52 |
+
|
| 53 |
+
#define _CUDA_AWBARRIER_NAMESPACE nvcuda::experimental
|
| 54 |
+
#define _CUDA_AWBARRIER_BEGIN_NAMESPACE namespace nvcuda { namespace experimental {
|
| 55 |
+
#define _CUDA_AWBARRIER_END_NAMESPACE } }
|
| 56 |
+
|
| 57 |
+
#define _CUDA_AWBARRIER_INTERNAL_NAMESPACE _CUDA_AWBARRIER_NAMESPACE::__awbarrier_internal
|
| 58 |
+
#define _CUDA_AWBARRIER_BEGIN_INTERNAL_NAMESPACE _CUDA_AWBARRIER_BEGIN_NAMESPACE namespace __awbarrier_internal {
|
| 59 |
+
#define _CUDA_AWBARRIER_END_INTERNAL_NAMESPACE } _CUDA_AWBARRIER_END_NAMESPACE
|
| 60 |
+
|
| 61 |
+
# if !defined(_CUDA_AWBARRIER_QUALIFIER)
|
| 62 |
+
# define _CUDA_AWBARRIER_QUALIFIER inline __device__
|
| 63 |
+
# endif
|
| 64 |
+
# if !defined(_CUDA_AWBARRIER_STATIC_QUALIFIER)
|
| 65 |
+
# define _CUDA_AWBARRIER_STATIC_QUALIFIER static inline __device__
|
| 66 |
+
#endif
|
| 67 |
+
|
| 68 |
+
#if defined(__CUDA_ARCH__)
|
| 69 |
+
#if (__CUDA_ARCH__ >= 900)
|
| 70 |
+
# define _CUDA_AWBARRIER_SM_TARGET _CUDA_AWBARRIER_SM_90
|
| 71 |
+
#elif (__CUDA_ARCH__ >= 800)
|
| 72 |
+
# define _CUDA_AWBARRIER_SM_TARGET _CUDA_AWBARRIER_SM_80
|
| 73 |
+
#elif (__CUDA_ARCH__ >= 700)
|
| 74 |
+
# define _CUDA_AWBARRIER_SM_TARGET _CUDA_AWBARRIER_SM_70
|
| 75 |
+
#endif
|
| 76 |
+
#else
|
| 77 |
+
# define _CUDA_AWBARRIER_SM_TARGET _CUDA_AWBARRIER_SM_70
|
| 78 |
+
#endif
|
| 79 |
+
|
| 80 |
+
#define _CUDA_AWBARRIER_MAX_COUNT ((1 << 14) - 1)
|
| 81 |
+
|
| 82 |
+
#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1900)))
|
| 83 |
+
# define _CUDA_AWBARRIER_CPLUSPLUS_11_OR_LATER
|
| 84 |
+
#endif
|
| 85 |
+
|
| 86 |
+
#if !defined(_CUDA_AWBARRIER_DEBUG)
|
| 87 |
+
# if defined(__CUDACC_DEBUG__)
|
| 88 |
+
# define _CUDA_AWBARRIER_DEBUG 1
|
| 89 |
+
# else
|
| 90 |
+
# define _CUDA_AWBARRIER_DEBUG 0
|
| 91 |
+
# endif
|
| 92 |
+
#endif
|
| 93 |
+
|
| 94 |
+
#if defined(_CUDA_AWBARRIER_DEBUG) && (_CUDA_AWBARRIER_DEBUG == 1) && !defined(NDEBUG)
|
| 95 |
+
# if !defined(__CUDACC_RTC__)
|
| 96 |
+
# include <cassert>
|
| 97 |
+
# endif
|
| 98 |
+
# define _CUDA_AWBARRIER_ASSERT(x) assert((x));
|
| 99 |
+
# define _CUDA_AWBARRIER_ABORT() assert(0);
|
| 100 |
+
#else
|
| 101 |
+
# define _CUDA_AWBARRIER_ASSERT(x)
|
| 102 |
+
# define _CUDA_AWBARRIER_ABORT() __trap();
|
| 103 |
+
#endif
|
| 104 |
+
|
| 105 |
+
#if defined(__CUDACC_RTC__)
|
| 106 |
+
typedef unsigned short uint16_t;
|
| 107 |
+
typedef unsigned int uint32_t;
|
| 108 |
+
typedef unsigned long long uint64_t;
|
| 109 |
+
typedef uint64_t uintptr_t;
|
| 110 |
+
#else
|
| 111 |
+
# include <stdint.h>
|
| 112 |
+
#endif
|
| 113 |
+
|
| 114 |
+
// implicitly provided by NVRTC
|
| 115 |
+
#ifndef __CUDACC_RTC__
|
| 116 |
+
#include <nv/target>
|
| 117 |
+
#endif /* !defined(__CUDACC_RTC__) */
|
| 118 |
+
|
| 119 |
+
typedef uint64_t __mbarrier_t;
|
| 120 |
+
typedef uint64_t __mbarrier_token_t;
|
| 121 |
+
|
| 122 |
+
_CUDA_AWBARRIER_BEGIN_INTERNAL_NAMESPACE
|
| 123 |
+
|
| 124 |
+
extern "C" __device__ uint32_t __nvvm_get_smem_pointer(void *);
|
| 125 |
+
|
| 126 |
+
union AWBarrier {
|
| 127 |
+
struct {
|
| 128 |
+
uint32_t expected;
|
| 129 |
+
uint32_t pending;
|
| 130 |
+
} split;
|
| 131 |
+
uint64_t raw;
|
| 132 |
+
};
|
| 133 |
+
|
| 134 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 135 |
+
void awbarrier_init(uint64_t* barrier, uint32_t expected_count) {
|
| 136 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 137 |
+
_CUDA_AWBARRIER_ASSERT(expected_count > 0 && expected_count < (1 << 29));
|
| 138 |
+
|
| 139 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80,
|
| 140 |
+
asm volatile ("mbarrier.init.shared.b64 [%0], %1;"
|
| 141 |
+
:
|
| 142 |
+
: "r"(__nvvm_get_smem_pointer(barrier)), "r"(expected_count)
|
| 143 |
+
: "memory");
|
| 144 |
+
return;
|
| 145 |
+
)
|
| 146 |
+
NV_IF_TARGET(NV_PROVIDES_SM_70,
|
| 147 |
+
AWBarrier* awbarrier = reinterpret_cast<AWBarrier*>(barrier);
|
| 148 |
+
|
| 149 |
+
awbarrier->split.expected = 0x40000000 - expected_count;
|
| 150 |
+
awbarrier->split.pending = 0x80000000 - expected_count;
|
| 151 |
+
return;
|
| 152 |
+
)
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 156 |
+
void awbarrier_inval(uint64_t* barrier) {
|
| 157 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 158 |
+
|
| 159 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80,
|
| 160 |
+
asm volatile ("mbarrier.inval.shared.b64 [%0];"
|
| 161 |
+
:
|
| 162 |
+
: "r"(__nvvm_get_smem_pointer(barrier))
|
| 163 |
+
: "memory");
|
| 164 |
+
return;
|
| 165 |
+
)
|
| 166 |
+
return;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 170 |
+
uint32_t awbarrier_token_pending_count(uint64_t token) {
|
| 171 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80,
|
| 172 |
+
uint32_t __pending_count;
|
| 173 |
+
|
| 174 |
+
asm ("mbarrier.pending_count.b64 %0, %1;"
|
| 175 |
+
: "=r"(__pending_count)
|
| 176 |
+
: "l"(token));
|
| 177 |
+
return __pending_count;
|
| 178 |
+
)
|
| 179 |
+
NV_IF_TARGET(NV_PROVIDES_SM_70,
|
| 180 |
+
const uint32_t pending = token >> 32;
|
| 181 |
+
return 0x80000000 - (pending & 0x7fffffff);
|
| 182 |
+
)
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
template<bool _Drop>
|
| 186 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 187 |
+
uint64_t awbarrier_arrive_drop(uint64_t* barrier) {
|
| 188 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 189 |
+
|
| 190 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80,
|
| 191 |
+
uint64_t token;
|
| 192 |
+
|
| 193 |
+
if (_Drop) {
|
| 194 |
+
asm volatile ("mbarrier.arrive_drop.shared.b64 %0, [%1];"
|
| 195 |
+
: "=l"(token)
|
| 196 |
+
: "r"(__nvvm_get_smem_pointer(barrier))
|
| 197 |
+
: "memory");
|
| 198 |
+
} else {
|
| 199 |
+
asm volatile ("mbarrier.arrive.shared.b64 %0, [%1];"
|
| 200 |
+
: "=l"(token)
|
| 201 |
+
: "r"(__nvvm_get_smem_pointer(barrier))
|
| 202 |
+
: "memory");
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
return token;
|
| 206 |
+
)
|
| 207 |
+
NV_IF_TARGET(NV_PROVIDES_SM_70,
|
| 208 |
+
AWBarrier* awbarrier = reinterpret_cast<AWBarrier*>(barrier);
|
| 209 |
+
|
| 210 |
+
while ((*reinterpret_cast<volatile uint32_t*>(&awbarrier->split.pending) & 0x7fffffff) == 0);
|
| 211 |
+
|
| 212 |
+
if (_Drop) {
|
| 213 |
+
(void)atomicAdd_block(&awbarrier->split.expected, 1);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
__threadfence_block();
|
| 217 |
+
|
| 218 |
+
const uint32_t old_pending = atomicAdd_block(&awbarrier->split.pending, 1);
|
| 219 |
+
const uint32_t new_pending = old_pending + 1;
|
| 220 |
+
const bool reset = (old_pending ^ new_pending) & 0x80000000;
|
| 221 |
+
|
| 222 |
+
if (reset) {
|
| 223 |
+
__threadfence_block();
|
| 224 |
+
|
| 225 |
+
uint32_t new_expected = *reinterpret_cast<volatile uint32_t*>(&awbarrier->split.expected);
|
| 226 |
+
new_expected &= ~0x40000000;
|
| 227 |
+
if (new_expected & 0x20000000) {
|
| 228 |
+
new_expected |= 0x40000000;
|
| 229 |
+
}
|
| 230 |
+
atomicAdd_block(&awbarrier->split.pending, new_expected);
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
return static_cast<uint64_t>(old_pending) << 32;
|
| 234 |
+
)
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
template<bool _Drop>
|
| 238 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 239 |
+
uint64_t awbarrier_arrive_drop_no_complete(uint64_t* barrier, uint32_t count) {
|
| 240 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 241 |
+
_CUDA_AWBARRIER_ASSERT(count > 0 && count < (1 << 29));
|
| 242 |
+
|
| 243 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80,
|
| 244 |
+
uint64_t token;
|
| 245 |
+
|
| 246 |
+
if (_Drop) {
|
| 247 |
+
asm volatile ("mbarrier.arrive_drop.noComplete.shared.b64 %0, [%1], %2;"
|
| 248 |
+
: "=l"(token)
|
| 249 |
+
: "r"(__nvvm_get_smem_pointer(barrier)), "r"(count)
|
| 250 |
+
: "memory");
|
| 251 |
+
} else {
|
| 252 |
+
asm volatile ("mbarrier.arrive.noComplete.shared.b64 %0, [%1], %2;"
|
| 253 |
+
: "=l"(token)
|
| 254 |
+
: "r"(__nvvm_get_smem_pointer(barrier)), "r"(count)
|
| 255 |
+
: "memory");
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
return token;
|
| 259 |
+
)
|
| 260 |
+
NV_IF_TARGET(NV_PROVIDES_SM_70,
|
| 261 |
+
AWBarrier* awbarrier = reinterpret_cast<AWBarrier*>(barrier);
|
| 262 |
+
|
| 263 |
+
while ((*reinterpret_cast<volatile uint32_t*>(&awbarrier->split.pending) & 0x7fffffff) == 0);
|
| 264 |
+
|
| 265 |
+
if (_Drop) {
|
| 266 |
+
(void)atomicAdd_block(&awbarrier->split.expected, count);
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
return static_cast<uint64_t>(atomicAdd_block(&awbarrier->split.pending, count)) << 32;
|
| 270 |
+
)
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 274 |
+
bool awbarrier_test_wait(uint64_t* barrier, uint64_t token) {
|
| 275 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 276 |
+
|
| 277 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80,
|
| 278 |
+
uint32_t __wait_complete;
|
| 279 |
+
|
| 280 |
+
asm volatile ("{"
|
| 281 |
+
" .reg .pred %%p;"
|
| 282 |
+
" mbarrier.test_wait.shared.b64 %%p, [%1], %2;"
|
| 283 |
+
" selp.b32 %0, 1, 0, %%p;"
|
| 284 |
+
"}"
|
| 285 |
+
: "=r"(__wait_complete)
|
| 286 |
+
: "r"(__nvvm_get_smem_pointer(barrier)), "l"(token)
|
| 287 |
+
: "memory");
|
| 288 |
+
return bool(__wait_complete);
|
| 289 |
+
)
|
| 290 |
+
NV_IF_TARGET(NV_PROVIDES_SM_70,
|
| 291 |
+
volatile AWBarrier* awbarrier = reinterpret_cast<volatile AWBarrier*>(barrier);
|
| 292 |
+
|
| 293 |
+
return ((token >> 32) ^ awbarrier->split.pending) & 0x80000000;
|
| 294 |
+
)
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 298 |
+
bool awbarrier_test_wait_parity(uint64_t* barrier, bool phase_parity) {
|
| 299 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 300 |
+
|
| 301 |
+
NV_IF_TARGET(NV_PROVIDES_SM_90,
|
| 302 |
+
uint32_t __wait_complete = 0;
|
| 303 |
+
|
| 304 |
+
asm volatile ("{"
|
| 305 |
+
".reg .pred %%p;"
|
| 306 |
+
"mbarrier.test_wait.parity.shared.b64 %%p, [%1], %2;"
|
| 307 |
+
"selp.b32 %0, 1, 0, %%p;"
|
| 308 |
+
"}"
|
| 309 |
+
: "=r"(__wait_complete)
|
| 310 |
+
: "r"(__nvvm_get_smem_pointer(barrier)), "r"(static_cast<uint32_t>(phase_parity))
|
| 311 |
+
: "memory");
|
| 312 |
+
|
| 313 |
+
return __wait_complete;
|
| 314 |
+
)
|
| 315 |
+
_CUDA_AWBARRIER_ABORT()
|
| 316 |
+
return false;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 320 |
+
bool awbarrier_try_wait(uint64_t* barrier, uint64_t token, uint32_t max_sleep_nanosec) {
|
| 321 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 322 |
+
|
| 323 |
+
NV_IF_TARGET(NV_PROVIDES_SM_90,
|
| 324 |
+
uint32_t __wait_complete = 0;
|
| 325 |
+
|
| 326 |
+
asm volatile ("{\n\t"
|
| 327 |
+
".reg .pred p;\n\t"
|
| 328 |
+
"mbarrier.try_wait.shared.b64 p, [%1], %2, %3;\n\t"
|
| 329 |
+
"selp.b32 %0, 1, 0, p;\n\t"
|
| 330 |
+
"}"
|
| 331 |
+
: "=r"(__wait_complete)
|
| 332 |
+
: "r"(__nvvm_get_smem_pointer(barrier)), "l"(token), "r"(max_sleep_nanosec)
|
| 333 |
+
: "memory");
|
| 334 |
+
|
| 335 |
+
return __wait_complete;
|
| 336 |
+
)
|
| 337 |
+
_CUDA_AWBARRIER_ABORT()
|
| 338 |
+
return false;
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 342 |
+
bool awbarrier_try_wait_parity(uint64_t* barrier, bool phase_parity, uint32_t max_sleep_nanosec) {
|
| 343 |
+
_CUDA_AWBARRIER_ASSERT(__isShared(barrier));
|
| 344 |
+
|
| 345 |
+
NV_IF_TARGET(NV_PROVIDES_SM_90,
|
| 346 |
+
uint32_t __wait_complete = 0;
|
| 347 |
+
|
| 348 |
+
asm volatile ("{\n\t"
|
| 349 |
+
".reg .pred p;\n\t"
|
| 350 |
+
"mbarrier.try_wait.parity.shared.b64 p, [%1], %2, %3;\n\t"
|
| 351 |
+
"selp.b32 %0, 1, 0, p;\n\t"
|
| 352 |
+
"}"
|
| 353 |
+
: "=r"(__wait_complete)
|
| 354 |
+
: "r"(__nvvm_get_smem_pointer(barrier)), "r"(static_cast<uint32_t>(phase_parity)), "r"(max_sleep_nanosec)
|
| 355 |
+
: "memory");
|
| 356 |
+
|
| 357 |
+
return __wait_complete;
|
| 358 |
+
)
|
| 359 |
+
_CUDA_AWBARRIER_ABORT()
|
| 360 |
+
return false;
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
_CUDA_AWBARRIER_END_INTERNAL_NAMESPACE
|
| 364 |
+
|
| 365 |
+
#endif /* !_CUDA_AWBARRIER_HELPERS_H_ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_awbarrier_primitives.h
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef _CUDA_AWBARRIER_PRIMITIVES_H_
|
| 51 |
+
#define _CUDA_AWBARRIER_PRIMITIVES_H_
|
| 52 |
+
|
| 53 |
+
#include "cuda_awbarrier_helpers.h"
|
| 54 |
+
|
| 55 |
+
#if !defined(_CUDA_AWBARRIER_SM_TARGET)
|
| 56 |
+
# error This file requires compute capability 7.0 or greater.
|
| 57 |
+
#endif
|
| 58 |
+
|
| 59 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER __host__
|
| 60 |
+
uint32_t __mbarrier_maximum_count() {
|
| 61 |
+
return _CUDA_AWBARRIER_MAX_COUNT;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 65 |
+
void __mbarrier_init(__mbarrier_t* barrier, uint32_t expected_count) {
|
| 66 |
+
_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_init(barrier, expected_count);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 70 |
+
void __mbarrier_inval(__mbarrier_t* barrier) {
|
| 71 |
+
_CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_inval(barrier);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 75 |
+
__mbarrier_token_t __mbarrier_arrive(__mbarrier_t* barrier) {
|
| 76 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop<false>(barrier);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 80 |
+
__mbarrier_token_t __mbarrier_arrive_and_drop(__mbarrier_t* barrier) {
|
| 81 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_arrive_drop<true>(barrier);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 85 |
+
bool __mbarrier_test_wait(__mbarrier_t* barrier, __mbarrier_token_t token) {
|
| 86 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait(barrier, token);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 90 |
+
uint32_t __mbarrier_token_pending_count(__mbarrier_token_t token) {
|
| 91 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_token_pending_count(token);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 95 |
+
bool __mbarrier_test_wait_parity(__mbarrier_t* barrier, bool phase_parity) {
|
| 96 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_test_wait_parity(barrier, phase_parity);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 100 |
+
bool __mbarrier_try_wait(__mbarrier_t* barrier, __mbarrier_token_t token, uint32_t max_sleep_nanosec) {
|
| 101 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_try_wait(barrier, token, max_sleep_nanosec);
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
_CUDA_AWBARRIER_STATIC_QUALIFIER
|
| 105 |
+
bool __mbarrier_try_wait_parity(__mbarrier_t* barrier, bool phase_parity, uint32_t max_sleep_nanosec) {
|
| 106 |
+
return _CUDA_AWBARRIER_INTERNAL_NAMESPACE::awbarrier_try_wait_parity(barrier, phase_parity, max_sleep_nanosec);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
#endif /* !_CUDA_AWBARRIER_PRIMITIVES_H_ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_bf16.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_bf16.hpp
ADDED
|
The diff for this file is too large to render.
See raw diff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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2021 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_DEVICE_RUNTIME_API_H__)
|
| 51 |
+
#define __CUDA_DEVICE_RUNTIME_API_H__
|
| 52 |
+
|
| 53 |
+
#if defined(__CUDACC__) && !defined(__CUDACC_RTC__)
|
| 54 |
+
#include <stdlib.h>
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
/*******************************************************************************
|
| 58 |
+
* *
|
| 59 |
+
* *
|
| 60 |
+
* *
|
| 61 |
+
*******************************************************************************/
|
| 62 |
+
|
| 63 |
+
#if !defined(CUDA_FORCE_CDP1_IF_SUPPORTED) && !defined(__CUDADEVRT_INTERNAL__) && !defined(_NVHPC_CUDA) && !(defined(_WIN32) && !defined(_WIN64))
|
| 64 |
+
#define __CUDA_INTERNAL_USE_CDP2
|
| 65 |
+
#endif
|
| 66 |
+
|
| 67 |
+
#if !defined(__CUDACC_RTC__)
|
| 68 |
+
|
| 69 |
+
#if !defined(__CUDACC_INTERNAL_NO_STUBS__) && !defined(__CUDACC_RDC__) && !defined(__CUDACC_EWP__) && defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 350) && !defined(__CUDADEVRT_INTERNAL__)
|
| 70 |
+
|
| 71 |
+
#if defined(__cplusplus)
|
| 72 |
+
extern "C" {
|
| 73 |
+
#endif
|
| 74 |
+
|
| 75 |
+
struct cudaFuncAttributes;
|
| 76 |
+
|
| 77 |
+
// Bug 4398304
|
| 78 |
+
// WAR for doxgyen processing duplicate entries causing warnings to be listed in the documentation
|
| 79 |
+
/** \cond impl_private */
|
| 80 |
+
|
| 81 |
+
#ifndef __CUDA_INTERNAL_USE_CDP2
|
| 82 |
+
inline __device__ cudaError_t CUDARTAPI cudaMalloc(void **p, size_t s)
|
| 83 |
+
{
|
| 84 |
+
return cudaErrorUnknown;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
inline __device__ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *p, const void *c)
|
| 88 |
+
{
|
| 89 |
+
return cudaErrorUnknown;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
inline __device__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device)
|
| 93 |
+
{
|
| 94 |
+
return cudaErrorUnknown;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
inline __device__ cudaError_t CUDARTAPI cudaGetDevice(int *device)
|
| 98 |
+
{
|
| 99 |
+
return cudaErrorUnknown;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
inline __device__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize)
|
| 103 |
+
{
|
| 104 |
+
return cudaErrorUnknown;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
inline __device__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags)
|
| 108 |
+
{
|
| 109 |
+
return cudaErrorUnknown;
|
| 110 |
+
}
|
| 111 |
+
#else // __CUDA_INTERNAL_USE_CDP2
|
| 112 |
+
inline __device__ cudaError_t CUDARTAPI __cudaCDP2Malloc(void **p, size_t s)
|
| 113 |
+
{
|
| 114 |
+
return cudaErrorUnknown;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
inline __device__ cudaError_t CUDARTAPI __cudaCDP2FuncGetAttributes(struct cudaFuncAttributes *p, const void *c)
|
| 118 |
+
{
|
| 119 |
+
return cudaErrorUnknown;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
inline __device__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device)
|
| 123 |
+
{
|
| 124 |
+
return cudaErrorUnknown;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
inline __device__ cudaError_t CUDARTAPI __cudaCDP2GetDevice(int *device)
|
| 128 |
+
{
|
| 129 |
+
return cudaErrorUnknown;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
inline __device__ cudaError_t CUDARTAPI __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize)
|
| 133 |
+
{
|
| 134 |
+
return cudaErrorUnknown;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
inline __device__ cudaError_t CUDARTAPI __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags)
|
| 138 |
+
{
|
| 139 |
+
return cudaErrorUnknown;
|
| 140 |
+
}
|
| 141 |
+
#endif // __CUDA_INTERNAL_USE_CDP2
|
| 142 |
+
|
| 143 |
+
/** \endcond */
|
| 144 |
+
|
| 145 |
+
#if defined(__cplusplus)
|
| 146 |
+
}
|
| 147 |
+
#endif
|
| 148 |
+
|
| 149 |
+
#endif /* !defined(__CUDACC_INTERNAL_NO_STUBS__) && !defined(__CUDACC_RDC__) && !defined(__CUDACC_EWP__) && defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 350) && !defined(__CUDADEVRT_INTERNAL__) */
|
| 150 |
+
|
| 151 |
+
#endif /* !defined(__CUDACC_RTC__) */
|
| 152 |
+
|
| 153 |
+
#if defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
|
| 154 |
+
# define __DEPRECATED__(msg)
|
| 155 |
+
#elif defined(_WIN32)
|
| 156 |
+
# define __DEPRECATED__(msg) __declspec(deprecated(msg))
|
| 157 |
+
#elif (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5 && !defined(__clang__))))
|
| 158 |
+
# define __DEPRECATED__(msg) __attribute__((deprecated))
|
| 159 |
+
#else
|
| 160 |
+
# define __DEPRECATED__(msg) __attribute__((deprecated(msg)))
|
| 161 |
+
#endif
|
| 162 |
+
|
| 163 |
+
#if defined(__CUDA_ARCH__) && !defined(__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING)
|
| 164 |
+
# define __CDPRT_DEPRECATED(func_name) __DEPRECATED__("Use of "#func_name" from device code is deprecated. Moreover, such use will cause this module to fail to load on sm_90+ devices. If calls to "#func_name" from device code cannot be removed for older devices at this time, you may guard them with __CUDA_ARCH__ macros to remove them only for sm_90+ devices, making sure to generate code for compute_90 for the macros to take effect. Note that this mitigation will no longer work when support for "#func_name" from device code is eventually dropped for all devices. Disable this warning with -D__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING.")
|
| 165 |
+
#else
|
| 166 |
+
# define __CDPRT_DEPRECATED(func_name)
|
| 167 |
+
#endif
|
| 168 |
+
|
| 169 |
+
#if defined(__cplusplus) && defined(__CUDACC__) /* Visible to nvcc front-end only */
|
| 170 |
+
#if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350) // Visible to SM>=3.5 and "__host__ __device__" only
|
| 171 |
+
|
| 172 |
+
#include "driver_types.h"
|
| 173 |
+
#include "crt/host_defines.h"
|
| 174 |
+
|
| 175 |
+
#define cudaStreamGraphTailLaunch (cudaStream_t)0x0100000000000000
|
| 176 |
+
#define cudaStreamGraphFireAndForget (cudaStream_t)0x0200000000000000
|
| 177 |
+
#define cudaStreamGraphFireAndForgetAsSibling (cudaStream_t)0x0300000000000000
|
| 178 |
+
|
| 179 |
+
#ifdef __CUDA_INTERNAL_USE_CDP2
|
| 180 |
+
#define cudaStreamTailLaunch ((cudaStream_t)0x3) /**< Per-grid stream with a tail launch semantics. Only applicable when used with CUDA Dynamic Parallelism. */
|
| 181 |
+
#define cudaStreamFireAndForget ((cudaStream_t)0x4) /**< Per-grid stream with a fire-and-forget synchronization behavior. Only applicable when used with CUDA Dynamic Parallelism. */
|
| 182 |
+
#endif
|
| 183 |
+
|
| 184 |
+
extern "C"
|
| 185 |
+
{
|
| 186 |
+
|
| 187 |
+
// Symbols beginning with __cudaCDP* should not be used outside
|
| 188 |
+
// this header file. Instead, compile with -DCUDA_FORCE_CDP1_IF_SUPPORTED if
|
| 189 |
+
// CDP1 support is required.
|
| 190 |
+
|
| 191 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaDeviceSynchronizeDeprecationAvoidance(void);
|
| 192 |
+
|
| 193 |
+
// Bug 4398304
|
| 194 |
+
// WAR for doxgyen processing duplicate entries causing warnings to be listed in the documentation
|
| 195 |
+
/** \cond impl_private */
|
| 196 |
+
|
| 197 |
+
#ifndef __CUDA_INTERNAL_USE_CDP2
|
| 198 |
+
//// CDP1 endpoints
|
| 199 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device);
|
| 200 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetLimit(size_t *pValue, enum cudaLimit limit);
|
| 201 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetCacheConfig(enum cudaFuncCache *pCacheConfig);
|
| 202 |
+
extern __DEPRECATED__("cudaDeviceGetSharedMemConfig deprecated") __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetSharedMemConfig(enum cudaSharedMemConfig *pConfig);
|
| 203 |
+
#if (__CUDA_ARCH__ < 900) && (defined(CUDA_FORCE_CDP1_IF_SUPPORTED) || (defined(_WIN32) && !defined(_WIN64)))
|
| 204 |
+
// cudaDeviceSynchronize is removed on sm_90+
|
| 205 |
+
extern __device__ __cudart_builtin__ __CDPRT_DEPRECATED(cudaDeviceSynchronize) cudaError_t CUDARTAPI cudaDeviceSynchronize(void);
|
| 206 |
+
#endif
|
| 207 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetLastError(void);
|
| 208 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaPeekAtLastError(void);
|
| 209 |
+
extern __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorString(cudaError_t error);
|
| 210 |
+
extern __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorName(cudaError_t error);
|
| 211 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDeviceCount(int *count);
|
| 212 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDevice(int *device);
|
| 213 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamCreateWithFlags(cudaStream_t *pStream, unsigned int flags);
|
| 214 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamDestroy(cudaStream_t stream);
|
| 215 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
|
| 216 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent_ptsz(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
|
| 217 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventCreateWithFlags(cudaEvent_t *event, unsigned int flags);
|
| 218 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord(cudaEvent_t event, cudaStream_t stream);
|
| 219 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord_ptsz(cudaEvent_t event, cudaStream_t stream);
|
| 220 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
|
| 221 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags_ptsz(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
|
| 222 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventDestroy(cudaEvent_t event);
|
| 223 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *attr, const void *func);
|
| 224 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFree(void *devPtr);
|
| 225 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMalloc(void **devPtr, size_t size);
|
| 226 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 227 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync_ptsz(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 228 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 229 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync_ptsz(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 230 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
|
| 231 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync_ptsz(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
|
| 232 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync(void *devPtr, int value, size_t count, cudaStream_t stream);
|
| 233 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync_ptsz(void *devPtr, int value, size_t count, cudaStream_t stream);
|
| 234 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
|
| 235 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync_ptsz(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
|
| 236 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
|
| 237 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync_ptsz(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
|
| 238 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaRuntimeGetVersion(int *runtimeVersion);
|
| 239 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize);
|
| 240 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags);
|
| 241 |
+
#endif // __CUDA_INTERNAL_USE_CDP2
|
| 242 |
+
|
| 243 |
+
//// CDP2 endpoints
|
| 244 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device);
|
| 245 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetLimit(size_t *pValue, enum cudaLimit limit);
|
| 246 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetCacheConfig(enum cudaFuncCache *pCacheConfig);
|
| 247 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2DeviceGetSharedMemConfig(enum cudaSharedMemConfig *pConfig);
|
| 248 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2GetLastError(void);
|
| 249 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2PeekAtLastError(void);
|
| 250 |
+
extern __device__ __cudart_builtin__ const char* CUDARTAPI __cudaCDP2GetErrorString(cudaError_t error);
|
| 251 |
+
extern __device__ __cudart_builtin__ const char* CUDARTAPI __cudaCDP2GetErrorName(cudaError_t error);
|
| 252 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2GetDeviceCount(int *count);
|
| 253 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2GetDevice(int *device);
|
| 254 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2StreamCreateWithFlags(cudaStream_t *pStream, unsigned int flags);
|
| 255 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2StreamDestroy(cudaStream_t stream);
|
| 256 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2StreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
|
| 257 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2StreamWaitEvent_ptsz(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
|
| 258 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventCreateWithFlags(cudaEvent_t *event, unsigned int flags);
|
| 259 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventRecord(cudaEvent_t event, cudaStream_t stream);
|
| 260 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventRecord_ptsz(cudaEvent_t event, cudaStream_t stream);
|
| 261 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventRecordWithFlags(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
|
| 262 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventRecordWithFlags_ptsz(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
|
| 263 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2EventDestroy(cudaEvent_t event);
|
| 264 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2FuncGetAttributes(struct cudaFuncAttributes *attr, const void *func);
|
| 265 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Free(void *devPtr);
|
| 266 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Malloc(void **devPtr, size_t size);
|
| 267 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2MemcpyAsync(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 268 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2MemcpyAsync_ptsz(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 269 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 270 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memcpy2DAsync_ptsz(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 271 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memcpy3DAsync(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
|
| 272 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memcpy3DAsync_ptsz(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
|
| 273 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2MemsetAsync(void *devPtr, int value, size_t count, cudaStream_t stream);
|
| 274 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2MemsetAsync_ptsz(void *devPtr, int value, size_t count, cudaStream_t stream);
|
| 275 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
|
| 276 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memset2DAsync_ptsz(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
|
| 277 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memset3DAsync(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
|
| 278 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2Memset3DAsync_ptsz(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
|
| 279 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2RuntimeGetVersion(int *runtimeVersion);
|
| 280 |
+
extern __device__ __cudart_builtin__ void * CUDARTAPI __cudaCDP2GetParameterBuffer(size_t alignment, size_t size);
|
| 281 |
+
extern __device__ __cudart_builtin__ void * CUDARTAPI __cudaCDP2GetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize);
|
| 282 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2LaunchDevice_ptsz(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
|
| 283 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2LaunchDeviceV2_ptsz(void *parameterBuffer, cudaStream_t stream);
|
| 284 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2LaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
|
| 285 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2LaunchDeviceV2(void *parameterBuffer, cudaStream_t stream);
|
| 286 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize);
|
| 287 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags);
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphLaunch(cudaGraphExec_t graphExec, cudaStream_t stream);
|
| 291 |
+
#if defined(CUDA_API_PER_THREAD_DEFAULT_STREAM)
|
| 292 |
+
static inline __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphLaunch_ptsz(cudaGraphExec_t graphExec, cudaStream_t stream)
|
| 293 |
+
{
|
| 294 |
+
if (stream == 0) {
|
| 295 |
+
stream = cudaStreamPerThread;
|
| 296 |
+
}
|
| 297 |
+
return cudaGraphLaunch(graphExec, stream);
|
| 298 |
+
}
|
| 299 |
+
#endif
|
| 300 |
+
|
| 301 |
+
/** \endcond */
|
| 302 |
+
|
| 303 |
+
/**
|
| 304 |
+
* \ingroup CUDART_GRAPH
|
| 305 |
+
* \brief Get the currently running device graph id.
|
| 306 |
+
*
|
| 307 |
+
* Get the currently running device graph id.
|
| 308 |
+
* \return Returns the current device graph id, 0 if the call is outside of a device graph.
|
| 309 |
+
* \sa cudaGraphLaunch
|
| 310 |
+
*/
|
| 311 |
+
static inline __device__ __cudart_builtin__ cudaGraphExec_t CUDARTAPI cudaGetCurrentGraphExec(void)
|
| 312 |
+
{
|
| 313 |
+
unsigned long long current_graph_exec;
|
| 314 |
+
asm ("mov.u64 %0, %%current_graph_exec;" : "=l"(current_graph_exec));
|
| 315 |
+
return (cudaGraphExec_t)current_graph_exec;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
/**
|
| 319 |
+
* \ingroup CUDART_GRAPH
|
| 320 |
+
* \brief Updates the kernel parameters of the given kernel node
|
| 321 |
+
*
|
| 322 |
+
* Updates \p size bytes in the kernel parameters of \p node at \p offset to
|
| 323 |
+
* the contents of \p value. \p node must be device-updatable, and must reside upon the same
|
| 324 |
+
* device as the calling kernel.
|
| 325 |
+
*
|
| 326 |
+
* If this function is called for the node's immediate dependent and that dependent is configured
|
| 327 |
+
* for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
|
| 328 |
+
* kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
|
| 329 |
+
* that the update is visible to that dependent node before it is launched.
|
| 330 |
+
*
|
| 331 |
+
* \param node - The node to update
|
| 332 |
+
* \param offset - The offset into the params at which to make the update
|
| 333 |
+
* \param value - Buffer containing the params to write
|
| 334 |
+
* \param size - Size in bytes to update
|
| 335 |
+
*
|
| 336 |
+
* \return
|
| 337 |
+
* cudaSucces,
|
| 338 |
+
* cudaErrorInvalidValue
|
| 339 |
+
* \notefnerr
|
| 340 |
+
*
|
| 341 |
+
* \sa
|
| 342 |
+
* ::cudaGraphKernelNodeSetEnabled,
|
| 343 |
+
* ::cudaGraphKernelNodeSetGridDim,
|
| 344 |
+
* ::cudaGraphKernelNodeUpdatesApply
|
| 345 |
+
*/
|
| 346 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeSetParam(cudaGraphDeviceNode_t node, size_t offset, const void *value , size_t size);
|
| 347 |
+
|
| 348 |
+
/**
|
| 349 |
+
* \ingroup CUDART_GRAPH
|
| 350 |
+
* \brief Enables or disables the given kernel node
|
| 351 |
+
*
|
| 352 |
+
* Enables or disables \p node based upon \p enable. If \p enable is true, the node will be enabled;
|
| 353 |
+
* if it is false, the node will be disabled. Disabled nodes will act as a NOP during execution.
|
| 354 |
+
* \p node must be device-updatable, and must reside upon the same device as the calling kernel.
|
| 355 |
+
*
|
| 356 |
+
* If this function is called for the node's immediate dependent and that dependent is configured
|
| 357 |
+
* for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
|
| 358 |
+
* kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
|
| 359 |
+
* that the update is visible to that dependent node before it is launched.
|
| 360 |
+
*
|
| 361 |
+
* \param node - The node to update
|
| 362 |
+
* \param enable - Whether to enable or disable the node
|
| 363 |
+
*
|
| 364 |
+
* \return
|
| 365 |
+
* cudaSucces,
|
| 366 |
+
* cudaErrorInvalidValue
|
| 367 |
+
* \notefnerr
|
| 368 |
+
*
|
| 369 |
+
* \sa
|
| 370 |
+
* ::cudaGraphKernelNodeSetParam,
|
| 371 |
+
* ::cudaGraphKernelNodeSetGridDim,
|
| 372 |
+
* ::cudaGraphKernelNodeUpdatesApply
|
| 373 |
+
*/
|
| 374 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeSetEnabled(cudaGraphDeviceNode_t node, bool enable);
|
| 375 |
+
|
| 376 |
+
/**
|
| 377 |
+
* \ingroup CUDART_GRAPH
|
| 378 |
+
* \brief Updates the grid dimensions of the given kernel node
|
| 379 |
+
*
|
| 380 |
+
* Sets the grid dimensions of \p node to \p gridDim. \p node must be device-updatable,
|
| 381 |
+
* and must reside upon the same device as thecalling kernel.
|
| 382 |
+
*
|
| 383 |
+
* If this function is called for the node's immediate dependent and that dependent is configured
|
| 384 |
+
* for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
|
| 385 |
+
* kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
|
| 386 |
+
* that the update is visible to that dependent node before it is launched.
|
| 387 |
+
*
|
| 388 |
+
* \param node - The node to update
|
| 389 |
+
* \param gridDim - The grid dimensions to set
|
| 390 |
+
*
|
| 391 |
+
* \return
|
| 392 |
+
* cudaSucces,
|
| 393 |
+
* cudaErrorInvalidValue
|
| 394 |
+
* \notefnerr
|
| 395 |
+
*
|
| 396 |
+
* \sa
|
| 397 |
+
* ::cudaGraphKernelNodeSetParam,
|
| 398 |
+
* ::cudaGraphKernelNodeSetEnabled,
|
| 399 |
+
* ::cudaGraphKernelNodeUpdatesApply
|
| 400 |
+
*/
|
| 401 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeSetGridDim(cudaGraphDeviceNode_t node, dim3 gridDim);
|
| 402 |
+
|
| 403 |
+
/**
|
| 404 |
+
* \ingroup CUDART_GRAPH
|
| 405 |
+
* \brief Batch applies multiple kernel node updates
|
| 406 |
+
*
|
| 407 |
+
* Batch applies one or more kernel node updates based on the information provided in \p updates.
|
| 408 |
+
* \p updateCount specifies the number of updates to apply. Each entry in \p updates must specify
|
| 409 |
+
* a node to update, the type of update to apply, and the parameters for that type of update. See
|
| 410 |
+
* the documentation for ::cudaGraphKernelNodeUpdate for more detail.
|
| 411 |
+
*
|
| 412 |
+
* If this function is called for the node's immediate dependent and that dependent is configured
|
| 413 |
+
* for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
|
| 414 |
+
* kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
|
| 415 |
+
* that the update is visible to that dependent node before it is launched.
|
| 416 |
+
*
|
| 417 |
+
* \param updates - The updates to apply
|
| 418 |
+
* \param updateCount - The number of updates to apply
|
| 419 |
+
*
|
| 420 |
+
* \return
|
| 421 |
+
* cudaSucces,
|
| 422 |
+
* cudaErrorInvalidValue
|
| 423 |
+
* \notefnerr
|
| 424 |
+
*
|
| 425 |
+
* \sa
|
| 426 |
+
* ::cudaGraphKernelNodeSetParam,
|
| 427 |
+
* ::cudaGraphKernelNodeSetEnabled,
|
| 428 |
+
* ::cudaGraphKernelNodeSetGridDim
|
| 429 |
+
*/
|
| 430 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeUpdatesApply(const cudaGraphKernelNodeUpdate *updates, size_t updateCount);
|
| 431 |
+
|
| 432 |
+
/**
|
| 433 |
+
* \ingroup CUDART_EXECUTION
|
| 434 |
+
* \brief Programmatic dependency trigger
|
| 435 |
+
*
|
| 436 |
+
* This device function ensures the programmatic launch completion edges /
|
| 437 |
+
* events are fulfilled. See
|
| 438 |
+
* ::cudaLaunchAttributeID::cudaLaunchAttributeProgrammaticStreamSerialization
|
| 439 |
+
* and ::cudaLaunchAttributeID::cudaLaunchAttributeProgrammaticEvent for more
|
| 440 |
+
* information. The event / edge kick off only happens when every CTAs
|
| 441 |
+
* in the grid has either exited or called this function at least once,
|
| 442 |
+
* otherwise the kick off happens automatically after all warps finishes
|
| 443 |
+
* execution but before the grid completes. The kick off only enables
|
| 444 |
+
* scheduling of the secondary kernel. It provides no memory visibility
|
| 445 |
+
* guarantee itself. The user could enforce memory visibility by inserting a
|
| 446 |
+
* memory fence of the correct scope.
|
| 447 |
+
*/
|
| 448 |
+
static inline __device__ __cudart_builtin__ void CUDARTAPI cudaTriggerProgrammaticLaunchCompletion(void)
|
| 449 |
+
{
|
| 450 |
+
asm volatile("griddepcontrol.launch_dependents;":::);
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
/**
|
| 454 |
+
* \ingroup CUDART_EXECUTION
|
| 455 |
+
* \brief Programmatic grid dependency synchronization
|
| 456 |
+
*
|
| 457 |
+
* This device function will block the thread until all direct grid
|
| 458 |
+
* dependencies have completed. This API is intended to use in conjuncture with
|
| 459 |
+
* programmatic / launch event / dependency. See
|
| 460 |
+
* ::cudaLaunchAttributeID::cudaLaunchAttributeProgrammaticStreamSerialization
|
| 461 |
+
* and ::cudaLaunchAttributeID::cudaLaunchAttributeProgrammaticEvent for more
|
| 462 |
+
* information.
|
| 463 |
+
*/
|
| 464 |
+
static inline __device__ __cudart_builtin__ void CUDARTAPI cudaGridDependencySynchronize(void)
|
| 465 |
+
{
|
| 466 |
+
asm volatile("griddepcontrol.wait;":::"memory");
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
/**
|
| 470 |
+
* \ingroup CUDART_GRAPH
|
| 471 |
+
* \brief Sets the condition value associated with a conditional node.
|
| 472 |
+
*
|
| 473 |
+
* Sets the condition value associated with a conditional node.
|
| 474 |
+
*
|
| 475 |
+
* Note: \p handle must be associated with the same context as the kernel calling this function.
|
| 476 |
+
*
|
| 477 |
+
* \sa cudaGraphConditionalHandleCreate
|
| 478 |
+
*/
|
| 479 |
+
extern __device__ __cudart_builtin__ void CUDARTAPI cudaGraphSetConditional(cudaGraphConditionalHandle handle, unsigned int value);
|
| 480 |
+
|
| 481 |
+
//// CG API
|
| 482 |
+
extern __device__ __cudart_builtin__ unsigned long long CUDARTAPI cudaCGGetIntrinsicHandle(enum cudaCGScope scope);
|
| 483 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGSynchronize(unsigned long long handle, unsigned int flags);
|
| 484 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGSynchronizeGrid(unsigned long long handle, unsigned int flags);
|
| 485 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGGetSize(unsigned int *numThreads, unsigned int *numGrids, unsigned long long handle);
|
| 486 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGGetRank(unsigned int *threadRank, unsigned int *gridRank, unsigned long long handle);
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
//// CDP API
|
| 490 |
+
|
| 491 |
+
#ifdef __CUDA_ARCH__
|
| 492 |
+
|
| 493 |
+
// Bug 4398304
|
| 494 |
+
// WAR for doxgyen processing duplicate entries causing warnings to be listed in the documentation
|
| 495 |
+
/** \cond impl_private */
|
| 496 |
+
|
| 497 |
+
#ifdef __CUDA_INTERNAL_USE_CDP2
|
| 498 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device)
|
| 499 |
+
{
|
| 500 |
+
return __cudaCDP2DeviceGetAttribute(value, attr, device);
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetLimit(size_t *pValue, enum cudaLimit limit)
|
| 504 |
+
{
|
| 505 |
+
return __cudaCDP2DeviceGetLimit(pValue, limit);
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetCacheConfig(enum cudaFuncCache *pCacheConfig)
|
| 509 |
+
{
|
| 510 |
+
return __cudaCDP2DeviceGetCacheConfig(pCacheConfig);
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetSharedMemConfig(enum cudaSharedMemConfig *pConfig)
|
| 514 |
+
{
|
| 515 |
+
return __cudaCDP2DeviceGetSharedMemConfig(pConfig);
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetLastError(void)
|
| 519 |
+
{
|
| 520 |
+
return __cudaCDP2GetLastError();
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaPeekAtLastError(void)
|
| 524 |
+
{
|
| 525 |
+
return __cudaCDP2PeekAtLastError();
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
static __inline__ __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorString(cudaError_t error)
|
| 529 |
+
{
|
| 530 |
+
return __cudaCDP2GetErrorString(error);
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
static __inline__ __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorName(cudaError_t error)
|
| 534 |
+
{
|
| 535 |
+
return __cudaCDP2GetErrorName(error);
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDeviceCount(int *count)
|
| 539 |
+
{
|
| 540 |
+
return __cudaCDP2GetDeviceCount(count);
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDevice(int *device)
|
| 544 |
+
{
|
| 545 |
+
return __cudaCDP2GetDevice(device);
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamCreateWithFlags(cudaStream_t *pStream, unsigned int flags)
|
| 549 |
+
{
|
| 550 |
+
return __cudaCDP2StreamCreateWithFlags(pStream, flags);
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamDestroy(cudaStream_t stream)
|
| 554 |
+
{
|
| 555 |
+
return __cudaCDP2StreamDestroy(stream);
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags)
|
| 559 |
+
{
|
| 560 |
+
return __cudaCDP2StreamWaitEvent(stream, event, flags);
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent_ptsz(cudaStream_t stream, cudaEvent_t event, unsigned int flags)
|
| 564 |
+
{
|
| 565 |
+
return __cudaCDP2StreamWaitEvent_ptsz(stream, event, flags);
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventCreateWithFlags(cudaEvent_t *event, unsigned int flags)
|
| 569 |
+
{
|
| 570 |
+
return __cudaCDP2EventCreateWithFlags(event, flags);
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord(cudaEvent_t event, cudaStream_t stream)
|
| 574 |
+
{
|
| 575 |
+
return __cudaCDP2EventRecord(event, stream);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord_ptsz(cudaEvent_t event, cudaStream_t stream)
|
| 579 |
+
{
|
| 580 |
+
return __cudaCDP2EventRecord_ptsz(event, stream);
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags(cudaEvent_t event, cudaStream_t stream, unsigned int flags)
|
| 584 |
+
{
|
| 585 |
+
return __cudaCDP2EventRecordWithFlags(event, stream, flags);
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags_ptsz(cudaEvent_t event, cudaStream_t stream, unsigned int flags)
|
| 589 |
+
{
|
| 590 |
+
return __cudaCDP2EventRecordWithFlags_ptsz(event, stream, flags);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventDestroy(cudaEvent_t event)
|
| 594 |
+
{
|
| 595 |
+
return __cudaCDP2EventDestroy(event);
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *attr, const void *func)
|
| 599 |
+
{
|
| 600 |
+
return __cudaCDP2FuncGetAttributes(attr, func);
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFree(void *devPtr)
|
| 604 |
+
{
|
| 605 |
+
return __cudaCDP2Free(devPtr);
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMalloc(void **devPtr, size_t size)
|
| 609 |
+
{
|
| 610 |
+
return __cudaCDP2Malloc(devPtr, size);
|
| 611 |
+
}
|
| 612 |
+
|
| 613 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
|
| 614 |
+
{
|
| 615 |
+
return __cudaCDP2MemcpyAsync(dst, src, count, kind, stream);
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync_ptsz(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
|
| 619 |
+
{
|
| 620 |
+
return __cudaCDP2MemcpyAsync_ptsz(dst, src, count, kind, stream);
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream)
|
| 624 |
+
{
|
| 625 |
+
return __cudaCDP2Memcpy2DAsync(dst, dpitch, src, spitch, width, height, kind, stream);
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync_ptsz(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream)
|
| 629 |
+
{
|
| 630 |
+
return __cudaCDP2Memcpy2DAsync_ptsz(dst, dpitch, src, spitch, width, height, kind, stream);
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync(const struct cudaMemcpy3DParms *p, cudaStream_t stream)
|
| 634 |
+
{
|
| 635 |
+
return __cudaCDP2Memcpy3DAsync(p, stream);
|
| 636 |
+
}
|
| 637 |
+
|
| 638 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync_ptsz(const struct cudaMemcpy3DParms *p, cudaStream_t stream)
|
| 639 |
+
{
|
| 640 |
+
return __cudaCDP2Memcpy3DAsync_ptsz(p, stream);
|
| 641 |
+
}
|
| 642 |
+
|
| 643 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync(void *devPtr, int value, size_t count, cudaStream_t stream)
|
| 644 |
+
{
|
| 645 |
+
return __cudaCDP2MemsetAsync(devPtr, value, count, stream);
|
| 646 |
+
}
|
| 647 |
+
|
| 648 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync_ptsz(void *devPtr, int value, size_t count, cudaStream_t stream)
|
| 649 |
+
{
|
| 650 |
+
return __cudaCDP2MemsetAsync_ptsz(devPtr, value, count, stream);
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream)
|
| 654 |
+
{
|
| 655 |
+
return __cudaCDP2Memset2DAsync(devPtr, pitch, value, width, height, stream);
|
| 656 |
+
}
|
| 657 |
+
|
| 658 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync_ptsz(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream)
|
| 659 |
+
{
|
| 660 |
+
return __cudaCDP2Memset2DAsync_ptsz(devPtr, pitch, value, width, height, stream);
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream)
|
| 664 |
+
{
|
| 665 |
+
return __cudaCDP2Memset3DAsync(pitchedDevPtr, value, extent, stream);
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync_ptsz(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream)
|
| 669 |
+
{
|
| 670 |
+
return __cudaCDP2Memset3DAsync_ptsz(pitchedDevPtr, value, extent, stream);
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaRuntimeGetVersion(int *runtimeVersion)
|
| 674 |
+
{
|
| 675 |
+
return __cudaCDP2RuntimeGetVersion(runtimeVersion);
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize)
|
| 679 |
+
{
|
| 680 |
+
return __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessor(numBlocks, func, blockSize, dynamicSmemSize);
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags)
|
| 684 |
+
{
|
| 685 |
+
return __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessorWithFlags(numBlocks, func, blockSize, dynamicSmemSize, flags);
|
| 686 |
+
}
|
| 687 |
+
#endif // __CUDA_INTERNAL_USE_CDP2
|
| 688 |
+
|
| 689 |
+
/** \endcond */
|
| 690 |
+
|
| 691 |
+
#endif // __CUDA_ARCH__
|
| 692 |
+
|
| 693 |
+
|
| 694 |
+
/**
|
| 695 |
+
* \ingroup CUDART_EXECUTION
|
| 696 |
+
* \brief Obtains a parameter buffer
|
| 697 |
+
*
|
| 698 |
+
* Obtains a parameter buffer which can be filled with parameters for a kernel launch.
|
| 699 |
+
* Parameters passed to ::cudaLaunchDevice must be allocated via this function.
|
| 700 |
+
*
|
| 701 |
+
* This is a low level API and can only be accessed from Parallel Thread Execution (PTX).
|
| 702 |
+
* CUDA user code should use <<< >>> to launch kernels.
|
| 703 |
+
*
|
| 704 |
+
* \param alignment - Specifies alignment requirement of the parameter buffer
|
| 705 |
+
* \param size - Specifies size requirement in bytes
|
| 706 |
+
*
|
| 707 |
+
* \return
|
| 708 |
+
* Returns pointer to the allocated parameterBuffer
|
| 709 |
+
* \notefnerr
|
| 710 |
+
*
|
| 711 |
+
* \sa cudaLaunchDevice
|
| 712 |
+
*/
|
| 713 |
+
#ifdef __CUDA_INTERNAL_USE_CDP2
|
| 714 |
+
static __inline__ __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBuffer(size_t alignment, size_t size)
|
| 715 |
+
{
|
| 716 |
+
return __cudaCDP2GetParameterBuffer(alignment, size);
|
| 717 |
+
}
|
| 718 |
+
#else
|
| 719 |
+
extern __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBuffer(size_t alignment, size_t size);
|
| 720 |
+
#endif
|
| 721 |
+
|
| 722 |
+
|
| 723 |
+
#ifdef __CUDA_INTERNAL_USE_CDP2
|
| 724 |
+
static __inline__ __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize)
|
| 725 |
+
{
|
| 726 |
+
return __cudaCDP2GetParameterBufferV2(func, gridDimension, blockDimension, sharedMemSize);
|
| 727 |
+
}
|
| 728 |
+
#else
|
| 729 |
+
extern __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize);
|
| 730 |
+
#endif
|
| 731 |
+
|
| 732 |
+
|
| 733 |
+
#ifdef __CUDA_INTERNAL_USE_CDP2
|
| 734 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice_ptsz(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream)
|
| 735 |
+
{
|
| 736 |
+
return __cudaCDP2LaunchDevice_ptsz(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2_ptsz(void *parameterBuffer, cudaStream_t stream)
|
| 740 |
+
{
|
| 741 |
+
return __cudaCDP2LaunchDeviceV2_ptsz(parameterBuffer, stream);
|
| 742 |
+
}
|
| 743 |
+
#else
|
| 744 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice_ptsz(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
|
| 745 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2_ptsz(void *parameterBuffer, cudaStream_t stream);
|
| 746 |
+
#endif
|
| 747 |
+
|
| 748 |
+
|
| 749 |
+
/**
|
| 750 |
+
* \ingroup CUDART_EXECUTION
|
| 751 |
+
* \brief Launches a specified kernel
|
| 752 |
+
*
|
| 753 |
+
* Launches a specified kernel with the specified parameter buffer. A parameter buffer can be obtained
|
| 754 |
+
* by calling ::cudaGetParameterBuffer().
|
| 755 |
+
*
|
| 756 |
+
* This is a low level API and can only be accessed from Parallel Thread Execution (PTX).
|
| 757 |
+
* CUDA user code should use <<< >>> to launch the kernels.
|
| 758 |
+
*
|
| 759 |
+
* \param func - Pointer to the kernel to be launched
|
| 760 |
+
* \param parameterBuffer - Holds the parameters to the launched kernel. parameterBuffer can be NULL. (Optional)
|
| 761 |
+
* \param gridDimension - Specifies grid dimensions
|
| 762 |
+
* \param blockDimension - Specifies block dimensions
|
| 763 |
+
* \param sharedMemSize - Specifies size of shared memory
|
| 764 |
+
* \param stream - Specifies the stream to be used
|
| 765 |
+
*
|
| 766 |
+
* \return
|
| 767 |
+
* ::cudaSuccess, ::cudaErrorInvalidDevice, ::cudaErrorLaunchMaxDepthExceeded, ::cudaErrorInvalidConfiguration,
|
| 768 |
+
* ::cudaErrorStartupFailure, ::cudaErrorLaunchPendingCountExceeded, ::cudaErrorLaunchOutOfResources
|
| 769 |
+
* \notefnerr
|
| 770 |
+
* \n Please refer to Execution Configuration and Parameter Buffer Layout from the CUDA Programming
|
| 771 |
+
* Guide for the detailed descriptions of launch configuration and parameter layout respectively.
|
| 772 |
+
*
|
| 773 |
+
* \sa cudaGetParameterBuffer
|
| 774 |
+
*/
|
| 775 |
+
#if defined(CUDA_API_PER_THREAD_DEFAULT_STREAM) && defined(__CUDA_ARCH__)
|
| 776 |
+
// When compiling for the device and per thread default stream is enabled, add
|
| 777 |
+
// a static inline redirect to the per thread stream entry points.
|
| 778 |
+
|
| 779 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI
|
| 780 |
+
cudaLaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream)
|
| 781 |
+
{
|
| 782 |
+
#ifdef __CUDA_INTERNAL_USE_CDP2
|
| 783 |
+
return __cudaCDP2LaunchDevice_ptsz(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
|
| 784 |
+
#else
|
| 785 |
+
return cudaLaunchDevice_ptsz(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
|
| 786 |
+
#endif
|
| 787 |
+
}
|
| 788 |
+
|
| 789 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI
|
| 790 |
+
cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream)
|
| 791 |
+
{
|
| 792 |
+
#ifdef __CUDA_INTERNAL_USE_CDP2
|
| 793 |
+
return __cudaCDP2LaunchDeviceV2_ptsz(parameterBuffer, stream);
|
| 794 |
+
#else
|
| 795 |
+
return cudaLaunchDeviceV2_ptsz(parameterBuffer, stream);
|
| 796 |
+
#endif
|
| 797 |
+
}
|
| 798 |
+
#else // defined(CUDA_API_PER_THREAD_DEFAULT_STREAM) && defined(__CUDA_ARCH__)
|
| 799 |
+
#ifdef __CUDA_INTERNAL_USE_CDP2
|
| 800 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream)
|
| 801 |
+
{
|
| 802 |
+
return __cudaCDP2LaunchDevice(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
|
| 803 |
+
}
|
| 804 |
+
|
| 805 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream)
|
| 806 |
+
{
|
| 807 |
+
return __cudaCDP2LaunchDeviceV2(parameterBuffer, stream);
|
| 808 |
+
}
|
| 809 |
+
#else // __CUDA_INTERNAL_USE_CDP2
|
| 810 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
|
| 811 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream);
|
| 812 |
+
#endif // __CUDA_INTERNAL_USE_CDP2
|
| 813 |
+
#endif // defined(CUDA_API_PER_THREAD_DEFAULT_STREAM) && defined(__CUDA_ARCH__)
|
| 814 |
+
|
| 815 |
+
|
| 816 |
+
// These symbols should not be used outside of this header file.
|
| 817 |
+
#define __cudaCDP2DeviceGetAttribute
|
| 818 |
+
#define __cudaCDP2DeviceGetLimit
|
| 819 |
+
#define __cudaCDP2DeviceGetCacheConfig
|
| 820 |
+
#define __cudaCDP2DeviceGetSharedMemConfig
|
| 821 |
+
#define __cudaCDP2GetLastError
|
| 822 |
+
#define __cudaCDP2PeekAtLastError
|
| 823 |
+
#define __cudaCDP2GetErrorString
|
| 824 |
+
#define __cudaCDP2GetErrorName
|
| 825 |
+
#define __cudaCDP2GetDeviceCount
|
| 826 |
+
#define __cudaCDP2GetDevice
|
| 827 |
+
#define __cudaCDP2StreamCreateWithFlags
|
| 828 |
+
#define __cudaCDP2StreamDestroy
|
| 829 |
+
#define __cudaCDP2StreamWaitEvent
|
| 830 |
+
#define __cudaCDP2StreamWaitEvent_ptsz
|
| 831 |
+
#define __cudaCDP2EventCreateWithFlags
|
| 832 |
+
#define __cudaCDP2EventRecord
|
| 833 |
+
#define __cudaCDP2EventRecord_ptsz
|
| 834 |
+
#define __cudaCDP2EventRecordWithFlags
|
| 835 |
+
#define __cudaCDP2EventRecordWithFlags_ptsz
|
| 836 |
+
#define __cudaCDP2EventDestroy
|
| 837 |
+
#define __cudaCDP2FuncGetAttributes
|
| 838 |
+
#define __cudaCDP2Free
|
| 839 |
+
#define __cudaCDP2Malloc
|
| 840 |
+
#define __cudaCDP2MemcpyAsync
|
| 841 |
+
#define __cudaCDP2MemcpyAsync_ptsz
|
| 842 |
+
#define __cudaCDP2Memcpy2DAsync
|
| 843 |
+
#define __cudaCDP2Memcpy2DAsync_ptsz
|
| 844 |
+
#define __cudaCDP2Memcpy3DAsync
|
| 845 |
+
#define __cudaCDP2Memcpy3DAsync_ptsz
|
| 846 |
+
#define __cudaCDP2MemsetAsync
|
| 847 |
+
#define __cudaCDP2MemsetAsync_ptsz
|
| 848 |
+
#define __cudaCDP2Memset2DAsync
|
| 849 |
+
#define __cudaCDP2Memset2DAsync_ptsz
|
| 850 |
+
#define __cudaCDP2Memset3DAsync
|
| 851 |
+
#define __cudaCDP2Memset3DAsync_ptsz
|
| 852 |
+
#define __cudaCDP2RuntimeGetVersion
|
| 853 |
+
#define __cudaCDP2GetParameterBuffer
|
| 854 |
+
#define __cudaCDP2GetParameterBufferV2
|
| 855 |
+
#define __cudaCDP2LaunchDevice_ptsz
|
| 856 |
+
#define __cudaCDP2LaunchDeviceV2_ptsz
|
| 857 |
+
#define __cudaCDP2LaunchDevice
|
| 858 |
+
#define __cudaCDP2LaunchDeviceV2
|
| 859 |
+
#define __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessor
|
| 860 |
+
#define __cudaCDP2OccupancyMaxActiveBlocksPerMultiprocessorWithFlags
|
| 861 |
+
|
| 862 |
+
}
|
| 863 |
+
|
| 864 |
+
// Bug 4398304
|
| 865 |
+
// WAR for doxgyen processing duplicate entries causing warnings to be listed in the documentation
|
| 866 |
+
/** \cond impl_private */
|
| 867 |
+
|
| 868 |
+
template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaMalloc(T **devPtr, size_t size);
|
| 869 |
+
template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaFuncGetAttributes(struct cudaFuncAttributes *attr, T *entry);
|
| 870 |
+
template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, T func, int blockSize, size_t dynamicSmemSize);
|
| 871 |
+
template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, T func, int blockSize, size_t dynamicSmemSize, unsigned int flags);
|
| 872 |
+
|
| 873 |
+
/** \endcond */
|
| 874 |
+
|
| 875 |
+
/**
|
| 876 |
+
* \ingroup CUDART_GRAPH
|
| 877 |
+
* \brief Updates the kernel parameters of the given kernel node
|
| 878 |
+
*
|
| 879 |
+
* Updates the kernel parameters of \p node at \p offset to \p value. \p node must be
|
| 880 |
+
* device-updatable, and must reside upon the same device as the calling kernel.
|
| 881 |
+
*
|
| 882 |
+
* If this function is called for the node's immediate dependent and that dependent is configured
|
| 883 |
+
* for programmatic dependent launch, then a memory fence must be invoked via __threadfence() before
|
| 884 |
+
* kickoff of the dependent is triggered via ::cudaTriggerProgrammaticLaunchCompletion() to ensure
|
| 885 |
+
* that the update is visible to that dependent node before it is launched.
|
| 886 |
+
*
|
| 887 |
+
* \param node - The node to update
|
| 888 |
+
* \param offset - The offset into the params at which to make the update
|
| 889 |
+
* \param value - Parameter value to write
|
| 890 |
+
*
|
| 891 |
+
* \return
|
| 892 |
+
* cudaSucces,
|
| 893 |
+
* cudaErrorInvalidValue
|
| 894 |
+
* \notefnerr
|
| 895 |
+
*
|
| 896 |
+
* \sa
|
| 897 |
+
* ::etblGraphKernelNodeSetEnabled,
|
| 898 |
+
* ::etblGraphKernelNodeSetGridDim,
|
| 899 |
+
* ::etblGraphKernelNodeUpdatesApply
|
| 900 |
+
*/
|
| 901 |
+
template <typename T>
|
| 902 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGraphKernelNodeSetParam(cudaGraphDeviceNode_t node, size_t offset, const T &value)
|
| 903 |
+
{
|
| 904 |
+
return cudaGraphKernelNodeSetParam(node, offset, &value, sizeof(T));
|
| 905 |
+
}
|
| 906 |
+
|
| 907 |
+
#endif // !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350)
|
| 908 |
+
#endif /* defined(__cplusplus) && defined(__CUDACC__) */
|
| 909 |
+
|
| 910 |
+
#undef __DEPRECATED__
|
| 911 |
+
#undef __CDPRT_DEPRECATED
|
| 912 |
+
#undef __CUDA_INTERNAL_USE_CDP2
|
| 913 |
+
|
| 914 |
+
#endif /* !__CUDA_DEVICE_RUNTIME_API_H__ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_egl_interop.h
ADDED
|
@@ -0,0 +1,645 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_EGL_INTEROP_H__)
|
| 51 |
+
#define __CUDA_EGL_INTEROP_H__
|
| 52 |
+
|
| 53 |
+
#include "cuda_runtime_api.h"
|
| 54 |
+
#include "cuda_runtime.h"
|
| 55 |
+
#include "cudart_platform.h"
|
| 56 |
+
#include "EGL/egl.h"
|
| 57 |
+
#include "EGL/eglext.h"
|
| 58 |
+
|
| 59 |
+
#if defined(__cplusplus)
|
| 60 |
+
extern "C" {
|
| 61 |
+
#endif /* __cplusplus */
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* \addtogroup CUDART_TYPES
|
| 65 |
+
* @{
|
| 66 |
+
*/
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Maximum number of planes per frame
|
| 70 |
+
*/
|
| 71 |
+
#define CUDA_EGL_MAX_PLANES 3
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* CUDA EglFrame type - array or pointer
|
| 75 |
+
*/
|
| 76 |
+
typedef enum cudaEglFrameType_enum
|
| 77 |
+
{
|
| 78 |
+
cudaEglFrameTypeArray = 0, /**< Frame type CUDA array */
|
| 79 |
+
cudaEglFrameTypePitch = 1, /**< Frame type CUDA pointer */
|
| 80 |
+
} cudaEglFrameType;
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Resource location flags- sysmem or vidmem
|
| 84 |
+
*
|
| 85 |
+
* For CUDA context on iGPU, since video and system memory are equivalent -
|
| 86 |
+
* these flags will not have an effect on the execution.
|
| 87 |
+
*
|
| 88 |
+
* For CUDA context on dGPU, applications can use the flag ::cudaEglResourceLocationFlags
|
| 89 |
+
* to give a hint about the desired location.
|
| 90 |
+
*
|
| 91 |
+
* ::cudaEglResourceLocationSysmem - the frame data is made resident on the system memory
|
| 92 |
+
* to be accessed by CUDA.
|
| 93 |
+
*
|
| 94 |
+
* ::cudaEglResourceLocationVidmem - the frame data is made resident on the dedicated
|
| 95 |
+
* video memory to be accessed by CUDA.
|
| 96 |
+
*
|
| 97 |
+
* There may be an additional latency due to new allocation and data migration,
|
| 98 |
+
* if the frame is produced on a different memory.
|
| 99 |
+
*/
|
| 100 |
+
typedef enum cudaEglResourceLocationFlags_enum {
|
| 101 |
+
cudaEglResourceLocationSysmem = 0x00, /**< Resource location sysmem */
|
| 102 |
+
cudaEglResourceLocationVidmem = 0x01, /**< Resource location vidmem */
|
| 103 |
+
} cudaEglResourceLocationFlags;
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* CUDA EGL Color Format - The different planar and multiplanar formats currently supported for CUDA_EGL interops.
|
| 107 |
+
*/
|
| 108 |
+
typedef enum cudaEglColorFormat_enum {
|
| 109 |
+
cudaEglColorFormatYUV420Planar = 0, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 110 |
+
cudaEglColorFormatYUV420SemiPlanar = 1, /**< Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV420Planar. */
|
| 111 |
+
cudaEglColorFormatYUV422Planar = 2, /**< Y, U, V each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 112 |
+
cudaEglColorFormatYUV422SemiPlanar = 3, /**< Y, UV in two surfaces with VU byte ordering, width, height ratio same as YUV422Planar. */
|
| 113 |
+
cudaEglColorFormatARGB = 6, /**< R/G/B/A four channels in one surface with BGRA byte ordering. */
|
| 114 |
+
cudaEglColorFormatRGBA = 7, /**< R/G/B/A four channels in one surface with ABGR byte ordering. */
|
| 115 |
+
cudaEglColorFormatL = 8, /**< single luminance channel in one surface. */
|
| 116 |
+
cudaEglColorFormatR = 9, /**< single color channel in one surface. */
|
| 117 |
+
cudaEglColorFormatYUV444Planar = 10, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height. */
|
| 118 |
+
cudaEglColorFormatYUV444SemiPlanar = 11, /**< Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV444Planar. */
|
| 119 |
+
cudaEglColorFormatYUYV422 = 12, /**< Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 120 |
+
cudaEglColorFormatUYVY422 = 13, /**< Y, U, V in one surface, interleaved as YUYV in one channel. */
|
| 121 |
+
cudaEglColorFormatABGR = 14, /**< R/G/B/A four channels in one surface with RGBA byte ordering. */
|
| 122 |
+
cudaEglColorFormatBGRA = 15, /**< R/G/B/A four channels in one surface with ARGB byte ordering. */
|
| 123 |
+
cudaEglColorFormatA = 16, /**< Alpha color format - one channel in one surface. */
|
| 124 |
+
cudaEglColorFormatRG = 17, /**< R/G color format - two channels in one surface with GR byte ordering */
|
| 125 |
+
cudaEglColorFormatAYUV = 18, /**< Y, U, V, A four channels in one surface, interleaved as VUYA. */
|
| 126 |
+
cudaEglColorFormatYVU444SemiPlanar = 19, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 127 |
+
cudaEglColorFormatYVU422SemiPlanar = 20, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 128 |
+
cudaEglColorFormatYVU420SemiPlanar = 21, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 129 |
+
cudaEglColorFormatY10V10U10_444SemiPlanar = 22, /**< Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 130 |
+
cudaEglColorFormatY10V10U10_420SemiPlanar = 23, /**< Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 131 |
+
cudaEglColorFormatY12V12U12_444SemiPlanar = 24, /**< Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 132 |
+
cudaEglColorFormatY12V12U12_420SemiPlanar = 25, /**< Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 133 |
+
cudaEglColorFormatVYUY_ER = 26, /**< Extended Range Y, U, V in one surface, interleaved as YVYU in one channel. */
|
| 134 |
+
cudaEglColorFormatUYVY_ER = 27, /**< Extended Range Y, U, V in one surface, interleaved as YUYV in one channel. */
|
| 135 |
+
cudaEglColorFormatYUYV_ER = 28, /**< Extended Range Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 136 |
+
cudaEglColorFormatYVYU_ER = 29, /**< Extended Range Y, U, V in one surface, interleaved as VYUY in one channel. */
|
| 137 |
+
cudaEglColorFormatYUVA_ER = 31, /**< Extended Range Y, U, V, A four channels in one surface, interleaved as AVUY. */
|
| 138 |
+
cudaEglColorFormatAYUV_ER = 32, /**< Extended Range Y, U, V, A four channels in one surface, interleaved as VUYA. */
|
| 139 |
+
cudaEglColorFormatYUV444Planar_ER = 33, /**< Extended Range Y, U, V in three surfaces, U/V width = Y width, U/V height = Y height. */
|
| 140 |
+
cudaEglColorFormatYUV422Planar_ER = 34, /**< Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 141 |
+
cudaEglColorFormatYUV420Planar_ER = 35, /**< Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 142 |
+
cudaEglColorFormatYUV444SemiPlanar_ER = 36, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 143 |
+
cudaEglColorFormatYUV422SemiPlanar_ER = 37, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 144 |
+
cudaEglColorFormatYUV420SemiPlanar_ER = 38, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 145 |
+
cudaEglColorFormatYVU444Planar_ER = 39, /**< Extended Range Y, V, U in three surfaces, U/V width = Y width, U/V height = Y height. */
|
| 146 |
+
cudaEglColorFormatYVU422Planar_ER = 40, /**< Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 147 |
+
cudaEglColorFormatYVU420Planar_ER = 41, /**< Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 148 |
+
cudaEglColorFormatYVU444SemiPlanar_ER = 42, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
|
| 149 |
+
cudaEglColorFormatYVU422SemiPlanar_ER = 43, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 150 |
+
cudaEglColorFormatYVU420SemiPlanar_ER = 44, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 151 |
+
cudaEglColorFormatBayerRGGB = 45, /**< Bayer format - one channel in one surface with interleaved RGGB ordering. */
|
| 152 |
+
cudaEglColorFormatBayerBGGR = 46, /**< Bayer format - one channel in one surface with interleaved BGGR ordering. */
|
| 153 |
+
cudaEglColorFormatBayerGRBG = 47, /**< Bayer format - one channel in one surface with interleaved GRBG ordering. */
|
| 154 |
+
cudaEglColorFormatBayerGBRG = 48, /**< Bayer format - one channel in one surface with interleaved GBRG ordering. */
|
| 155 |
+
cudaEglColorFormatBayer10RGGB = 49, /**< Bayer10 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 156 |
+
cudaEglColorFormatBayer10BGGR = 50, /**< Bayer10 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 157 |
+
cudaEglColorFormatBayer10GRBG = 51, /**< Bayer10 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 158 |
+
cudaEglColorFormatBayer10GBRG = 52, /**< Bayer10 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 159 |
+
cudaEglColorFormatBayer12RGGB = 53, /**< Bayer12 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 160 |
+
cudaEglColorFormatBayer12BGGR = 54, /**< Bayer12 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 161 |
+
cudaEglColorFormatBayer12GRBG = 55, /**< Bayer12 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 162 |
+
cudaEglColorFormatBayer12GBRG = 56, /**< Bayer12 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 163 |
+
cudaEglColorFormatBayer14RGGB = 57, /**< Bayer14 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
|
| 164 |
+
cudaEglColorFormatBayer14BGGR = 58, /**< Bayer14 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
|
| 165 |
+
cudaEglColorFormatBayer14GRBG = 59, /**< Bayer14 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
|
| 166 |
+
cudaEglColorFormatBayer14GBRG = 60, /**< Bayer14 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
|
| 167 |
+
cudaEglColorFormatBayer20RGGB = 61, /**< Bayer20 format - one channel in one surface with interleaved RGGB ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
|
| 168 |
+
cudaEglColorFormatBayer20BGGR = 62, /**< Bayer20 format - one channel in one surface with interleaved BGGR ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
|
| 169 |
+
cudaEglColorFormatBayer20GRBG = 63, /**< Bayer20 format - one channel in one surface with interleaved GRBG ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
|
| 170 |
+
cudaEglColorFormatBayer20GBRG = 64, /**< Bayer20 format - one channel in one surface with interleaved GBRG ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
|
| 171 |
+
cudaEglColorFormatYVU444Planar = 65, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height. */
|
| 172 |
+
cudaEglColorFormatYVU422Planar = 66, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height. */
|
| 173 |
+
cudaEglColorFormatYVU420Planar = 67, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 174 |
+
cudaEglColorFormatBayerIspRGGB = 68, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved RGGB ordering and mapped to opaque integer datatype. */
|
| 175 |
+
cudaEglColorFormatBayerIspBGGR = 69, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved BGGR ordering and mapped to opaque integer datatype. */
|
| 176 |
+
cudaEglColorFormatBayerIspGRBG = 70, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GRBG ordering and mapped to opaque integer datatype. */
|
| 177 |
+
cudaEglColorFormatBayerIspGBRG = 71, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GBRG ordering and mapped to opaque integer datatype. */
|
| 178 |
+
cudaEglColorFormatBayerBCCR = 72, /**< Bayer format - one channel in one surface with interleaved BCCR ordering. */
|
| 179 |
+
cudaEglColorFormatBayerRCCB = 73, /**< Bayer format - one channel in one surface with interleaved RCCB ordering. */
|
| 180 |
+
cudaEglColorFormatBayerCRBC = 74, /**< Bayer format - one channel in one surface with interleaved CRBC ordering. */
|
| 181 |
+
cudaEglColorFormatBayerCBRC = 75, /**< Bayer format - one channel in one surface with interleaved CBRC ordering. */
|
| 182 |
+
cudaEglColorFormatBayer10CCCC = 76, /**< Bayer10 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
|
| 183 |
+
cudaEglColorFormatBayer12BCCR = 77, /**< Bayer12 format - one channel in one surface with interleaved BCCR ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 184 |
+
cudaEglColorFormatBayer12RCCB = 78, /**< Bayer12 format - one channel in one surface with interleaved RCCB ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 185 |
+
cudaEglColorFormatBayer12CRBC = 79, /**< Bayer12 format - one channel in one surface with interleaved CRBC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 186 |
+
cudaEglColorFormatBayer12CBRC = 80, /**< Bayer12 format - one channel in one surface with interleaved CBRC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 187 |
+
cudaEglColorFormatBayer12CCCC = 81, /**< Bayer12 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
|
| 188 |
+
cudaEglColorFormatY = 82, /**< Color format for single Y plane. */
|
| 189 |
+
cudaEglColorFormatYUV420SemiPlanar_2020 = 83, /**< Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 190 |
+
cudaEglColorFormatYVU420SemiPlanar_2020 = 84, /**< Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 191 |
+
cudaEglColorFormatYUV420Planar_2020 = 85, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 192 |
+
cudaEglColorFormatYVU420Planar_2020 = 86, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 193 |
+
cudaEglColorFormatYUV420SemiPlanar_709 = 87, /**< Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 194 |
+
cudaEglColorFormatYVU420SemiPlanar_709 = 88, /**< Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 195 |
+
cudaEglColorFormatYUV420Planar_709 = 89, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 196 |
+
cudaEglColorFormatYVU420Planar_709 = 90, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 197 |
+
cudaEglColorFormatY10V10U10_420SemiPlanar_709 = 91, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 198 |
+
cudaEglColorFormatY10V10U10_420SemiPlanar_2020 = 92, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 199 |
+
cudaEglColorFormatY10V10U10_422SemiPlanar_2020 = 93, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
|
| 200 |
+
cudaEglColorFormatY10V10U10_422SemiPlanar = 94, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
|
| 201 |
+
cudaEglColorFormatY10V10U10_422SemiPlanar_709 = 95, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
|
| 202 |
+
cudaEglColorFormatY_ER = 96, /**< Extended Range Color format for single Y plane. */
|
| 203 |
+
cudaEglColorFormatY_709_ER = 97, /**< Extended Range Color format for single Y plane. */
|
| 204 |
+
cudaEglColorFormatY10_ER = 98, /**< Extended Range Color format for single Y10 plane. */
|
| 205 |
+
cudaEglColorFormatY10_709_ER = 99, /**< Extended Range Color format for single Y10 plane. */
|
| 206 |
+
cudaEglColorFormatY12_ER = 100, /**< Extended Range Color format for single Y12 plane. */
|
| 207 |
+
cudaEglColorFormatY12_709_ER = 101, /**< Extended Range Color format for single Y12 plane. */
|
| 208 |
+
cudaEglColorFormatYUVA = 102, /**< Y, U, V, A four channels in one surface, interleaved as AVUY. */
|
| 209 |
+
cudaEglColorFormatYVYU = 104, /**< Y, U, V in one surface, interleaved as YVYU in one channel. */
|
| 210 |
+
cudaEglColorFormatVYUY = 105, /**< Y, U, V in one surface, interleaved as VYUY in one channel. */
|
| 211 |
+
cudaEglColorFormatY10V10U10_420SemiPlanar_ER = 106, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 212 |
+
cudaEglColorFormatY10V10U10_420SemiPlanar_709_ER = 107, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 213 |
+
cudaEglColorFormatY10V10U10_444SemiPlanar_ER = 108, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
|
| 214 |
+
cudaEglColorFormatY10V10U10_444SemiPlanar_709_ER = 109, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
|
| 215 |
+
cudaEglColorFormatY12V12U12_420SemiPlanar_ER = 110, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 216 |
+
cudaEglColorFormatY12V12U12_420SemiPlanar_709_ER = 111, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
|
| 217 |
+
cudaEglColorFormatY12V12U12_444SemiPlanar_ER = 112, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
|
| 218 |
+
cudaEglColorFormatY12V12U12_444SemiPlanar_709_ER = 113, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
|
| 219 |
+
cudaEglColorFormatUYVY709 = 114, /**< Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 220 |
+
cudaEglColorFormatUYVY709_ER = 115, /**< Extended Range Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 221 |
+
cudaEglColorFormatUYVY2020 = 116, /**< Y, U, V in one surface, interleaved as UYVY in one channel. */
|
| 222 |
+
} cudaEglColorFormat;
|
| 223 |
+
|
| 224 |
+
/**
|
| 225 |
+
* CUDA EGL Plane Descriptor - structure defining each plane of a CUDA EGLFrame
|
| 226 |
+
*/
|
| 227 |
+
typedef struct cudaEglPlaneDesc_st {
|
| 228 |
+
unsigned int width; /**< Width of plane */
|
| 229 |
+
unsigned int height; /**< Height of plane */
|
| 230 |
+
unsigned int depth; /**< Depth of plane */
|
| 231 |
+
unsigned int pitch; /**< Pitch of plane */
|
| 232 |
+
unsigned int numChannels; /**< Number of channels for the plane */
|
| 233 |
+
struct cudaChannelFormatDesc channelDesc; /**< Channel Format Descriptor */
|
| 234 |
+
unsigned int reserved[4]; /**< Reserved for future use */
|
| 235 |
+
} cudaEglPlaneDesc;
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* CUDA EGLFrame Descriptor - structure defining one frame of EGL.
|
| 239 |
+
*
|
| 240 |
+
* Each frame may contain one or more planes depending on whether the surface is Multiplanar or not.
|
| 241 |
+
* Each plane of EGLFrame is represented by ::cudaEglPlaneDesc which is defined as:
|
| 242 |
+
* \code
|
| 243 |
+
* typedef struct cudaEglPlaneDesc_st {
|
| 244 |
+
* unsigned int width;
|
| 245 |
+
* unsigned int height;
|
| 246 |
+
* unsigned int depth;
|
| 247 |
+
* unsigned int pitch;
|
| 248 |
+
* unsigned int numChannels;
|
| 249 |
+
* struct cudaChannelFormatDesc channelDesc;
|
| 250 |
+
* unsigned int reserved[4];
|
| 251 |
+
* } cudaEglPlaneDesc;
|
| 252 |
+
* \endcode
|
| 253 |
+
|
| 254 |
+
*/
|
| 255 |
+
typedef struct cudaEglFrame_st {
|
| 256 |
+
union {
|
| 257 |
+
cudaArray_t pArray[CUDA_EGL_MAX_PLANES]; /**< Array of CUDA arrays corresponding to each plane*/
|
| 258 |
+
struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES]; /**< Array of Pointers corresponding to each plane*/
|
| 259 |
+
} frame;
|
| 260 |
+
cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES]; /**< CUDA EGL Plane Descriptor ::cudaEglPlaneDesc*/
|
| 261 |
+
unsigned int planeCount; /**< Number of planes */
|
| 262 |
+
cudaEglFrameType frameType; /**< Array or Pitch */
|
| 263 |
+
cudaEglColorFormat eglColorFormat; /**< CUDA EGL Color Format*/
|
| 264 |
+
} cudaEglFrame;
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* CUDA EGLSream Connection
|
| 268 |
+
*/
|
| 269 |
+
typedef struct CUeglStreamConnection_st *cudaEglStreamConnection;
|
| 270 |
+
|
| 271 |
+
/** @} */ /* END CUDART_TYPES */
|
| 272 |
+
|
| 273 |
+
/**
|
| 274 |
+
* \addtogroup CUDART_EGL EGL Interoperability
|
| 275 |
+
* This section describes the EGL interoperability functions of the CUDA
|
| 276 |
+
* runtime application programming interface.
|
| 277 |
+
*
|
| 278 |
+
* @{
|
| 279 |
+
*/
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* \brief Registers an EGL image
|
| 283 |
+
*
|
| 284 |
+
* Registers the EGLImageKHR specified by \p image for access by
|
| 285 |
+
* CUDA. A handle to the registered object is returned as \p pCudaResource.
|
| 286 |
+
* Additional Mapping/Unmapping is not required for the registered resource and
|
| 287 |
+
* ::cudaGraphicsResourceGetMappedEglFrame can be directly called on the \p pCudaResource.
|
| 288 |
+
*
|
| 289 |
+
* The application will be responsible for synchronizing access to shared objects.
|
| 290 |
+
* The application must ensure that any pending operation which access the objects have completed
|
| 291 |
+
* before passing control to CUDA. This may be accomplished by issuing and waiting for
|
| 292 |
+
* glFinish command on all GLcontexts (for OpenGL and likewise for other APIs).
|
| 293 |
+
* The application will be also responsible for ensuring that any pending operation on the
|
| 294 |
+
* registered CUDA resource has completed prior to executing subsequent commands in other APIs
|
| 295 |
+
* accesing the same memory objects.
|
| 296 |
+
* This can be accomplished by calling cuCtxSynchronize or cuEventSynchronize (preferably).
|
| 297 |
+
*
|
| 298 |
+
* The surface's intended usage is specified using \p flags, as follows:
|
| 299 |
+
*
|
| 300 |
+
* - ::cudaGraphicsRegisterFlagsNone: Specifies no hints about how this
|
| 301 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 302 |
+
* read from and written to by CUDA. This is the default value.
|
| 303 |
+
* - ::cudaGraphicsRegisterFlagsReadOnly: Specifies that CUDA
|
| 304 |
+
* will not write to this resource.
|
| 305 |
+
* - ::cudaGraphicsRegisterFlagsWriteDiscard: Specifies that
|
| 306 |
+
* CUDA will not read from this resource and will write over the
|
| 307 |
+
* entire contents of the resource, so none of the data previously
|
| 308 |
+
* stored in the resource will be preserved.
|
| 309 |
+
*
|
| 310 |
+
* The EGLImageKHR is an object which can be used to create EGLImage target resource. It is defined as a void pointer.
|
| 311 |
+
* typedef void* EGLImageKHR
|
| 312 |
+
*
|
| 313 |
+
* \param pCudaResource - Pointer to the returned object handle
|
| 314 |
+
* \param image - An EGLImageKHR image which can be used to create target resource.
|
| 315 |
+
* \param flags - Map flags
|
| 316 |
+
*
|
| 317 |
+
* \return
|
| 318 |
+
* ::cudaSuccess,
|
| 319 |
+
* ::cudaErrorInvalidResourceHandle,
|
| 320 |
+
* ::cudaErrorInvalidValue,
|
| 321 |
+
* ::cudaErrorUnknown
|
| 322 |
+
*
|
| 323 |
+
* \sa
|
| 324 |
+
* ::cudaGraphicsUnregisterResource,
|
| 325 |
+
* ::cudaGraphicsResourceGetMappedEglFrame,
|
| 326 |
+
* ::cuGraphicsEGLRegisterImage
|
| 327 |
+
*/
|
| 328 |
+
extern __host__ cudaError_t CUDARTAPI cudaGraphicsEGLRegisterImage(struct cudaGraphicsResource **pCudaResource, EGLImageKHR image, unsigned int flags);
|
| 329 |
+
|
| 330 |
+
/**
|
| 331 |
+
* \brief Connect CUDA to EGLStream as a consumer.
|
| 332 |
+
*
|
| 333 |
+
* Connect CUDA as a consumer to EGLStreamKHR specified by \p eglStream.
|
| 334 |
+
*
|
| 335 |
+
* The EGLStreamKHR is an EGL object that transfers a sequence of image frames from one
|
| 336 |
+
* API to another.
|
| 337 |
+
*
|
| 338 |
+
* \param conn - Pointer to the returned connection handle
|
| 339 |
+
* \param eglStream - EGLStreamKHR handle
|
| 340 |
+
*
|
| 341 |
+
* \return
|
| 342 |
+
* ::cudaSuccess,
|
| 343 |
+
* ::cudaErrorInvalidValue,
|
| 344 |
+
* ::cudaErrorUnknown
|
| 345 |
+
*
|
| 346 |
+
* \sa
|
| 347 |
+
* ::cudaEGLStreamConsumerDisconnect,
|
| 348 |
+
* ::cudaEGLStreamConsumerAcquireFrame,
|
| 349 |
+
* ::cudaEGLStreamConsumerReleaseFrame,
|
| 350 |
+
* ::cuEGLStreamConsumerConnect
|
| 351 |
+
*/
|
| 352 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerConnect(cudaEglStreamConnection *conn, EGLStreamKHR eglStream);
|
| 353 |
+
|
| 354 |
+
/**
|
| 355 |
+
* \brief Connect CUDA to EGLStream as a consumer with given flags.
|
| 356 |
+
*
|
| 357 |
+
* Connect CUDA as a consumer to EGLStreamKHR specified by \p stream with specified \p flags defined by
|
| 358 |
+
* ::cudaEglResourceLocationFlags.
|
| 359 |
+
*
|
| 360 |
+
* The flags specify whether the consumer wants to access frames from system memory or video memory.
|
| 361 |
+
* Default is ::cudaEglResourceLocationVidmem.
|
| 362 |
+
*
|
| 363 |
+
* \param conn - Pointer to the returned connection handle
|
| 364 |
+
* \param eglStream - EGLStreamKHR handle
|
| 365 |
+
* \param flags - Flags denote intended location - system or video.
|
| 366 |
+
*
|
| 367 |
+
* \return
|
| 368 |
+
* ::cudaSuccess,
|
| 369 |
+
* ::cudaErrorInvalidValue,
|
| 370 |
+
* ::cudaErrorUnknown
|
| 371 |
+
*
|
| 372 |
+
* \sa
|
| 373 |
+
* ::cudaEGLStreamConsumerDisconnect,
|
| 374 |
+
* ::cudaEGLStreamConsumerAcquireFrame,
|
| 375 |
+
* ::cudaEGLStreamConsumerReleaseFrame,
|
| 376 |
+
* ::cuEGLStreamConsumerConnectWithFlags
|
| 377 |
+
*/
|
| 378 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerConnectWithFlags(cudaEglStreamConnection *conn, EGLStreamKHR eglStream, unsigned int flags);
|
| 379 |
+
|
| 380 |
+
/**
|
| 381 |
+
* \brief Disconnect CUDA as a consumer to EGLStream .
|
| 382 |
+
*
|
| 383 |
+
* Disconnect CUDA as a consumer to EGLStreamKHR.
|
| 384 |
+
*
|
| 385 |
+
* \param conn - Conection to disconnect.
|
| 386 |
+
*
|
| 387 |
+
* \return
|
| 388 |
+
* ::cudaSuccess,
|
| 389 |
+
* ::cudaErrorInvalidValue,
|
| 390 |
+
* ::cudaErrorUnknown
|
| 391 |
+
*
|
| 392 |
+
* \sa
|
| 393 |
+
* ::cudaEGLStreamConsumerConnect,
|
| 394 |
+
* ::cudaEGLStreamConsumerAcquireFrame,
|
| 395 |
+
* ::cudaEGLStreamConsumerReleaseFrame,
|
| 396 |
+
* ::cuEGLStreamConsumerDisconnect
|
| 397 |
+
*/
|
| 398 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerDisconnect(cudaEglStreamConnection *conn);
|
| 399 |
+
|
| 400 |
+
/**
|
| 401 |
+
* \brief Acquire an image frame from the EGLStream with CUDA as a consumer.
|
| 402 |
+
*
|
| 403 |
+
* Acquire an image frame from EGLStreamKHR.
|
| 404 |
+
* ::cudaGraphicsResourceGetMappedEglFrame can be called on \p pCudaResource to get
|
| 405 |
+
* ::cudaEglFrame.
|
| 406 |
+
*
|
| 407 |
+
* \param conn - Connection on which to acquire
|
| 408 |
+
* \param pCudaResource - CUDA resource on which the EGLStream frame will be mapped for use.
|
| 409 |
+
* \param pStream - CUDA stream for synchronization and any data migrations
|
| 410 |
+
* implied by ::cudaEglResourceLocationFlags.
|
| 411 |
+
* \param timeout - Desired timeout in usec.
|
| 412 |
+
*
|
| 413 |
+
* \return
|
| 414 |
+
* ::cudaSuccess,
|
| 415 |
+
* ::cudaErrorInvalidValue,
|
| 416 |
+
* ::cudaErrorUnknown,
|
| 417 |
+
* ::cudaErrorLaunchTimeout
|
| 418 |
+
*
|
| 419 |
+
* \sa
|
| 420 |
+
* ::cudaEGLStreamConsumerConnect,
|
| 421 |
+
* ::cudaEGLStreamConsumerDisconnect,
|
| 422 |
+
* ::cudaEGLStreamConsumerReleaseFrame,
|
| 423 |
+
* ::cuEGLStreamConsumerAcquireFrame
|
| 424 |
+
*/
|
| 425 |
+
|
| 426 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerAcquireFrame(cudaEglStreamConnection *conn,
|
| 427 |
+
cudaGraphicsResource_t *pCudaResource, cudaStream_t *pStream, unsigned int timeout);
|
| 428 |
+
/**
|
| 429 |
+
* \brief Releases the last frame acquired from the EGLStream.
|
| 430 |
+
*
|
| 431 |
+
* Release the acquired image frame specified by \p pCudaResource to EGLStreamKHR.
|
| 432 |
+
*
|
| 433 |
+
* \param conn - Connection on which to release
|
| 434 |
+
* \param pCudaResource - CUDA resource whose corresponding frame is to be released
|
| 435 |
+
* \param pStream - CUDA stream on which release will be done.
|
| 436 |
+
*
|
| 437 |
+
* \return
|
| 438 |
+
* ::cudaSuccess,
|
| 439 |
+
* ::cudaErrorInvalidValue,
|
| 440 |
+
* ::cudaErrorUnknown
|
| 441 |
+
*
|
| 442 |
+
* \sa
|
| 443 |
+
* ::cudaEGLStreamConsumerConnect,
|
| 444 |
+
* ::cudaEGLStreamConsumerDisconnect,
|
| 445 |
+
* ::cudaEGLStreamConsumerAcquireFrame,
|
| 446 |
+
* ::cuEGLStreamConsumerReleaseFrame
|
| 447 |
+
*/
|
| 448 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerReleaseFrame(cudaEglStreamConnection *conn,
|
| 449 |
+
cudaGraphicsResource_t pCudaResource, cudaStream_t *pStream);
|
| 450 |
+
|
| 451 |
+
/**
|
| 452 |
+
* \brief Connect CUDA to EGLStream as a producer.
|
| 453 |
+
*
|
| 454 |
+
* Connect CUDA as a producer to EGLStreamKHR specified by \p stream.
|
| 455 |
+
*
|
| 456 |
+
* The EGLStreamKHR is an EGL object that transfers a sequence of image frames from one
|
| 457 |
+
* API to another.
|
| 458 |
+
*
|
| 459 |
+
* \param conn - Pointer to the returned connection handle
|
| 460 |
+
* \param eglStream - EGLStreamKHR handle
|
| 461 |
+
* \param width - width of the image to be submitted to the stream
|
| 462 |
+
* \param height - height of the image to be submitted to the stream
|
| 463 |
+
*
|
| 464 |
+
* \return
|
| 465 |
+
* ::cudaSuccess,
|
| 466 |
+
* ::cudaErrorInvalidValue,
|
| 467 |
+
* ::cudaErrorUnknown
|
| 468 |
+
*
|
| 469 |
+
* \sa
|
| 470 |
+
* ::cudaEGLStreamProducerDisconnect,
|
| 471 |
+
* ::cudaEGLStreamProducerPresentFrame,
|
| 472 |
+
* ::cudaEGLStreamProducerReturnFrame,
|
| 473 |
+
* ::cuEGLStreamProducerConnect
|
| 474 |
+
*/
|
| 475 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerConnect(cudaEglStreamConnection *conn,
|
| 476 |
+
EGLStreamKHR eglStream, EGLint width, EGLint height);
|
| 477 |
+
|
| 478 |
+
/**
|
| 479 |
+
* \brief Disconnect CUDA as a producer to EGLStream .
|
| 480 |
+
*
|
| 481 |
+
* Disconnect CUDA as a producer to EGLStreamKHR.
|
| 482 |
+
*
|
| 483 |
+
* \param conn - Conection to disconnect.
|
| 484 |
+
*
|
| 485 |
+
* \return
|
| 486 |
+
* ::cudaSuccess,
|
| 487 |
+
* ::cudaErrorInvalidValue,
|
| 488 |
+
* ::cudaErrorUnknown
|
| 489 |
+
*
|
| 490 |
+
* \sa
|
| 491 |
+
* ::cudaEGLStreamProducerConnect,
|
| 492 |
+
* ::cudaEGLStreamProducerPresentFrame,
|
| 493 |
+
* ::cudaEGLStreamProducerReturnFrame,
|
| 494 |
+
* ::cuEGLStreamProducerDisconnect
|
| 495 |
+
*/
|
| 496 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerDisconnect(cudaEglStreamConnection *conn);
|
| 497 |
+
|
| 498 |
+
/**
|
| 499 |
+
* \brief Present a CUDA eglFrame to the EGLStream with CUDA as a producer.
|
| 500 |
+
*
|
| 501 |
+
* The ::cudaEglFrame is defined as:
|
| 502 |
+
* \code
|
| 503 |
+
* typedef struct cudaEglFrame_st {
|
| 504 |
+
* union {
|
| 505 |
+
* cudaArray_t pArray[CUDA_EGL_MAX_PLANES];
|
| 506 |
+
* struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES];
|
| 507 |
+
* } frame;
|
| 508 |
+
* cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES];
|
| 509 |
+
* unsigned int planeCount;
|
| 510 |
+
* cudaEglFrameType frameType;
|
| 511 |
+
* cudaEglColorFormat eglColorFormat;
|
| 512 |
+
* } cudaEglFrame;
|
| 513 |
+
* \endcode
|
| 514 |
+
*
|
| 515 |
+
* For ::cudaEglFrame of type ::cudaEglFrameTypePitch, the application may present sub-region of a memory
|
| 516 |
+
* allocation. In that case, ::cudaPitchedPtr::ptr will specify the start address of the sub-region in
|
| 517 |
+
* the allocation and ::cudaEglPlaneDesc will specify the dimensions of the sub-region.
|
| 518 |
+
*
|
| 519 |
+
* \param conn - Connection on which to present the CUDA array
|
| 520 |
+
* \param eglframe - CUDA Eglstream Proucer Frame handle to be sent to the consumer over EglStream.
|
| 521 |
+
* \param pStream - CUDA stream on which to present the frame.
|
| 522 |
+
*
|
| 523 |
+
* \return
|
| 524 |
+
* ::cudaSuccess,
|
| 525 |
+
* ::cudaErrorInvalidValue,
|
| 526 |
+
* ::cudaErrorUnknown
|
| 527 |
+
*
|
| 528 |
+
* \sa
|
| 529 |
+
* ::cudaEGLStreamProducerConnect,
|
| 530 |
+
* ::cudaEGLStreamProducerDisconnect,
|
| 531 |
+
* ::cudaEGLStreamProducerReturnFrame,
|
| 532 |
+
* ::cuEGLStreamProducerPresentFrame
|
| 533 |
+
*/
|
| 534 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerPresentFrame(cudaEglStreamConnection *conn,
|
| 535 |
+
cudaEglFrame eglframe, cudaStream_t *pStream);
|
| 536 |
+
|
| 537 |
+
/**
|
| 538 |
+
* \brief Return the CUDA eglFrame to the EGLStream last released by the consumer.
|
| 539 |
+
*
|
| 540 |
+
* This API can potentially return cudaErrorLaunchTimeout if the consumer has not
|
| 541 |
+
* returned a frame to EGL stream. If timeout is returned the application can retry.
|
| 542 |
+
*
|
| 543 |
+
* \param conn - Connection on which to present the CUDA array
|
| 544 |
+
* \param eglframe - CUDA Eglstream Proucer Frame handle returned from the consumer over EglStream.
|
| 545 |
+
* \param pStream - CUDA stream on which to return the frame.
|
| 546 |
+
*
|
| 547 |
+
* \return
|
| 548 |
+
* ::cudaSuccess,
|
| 549 |
+
* ::cudaErrorLaunchTimeout,
|
| 550 |
+
* ::cudaErrorInvalidValue,
|
| 551 |
+
* ::cudaErrorUnknown
|
| 552 |
+
*
|
| 553 |
+
* \sa
|
| 554 |
+
* ::cudaEGLStreamProducerConnect,
|
| 555 |
+
* ::cudaEGLStreamProducerDisconnect,
|
| 556 |
+
* ::cudaEGLStreamProducerPresentFrame,
|
| 557 |
+
* ::cuEGLStreamProducerReturnFrame
|
| 558 |
+
*/
|
| 559 |
+
extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerReturnFrame(cudaEglStreamConnection *conn,
|
| 560 |
+
cudaEglFrame *eglframe, cudaStream_t *pStream);
|
| 561 |
+
|
| 562 |
+
/**
|
| 563 |
+
* \brief Get an eglFrame through which to access a registered EGL graphics resource.
|
| 564 |
+
*
|
| 565 |
+
* Returns in \p *eglFrame an eglFrame pointer through which the registered graphics resource
|
| 566 |
+
* \p resource may be accessed.
|
| 567 |
+
* This API can only be called for EGL graphics resources.
|
| 568 |
+
*
|
| 569 |
+
* The ::cudaEglFrame is defined as
|
| 570 |
+
* \code
|
| 571 |
+
* typedef struct cudaEglFrame_st {
|
| 572 |
+
* union {
|
| 573 |
+
* cudaArray_t pArray[CUDA_EGL_MAX_PLANES];
|
| 574 |
+
* struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES];
|
| 575 |
+
* } frame;
|
| 576 |
+
* cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES];
|
| 577 |
+
* unsigned int planeCount;
|
| 578 |
+
* cudaEglFrameType frameType;
|
| 579 |
+
* cudaEglColorFormat eglColorFormat;
|
| 580 |
+
* } cudaEglFrame;
|
| 581 |
+
* \endcode
|
| 582 |
+
*
|
| 583 |
+
*
|
| 584 |
+
* \param eglFrame - Returned eglFrame.
|
| 585 |
+
* \param resource - Registered resource to access.
|
| 586 |
+
* \param index - Index for cubemap surfaces.
|
| 587 |
+
* \param mipLevel - Mipmap level for the subresource to access.
|
| 588 |
+
*
|
| 589 |
+
* \return
|
| 590 |
+
* ::cudaSuccess,
|
| 591 |
+
* ::cudaErrorInvalidValue,
|
| 592 |
+
* ::cudaErrorUnknown
|
| 593 |
+
*
|
| 594 |
+
* \note Note that in case of multiplanar \p *eglFrame, pitch of only first plane (unsigned int cudaEglPlaneDesc::pitch) is to be considered by the application.
|
| 595 |
+
*
|
| 596 |
+
* \sa
|
| 597 |
+
* ::cudaGraphicsSubResourceGetMappedArray,
|
| 598 |
+
* ::cudaGraphicsResourceGetMappedPointer,
|
| 599 |
+
* ::cuGraphicsResourceGetMappedEglFrame
|
| 600 |
+
*/
|
| 601 |
+
extern __host__ cudaError_t CUDARTAPI cudaGraphicsResourceGetMappedEglFrame(cudaEglFrame* eglFrame,
|
| 602 |
+
cudaGraphicsResource_t resource, unsigned int index, unsigned int mipLevel);
|
| 603 |
+
|
| 604 |
+
/**
|
| 605 |
+
* \brief Creates an event from EGLSync object
|
| 606 |
+
*
|
| 607 |
+
* Creates an event *phEvent from an EGLSyncKHR eglSync with the flages specified
|
| 608 |
+
* via \p flags. Valid flags include:
|
| 609 |
+
* - ::cudaEventDefault: Default event creation flag.
|
| 610 |
+
* - ::cudaEventBlockingSync: Specifies that the created event should use blocking
|
| 611 |
+
* synchronization. A CPU thread that uses ::cudaEventSynchronize() to wait on
|
| 612 |
+
* an event created with this flag will block until the event has actually
|
| 613 |
+
* been completed.
|
| 614 |
+
*
|
| 615 |
+
* ::cudaEventRecord and TimingData are not supported for events created from EGLSync.
|
| 616 |
+
*
|
| 617 |
+
* The EGLSyncKHR is an opaque handle to an EGL sync object.
|
| 618 |
+
* typedef void* EGLSyncKHR
|
| 619 |
+
*
|
| 620 |
+
* \param phEvent - Returns newly created event
|
| 621 |
+
* \param eglSync - Opaque handle to EGLSync object
|
| 622 |
+
* \param flags - Event creation flags
|
| 623 |
+
*
|
| 624 |
+
* \return
|
| 625 |
+
* ::cudaSuccess,
|
| 626 |
+
* ::cudaErrorInitializationError,
|
| 627 |
+
* ::cudaErrorInvalidValue,
|
| 628 |
+
* ::cudaErrorLaunchFailure,
|
| 629 |
+
* ::cudaErrorMemoryAllocation
|
| 630 |
+
*
|
| 631 |
+
* \sa
|
| 632 |
+
* ::cudaEventQuery,
|
| 633 |
+
* ::cudaEventSynchronize,
|
| 634 |
+
* ::cudaEventDestroy
|
| 635 |
+
*/
|
| 636 |
+
extern __host__ cudaError_t CUDARTAPI cudaEventCreateFromEGLSync(cudaEvent_t *phEvent, EGLSyncKHR eglSync, unsigned int flags);
|
| 637 |
+
|
| 638 |
+
/** @} */ /* END CUDART_EGL */
|
| 639 |
+
|
| 640 |
+
#if defined(__cplusplus)
|
| 641 |
+
}
|
| 642 |
+
#endif /* __cplusplus */
|
| 643 |
+
|
| 644 |
+
#endif /* __CUDA_EGL_INTEROP_H__ */
|
| 645 |
+
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp16.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp16.hpp
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp4.h
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2024 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef __CUDA_FP4_H__
|
| 51 |
+
#define __CUDA_FP4_H__
|
| 52 |
+
|
| 53 |
+
/* Set up function decorations */
|
| 54 |
+
#if defined(__CUDACC__)
|
| 55 |
+
#define __CUDA_FP4_DECL__ static __device__ __inline__
|
| 56 |
+
#define __CUDA_HOSTDEVICE_FP4__ __host__ __device__
|
| 57 |
+
#define __CUDA_HOSTDEVICE_FP4_DECL__ static __host__ __device__ __inline__
|
| 58 |
+
#else /* !defined(__CUDACC__) */
|
| 59 |
+
#if defined(__GNUC__)
|
| 60 |
+
#define __CUDA_HOSTDEVICE_FP4_DECL__ static __attribute__((unused))
|
| 61 |
+
#else
|
| 62 |
+
#define __CUDA_HOSTDEVICE_FP4_DECL__ static
|
| 63 |
+
#endif /* defined(__GNUC__) */
|
| 64 |
+
#define __CUDA_HOSTDEVICE_FP4__
|
| 65 |
+
#endif /* defined(__CUDACC_) */
|
| 66 |
+
|
| 67 |
+
#if !defined(_MSC_VER) && __cplusplus >= 201103L
|
| 68 |
+
#define __CPP_VERSION_AT_LEAST_11_FP4
|
| 69 |
+
#elif _MSC_FULL_VER >= 190024210 && _MSVC_LANG >= 201103L
|
| 70 |
+
#define __CPP_VERSION_AT_LEAST_11_FP4
|
| 71 |
+
#endif
|
| 72 |
+
|
| 73 |
+
/* bring in fp6 types infrastructure and dependencies */
|
| 74 |
+
#include "cuda_fp6.h"
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* \defgroup CUDA_MATH_INTRINSIC_FP4 FP4 Intrinsics
|
| 78 |
+
* This section describes fp4 intrinsic functions.
|
| 79 |
+
* To use these functions, include the header file \p cuda_fp4.h in your
|
| 80 |
+
* program.
|
| 81 |
+
*
|
| 82 |
+
* \note Most of the operations defined here benefit from native HW support
|
| 83 |
+
* when compiled for specific GPU targets (e.g. devices of compute capability 10.0a),
|
| 84 |
+
* other targets use emulation path.
|
| 85 |
+
*
|
| 86 |
+
* The following macros are available to help users selectively enable/disable
|
| 87 |
+
* various definitions present in the header file:
|
| 88 |
+
* - \p __CUDA_NO_FP4_CONVERSIONS__ - If defined, this macro will prevent any
|
| 89 |
+
* use of the C++ type conversions (converting constructors and conversion
|
| 90 |
+
* operators) defined in the header.
|
| 91 |
+
* - \p __CUDA_NO_FP4_CONVERSION_OPERATORS__ - If defined, this macro will
|
| 92 |
+
* prevent any use of the C++ conversion operators from \p fp4 to other types.
|
| 93 |
+
*/
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* \defgroup CUDA_MATH_FP4_MISC FP4 Conversion and Data Movement
|
| 97 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP4
|
| 98 |
+
* To use these functions, include the header file \p cuda_fp4.h in your
|
| 99 |
+
* program.
|
| 100 |
+
*/
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 104 |
+
* \brief 8-bit \p unsigned \p integer
|
| 105 |
+
* type abstraction used for \p fp4 floating-point
|
| 106 |
+
* numbers storage.
|
| 107 |
+
*/
|
| 108 |
+
typedef __nv_fp8_storage_t __nv_fp4_storage_t;
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 112 |
+
* \brief 8-bit \p unsigned \p integer
|
| 113 |
+
* type abstraction used for storage of pairs of
|
| 114 |
+
* \p fp4 floating-point numbers.
|
| 115 |
+
*/
|
| 116 |
+
typedef __nv_fp8_storage_t __nv_fp4x2_storage_t;
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 120 |
+
* \brief 16-bit \p unsigned \p integer
|
| 121 |
+
* type abstraction used for storage of tetrads of
|
| 122 |
+
* \p fp4 floating-point numbers.
|
| 123 |
+
*/
|
| 124 |
+
typedef __nv_fp8x2_storage_t __nv_fp4x4_storage_t;
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 128 |
+
* \brief Enumerates the possible
|
| 129 |
+
* interpretations of the 4-bit values when referring to them as
|
| 130 |
+
* \p fp4 types.
|
| 131 |
+
*/
|
| 132 |
+
typedef enum __nv_fp4_interpretation_t {
|
| 133 |
+
__NV_E2M1, /**< Stands for \p fp4 numbers of \p e2m1 kind. */
|
| 134 |
+
} __nv_fp4_interpretation_t;
|
| 135 |
+
|
| 136 |
+
/* Forward-declaration of C-style APIs */
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 140 |
+
* \brief Converts input \p double precision \p x to \p fp4 type of the
|
| 141 |
+
* requested kind using specified rounding mode and saturating
|
| 142 |
+
* the out-of-range values.
|
| 143 |
+
*
|
| 144 |
+
* \details Converts input \p x to \p fp4 type of the kind specified by
|
| 145 |
+
* \p fp4_interpretation parameter,
|
| 146 |
+
* using rounding mode specified by \p rounding parameter.
|
| 147 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 148 |
+
* \p NaN input values result in positive MAXNORM.
|
| 149 |
+
*
|
| 150 |
+
* \returns
|
| 151 |
+
* - The \p __nv_fp4_storage_t value holds the result of conversion.
|
| 152 |
+
*/
|
| 153 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t
|
| 154 |
+
__nv_cvt_double_to_fp4(const double x,
|
| 155 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 156 |
+
const enum cudaRoundMode rounding);
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 160 |
+
* \brief Converts input vector of two \p double precision numbers packed
|
| 161 |
+
* in \p double2 \p x into a vector of two values of \p fp4 type of the
|
| 162 |
+
* requested kind using specified rounding mode and saturating
|
| 163 |
+
* the out-of-range values.
|
| 164 |
+
*
|
| 165 |
+
* \details Converts input vector \p x to a vector of two \p fp4 values of the
|
| 166 |
+
* kind specified by \p fp4_interpretation parameter, using
|
| 167 |
+
* rounding mode specified by \p rounding parameter.
|
| 168 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 169 |
+
* \p NaN input values result in positive MAXNORM.
|
| 170 |
+
*
|
| 171 |
+
* \returns
|
| 172 |
+
* - The \p __nv_fp4x2_storage_t value holds the result of conversion.
|
| 173 |
+
*/
|
| 174 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t
|
| 175 |
+
__nv_cvt_double2_to_fp4x2(const double2 x,
|
| 176 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 177 |
+
const enum cudaRoundMode rounding);
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 181 |
+
* \brief Converts input \p single precision \p x to \p fp4 type of the
|
| 182 |
+
* requested kind using specified rounding mode and saturating
|
| 183 |
+
* the out-of-range values.
|
| 184 |
+
*
|
| 185 |
+
* \details Converts input \p x to \p fp4 type of the kind specified by
|
| 186 |
+
* \p fp4_interpretation parameter, using
|
| 187 |
+
* rounding mode specified by \p rounding parameter.
|
| 188 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 189 |
+
* \p NaN input values result in positive MAXNORM.
|
| 190 |
+
*
|
| 191 |
+
* \returns
|
| 192 |
+
* - The \p __nv_fp4_storage_t value holds the result of conversion.
|
| 193 |
+
*/
|
| 194 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t
|
| 195 |
+
__nv_cvt_float_to_fp4(const float x,
|
| 196 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 197 |
+
const enum cudaRoundMode rounding);
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 201 |
+
* \brief Converts input vector of two \p single precision numbers packed
|
| 202 |
+
* in \p float2 \p x into a vector of two values of \p fp4 type of the
|
| 203 |
+
* requested kind using specified rounding mode and saturating
|
| 204 |
+
* the out-of-range values.
|
| 205 |
+
*
|
| 206 |
+
* \details Converts input vector \p x to a vector of two \p fp4 values of the
|
| 207 |
+
* kind specified by \p fp4_interpretation parameter,
|
| 208 |
+
* using rounding mode specified by \p rounding parameter.
|
| 209 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 210 |
+
* \p NaN input values result in positive MAXNORM.
|
| 211 |
+
*
|
| 212 |
+
* \returns
|
| 213 |
+
* - The \p __nv_fp4x2_storage_t value holds the result of conversion.
|
| 214 |
+
*/
|
| 215 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t
|
| 216 |
+
__nv_cvt_float2_to_fp4x2(const float2 x,
|
| 217 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 218 |
+
const enum cudaRoundMode rounding);
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 222 |
+
* \brief Converts input \p half precision \p x to \p fp4 type of the
|
| 223 |
+
* requested kind using specified rounding mode and saturating
|
| 224 |
+
* the out-of-range values.
|
| 225 |
+
*
|
| 226 |
+
* \details Converts input \p x to \p fp4 type of the kind specified by
|
| 227 |
+
* \p fp4_interpretation parameter,
|
| 228 |
+
* using rounding mode specified by \p rounding parameter.
|
| 229 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 230 |
+
* \p NaN input values result in positive MAXNORM.
|
| 231 |
+
*
|
| 232 |
+
* \returns
|
| 233 |
+
* - The \p __nv_fp4_storage_t value holds the result of conversion.
|
| 234 |
+
*/
|
| 235 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t
|
| 236 |
+
__nv_cvt_halfraw_to_fp4(const __half_raw x,
|
| 237 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 238 |
+
const enum cudaRoundMode rounding);
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 242 |
+
* \brief Converts input vector of two \p half precision numbers packed
|
| 243 |
+
* in \p __half2_raw \p x into a vector of two values of \p fp4 type of the
|
| 244 |
+
* requested kind using specified rounding mode and saturating
|
| 245 |
+
* the out-of-range values.
|
| 246 |
+
*
|
| 247 |
+
* \details Converts input vector \p x to a vector of two \p fp4 values of the
|
| 248 |
+
* kind specified by \p fp4_interpretation parameter,
|
| 249 |
+
* using rounding mode specified by \p rounding parameter.
|
| 250 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 251 |
+
* \p NaN input values result in positive MAXNORM.
|
| 252 |
+
*
|
| 253 |
+
* \returns
|
| 254 |
+
* - The \p __nv_fp4x2_storage_t value holds the result of conversion.
|
| 255 |
+
*/
|
| 256 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t __nv_cvt_halfraw2_to_fp4x2(
|
| 257 |
+
const __half2_raw x,
|
| 258 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 259 |
+
const enum cudaRoundMode rounding);
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 263 |
+
* \brief Converts input \p nv_bfloat16 precision \p x to \p fp4 type of the
|
| 264 |
+
* requested kind using specified rounding mode and saturating
|
| 265 |
+
* the out-of-range values.
|
| 266 |
+
*
|
| 267 |
+
* \details Converts input \p x to \p fp4 type of the kind specified by
|
| 268 |
+
* \p fp4_interpretation parameter,
|
| 269 |
+
* using rounding mode specified by \p rounding parameter.
|
| 270 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 271 |
+
* \p NaN input values result in positive MAXNORM.
|
| 272 |
+
*
|
| 273 |
+
* \returns
|
| 274 |
+
* - The \p __nv_fp4_storage_t value holds the result of conversion.
|
| 275 |
+
*/
|
| 276 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t __nv_cvt_bfloat16raw_to_fp4(
|
| 277 |
+
const __nv_bfloat16_raw x,
|
| 278 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 279 |
+
const enum cudaRoundMode rounding);
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 283 |
+
* \brief Converts input vector of two \p nv_bfloat16 precision numbers packed
|
| 284 |
+
* in \p __nv_bfloat162_raw \p x into a vector of two values of \p fp4 type of the
|
| 285 |
+
* requested kind using specified rounding mode and saturating
|
| 286 |
+
* the out-of-range values.
|
| 287 |
+
*
|
| 288 |
+
* \details Converts input vector \p x to a vector of two \p fp4 values of the
|
| 289 |
+
* kind specified by \p fp4_interpretation parameter,
|
| 290 |
+
* using rounding mode specified by \p rounding parameter.
|
| 291 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 292 |
+
* \p NaN input values result in positive MAXNORM.
|
| 293 |
+
*
|
| 294 |
+
* \returns
|
| 295 |
+
* - The \p __nv_fp4x2_storage_t value holds the result of conversion.
|
| 296 |
+
*/
|
| 297 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t
|
| 298 |
+
__nv_cvt_bfloat16raw2_to_fp4x2(
|
| 299 |
+
const __nv_bfloat162_raw x,
|
| 300 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 301 |
+
const enum cudaRoundMode rounding);
|
| 302 |
+
|
| 303 |
+
/**
|
| 304 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 305 |
+
* \brief Converts input \p fp4 \p x of the specified kind
|
| 306 |
+
* to \p half precision.
|
| 307 |
+
*
|
| 308 |
+
* \details Converts input \p x of \p fp4 type of the kind specified by
|
| 309 |
+
* \p fp4_interpretation parameter
|
| 310 |
+
* to \p half precision.
|
| 311 |
+
*
|
| 312 |
+
* \returns
|
| 313 |
+
* - The \p __half_raw value holds the result of conversion.
|
| 314 |
+
*/
|
| 315 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __half_raw
|
| 316 |
+
__nv_cvt_fp4_to_halfraw(const __nv_fp4_storage_t x,
|
| 317 |
+
const __nv_fp4_interpretation_t fp4_interpretation);
|
| 318 |
+
/**
|
| 319 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 320 |
+
* \brief Converts input vector of two \p fp4 values of the specified kind
|
| 321 |
+
* to a vector of two \p half precision values packed in \p __half2_raw
|
| 322 |
+
* structure.
|
| 323 |
+
*
|
| 324 |
+
* \details Converts input vector \p x of \p fp4 type of the kind specified by
|
| 325 |
+
* \p fp4_interpretation parameter
|
| 326 |
+
* to a vector of two \p half precision values and returns as \p __half2_raw
|
| 327 |
+
* structure.
|
| 328 |
+
*
|
| 329 |
+
* \returns
|
| 330 |
+
* - The \p __half2_raw value holds the result of conversion.
|
| 331 |
+
*/
|
| 332 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __half2_raw
|
| 333 |
+
__nv_cvt_fp4x2_to_halfraw2(const __nv_fp4x2_storage_t x,
|
| 334 |
+
const __nv_fp4_interpretation_t fp4_interpretation);
|
| 335 |
+
|
| 336 |
+
#if defined(__cplusplus)
|
| 337 |
+
|
| 338 |
+
#define __CUDA_FP4_TYPES_EXIST__
|
| 339 |
+
|
| 340 |
+
/* Forward-declaration of structures defined in "cuda_fp4.hpp" */
|
| 341 |
+
struct __nv_fp4_e2m1;
|
| 342 |
+
struct __nv_fp4x2_e2m1;
|
| 343 |
+
struct __nv_fp4x4_e2m1;
|
| 344 |
+
|
| 345 |
+
#endif /* defined(__cplusplus) */
|
| 346 |
+
|
| 347 |
+
#include "cuda_fp4.hpp"
|
| 348 |
+
|
| 349 |
+
#undef __CUDA_FP4_DECL__
|
| 350 |
+
#undef __CUDA_HOSTDEVICE_FP4__
|
| 351 |
+
#undef __CUDA_HOSTDEVICE_FP4_DECL__
|
| 352 |
+
|
| 353 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP4)
|
| 354 |
+
#undef __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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2024 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_FP4_HPP__)
|
| 51 |
+
#define __CUDA_FP4_HPP__
|
| 52 |
+
|
| 53 |
+
#if !defined(__CUDA_FP4_H__)
|
| 54 |
+
#error "Do not include this file directly. Instead, include cuda_fp4.h."
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
/* C++ header for std::memcpy (used for type punning in host-side
|
| 58 |
+
* implementations). When compiling as a CUDA source file memcpy is provided
|
| 59 |
+
* implicitly. !defined(__CUDACC__) implies !defined(__CUDACC_RTC__).
|
| 60 |
+
*/
|
| 61 |
+
#if defined(__cplusplus) && !defined(__CUDACC__)
|
| 62 |
+
#include <cstring>
|
| 63 |
+
#elif !defined(__cplusplus) && !defined(__CUDACC__)
|
| 64 |
+
#include <string.h>
|
| 65 |
+
#endif /* defined(__cplusplus) && !defined(__CUDACC__) */
|
| 66 |
+
|
| 67 |
+
/*
|
| 68 |
+
* Bring in the standard assertions header to enforce the subset
|
| 69 |
+
* of rounding modes supported by the APIs defined here.
|
| 70 |
+
* NOTE: NVRTC defines its own assert
|
| 71 |
+
*/
|
| 72 |
+
#if !defined (__CUDACC_RTC__)
|
| 73 |
+
#include <assert.h>
|
| 74 |
+
#endif
|
| 75 |
+
|
| 76 |
+
/* Set up structure-alignment attribute */
|
| 77 |
+
#if !(defined __CUDA_ALIGN__)
|
| 78 |
+
#if defined(__CUDACC__)
|
| 79 |
+
#define __CUDA_ALIGN__(align) __align__(align)
|
| 80 |
+
#else
|
| 81 |
+
/* Define alignment macro based on compiler type (cannot assume C11 "_Alignas"
|
| 82 |
+
* is available) */
|
| 83 |
+
#if __cplusplus >= 201103L
|
| 84 |
+
#define __CUDA_ALIGN__(n) \
|
| 85 |
+
alignas(n) /* C++11 kindly gives us a keyword for this */
|
| 86 |
+
#else /* !defined(__CPP_VERSION_AT_LEAST_11_FP4)*/
|
| 87 |
+
#if defined(__GNUC__)
|
| 88 |
+
#define __CUDA_ALIGN__(n) __attribute__((aligned(n)))
|
| 89 |
+
#elif defined(_MSC_VER)
|
| 90 |
+
#define __CUDA_ALIGN__(n) __declspec(align(n))
|
| 91 |
+
#else
|
| 92 |
+
#define __CUDA_ALIGN__(n)
|
| 93 |
+
#endif /* defined(__GNUC__) */
|
| 94 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP4) */
|
| 95 |
+
#endif /* defined(__CUDACC__) */
|
| 96 |
+
#endif /* !(defined __CUDA_ALIGN__) */
|
| 97 |
+
|
| 98 |
+
#if !(defined __CPP_VERSION_AT_LEAST_11_FP4)
|
| 99 |
+
/* need c++11 for explicit operators */
|
| 100 |
+
#define __CUDA_NO_FP4_CONVERSION_OPERATORS__
|
| 101 |
+
#endif
|
| 102 |
+
|
| 103 |
+
#if !(defined __DOXYGEN_ONLY__)
|
| 104 |
+
|
| 105 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t
|
| 106 |
+
__nv_cvt_double_to_fp4(const double x,
|
| 107 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 108 |
+
const enum cudaRoundMode rounding) {
|
| 109 |
+
unsigned char res;
|
| 110 |
+
unsigned long long int xbits;
|
| 111 |
+
|
| 112 |
+
#if defined(__CUDACC__) || (!defined __cplusplus)
|
| 113 |
+
(void)memcpy(&xbits, &x, sizeof(x));
|
| 114 |
+
#else
|
| 115 |
+
(void)std::memcpy(&xbits, &x, sizeof(x));
|
| 116 |
+
#endif
|
| 117 |
+
unsigned char FP4_MAXNORM;
|
| 118 |
+
unsigned char FP4_MANTISSA_MASK;
|
| 119 |
+
unsigned short int FP4_EXP_BIAS;
|
| 120 |
+
unsigned long long int FP4_SIGNIFICAND_BITS;
|
| 121 |
+
unsigned long long int FP4_MINDENORM_O2;
|
| 122 |
+
unsigned long long int FP4_OVERFLOW_THRESHOLD;
|
| 123 |
+
unsigned long long int FP4_MINNORM;
|
| 124 |
+
const unsigned long long int DP_INF_BITS = 0x7FF0000000000000ULL;
|
| 125 |
+
|
| 126 |
+
// fp4_interpretation == __NV_E2M1
|
| 127 |
+
FP4_EXP_BIAS = 1U;
|
| 128 |
+
FP4_SIGNIFICAND_BITS = 2ULL;
|
| 129 |
+
FP4_MANTISSA_MASK = 0x1U;
|
| 130 |
+
FP4_MINDENORM_O2 = 0x3FD0000000000000ULL; // mindenorm/2 = 2^-2
|
| 131 |
+
FP4_OVERFLOW_THRESHOLD =
|
| 132 |
+
0x4018000000000000ULL; // maxnorm = 6.0
|
| 133 |
+
FP4_MAXNORM = 0x7U;
|
| 134 |
+
FP4_MINNORM = 0x3FF0000000000000ULL; // minnorm = 2^0
|
| 135 |
+
|
| 136 |
+
// 1/2 LSB of the target format, positioned in double precision mantissa
|
| 137 |
+
// helpful in midpoints detection during round-to-nearest-even step
|
| 138 |
+
const unsigned long long int FP4_DP_HALF_ULP =
|
| 139 |
+
(unsigned long long int)1ULL << (53ULL - FP4_SIGNIFICAND_BITS - 1ULL);
|
| 140 |
+
// prepare sign bit in target format
|
| 141 |
+
unsigned char sign = (unsigned char)((xbits >> 63ULL) << 3U);
|
| 142 |
+
// prepare exponent field in target format
|
| 143 |
+
unsigned char exp =
|
| 144 |
+
(unsigned char)((((unsigned short int)(xbits >> 52ULL)) & 0x7FFU) -
|
| 145 |
+
1023U + FP4_EXP_BIAS);
|
| 146 |
+
// round mantissa to target format width, rounding towards zero
|
| 147 |
+
unsigned char mantissa =
|
| 148 |
+
(unsigned char)(xbits >> (53ULL - FP4_SIGNIFICAND_BITS)) &
|
| 149 |
+
FP4_MANTISSA_MASK;
|
| 150 |
+
unsigned long long int absx = xbits & 0x7FFFFFFFFFFFFFFFULL;
|
| 151 |
+
|
| 152 |
+
if (absx <= FP4_MINDENORM_O2) {
|
| 153 |
+
// zero or underflow
|
| 154 |
+
res = 0U;
|
| 155 |
+
} else if (absx > FP4_OVERFLOW_THRESHOLD) {
|
| 156 |
+
// overflow or NaN
|
| 157 |
+
if (absx > DP_INF_BITS)
|
| 158 |
+
{
|
| 159 |
+
// NaN converts to positive FP4_MAXNORM
|
| 160 |
+
sign = 0U;
|
| 161 |
+
}
|
| 162 |
+
res = FP4_MAXNORM;
|
| 163 |
+
} else if (absx >= FP4_MINNORM) {
|
| 164 |
+
res = (unsigned char)((exp << (FP4_SIGNIFICAND_BITS - 1U)) | mantissa);
|
| 165 |
+
// rounded-off bits
|
| 166 |
+
unsigned long long int round =
|
| 167 |
+
xbits & ((FP4_DP_HALF_ULP << 1ULL) - 1ULL);
|
| 168 |
+
if (rounding == cudaRoundNearest)
|
| 169 |
+
{
|
| 170 |
+
// round-to-nearest-even adjustment
|
| 171 |
+
if ((round > FP4_DP_HALF_ULP) ||
|
| 172 |
+
((round == FP4_DP_HALF_ULP) && (mantissa & 1U))) {
|
| 173 |
+
res = (unsigned char)(res + 1U);
|
| 174 |
+
}
|
| 175 |
+
} else {
|
| 176 |
+
assert(rounding == cudaRoundZero);
|
| 177 |
+
}
|
| 178 |
+
} else // Denormal range
|
| 179 |
+
{
|
| 180 |
+
unsigned char shift = (unsigned char)(1U - exp);
|
| 181 |
+
// add implicit leading bit
|
| 182 |
+
mantissa |= (unsigned char)(1U << (FP4_SIGNIFICAND_BITS - 1U));
|
| 183 |
+
// additional round-off due to denormalization
|
| 184 |
+
res = (unsigned char)(mantissa >> shift);
|
| 185 |
+
|
| 186 |
+
if (rounding == cudaRoundNearest)
|
| 187 |
+
{
|
| 188 |
+
// rounded-off bits, including implicit leading bit
|
| 189 |
+
unsigned long long int round =
|
| 190 |
+
(xbits | ((unsigned long long int)1ULL << (53ULL - 1ULL))) &
|
| 191 |
+
((FP4_DP_HALF_ULP << (shift + 1ULL)) - 1ULL);
|
| 192 |
+
// round-to-nearest-even adjustment
|
| 193 |
+
if ((round > (FP4_DP_HALF_ULP << shift)) ||
|
| 194 |
+
((round == (FP4_DP_HALF_ULP << shift)) && (res & 1U))) {
|
| 195 |
+
res = (unsigned char)(res + 1U);
|
| 196 |
+
}
|
| 197 |
+
} else {
|
| 198 |
+
assert(rounding == cudaRoundZero);
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
res |= sign;
|
| 203 |
+
|
| 204 |
+
return (__nv_fp4_storage_t)res;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t
|
| 208 |
+
__nv_cvt_double2_to_fp4x2(const double2 x,
|
| 209 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 210 |
+
const enum cudaRoundMode rounding) {
|
| 211 |
+
__nv_fp4x2_storage_t storage = (__nv_fp4x2_storage_t)__nv_cvt_double_to_fp4(
|
| 212 |
+
x.y, fp4_interpretation, rounding);
|
| 213 |
+
storage = (__nv_fp4x2_storage_t)(storage << 4U);
|
| 214 |
+
storage = (__nv_fp4x2_storage_t)(storage |
|
| 215 |
+
__nv_cvt_double_to_fp4(
|
| 216 |
+
x.x, fp4_interpretation, rounding));
|
| 217 |
+
return storage;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t
|
| 221 |
+
__nv_cvt_float_to_fp4(const float x,
|
| 222 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 223 |
+
const enum cudaRoundMode rounding) {
|
| 224 |
+
__nv_fp4_storage_t res = 0U;
|
| 225 |
+
assert((rounding == cudaRoundNearest) || (rounding == cudaRoundZero));
|
| 226 |
+
#if ((defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && \
|
| 227 |
+
((__CUDA_ARCH_HAS_FEATURE__(SM100_ALL)) || \
|
| 228 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM101_ALL)) || \
|
| 229 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM120_ALL))))
|
| 230 |
+
if (rounding == cudaRoundNearest)
|
| 231 |
+
{
|
| 232 |
+
unsigned short storage;
|
| 233 |
+
// fp4_interpretation == __NV_E2M1
|
| 234 |
+
asm("{ .reg .b8 __$temp1; \n"
|
| 235 |
+
" cvt.rn.satfinite.e2m1x2.f32 __$temp1, %2, %1; \n"
|
| 236 |
+
" mov.b16 %0, {__$temp1, 0}; }\n"
|
| 237 |
+
: "=h"(storage)
|
| 238 |
+
: "f"(x), "f"(0.0f));
|
| 239 |
+
res = (__nv_fp4_storage_t)storage;
|
| 240 |
+
} else
|
| 241 |
+
#endif
|
| 242 |
+
{
|
| 243 |
+
res = __nv_cvt_double_to_fp4((double)x, fp4_interpretation, rounding);
|
| 244 |
+
}
|
| 245 |
+
return res;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t
|
| 249 |
+
__nv_cvt_float2_to_fp4x2(const float2 x,
|
| 250 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 251 |
+
const enum cudaRoundMode rounding) {
|
| 252 |
+
assert((rounding == cudaRoundNearest) || (rounding == cudaRoundZero));
|
| 253 |
+
unsigned short storage;
|
| 254 |
+
#if ((defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && \
|
| 255 |
+
((__CUDA_ARCH_HAS_FEATURE__(SM100_ALL)) || \
|
| 256 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM101_ALL)) || \
|
| 257 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM120_ALL))))
|
| 258 |
+
if (rounding == cudaRoundNearest) {
|
| 259 |
+
// fp4_interpretation == __NV_E2M1
|
| 260 |
+
asm("{ .reg .b8 __$temp1; \n"
|
| 261 |
+
" cvt.rn.satfinite.e2m1x2.f32 __$temp1, %2, %1; \n"
|
| 262 |
+
" mov.b16 %0, {__$temp1, 0}; }\n"
|
| 263 |
+
: "=h"(storage)
|
| 264 |
+
: "f"(x.x), "f"(x.y));
|
| 265 |
+
} else
|
| 266 |
+
#endif
|
| 267 |
+
{
|
| 268 |
+
storage = (__nv_fp4x2_storage_t)__nv_cvt_float_to_fp4(
|
| 269 |
+
x.y, fp4_interpretation, rounding);
|
| 270 |
+
storage = (__nv_fp4x2_storage_t)(storage << 4U);
|
| 271 |
+
storage = (__nv_fp4x2_storage_t)(storage | __nv_cvt_float_to_fp4(
|
| 272 |
+
x.x,
|
| 273 |
+
fp4_interpretation, rounding));
|
| 274 |
+
}
|
| 275 |
+
return (__nv_fp4x2_storage_t)storage;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t
|
| 279 |
+
__nv_cvt_halfraw_to_fp4(const __half_raw x,
|
| 280 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 281 |
+
const enum cudaRoundMode rounding) {
|
| 282 |
+
assert((rounding == cudaRoundNearest) || (rounding == cudaRoundZero));
|
| 283 |
+
__nv_fp4_storage_t res = 0U;
|
| 284 |
+
float fx = __internal_halfraw_to_float(x);
|
| 285 |
+
res = __nv_cvt_float_to_fp4(fx, fp4_interpretation, rounding);
|
| 286 |
+
return res;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t __nv_cvt_halfraw2_to_fp4x2(
|
| 290 |
+
const __half2_raw x,
|
| 291 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 292 |
+
const enum cudaRoundMode rounding) {
|
| 293 |
+
assert((rounding == cudaRoundNearest) || (rounding == cudaRoundZero));
|
| 294 |
+
unsigned short tmp;
|
| 295 |
+
__half_raw raw;
|
| 296 |
+
raw.x = x.x;
|
| 297 |
+
__nv_fp4_storage_t lo =
|
| 298 |
+
__nv_cvt_halfraw_to_fp4(raw, fp4_interpretation, rounding);
|
| 299 |
+
raw.x = x.y;
|
| 300 |
+
__nv_fp4_storage_t hi =
|
| 301 |
+
__nv_cvt_halfraw_to_fp4(raw, fp4_interpretation, rounding);
|
| 302 |
+
tmp = hi;
|
| 303 |
+
tmp = (__nv_fp4x2_storage_t)(tmp << 4U);
|
| 304 |
+
tmp = (__nv_fp4x2_storage_t)(tmp | lo);
|
| 305 |
+
return (__nv_fp4x2_storage_t)tmp;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t __nv_cvt_bfloat16raw_to_fp4(
|
| 309 |
+
const __nv_bfloat16_raw x,
|
| 310 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 311 |
+
const enum cudaRoundMode rounding) {
|
| 312 |
+
const float fx = __internal_bf16raw_to_float(x);
|
| 313 |
+
const __nv_fp4_storage_t res =
|
| 314 |
+
__nv_cvt_float_to_fp4(fx, fp4_interpretation, rounding);
|
| 315 |
+
return res;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t
|
| 319 |
+
__nv_cvt_bfloat16raw2_to_fp4x2(
|
| 320 |
+
const __nv_bfloat162_raw x,
|
| 321 |
+
const __nv_fp4_interpretation_t fp4_interpretation,
|
| 322 |
+
const enum cudaRoundMode rounding) {
|
| 323 |
+
__nv_bfloat16_raw raw;
|
| 324 |
+
raw.x = x.y;
|
| 325 |
+
__nv_fp4x2_storage_t storage =
|
| 326 |
+
(__nv_fp4x2_storage_t)__nv_cvt_bfloat16raw_to_fp4(raw,
|
| 327 |
+
fp4_interpretation, rounding);
|
| 328 |
+
storage = (__nv_fp4x2_storage_t)(storage << 4U);
|
| 329 |
+
raw.x = x.x;
|
| 330 |
+
storage = (__nv_fp4x2_storage_t)(storage |
|
| 331 |
+
__nv_cvt_bfloat16raw_to_fp4(raw,
|
| 332 |
+
fp4_interpretation, rounding));
|
| 333 |
+
return storage;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __half2_raw
|
| 337 |
+
__nv_cvt_fp4x2_to_halfraw2(const __nv_fp4x2_storage_t x,
|
| 338 |
+
const __nv_fp4_interpretation_t fp4_interpretation);
|
| 339 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __half_raw
|
| 340 |
+
__nv_cvt_fp4_to_halfraw(const __nv_fp4_storage_t x,
|
| 341 |
+
const __nv_fp4_interpretation_t fp4_interpretation) {
|
| 342 |
+
__half_raw res;
|
| 343 |
+
res.x = 0U;
|
| 344 |
+
#if ((defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && \
|
| 345 |
+
((__CUDA_ARCH_HAS_FEATURE__(SM100_ALL)) || \
|
| 346 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM101_ALL)) || \
|
| 347 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM120_ALL))))
|
| 348 |
+
res.x =
|
| 349 |
+
__nv_cvt_fp4x2_to_halfraw2((__nv_fp4x2_storage_t)x, fp4_interpretation)
|
| 350 |
+
.x;
|
| 351 |
+
#else
|
| 352 |
+
{
|
| 353 |
+
// fp4_interpretation == __NV_E2M1
|
| 354 |
+
// convert to e2m3 first
|
| 355 |
+
__nv_fp6_storage_t fp6e2m3 = (x & 0xFU) << 2U;
|
| 356 |
+
res = __nv_cvt_fp6_to_halfraw(fp6e2m3, __NV_E2M3);
|
| 357 |
+
}
|
| 358 |
+
#endif
|
| 359 |
+
return res;
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ __half2_raw
|
| 363 |
+
__nv_cvt_fp4x2_to_halfraw2(const __nv_fp4x2_storage_t x,
|
| 364 |
+
const __nv_fp4_interpretation_t fp4_interpretation) {
|
| 365 |
+
__half2_raw res;
|
| 366 |
+
#if ((defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && \
|
| 367 |
+
((__CUDA_ARCH_HAS_FEATURE__(SM100_ALL)) || \
|
| 368 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM101_ALL)) || \
|
| 369 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM120_ALL))))
|
| 370 |
+
unsigned int half2_storage;
|
| 371 |
+
unsigned short tmp = (unsigned short)x;
|
| 372 |
+
asm("{ .reg .b8 __$temp1, __$tempz; \n"
|
| 373 |
+
" mov.b16 {__$temp1, __$tempz}, %1; \n"
|
| 374 |
+
" cvt.rn.f16x2.e2m1x2 %0, __$temp1; }\n"
|
| 375 |
+
: "=r"(half2_storage)
|
| 376 |
+
: "h"(tmp));
|
| 377 |
+
(void)memcpy(&res, &half2_storage, sizeof(half2_storage));
|
| 378 |
+
#else
|
| 379 |
+
res.x =
|
| 380 |
+
__nv_cvt_fp4_to_halfraw((__nv_fp4_storage_t)x, fp4_interpretation).x;
|
| 381 |
+
res.y = __nv_cvt_fp4_to_halfraw((__nv_fp4_storage_t)(x >> 4U),
|
| 382 |
+
fp4_interpretation)
|
| 383 |
+
.x;
|
| 384 |
+
#endif
|
| 385 |
+
return res;
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
__CUDA_HOSTDEVICE_FP4_DECL__ unsigned short int
|
| 389 |
+
__internal_pack_u8x2_to_u16(const unsigned char src_lo,
|
| 390 |
+
const unsigned char src_hi) {
|
| 391 |
+
return (((unsigned short int)src_hi) << 8U) |
|
| 392 |
+
((unsigned short int)src_lo);
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
#endif /* !(defined __DOXYGEN_ONLY__) */
|
| 396 |
+
|
| 397 |
+
/* All other definitions in this file are only visible to C++ compilers */
|
| 398 |
+
#if defined(__cplusplus)
|
| 399 |
+
|
| 400 |
+
/**
|
| 401 |
+
* \defgroup CUDA_MATH_FP4_E2M1_STRUCT C++ struct for handling fp4 data type of e2m1 kind.
|
| 402 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP4
|
| 403 |
+
*/
|
| 404 |
+
|
| 405 |
+
/**
|
| 406 |
+
* \ingroup CUDA_MATH_FP4_E2M1_STRUCT
|
| 407 |
+
* \brief __nv_fp4_e2m1 datatype
|
| 408 |
+
*
|
| 409 |
+
* \details This structure implements the datatype for handling
|
| 410 |
+
* \p fp4 floating-point numbers of \p e2m1 kind:
|
| 411 |
+
* with 1 sign, 2 exponent, 1 implicit and 1 explicit mantissa bits.
|
| 412 |
+
* This encoding does not support Inf/NaN.
|
| 413 |
+
*
|
| 414 |
+
* The structure implements converting constructors and operators.
|
| 415 |
+
*/
|
| 416 |
+
struct __CUDA_ALIGN__(1) __nv_fp4_e2m1 {
|
| 417 |
+
public:
|
| 418 |
+
/**
|
| 419 |
+
* \ingroup CUDA_MATH_FP4_E2M1_STRUCT
|
| 420 |
+
* Storage variable contains the \p fp4 floating-point data.
|
| 421 |
+
*/
|
| 422 |
+
__nv_fp4_storage_t __x;
|
| 423 |
+
|
| 424 |
+
/**
|
| 425 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 426 |
+
* Constructor by default.
|
| 427 |
+
*/
|
| 428 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP4)
|
| 429 |
+
__nv_fp4_e2m1() = default;
|
| 430 |
+
#else
|
| 431 |
+
__CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1() {}
|
| 432 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP4) */
|
| 433 |
+
|
| 434 |
+
#if !defined(__CUDA_NO_FP4_CONVERSIONS__)
|
| 435 |
+
|
| 436 |
+
/* Construct from wider FP types */
|
| 437 |
+
/* Note we do avoid constructor init-list because of special host/device
|
| 438 |
+
* compilation rules */
|
| 439 |
+
|
| 440 |
+
/**
|
| 441 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 442 |
+
* Constructor from \p __half data type, relies on \p __NV_SATFINITE
|
| 443 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 444 |
+
*/
|
| 445 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const __half f) {
|
| 446 |
+
__x = __nv_cvt_halfraw_to_fp4(static_cast<__half_raw>(f),
|
| 447 |
+
__NV_E2M1, cudaRoundNearest);
|
| 448 |
+
}
|
| 449 |
+
/**
|
| 450 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 451 |
+
* Constructor from \p __nv_bfloat16 data type, relies on \p __NV_SATFINITE
|
| 452 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 453 |
+
*/
|
| 454 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const __nv_bfloat16 f) {
|
| 455 |
+
__x = __nv_cvt_bfloat16raw_to_fp4(static_cast<__nv_bfloat16_raw>(f),
|
| 456 |
+
__NV_E2M1, cudaRoundNearest);
|
| 457 |
+
}
|
| 458 |
+
/**
|
| 459 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 460 |
+
* Constructor from \p float data type, relies on \p __NV_SATFINITE
|
| 461 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 462 |
+
*/
|
| 463 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const float f) {
|
| 464 |
+
__x = __nv_cvt_float_to_fp4(f, __NV_E2M1, cudaRoundNearest);
|
| 465 |
+
}
|
| 466 |
+
/**
|
| 467 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 468 |
+
* Constructor from \p double data type, relies on \p __NV_SATFINITE
|
| 469 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 470 |
+
*/
|
| 471 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const double f) {
|
| 472 |
+
__x = __nv_cvt_double_to_fp4(f, __NV_E2M1, cudaRoundNearest);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
/* Converts from integral */
|
| 476 |
+
|
| 477 |
+
/**
|
| 478 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 479 |
+
* Constructor from \p unsigned \p short \p int data type, relies on \p
|
| 480 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 481 |
+
*/
|
| 482 |
+
explicit __CUDA_HOSTDEVICE_FP4__
|
| 483 |
+
__nv_fp4_e2m1(const unsigned short int val) {
|
| 484 |
+
__x = static_cast<__nv_fp4_e2m1>(static_cast<float>(val)).__x;
|
| 485 |
+
}
|
| 486 |
+
/**
|
| 487 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 488 |
+
* Constructor from \p unsigned \p int data type, relies on \p
|
| 489 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 490 |
+
*/
|
| 491 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const unsigned int val) {
|
| 492 |
+
__x = static_cast<__nv_fp4_e2m1>(static_cast<float>(val)).__x;
|
| 493 |
+
}
|
| 494 |
+
/**
|
| 495 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 496 |
+
* Constructor from \p unsigned \p long \p int data type, relies on \p
|
| 497 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 498 |
+
*/
|
| 499 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const unsigned long int val) {
|
| 500 |
+
__x = static_cast<__nv_fp4_e2m1>(static_cast<float>(val)).__x;
|
| 501 |
+
}
|
| 502 |
+
/**
|
| 503 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 504 |
+
* Constructor from \p unsigned \p long \p long \p int data type, relies on
|
| 505 |
+
* \p __NV_SATFINITE behavior for out-of-range values.
|
| 506 |
+
*/
|
| 507 |
+
explicit __CUDA_HOSTDEVICE_FP4__
|
| 508 |
+
__nv_fp4_e2m1(const unsigned long long int val) {
|
| 509 |
+
__x = static_cast<__nv_fp4_e2m1>(static_cast<float>(val)).__x;
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
/**
|
| 513 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 514 |
+
* Constructor from \p short \p int data type.
|
| 515 |
+
*/
|
| 516 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const short int val) {
|
| 517 |
+
__x = static_cast<__nv_fp4_e2m1>(static_cast<float>(val)).__x;
|
| 518 |
+
}
|
| 519 |
+
/**
|
| 520 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 521 |
+
* Constructor from \p int data type, relies on \p __NV_SATFINITE behavior
|
| 522 |
+
* for out-of-range values.
|
| 523 |
+
*/
|
| 524 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const int val) {
|
| 525 |
+
__x = static_cast<__nv_fp4_e2m1>(static_cast<float>(val)).__x;
|
| 526 |
+
}
|
| 527 |
+
/**
|
| 528 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 529 |
+
* Constructor from \p long \p int data type, relies on \p __NV_SATFINITE behavior
|
| 530 |
+
* for out-of-range values.
|
| 531 |
+
*/
|
| 532 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const long int val) {
|
| 533 |
+
__x = static_cast<__nv_fp4_e2m1>(static_cast<float>(val)).__x;
|
| 534 |
+
}
|
| 535 |
+
/**
|
| 536 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 537 |
+
* Constructor from \p long \p long \p int data type, relies on \p
|
| 538 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 539 |
+
*/
|
| 540 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4_e2m1(const long long int val) {
|
| 541 |
+
__x = static_cast<__nv_fp4_e2m1>(static_cast<float>(val)).__x;
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
#if !defined(__CUDA_NO_FP4_CONVERSION_OPERATORS__)
|
| 545 |
+
/* Widening FP converts */
|
| 546 |
+
/**
|
| 547 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 548 |
+
* Conversion operator to \p __half data type.
|
| 549 |
+
*/
|
| 550 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator __half() const {
|
| 551 |
+
return static_cast<__half>(__nv_cvt_fp4_to_halfraw(__x, __NV_E2M1));
|
| 552 |
+
}
|
| 553 |
+
/**
|
| 554 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 555 |
+
* Conversion operator to \p float data type.
|
| 556 |
+
*/
|
| 557 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator float() const {
|
| 558 |
+
return __internal_halfraw_to_float(
|
| 559 |
+
__nv_cvt_fp4_to_halfraw(__x, __NV_E2M1));
|
| 560 |
+
}
|
| 561 |
+
/**
|
| 562 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 563 |
+
* Conversion operator to \p __nv_bfloat16 data type.
|
| 564 |
+
*/
|
| 565 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator __nv_bfloat16() const {
|
| 566 |
+
return __float2bfloat16_rz(float(*this));
|
| 567 |
+
}
|
| 568 |
+
/**
|
| 569 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 570 |
+
* Conversion operator to \p double data type.
|
| 571 |
+
*/
|
| 572 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator double() const {
|
| 573 |
+
return static_cast<double>(float(*this));
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
/* Convert to integral */
|
| 577 |
+
|
| 578 |
+
/**
|
| 579 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 580 |
+
* Conversion operator to \p unsigned \p char data type.
|
| 581 |
+
* Clamps negative inputs to zero.
|
| 582 |
+
*/
|
| 583 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator unsigned char() const {
|
| 584 |
+
unsigned char i;
|
| 585 |
+
const float f = float(*this);
|
| 586 |
+
|
| 587 |
+
if (f < 0.0f) {
|
| 588 |
+
// saturate minimum
|
| 589 |
+
i = 0U;
|
| 590 |
+
} else {
|
| 591 |
+
// normal value
|
| 592 |
+
i = static_cast<unsigned char>(f);
|
| 593 |
+
}
|
| 594 |
+
return i;
|
| 595 |
+
}
|
| 596 |
+
/**
|
| 597 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 598 |
+
* Conversion operator to \p unsigned \p short \p int data type.
|
| 599 |
+
* Clamps negative inputs to zero.
|
| 600 |
+
*/
|
| 601 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator unsigned short int() const {
|
| 602 |
+
return __half2ushort_rz(__half(*this));
|
| 603 |
+
}
|
| 604 |
+
/**
|
| 605 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 606 |
+
* Conversion operator to \p unsigned \p int data type.
|
| 607 |
+
* Clamps negative inputs to zero.
|
| 608 |
+
*/
|
| 609 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator unsigned int() const {
|
| 610 |
+
return __half2uint_rz(__half(*this));
|
| 611 |
+
}
|
| 612 |
+
/**
|
| 613 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 614 |
+
* Conversion operator to \p unsigned \p long \p int data type.
|
| 615 |
+
* Clamps negative inputs to zero.
|
| 616 |
+
*/
|
| 617 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator unsigned long int() const {
|
| 618 |
+
unsigned long retval;
|
| 619 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 620 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 621 |
+
#pragma warning (push)
|
| 622 |
+
#pragma warning (disable: 4127)
|
| 623 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 624 |
+
if (sizeof(unsigned long) == sizeof(unsigned long long))
|
| 625 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 626 |
+
#pragma warning (pop)
|
| 627 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 628 |
+
{
|
| 629 |
+
retval = static_cast<unsigned long>(__half2ull_rz(__half(*this)));
|
| 630 |
+
}
|
| 631 |
+
else
|
| 632 |
+
{
|
| 633 |
+
retval = static_cast<unsigned long>(__half2uint_rz(__half(*this)));
|
| 634 |
+
}
|
| 635 |
+
return retval;
|
| 636 |
+
}
|
| 637 |
+
/**
|
| 638 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 639 |
+
* Conversion operator to \p unsigned \p long \p long \p int data type.
|
| 640 |
+
* Clamps negative inputs to zero.
|
| 641 |
+
*/
|
| 642 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator unsigned long long int() const {
|
| 643 |
+
return __half2ull_rz(__half(*this));
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
/**
|
| 647 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 648 |
+
* Conversion operator to \p signed \p char data type.
|
| 649 |
+
*/
|
| 650 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator signed char() const {
|
| 651 |
+
const float f = float(*this);
|
| 652 |
+
return static_cast<signed char>(f);
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
/**
|
| 656 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 657 |
+
* Conversion operator to an implementation defined \p char data type.
|
| 658 |
+
*
|
| 659 |
+
* Detects signedness of the \p char type and proceeds accordingly, see
|
| 660 |
+
* further details in signed and unsigned char operators.
|
| 661 |
+
*
|
| 662 |
+
* Clamps inputs to the output range.
|
| 663 |
+
*/
|
| 664 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator char() const {
|
| 665 |
+
char value;
|
| 666 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 667 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 668 |
+
#pragma warning (push)
|
| 669 |
+
#pragma warning (disable: 4127)
|
| 670 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 671 |
+
if (((char)-1) < (char)0)
|
| 672 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 673 |
+
#pragma warning (pop)
|
| 674 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 675 |
+
{
|
| 676 |
+
value = static_cast<char>(static_cast<signed char>(*this));
|
| 677 |
+
}
|
| 678 |
+
else
|
| 679 |
+
{
|
| 680 |
+
value = static_cast<char>(static_cast<unsigned char>(*this));
|
| 681 |
+
}
|
| 682 |
+
return value;
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
/**
|
| 686 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 687 |
+
* Conversion operator to \p short \p int data type.
|
| 688 |
+
*/
|
| 689 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator short int() const {
|
| 690 |
+
return __half2short_rz(__half(*this));
|
| 691 |
+
}
|
| 692 |
+
/**
|
| 693 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 694 |
+
* Conversion operator to \p int data type.
|
| 695 |
+
*/
|
| 696 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator int() const {
|
| 697 |
+
return __half2int_rz(__half(*this));
|
| 698 |
+
}
|
| 699 |
+
/**
|
| 700 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 701 |
+
* Conversion operator to \p long \p int data type.
|
| 702 |
+
*/
|
| 703 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator long int() const {
|
| 704 |
+
long retval;
|
| 705 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 706 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 707 |
+
#pragma warning (push)
|
| 708 |
+
#pragma warning (disable: 4127)
|
| 709 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 710 |
+
if (sizeof(long) == sizeof(long long))
|
| 711 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 712 |
+
#pragma warning (pop)
|
| 713 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 714 |
+
{
|
| 715 |
+
retval = static_cast<long>(__half2ll_rz(__half(*this)));
|
| 716 |
+
}
|
| 717 |
+
else
|
| 718 |
+
{
|
| 719 |
+
retval = static_cast<long>(__half2int_rz(__half(*this)));
|
| 720 |
+
}
|
| 721 |
+
return retval;
|
| 722 |
+
}
|
| 723 |
+
/**
|
| 724 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 725 |
+
* Conversion operator to \p long \p long \p int data type.
|
| 726 |
+
*/
|
| 727 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator long long int() const {
|
| 728 |
+
return __half2ll_rz(__half(*this));
|
| 729 |
+
}
|
| 730 |
+
|
| 731 |
+
/**
|
| 732 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 733 |
+
* Conversion operator to \p bool data type.
|
| 734 |
+
* +0 and -0 inputs convert to \p false.
|
| 735 |
+
* Non-zero inputs convert to \p true.
|
| 736 |
+
*/
|
| 737 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator bool() const {
|
| 738 |
+
return (__x & 0x7U) != 0U;
|
| 739 |
+
}
|
| 740 |
+
#endif /* !defined(__CUDA_NO_FP4_CONVERSION_OPERATORS__) */
|
| 741 |
+
#endif /* !defined(__CUDA_NO_FP4_CONVERSIONS__) */
|
| 742 |
+
};
|
| 743 |
+
|
| 744 |
+
/**
|
| 745 |
+
* \defgroup CUDA_MATH_FP4X2_E2M1_STRUCT C++ struct for handling vector type of two fp4 values of e2m1 kind.
|
| 746 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP4
|
| 747 |
+
*/
|
| 748 |
+
|
| 749 |
+
/**
|
| 750 |
+
* \ingroup CUDA_MATH_FP4X2_E2M1_STRUCT
|
| 751 |
+
* \brief __nv_fp4x2_e2m1 datatype
|
| 752 |
+
*
|
| 753 |
+
* \details This structure implements the datatype for handling two
|
| 754 |
+
* \p fp4 floating-point numbers of \p e2m1 kind each.
|
| 755 |
+
*
|
| 756 |
+
* The structure implements converting constructors and operators.
|
| 757 |
+
*/
|
| 758 |
+
struct __CUDA_ALIGN__(1) __nv_fp4x2_e2m1 {
|
| 759 |
+
public:
|
| 760 |
+
/**
|
| 761 |
+
* \ingroup CUDA_MATH_FP4X2_E2M1_STRUCT
|
| 762 |
+
* Storage variable contains the vector of two \p fp4 floating-point data
|
| 763 |
+
* values.
|
| 764 |
+
*/
|
| 765 |
+
__nv_fp4x2_storage_t __x;
|
| 766 |
+
|
| 767 |
+
/**
|
| 768 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 769 |
+
* Constructor by default.
|
| 770 |
+
*/
|
| 771 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP4)
|
| 772 |
+
__nv_fp4x2_e2m1() = default;
|
| 773 |
+
#else
|
| 774 |
+
__CUDA_HOSTDEVICE_FP4__ __nv_fp4x2_e2m1() {}
|
| 775 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP4) */
|
| 776 |
+
|
| 777 |
+
#if !defined(__CUDA_NO_FP4_CONVERSIONS__)
|
| 778 |
+
|
| 779 |
+
/* Construct from wider types */
|
| 780 |
+
|
| 781 |
+
/**
|
| 782 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 783 |
+
* Constructor from \p __half2 data type, relies on \p __NV_SATFINITE
|
| 784 |
+
* behavior for out-of-range values.
|
| 785 |
+
*/
|
| 786 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4x2_e2m1(const __half2 f) {
|
| 787 |
+
__x = __nv_cvt_halfraw2_to_fp4x2(static_cast<__half2_raw>(f),
|
| 788 |
+
__NV_E2M1, cudaRoundNearest);
|
| 789 |
+
}
|
| 790 |
+
/**
|
| 791 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 792 |
+
* Constructor from \p __nv_bfloat162 data type, relies on \p __NV_SATFINITE
|
| 793 |
+
* behavior for out-of-range values.
|
| 794 |
+
*/
|
| 795 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4x2_e2m1(const __nv_bfloat162 f) {
|
| 796 |
+
__x = __nv_cvt_bfloat16raw2_to_fp4x2(static_cast<__nv_bfloat162_raw>(f),
|
| 797 |
+
__NV_E2M1, cudaRoundNearest);
|
| 798 |
+
}
|
| 799 |
+
/**
|
| 800 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 801 |
+
* Constructor from \p float2 data type, relies on \p __NV_SATFINITE
|
| 802 |
+
* behavior for out-of-range values.
|
| 803 |
+
*/
|
| 804 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4x2_e2m1(const float2 f) {
|
| 805 |
+
__x = __nv_cvt_float2_to_fp4x2(f, __NV_E2M1, cudaRoundNearest);
|
| 806 |
+
}
|
| 807 |
+
/**
|
| 808 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 809 |
+
* Constructor from \p double2 data type, relies on \p __NV_SATFINITE
|
| 810 |
+
* behavior for out-of-range values.
|
| 811 |
+
*/
|
| 812 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4x2_e2m1(const double2 f) {
|
| 813 |
+
__x = __nv_cvt_double2_to_fp4x2(f, __NV_E2M1, cudaRoundNearest);
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
#if !defined(__CUDA_NO_FP4_CONVERSION_OPERATORS__)
|
| 817 |
+
/* Widening converts */
|
| 818 |
+
/**
|
| 819 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 820 |
+
* Conversion operator to \p __half2 data type.
|
| 821 |
+
*/
|
| 822 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator __half2() const {
|
| 823 |
+
return static_cast<__half2>(__nv_cvt_fp4x2_to_halfraw2(__x, __NV_E2M1));
|
| 824 |
+
}
|
| 825 |
+
/**
|
| 826 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 827 |
+
* Conversion operator to \p float2 data type.
|
| 828 |
+
*/
|
| 829 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator float2() const {
|
| 830 |
+
return __internal_halfraw2_to_float2(
|
| 831 |
+
__nv_cvt_fp4x2_to_halfraw2(__x, __NV_E2M1));
|
| 832 |
+
}
|
| 833 |
+
#endif /* !defined(__CUDA_NO_FP4_CONVERSION_OPERATORS__) */
|
| 834 |
+
#endif /* !defined(__CUDA_NO_FP4_CONVERSIONS__) */
|
| 835 |
+
};
|
| 836 |
+
|
| 837 |
+
/**
|
| 838 |
+
* \defgroup CUDA_MATH_FP4X4_E2M1_STRUCT C++ struct for handling vector type of four fp4 values of e2m1 kind.
|
| 839 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP4
|
| 840 |
+
*/
|
| 841 |
+
|
| 842 |
+
/**
|
| 843 |
+
* \ingroup CUDA_MATH_FP4X4_E2M1_STRUCT
|
| 844 |
+
* \brief __nv_fp4x4_e2m1 datatype
|
| 845 |
+
*
|
| 846 |
+
* \details This structure implements the datatype for handling four
|
| 847 |
+
* \p fp4 floating-point numbers of \p e2m1 kind each.
|
| 848 |
+
*
|
| 849 |
+
* The structure implements converting constructors and operators.
|
| 850 |
+
*/
|
| 851 |
+
struct __CUDA_ALIGN__(2) __nv_fp4x4_e2m1 {
|
| 852 |
+
public:
|
| 853 |
+
/**
|
| 854 |
+
* \ingroup CUDA_MATH_FP4X4_E2M1_STRUCT
|
| 855 |
+
* Storage variable contains the vector of four \p fp4 floating-point data
|
| 856 |
+
* values.
|
| 857 |
+
*/
|
| 858 |
+
__nv_fp4x4_storage_t __x;
|
| 859 |
+
|
| 860 |
+
/**
|
| 861 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 862 |
+
* Constructor by default.
|
| 863 |
+
*/
|
| 864 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP4)
|
| 865 |
+
__nv_fp4x4_e2m1() = default;
|
| 866 |
+
#else
|
| 867 |
+
__CUDA_HOSTDEVICE_FP4__ __nv_fp4x4_e2m1() {}
|
| 868 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP4) */
|
| 869 |
+
|
| 870 |
+
#if !defined(__CUDA_NO_FP4_CONVERSIONS__)
|
| 871 |
+
|
| 872 |
+
/* Construct from wider types */
|
| 873 |
+
|
| 874 |
+
/**
|
| 875 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 876 |
+
* Constructor from a pair of \p __half2 data type values,
|
| 877 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 878 |
+
*/
|
| 879 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4x4_e2m1(const __half2 flo,
|
| 880 |
+
const __half2 fhi) {
|
| 881 |
+
const __nv_fp4x2_storage_t rlo = __nv_cvt_halfraw2_to_fp4x2(
|
| 882 |
+
static_cast<__half2_raw>(flo), __NV_E2M1, cudaRoundNearest);
|
| 883 |
+
const __nv_fp4x2_storage_t rhi = __nv_cvt_halfraw2_to_fp4x2(
|
| 884 |
+
static_cast<__half2_raw>(fhi), __NV_E2M1, cudaRoundNearest);
|
| 885 |
+
__x = __internal_pack_u8x2_to_u16(rlo, rhi);
|
| 886 |
+
}
|
| 887 |
+
/**
|
| 888 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 889 |
+
* Constructor from a pair of \p __nv_bfloat162 data type values,
|
| 890 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 891 |
+
*/
|
| 892 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4x4_e2m1(const __nv_bfloat162 flo,
|
| 893 |
+
const __nv_bfloat162 fhi) {
|
| 894 |
+
const __nv_fp4x2_storage_t rlo = __nv_cvt_bfloat16raw2_to_fp4x2(
|
| 895 |
+
static_cast<__nv_bfloat162_raw>(flo), __NV_E2M1, cudaRoundNearest);
|
| 896 |
+
const __nv_fp4x2_storage_t rhi = __nv_cvt_bfloat16raw2_to_fp4x2(
|
| 897 |
+
static_cast<__nv_bfloat162_raw>(fhi), __NV_E2M1, cudaRoundNearest);
|
| 898 |
+
__x = __internal_pack_u8x2_to_u16(rlo, rhi);
|
| 899 |
+
}
|
| 900 |
+
/**
|
| 901 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 902 |
+
* Constructor from \p float4 vector data type,
|
| 903 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 904 |
+
*/
|
| 905 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4x4_e2m1(const float4 f) {
|
| 906 |
+
const float2 flo = {f.x, f.y};
|
| 907 |
+
const float2 fhi = {f.z, f.w};
|
| 908 |
+
const __nv_fp4x2_storage_t rlo =
|
| 909 |
+
__nv_cvt_float2_to_fp4x2(flo, __NV_E2M1, cudaRoundNearest);
|
| 910 |
+
const __nv_fp4x2_storage_t rhi =
|
| 911 |
+
__nv_cvt_float2_to_fp4x2(fhi, __NV_E2M1, cudaRoundNearest);
|
| 912 |
+
__x = __internal_pack_u8x2_to_u16(rlo, rhi);
|
| 913 |
+
}
|
| 914 |
+
/**
|
| 915 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 916 |
+
* Constructor from \p double4 vector data type,
|
| 917 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 918 |
+
*/
|
| 919 |
+
explicit __CUDA_HOSTDEVICE_FP4__ __nv_fp4x4_e2m1(const double4 f) {
|
| 920 |
+
const double2 flo = {f.x, f.y};
|
| 921 |
+
const double2 fhi = {f.z, f.w};
|
| 922 |
+
const __nv_fp4x2_storage_t rlo =
|
| 923 |
+
__nv_cvt_double2_to_fp4x2(flo, __NV_E2M1, cudaRoundNearest);
|
| 924 |
+
const __nv_fp4x2_storage_t rhi =
|
| 925 |
+
__nv_cvt_double2_to_fp4x2(fhi, __NV_E2M1, cudaRoundNearest);
|
| 926 |
+
__x = __internal_pack_u8x2_to_u16(rlo, rhi);
|
| 927 |
+
}
|
| 928 |
+
|
| 929 |
+
#if !defined(__CUDA_NO_FP4_CONVERSION_OPERATORS__)
|
| 930 |
+
/* Widening converts */
|
| 931 |
+
|
| 932 |
+
/**
|
| 933 |
+
* \ingroup CUDA_MATH_FP4_MISC
|
| 934 |
+
* Conversion operator to \p float4 vector data type.
|
| 935 |
+
*/
|
| 936 |
+
explicit __CUDA_HOSTDEVICE_FP4__ operator float4() const {
|
| 937 |
+
const __nv_fp4x2_storage_t slo = static_cast<__nv_fp4x2_storage_t>(__x);
|
| 938 |
+
const __nv_fp4x2_storage_t shi =
|
| 939 |
+
static_cast<__nv_fp4x2_storage_t>(__x >> 8U);
|
| 940 |
+
float2 rlo = __internal_halfraw2_to_float2(
|
| 941 |
+
__nv_cvt_fp4x2_to_halfraw2(slo, __NV_E2M1));
|
| 942 |
+
float2 rhi = __internal_halfraw2_to_float2(
|
| 943 |
+
__nv_cvt_fp4x2_to_halfraw2(shi, __NV_E2M1));
|
| 944 |
+
float4 res = {rlo.x, rlo.y, rhi.x, rhi.y};
|
| 945 |
+
return res;
|
| 946 |
+
}
|
| 947 |
+
#endif /* !defined(__CUDA_NO_FP4_CONVERSION_OPERATORS__) */
|
| 948 |
+
#endif /* !defined(__CUDA_NO_FP4_CONVERSIONS__) */
|
| 949 |
+
};
|
| 950 |
+
|
| 951 |
+
#endif /* defined(__cplusplus) */
|
| 952 |
+
|
| 953 |
+
#endif /* end of include guard: __CUDA_FP4_HPP__ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp6.h
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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yright 2024 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef __CUDA_FP6_H__
|
| 51 |
+
#define __CUDA_FP6_H__
|
| 52 |
+
|
| 53 |
+
/* Set up function decorations */
|
| 54 |
+
#if defined(__CUDACC__)
|
| 55 |
+
#define __CUDA_FP6_DECL__ static __device__ __inline__
|
| 56 |
+
#define __CUDA_HOSTDEVICE_FP6__ __host__ __device__
|
| 57 |
+
#define __CUDA_HOSTDEVICE_FP6_DECL__ static __host__ __device__ __inline__
|
| 58 |
+
#else /* !defined(__CUDACC__) */
|
| 59 |
+
#if defined(__GNUC__)
|
| 60 |
+
#define __CUDA_HOSTDEVICE_FP6_DECL__ static __attribute__((unused))
|
| 61 |
+
#else
|
| 62 |
+
#define __CUDA_HOSTDEVICE_FP6_DECL__ static
|
| 63 |
+
#endif /* defined(__GNUC__) */
|
| 64 |
+
#define __CUDA_HOSTDEVICE_FP6__
|
| 65 |
+
#endif /* defined(__CUDACC_) */
|
| 66 |
+
|
| 67 |
+
#if !defined(_MSC_VER) && __cplusplus >= 201103L
|
| 68 |
+
#define __CPP_VERSION_AT_LEAST_11_FP6
|
| 69 |
+
#elif _MSC_FULL_VER >= 190024210 && _MSVC_LANG >= 201103L
|
| 70 |
+
#define __CPP_VERSION_AT_LEAST_11_FP6
|
| 71 |
+
#endif
|
| 72 |
+
|
| 73 |
+
/* bring in fp8 types infrastructure and dependencies */
|
| 74 |
+
#include "cuda_fp8.h"
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* \defgroup CUDA_MATH_INTRINSIC_FP6 FP6 Intrinsics
|
| 78 |
+
* This section describes fp6 intrinsic functions.
|
| 79 |
+
* To use these functions, include the header file \p cuda_fp6.h in your
|
| 80 |
+
* program.
|
| 81 |
+
*
|
| 82 |
+
* \note Most of the operations defined here benefit from native HW support
|
| 83 |
+
* when compiled for specific GPU targets (e.g. devices of compute capability 10.0a),
|
| 84 |
+
* other targets use emulation path.
|
| 85 |
+
*
|
| 86 |
+
* The following macros are available to help users selectively enable/disable
|
| 87 |
+
* various definitions present in the header file:
|
| 88 |
+
* - \p __CUDA_NO_FP6_CONVERSIONS__ - If defined, this macro will prevent any
|
| 89 |
+
* use of the C++ type conversions (converting constructors and conversion
|
| 90 |
+
* operators) defined in the header.
|
| 91 |
+
* - \p __CUDA_NO_FP6_CONVERSION_OPERATORS__ - If defined, this macro will
|
| 92 |
+
* prevent any use of the C++ conversion operators from \p fp6 to other types.
|
| 93 |
+
*/
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* \defgroup CUDA_MATH_FP6_MISC FP6 Conversion and Data Movement
|
| 97 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP6
|
| 98 |
+
* To use these functions, include the header file \p cuda_fp6.h in your
|
| 99 |
+
* program.
|
| 100 |
+
*/
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 104 |
+
* \brief 8-bit \p unsigned \p integer
|
| 105 |
+
* type abstraction used for \p fp6 floating-point
|
| 106 |
+
* numbers storage.
|
| 107 |
+
*/
|
| 108 |
+
typedef __nv_fp8_storage_t __nv_fp6_storage_t;
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 112 |
+
* \brief 16-bit \p unsigned \p integer
|
| 113 |
+
* type abstraction used for storage of pairs of
|
| 114 |
+
* \p fp6 floating-point numbers.
|
| 115 |
+
*/
|
| 116 |
+
typedef __nv_fp8x2_storage_t __nv_fp6x2_storage_t;
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 120 |
+
* \brief 32-bit \p unsigned \p integer
|
| 121 |
+
* type abstraction used for storage of tetrads of
|
| 122 |
+
* \p fp6 floating-point numbers.
|
| 123 |
+
*/
|
| 124 |
+
typedef __nv_fp8x4_storage_t __nv_fp6x4_storage_t;
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 128 |
+
* \brief Enumerates the possible
|
| 129 |
+
* interpretations of the 8-bit values when referring to them as
|
| 130 |
+
* \p fp6 types.
|
| 131 |
+
*/
|
| 132 |
+
typedef enum __nv_fp6_interpretation_t {
|
| 133 |
+
__NV_E2M3, /**< Stands for \p fp6 numbers of \p e2m3 kind. */
|
| 134 |
+
__NV_E3M2, /**< Stands for \p fp6 numbers of \p e3m2 kind. */
|
| 135 |
+
} __nv_fp6_interpretation_t;
|
| 136 |
+
|
| 137 |
+
/* Forward-declaration of C-style APIs */
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 141 |
+
* \brief Converts input \p double precision \p x to \p fp6 type of the
|
| 142 |
+
* requested kind using specified rounding mode and saturating
|
| 143 |
+
* the out-of-range values.
|
| 144 |
+
*
|
| 145 |
+
* \details Converts input \p x to \p fp6 type of the kind specified by
|
| 146 |
+
* \p fp6_interpretation parameter,
|
| 147 |
+
* using rounding mode specified by \p rounding parameter.
|
| 148 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 149 |
+
* \p NaN input values result in positive MAXNORM.
|
| 150 |
+
*
|
| 151 |
+
* \returns
|
| 152 |
+
* - The \p __nv_fp6_storage_t value holds the result of conversion.
|
| 153 |
+
*/
|
| 154 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6_storage_t
|
| 155 |
+
__nv_cvt_double_to_fp6(const double x,
|
| 156 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 157 |
+
const enum cudaRoundMode rounding);
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 161 |
+
* \brief Converts input vector of two \p double precision numbers packed
|
| 162 |
+
* in \p double2 \p x into a vector of two values of \p fp6 type of the
|
| 163 |
+
* requested kind using specified rounding mode and saturating
|
| 164 |
+
* the out-of-range values.
|
| 165 |
+
*
|
| 166 |
+
* \details Converts input vector \p x to a vector of two \p fp6 values of the
|
| 167 |
+
* kind specified by \p fp6_interpretation parameter, using
|
| 168 |
+
* rounding mode specified by \p rounding parameter.
|
| 169 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 170 |
+
* \p NaN input values result in positive MAXNORM.
|
| 171 |
+
*
|
| 172 |
+
* \returns
|
| 173 |
+
* - The \p __nv_fp6x2_storage_t value holds the result of conversion.
|
| 174 |
+
*/
|
| 175 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6x2_storage_t
|
| 176 |
+
__nv_cvt_double2_to_fp6x2(const double2 x,
|
| 177 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 178 |
+
const enum cudaRoundMode rounding);
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 182 |
+
* \brief Converts input \p single precision \p x to \p fp6 type of the
|
| 183 |
+
* requested kind using specified rounding mode and saturating
|
| 184 |
+
* the out-of-range values.
|
| 185 |
+
*
|
| 186 |
+
* \details Converts input \p x to \p fp6 type of the kind specified by
|
| 187 |
+
* \p fp6_interpretation parameter, using
|
| 188 |
+
* rounding mode specified by \p rounding parameter.
|
| 189 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 190 |
+
* \p NaN input values result in positive MAXNORM.
|
| 191 |
+
*
|
| 192 |
+
* \returns
|
| 193 |
+
* - The \p __nv_fp6_storage_t value holds the result of conversion.
|
| 194 |
+
*/
|
| 195 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6_storage_t
|
| 196 |
+
__nv_cvt_float_to_fp6(const float x,
|
| 197 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 198 |
+
const enum cudaRoundMode rounding);
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 202 |
+
* \brief Converts input vector of two \p single precision numbers packed
|
| 203 |
+
* in \p float2 \p x into a vector of two values of \p fp6 type of the
|
| 204 |
+
* requested kind using specified rounding mode and saturating
|
| 205 |
+
* the out-of-range values.
|
| 206 |
+
*
|
| 207 |
+
* \details Converts input vector \p x to a vector of two \p fp6 values of the
|
| 208 |
+
* kind specified by \p fp6_interpretation parameter,
|
| 209 |
+
* using rounding mode specified by \p rounding parameter.
|
| 210 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 211 |
+
* \p NaN input values result in positive MAXNORM.
|
| 212 |
+
*
|
| 213 |
+
* \returns
|
| 214 |
+
* - The \p __nv_fp6x2_storage_t value holds the result of conversion.
|
| 215 |
+
*/
|
| 216 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6x2_storage_t
|
| 217 |
+
__nv_cvt_float2_to_fp6x2(const float2 x,
|
| 218 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 219 |
+
const enum cudaRoundMode rounding);
|
| 220 |
+
|
| 221 |
+
/**
|
| 222 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 223 |
+
* \brief Converts input \p half precision \p x to \p fp6 type of the
|
| 224 |
+
* requested kind using specified rounding mode and saturating
|
| 225 |
+
* the out-of-range values.
|
| 226 |
+
*
|
| 227 |
+
* \details Converts input \p x to \p fp6 type of the kind specified by
|
| 228 |
+
* \p fp6_interpretation parameter,
|
| 229 |
+
* using rounding mode specified by \p rounding parameter.
|
| 230 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 231 |
+
* \p NaN input values result in positive MAXNORM.
|
| 232 |
+
*
|
| 233 |
+
* \returns
|
| 234 |
+
* - The \p __nv_fp6_storage_t value holds the result of conversion.
|
| 235 |
+
*/
|
| 236 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6_storage_t
|
| 237 |
+
__nv_cvt_halfraw_to_fp6(const __half_raw x,
|
| 238 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 239 |
+
const enum cudaRoundMode rounding);
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 243 |
+
* \brief Converts input vector of two \p half precision numbers packed
|
| 244 |
+
* in \p __half2_raw \p x into a vector of two values of \p fp6 type of the
|
| 245 |
+
* requested kind using specified rounding mode and saturating
|
| 246 |
+
* the out-of-range values.
|
| 247 |
+
*
|
| 248 |
+
* \details Converts input vector \p x to a vector of two \p fp6 values of the
|
| 249 |
+
* kind specified by \p fp6_interpretation parameter,
|
| 250 |
+
* using rounding mode specified by \p rounding parameter.
|
| 251 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 252 |
+
* \p NaN input values result in positive MAXNORM.
|
| 253 |
+
*
|
| 254 |
+
* \returns
|
| 255 |
+
* - The \p __nv_fp6x2_storage_t value holds the result of conversion.
|
| 256 |
+
*/
|
| 257 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6x2_storage_t __nv_cvt_halfraw2_to_fp6x2(
|
| 258 |
+
const __half2_raw x,
|
| 259 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 260 |
+
const enum cudaRoundMode rounding);
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 264 |
+
* \brief Converts input \p nv_bfloat16 precision \p x to \p fp6 type of the
|
| 265 |
+
* requested kind using specified rounding mode and saturating
|
| 266 |
+
* the out-of-range values.
|
| 267 |
+
*
|
| 268 |
+
* \details Converts input \p x to \p fp6 type of the kind specified by
|
| 269 |
+
* \p fp6_interpretation parameter,
|
| 270 |
+
* using rounding mode specified by \p rounding parameter.
|
| 271 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 272 |
+
* \p NaN input values result in positive MAXNORM.
|
| 273 |
+
*
|
| 274 |
+
* \returns
|
| 275 |
+
* - The \p __nv_fp6_storage_t value holds the result of conversion.
|
| 276 |
+
*/
|
| 277 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6_storage_t __nv_cvt_bfloat16raw_to_fp6(
|
| 278 |
+
const __nv_bfloat16_raw x,
|
| 279 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 280 |
+
const enum cudaRoundMode rounding);
|
| 281 |
+
|
| 282 |
+
/**
|
| 283 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 284 |
+
* \brief Converts input vector of two \p nv_bfloat16 precision numbers packed
|
| 285 |
+
* in \p __nv_bfloat162_raw \p x into a vector of two values of \p fp6 type of the
|
| 286 |
+
* requested kind using specified rounding mode and saturating
|
| 287 |
+
* the out-of-range values.
|
| 288 |
+
*
|
| 289 |
+
* \details Converts input vector \p x to a vector of two \p fp6 values of the
|
| 290 |
+
* kind specified by \p fp6_interpretation parameter,
|
| 291 |
+
* using rounding mode specified by \p rounding parameter.
|
| 292 |
+
* Large out-of-range values saturate to MAXNORM of the same sign.
|
| 293 |
+
* \p NaN input values result in positive MAXNORM.
|
| 294 |
+
*
|
| 295 |
+
* \returns
|
| 296 |
+
* - The \p __nv_fp6x2_storage_t value holds the result of conversion.
|
| 297 |
+
*/
|
| 298 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6x2_storage_t
|
| 299 |
+
__nv_cvt_bfloat16raw2_to_fp6x2(
|
| 300 |
+
const __nv_bfloat162_raw x,
|
| 301 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 302 |
+
const enum cudaRoundMode rounding);
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 306 |
+
* \brief Converts input \p fp6 \p x of the specified kind
|
| 307 |
+
* to \p half precision.
|
| 308 |
+
*
|
| 309 |
+
* \details Converts input \p x of \p fp6 type of the kind specified by
|
| 310 |
+
* \p fp6_interpretation parameter
|
| 311 |
+
* to \p half precision.
|
| 312 |
+
*
|
| 313 |
+
* \returns
|
| 314 |
+
* - The \p __half_raw value holds the result of conversion.
|
| 315 |
+
*/
|
| 316 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __half_raw
|
| 317 |
+
__nv_cvt_fp6_to_halfraw(const __nv_fp6_storage_t x,
|
| 318 |
+
const __nv_fp6_interpretation_t fp6_interpretation);
|
| 319 |
+
/**
|
| 320 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 321 |
+
* \brief Converts input vector of two \p fp6 values of the specified kind
|
| 322 |
+
* to a vector of two \p half precision values packed in \p __half2_raw
|
| 323 |
+
* structure.
|
| 324 |
+
*
|
| 325 |
+
* \details Converts input vector \p x of \p fp6 type of the kind specified by
|
| 326 |
+
* \p fp6_interpretation parameter
|
| 327 |
+
* to a vector of two \p half precision values and returns as \p __half2_raw
|
| 328 |
+
* structure.
|
| 329 |
+
*
|
| 330 |
+
* \returns
|
| 331 |
+
* - The \p __half2_raw value holds the result of conversion.
|
| 332 |
+
*/
|
| 333 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __half2_raw
|
| 334 |
+
__nv_cvt_fp6x2_to_halfraw2(const __nv_fp6x2_storage_t x,
|
| 335 |
+
const __nv_fp6_interpretation_t fp6_interpretation);
|
| 336 |
+
|
| 337 |
+
#if defined(__cplusplus)
|
| 338 |
+
|
| 339 |
+
#define __CUDA_FP6_TYPES_EXIST__
|
| 340 |
+
|
| 341 |
+
/* Forward-declaration of structures defined in "cuda_fp6.hpp" */
|
| 342 |
+
struct __nv_fp6_e3m2;
|
| 343 |
+
struct __nv_fp6x2_e3m2;
|
| 344 |
+
struct __nv_fp6x4_e3m2;
|
| 345 |
+
|
| 346 |
+
struct __nv_fp6_e2m3;
|
| 347 |
+
struct __nv_fp6x2_e2m3;
|
| 348 |
+
struct __nv_fp6x4_e2m3;
|
| 349 |
+
|
| 350 |
+
#endif /* defined(__cplusplus) */
|
| 351 |
+
|
| 352 |
+
#include "cuda_fp6.hpp"
|
| 353 |
+
|
| 354 |
+
#undef __CUDA_FP6_DECL__
|
| 355 |
+
#undef __CUDA_HOSTDEVICE_FP6__
|
| 356 |
+
#undef __CUDA_HOSTDEVICE_FP6_DECL__
|
| 357 |
+
|
| 358 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP6)
|
| 359 |
+
#undef __CPP_VERSION_AT_LEAST_11_FP6
|
| 360 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP6) */
|
| 361 |
+
|
| 362 |
+
#endif /* end of include guard: __CUDA_FP6_H__ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp6.hpp
ADDED
|
@@ -0,0 +1,1549 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_FP6_HPP__)
|
| 51 |
+
#define __CUDA_FP6_HPP__
|
| 52 |
+
|
| 53 |
+
#if !defined(__CUDA_FP6_H__)
|
| 54 |
+
#error "Do not include this file directly. Instead, include cuda_fp6.h."
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
/* C++ header for std::memcpy (used for type punning in host-side
|
| 58 |
+
* implementations). When compiling as a CUDA source file memcpy is provided
|
| 59 |
+
* implicitly. !defined(__CUDACC__) implies !defined(__CUDACC_RTC__).
|
| 60 |
+
*/
|
| 61 |
+
#if defined(__cplusplus) && !defined(__CUDACC__)
|
| 62 |
+
#include <cstring>
|
| 63 |
+
#elif !defined(__cplusplus) && !defined(__CUDACC__)
|
| 64 |
+
#include <string.h>
|
| 65 |
+
#endif /* defined(__cplusplus) && !defined(__CUDACC__) */
|
| 66 |
+
|
| 67 |
+
/*
|
| 68 |
+
* Bring in the standard assertions header to enforce the subset
|
| 69 |
+
* of rounding modes supported by the APIs defined here.
|
| 70 |
+
* NOTE: NVRTC defines its own assert
|
| 71 |
+
*/
|
| 72 |
+
#if !defined (__CUDACC_RTC__)
|
| 73 |
+
#include <assert.h>
|
| 74 |
+
#endif
|
| 75 |
+
|
| 76 |
+
/* Set up structure-alignment attribute */
|
| 77 |
+
#if !(defined __CUDA_ALIGN__)
|
| 78 |
+
#if defined(__CUDACC__)
|
| 79 |
+
#define __CUDA_ALIGN__(align) __align__(align)
|
| 80 |
+
#else
|
| 81 |
+
/* Define alignment macro based on compiler type (cannot assume C11 "_Alignas"
|
| 82 |
+
* is available) */
|
| 83 |
+
#if __cplusplus >= 201103L
|
| 84 |
+
#define __CUDA_ALIGN__(n) \
|
| 85 |
+
alignas(n) /* C++11 kindly gives us a keyword for this */
|
| 86 |
+
#else /* !defined(__CPP_VERSION_AT_LEAST_11_FP6)*/
|
| 87 |
+
#if defined(__GNUC__)
|
| 88 |
+
#define __CUDA_ALIGN__(n) __attribute__((aligned(n)))
|
| 89 |
+
#elif defined(_MSC_VER)
|
| 90 |
+
#define __CUDA_ALIGN__(n) __declspec(align(n))
|
| 91 |
+
#else
|
| 92 |
+
#define __CUDA_ALIGN__(n)
|
| 93 |
+
#endif /* defined(__GNUC__) */
|
| 94 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP6) */
|
| 95 |
+
#endif /* defined(__CUDACC__) */
|
| 96 |
+
#endif /* !(defined __CUDA_ALIGN__) */
|
| 97 |
+
|
| 98 |
+
#if !(defined __CPP_VERSION_AT_LEAST_11_FP6)
|
| 99 |
+
/* need c++11 for explicit operators */
|
| 100 |
+
#define __CUDA_NO_FP6_CONVERSION_OPERATORS__
|
| 101 |
+
#endif
|
| 102 |
+
|
| 103 |
+
#if !(defined __DOXYGEN_ONLY__)
|
| 104 |
+
|
| 105 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6_storage_t
|
| 106 |
+
__nv_cvt_double_to_fp6(const double x,
|
| 107 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 108 |
+
const enum cudaRoundMode rounding) {
|
| 109 |
+
unsigned char res;
|
| 110 |
+
unsigned long long int xbits;
|
| 111 |
+
|
| 112 |
+
#if defined(__CUDACC__) || (!defined __cplusplus)
|
| 113 |
+
(void)memcpy(&xbits, &x, sizeof(x));
|
| 114 |
+
#else
|
| 115 |
+
(void)std::memcpy(&xbits, &x, sizeof(x));
|
| 116 |
+
#endif
|
| 117 |
+
unsigned char FP6_MAXNORM;
|
| 118 |
+
unsigned char FP6_MANTISSA_MASK;
|
| 119 |
+
unsigned short int FP6_EXP_BIAS;
|
| 120 |
+
unsigned long long int FP6_SIGNIFICAND_BITS;
|
| 121 |
+
unsigned long long int FP6_MINDENORM_O2;
|
| 122 |
+
unsigned long long int FP6_OVERFLOW_THRESHOLD;
|
| 123 |
+
unsigned long long int FP6_MINNORM;
|
| 124 |
+
const unsigned long long int DP_INF_BITS = 0x7FF0000000000000ULL;
|
| 125 |
+
|
| 126 |
+
switch (fp6_interpretation)
|
| 127 |
+
{
|
| 128 |
+
case __NV_E2M3:
|
| 129 |
+
FP6_EXP_BIAS = 1U;
|
| 130 |
+
FP6_SIGNIFICAND_BITS = 4ULL;
|
| 131 |
+
FP6_MANTISSA_MASK = 0x7U;
|
| 132 |
+
FP6_MINDENORM_O2 = 0x3FB0000000000000ULL; // mindenorm/2 = 2^-4
|
| 133 |
+
FP6_OVERFLOW_THRESHOLD =
|
| 134 |
+
0x401E000000000000ULL; // maxnorm = 7.5
|
| 135 |
+
FP6_MAXNORM = 0x1FU;
|
| 136 |
+
FP6_MINNORM = 0x3FF0000000000000ULL; // minnorm = 2^0
|
| 137 |
+
break;
|
| 138 |
+
case __NV_E3M2:
|
| 139 |
+
default:
|
| 140 |
+
FP6_EXP_BIAS = 3U;
|
| 141 |
+
FP6_SIGNIFICAND_BITS = 3ULL;
|
| 142 |
+
FP6_MANTISSA_MASK = 0x3U;
|
| 143 |
+
FP6_MINDENORM_O2 = 0x3FA0000000000000ULL; // mindenorm/2 = 2^-5
|
| 144 |
+
FP6_OVERFLOW_THRESHOLD =
|
| 145 |
+
0x403C000000000000ULL; // maxnorm = 28
|
| 146 |
+
FP6_MAXNORM = 0x1FU;
|
| 147 |
+
FP6_MINNORM = 0x3FD0000000000000ULL; // minnorm = 2^-2
|
| 148 |
+
break;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
// 1/2 LSB of the target format, positioned in double precision mantissa
|
| 152 |
+
// helpful in midpoints detection during round-to-nearest-even step
|
| 153 |
+
const unsigned long long int FP6_DP_HALF_ULP =
|
| 154 |
+
(unsigned long long int)1ULL << (53ULL - FP6_SIGNIFICAND_BITS - 1ULL);
|
| 155 |
+
// prepare sign bit in target format
|
| 156 |
+
unsigned char sign = (unsigned char)((xbits >> 63ULL) << 5U);
|
| 157 |
+
// prepare exponent field in target format
|
| 158 |
+
unsigned char exp =
|
| 159 |
+
(unsigned char)((((unsigned short int)(xbits >> 52ULL)) & 0x7FFU) -
|
| 160 |
+
1023U + FP6_EXP_BIAS);
|
| 161 |
+
// round mantissa to target format width, rounding towards zero
|
| 162 |
+
unsigned char mantissa =
|
| 163 |
+
(unsigned char)(xbits >> (53ULL - FP6_SIGNIFICAND_BITS)) &
|
| 164 |
+
FP6_MANTISSA_MASK;
|
| 165 |
+
unsigned long long int absx = xbits & 0x7FFFFFFFFFFFFFFFULL;
|
| 166 |
+
|
| 167 |
+
if (absx <= FP6_MINDENORM_O2) {
|
| 168 |
+
// zero or underflow
|
| 169 |
+
res = 0U;
|
| 170 |
+
} else if (absx > FP6_OVERFLOW_THRESHOLD) {
|
| 171 |
+
// overflow or NaN
|
| 172 |
+
if (absx > DP_INF_BITS)
|
| 173 |
+
{
|
| 174 |
+
// NaN converts to positive FP6_MAXNORM
|
| 175 |
+
sign = 0U;
|
| 176 |
+
}
|
| 177 |
+
res = FP6_MAXNORM;
|
| 178 |
+
} else if (absx >= FP6_MINNORM) {
|
| 179 |
+
res = (unsigned char)((exp << (FP6_SIGNIFICAND_BITS - 1U)) | mantissa);
|
| 180 |
+
// rounded-off bits
|
| 181 |
+
unsigned long long int round =
|
| 182 |
+
xbits & ((FP6_DP_HALF_ULP << 1ULL) - 1ULL);
|
| 183 |
+
if (rounding == cudaRoundNearest)
|
| 184 |
+
{
|
| 185 |
+
// round-to-nearest-even adjustment
|
| 186 |
+
if ((round > FP6_DP_HALF_ULP) ||
|
| 187 |
+
((round == FP6_DP_HALF_ULP) && (mantissa & 1U))) {
|
| 188 |
+
res = (unsigned char)(res + 1U);
|
| 189 |
+
}
|
| 190 |
+
} else {
|
| 191 |
+
assert(rounding == cudaRoundZero);
|
| 192 |
+
}
|
| 193 |
+
} else // Denormal range
|
| 194 |
+
{
|
| 195 |
+
unsigned char shift = (unsigned char)(1U - exp);
|
| 196 |
+
// add implicit leading bit
|
| 197 |
+
mantissa |= (unsigned char)(1U << (FP6_SIGNIFICAND_BITS - 1U));
|
| 198 |
+
// additional round-off due to denormalization
|
| 199 |
+
res = (unsigned char)(mantissa >> shift);
|
| 200 |
+
|
| 201 |
+
if (rounding == cudaRoundNearest)
|
| 202 |
+
{
|
| 203 |
+
// rounded-off bits, including implicit leading bit
|
| 204 |
+
unsigned long long int round =
|
| 205 |
+
(xbits | ((unsigned long long int)1ULL << (53ULL - 1ULL))) &
|
| 206 |
+
((FP6_DP_HALF_ULP << (shift + 1ULL)) - 1ULL);
|
| 207 |
+
// round-to-nearest-even adjustment
|
| 208 |
+
if ((round > (FP6_DP_HALF_ULP << shift)) ||
|
| 209 |
+
((round == (FP6_DP_HALF_ULP << shift)) && (res & 1U))) {
|
| 210 |
+
res = (unsigned char)(res + 1U);
|
| 211 |
+
}
|
| 212 |
+
} else {
|
| 213 |
+
assert(rounding == cudaRoundZero);
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
res |= sign;
|
| 218 |
+
|
| 219 |
+
return (__nv_fp6_storage_t)res;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6x2_storage_t
|
| 223 |
+
__nv_cvt_double2_to_fp6x2(const double2 x,
|
| 224 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 225 |
+
const enum cudaRoundMode rounding) {
|
| 226 |
+
__nv_fp6x2_storage_t storage = (__nv_fp6x2_storage_t)__nv_cvt_double_to_fp6(
|
| 227 |
+
x.y, fp6_interpretation, rounding);
|
| 228 |
+
storage = (__nv_fp6x2_storage_t)(storage << 8U);
|
| 229 |
+
storage = (__nv_fp6x2_storage_t)(storage |
|
| 230 |
+
__nv_cvt_double_to_fp6(
|
| 231 |
+
x.x, fp6_interpretation, rounding));
|
| 232 |
+
return storage;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6_storage_t
|
| 236 |
+
__nv_cvt_float_to_fp6(const float x,
|
| 237 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 238 |
+
const enum cudaRoundMode rounding) {
|
| 239 |
+
__nv_fp6_storage_t res = 0U;
|
| 240 |
+
assert((rounding == cudaRoundNearest) || (rounding == cudaRoundZero));
|
| 241 |
+
#if ((defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && \
|
| 242 |
+
((__CUDA_ARCH_HAS_FEATURE__(SM100_ALL)) || \
|
| 243 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM101_ALL)) || \
|
| 244 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM120_ALL))))
|
| 245 |
+
if (rounding == cudaRoundNearest)
|
| 246 |
+
{
|
| 247 |
+
__nv_fp6x2_storage_t storage;
|
| 248 |
+
if (fp6_interpretation == __NV_E3M2) {
|
| 249 |
+
asm("{cvt.rn.satfinite.e3m2x2.f32 %0, %2, %1;}\n"
|
| 250 |
+
: "=h"(storage)
|
| 251 |
+
: "f"(x), "f"(0.0f));
|
| 252 |
+
} else {
|
| 253 |
+
asm("{cvt.rn.satfinite.e2m3x2.f32 %0, %2, %1;}\n"
|
| 254 |
+
: "=h"(storage)
|
| 255 |
+
: "f"(x), "f"(0.0f));
|
| 256 |
+
}
|
| 257 |
+
res = (__nv_fp6_storage_t)storage;
|
| 258 |
+
} else
|
| 259 |
+
#endif
|
| 260 |
+
{
|
| 261 |
+
res = __nv_cvt_double_to_fp6((double)x, fp6_interpretation, rounding);
|
| 262 |
+
}
|
| 263 |
+
return res;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6x2_storage_t
|
| 267 |
+
__nv_cvt_float2_to_fp6x2(const float2 x,
|
| 268 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 269 |
+
const enum cudaRoundMode rounding) {
|
| 270 |
+
assert((rounding == cudaRoundNearest) || (rounding == cudaRoundZero));
|
| 271 |
+
__nv_fp6x2_storage_t storage;
|
| 272 |
+
#if ((defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && \
|
| 273 |
+
((__CUDA_ARCH_HAS_FEATURE__(SM100_ALL)) || \
|
| 274 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM101_ALL)) || \
|
| 275 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM120_ALL))))
|
| 276 |
+
if (rounding == cudaRoundNearest) {
|
| 277 |
+
if (fp6_interpretation == __NV_E3M2) {
|
| 278 |
+
asm("{cvt.rn.satfinite.e3m2x2.f32 %0, %2, %1;}\n"
|
| 279 |
+
: "=h"(storage)
|
| 280 |
+
: "f"(x.x), "f"(x.y));
|
| 281 |
+
} else {
|
| 282 |
+
asm("{cvt.rn.satfinite.e2m3x2.f32 %0, %2, %1;}\n"
|
| 283 |
+
: "=h"(storage)
|
| 284 |
+
: "f"(x.x), "f"(x.y));
|
| 285 |
+
}
|
| 286 |
+
} else
|
| 287 |
+
#endif
|
| 288 |
+
{
|
| 289 |
+
storage = (__nv_fp6x2_storage_t)__nv_cvt_float_to_fp6(
|
| 290 |
+
x.y, fp6_interpretation, rounding);
|
| 291 |
+
storage = (__nv_fp6x2_storage_t)(storage << 8U);
|
| 292 |
+
storage = (__nv_fp6x2_storage_t)(storage | __nv_cvt_float_to_fp6(
|
| 293 |
+
x.x,
|
| 294 |
+
fp6_interpretation, rounding));
|
| 295 |
+
}
|
| 296 |
+
return storage;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6_storage_t
|
| 300 |
+
__nv_cvt_halfraw_to_fp6(const __half_raw x,
|
| 301 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 302 |
+
const enum cudaRoundMode rounding) {
|
| 303 |
+
assert((rounding == cudaRoundNearest) || (rounding == cudaRoundZero));
|
| 304 |
+
__nv_fp6_storage_t res = 0U;
|
| 305 |
+
float fx = __internal_halfraw_to_float(x);
|
| 306 |
+
res = __nv_cvt_float_to_fp6(fx, fp6_interpretation, rounding);
|
| 307 |
+
return res;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6x2_storage_t __nv_cvt_halfraw2_to_fp6x2(
|
| 311 |
+
const __half2_raw x,
|
| 312 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 313 |
+
const enum cudaRoundMode rounding) {
|
| 314 |
+
assert((rounding == cudaRoundNearest) || (rounding == cudaRoundZero));
|
| 315 |
+
__nv_fp6x2_storage_t tmp;
|
| 316 |
+
__half_raw raw;
|
| 317 |
+
raw.x = x.x;
|
| 318 |
+
__nv_fp6_storage_t lo =
|
| 319 |
+
__nv_cvt_halfraw_to_fp6(raw, fp6_interpretation, rounding);
|
| 320 |
+
raw.x = x.y;
|
| 321 |
+
__nv_fp6_storage_t hi =
|
| 322 |
+
__nv_cvt_halfraw_to_fp6(raw, fp6_interpretation, rounding);
|
| 323 |
+
tmp = hi;
|
| 324 |
+
tmp = (__nv_fp6x2_storage_t)(tmp << 8U);
|
| 325 |
+
tmp = (__nv_fp6x2_storage_t)(tmp | lo);
|
| 326 |
+
return tmp;
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6_storage_t __nv_cvt_bfloat16raw_to_fp6(
|
| 330 |
+
const __nv_bfloat16_raw x,
|
| 331 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 332 |
+
const enum cudaRoundMode rounding) {
|
| 333 |
+
const float fx = __internal_bf16raw_to_float(x);
|
| 334 |
+
const __nv_fp6_storage_t res =
|
| 335 |
+
__nv_cvt_float_to_fp6(fx, fp6_interpretation, rounding);
|
| 336 |
+
return res;
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __nv_fp6x2_storage_t
|
| 340 |
+
__nv_cvt_bfloat16raw2_to_fp6x2(
|
| 341 |
+
const __nv_bfloat162_raw x,
|
| 342 |
+
const __nv_fp6_interpretation_t fp6_interpretation,
|
| 343 |
+
const enum cudaRoundMode rounding) {
|
| 344 |
+
__nv_bfloat16_raw raw;
|
| 345 |
+
raw.x = x.y;
|
| 346 |
+
__nv_fp6x2_storage_t storage =
|
| 347 |
+
(__nv_fp6x2_storage_t)__nv_cvt_bfloat16raw_to_fp6(raw,
|
| 348 |
+
fp6_interpretation, rounding);
|
| 349 |
+
storage = (__nv_fp6x2_storage_t)(storage << 8U);
|
| 350 |
+
raw.x = x.x;
|
| 351 |
+
storage = (__nv_fp6x2_storage_t)(storage |
|
| 352 |
+
__nv_cvt_bfloat16raw_to_fp6(raw,
|
| 353 |
+
fp6_interpretation, rounding));
|
| 354 |
+
return storage;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __half2_raw
|
| 358 |
+
__nv_cvt_fp6x2_to_halfraw2(const __nv_fp6x2_storage_t x,
|
| 359 |
+
const __nv_fp6_interpretation_t fp6_interpretation);
|
| 360 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __half_raw
|
| 361 |
+
__nv_cvt_fp6_to_halfraw(const __nv_fp6_storage_t x,
|
| 362 |
+
const __nv_fp6_interpretation_t fp6_interpretation) {
|
| 363 |
+
__half_raw res;
|
| 364 |
+
res.x = 0U;
|
| 365 |
+
#if ((defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && \
|
| 366 |
+
((__CUDA_ARCH_HAS_FEATURE__(SM100_ALL)) || \
|
| 367 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM101_ALL)) || \
|
| 368 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM120_ALL))))
|
| 369 |
+
res.x =
|
| 370 |
+
__nv_cvt_fp6x2_to_halfraw2((__nv_fp6x2_storage_t)x, fp6_interpretation)
|
| 371 |
+
.x;
|
| 372 |
+
#else
|
| 373 |
+
{
|
| 374 |
+
unsigned short int ur = (unsigned short int)x;
|
| 375 |
+
ur = (unsigned short int)(ur << 10U);
|
| 376 |
+
|
| 377 |
+
unsigned short int sign = ur & 0x8000U;
|
| 378 |
+
unsigned short int exponent;
|
| 379 |
+
unsigned short int bias_difference;
|
| 380 |
+
unsigned short int mantissa;
|
| 381 |
+
|
| 382 |
+
if (fp6_interpretation == __NV_E3M2) {
|
| 383 |
+
bias_difference = (unsigned short int)(15 - 3) << 10U;
|
| 384 |
+
exponent = (unsigned short int)(((ur & 0x7000U) >> 2U) + bias_difference);
|
| 385 |
+
mantissa = (ur & 0x0C00U) >> 2U;
|
| 386 |
+
} else {
|
| 387 |
+
//__NV_E2M3
|
| 388 |
+
bias_difference = (unsigned short int)(15 - 1) << 10U;
|
| 389 |
+
exponent = (unsigned short int)(((ur & 0x6000U) >> 3U) + bias_difference);
|
| 390 |
+
mantissa = (ur & 0x1C00U) >> 3U;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
if (exponent == bias_difference) {
|
| 394 |
+
// zero or denormal
|
| 395 |
+
if (mantissa != 0U) {
|
| 396 |
+
// normalize
|
| 397 |
+
mantissa = (unsigned short int)(mantissa << 1U);
|
| 398 |
+
while ((mantissa & 0x0400U) == 0U) {
|
| 399 |
+
mantissa = (unsigned short int)(mantissa << 1U);
|
| 400 |
+
exponent = (unsigned short int)(exponent - 0x0400U);
|
| 401 |
+
}
|
| 402 |
+
// discard implicit leading bit
|
| 403 |
+
mantissa &= 0x03FFU;
|
| 404 |
+
} else { // Zero
|
| 405 |
+
exponent = 0U;
|
| 406 |
+
}
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
res.x = (sign | exponent) | mantissa;
|
| 410 |
+
}
|
| 411 |
+
#endif
|
| 412 |
+
return res;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
__CUDA_HOSTDEVICE_FP6_DECL__ __half2_raw
|
| 416 |
+
__nv_cvt_fp6x2_to_halfraw2(const __nv_fp6x2_storage_t x,
|
| 417 |
+
const __nv_fp6_interpretation_t fp6_interpretation) {
|
| 418 |
+
__half2_raw res;
|
| 419 |
+
#if ((defined __CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && \
|
| 420 |
+
((__CUDA_ARCH_HAS_FEATURE__(SM100_ALL)) || \
|
| 421 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM101_ALL)) || \
|
| 422 |
+
(__CUDA_ARCH_HAS_FEATURE__(SM120_ALL))))
|
| 423 |
+
unsigned int half2_storage;
|
| 424 |
+
if (fp6_interpretation == __NV_E3M2) {
|
| 425 |
+
asm("{cvt.rn.f16x2.e3m2x2 %0, %1;}\n" : "=r"(half2_storage) : "h"(x));
|
| 426 |
+
} else {
|
| 427 |
+
asm("{cvt.rn.f16x2.e2m3x2 %0, %1;}\n" : "=r"(half2_storage) : "h"(x));
|
| 428 |
+
}
|
| 429 |
+
(void)memcpy(&res, &half2_storage, sizeof(half2_storage));
|
| 430 |
+
#else
|
| 431 |
+
res.x =
|
| 432 |
+
__nv_cvt_fp6_to_halfraw((__nv_fp6_storage_t)x, fp6_interpretation).x;
|
| 433 |
+
res.y = __nv_cvt_fp6_to_halfraw((__nv_fp6_storage_t)(x >> 8U),
|
| 434 |
+
fp6_interpretation)
|
| 435 |
+
.x;
|
| 436 |
+
#endif
|
| 437 |
+
return res;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
#endif /* !(defined __DOXYGEN_ONLY__) */
|
| 441 |
+
|
| 442 |
+
/* All other definitions in this file are only visible to C++ compilers */
|
| 443 |
+
#if defined(__cplusplus)
|
| 444 |
+
|
| 445 |
+
/**
|
| 446 |
+
* \defgroup CUDA_MATH_FP6_E3M2_STRUCT C++ struct for handling fp6 data type of e3m2 kind.
|
| 447 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP6
|
| 448 |
+
*/
|
| 449 |
+
|
| 450 |
+
/**
|
| 451 |
+
* \ingroup CUDA_MATH_FP6_E3M2_STRUCT
|
| 452 |
+
* \brief __nv_fp6_e3m2 datatype
|
| 453 |
+
*
|
| 454 |
+
* \details This structure implements the datatype for handling
|
| 455 |
+
* \p fp6 floating-point numbers of \p e3m2 kind:
|
| 456 |
+
* with 1 sign, 3 exponent, 1 implicit and 2 explicit mantissa bits.
|
| 457 |
+
* This encoding does not support Inf/NaN.
|
| 458 |
+
*
|
| 459 |
+
* The structure implements converting constructors and operators.
|
| 460 |
+
*/
|
| 461 |
+
struct __CUDA_ALIGN__(1) __nv_fp6_e3m2 {
|
| 462 |
+
public:
|
| 463 |
+
/**
|
| 464 |
+
* \ingroup CUDA_MATH_FP6_E3M2_STRUCT
|
| 465 |
+
* Storage variable contains the \p fp6 floating-point data.
|
| 466 |
+
*/
|
| 467 |
+
__nv_fp6_storage_t __x;
|
| 468 |
+
|
| 469 |
+
/**
|
| 470 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 471 |
+
* Constructor by default.
|
| 472 |
+
*/
|
| 473 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP6)
|
| 474 |
+
__nv_fp6_e3m2() = default;
|
| 475 |
+
#else
|
| 476 |
+
__CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2() {}
|
| 477 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP6) */
|
| 478 |
+
|
| 479 |
+
#if !defined(__CUDA_NO_FP6_CONVERSIONS__)
|
| 480 |
+
|
| 481 |
+
/* Construct from wider FP types */
|
| 482 |
+
/* Note we do avoid constructor init-list because of special host/device
|
| 483 |
+
* compilation rules */
|
| 484 |
+
|
| 485 |
+
/**
|
| 486 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 487 |
+
* Constructor from \p __half data type, relies on \p __NV_SATFINITE
|
| 488 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 489 |
+
*/
|
| 490 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const __half f) {
|
| 491 |
+
__x = __nv_cvt_halfraw_to_fp6(static_cast<__half_raw>(f),
|
| 492 |
+
__NV_E3M2, cudaRoundNearest);
|
| 493 |
+
}
|
| 494 |
+
/**
|
| 495 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 496 |
+
* Constructor from \p __nv_bfloat16 data type, relies on \p __NV_SATFINITE
|
| 497 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 498 |
+
*/
|
| 499 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const __nv_bfloat16 f) {
|
| 500 |
+
__x = __nv_cvt_bfloat16raw_to_fp6(static_cast<__nv_bfloat16_raw>(f),
|
| 501 |
+
__NV_E3M2, cudaRoundNearest);
|
| 502 |
+
}
|
| 503 |
+
/**
|
| 504 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 505 |
+
* Constructor from \p float data type, relies on \p __NV_SATFINITE
|
| 506 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 507 |
+
*/
|
| 508 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const float f) {
|
| 509 |
+
__x = __nv_cvt_float_to_fp6(f, __NV_E3M2, cudaRoundNearest);
|
| 510 |
+
}
|
| 511 |
+
/**
|
| 512 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 513 |
+
* Constructor from \p double data type, relies on \p __NV_SATFINITE
|
| 514 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 515 |
+
*/
|
| 516 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const double f) {
|
| 517 |
+
__x = __nv_cvt_double_to_fp6(f, __NV_E3M2, cudaRoundNearest);
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
/* Converts from integral */
|
| 521 |
+
|
| 522 |
+
/**
|
| 523 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 524 |
+
* Constructor from \p unsigned \p short \p int data type, relies on \p
|
| 525 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 526 |
+
*/
|
| 527 |
+
explicit __CUDA_HOSTDEVICE_FP6__
|
| 528 |
+
__nv_fp6_e3m2(const unsigned short int val) {
|
| 529 |
+
__x = static_cast<__nv_fp6_e3m2>(static_cast<float>(val)).__x;
|
| 530 |
+
}
|
| 531 |
+
/**
|
| 532 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 533 |
+
* Constructor from \p unsigned \p int data type, relies on \p
|
| 534 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 535 |
+
*/
|
| 536 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const unsigned int val) {
|
| 537 |
+
__x = static_cast<__nv_fp6_e3m2>(static_cast<float>(val)).__x;
|
| 538 |
+
}
|
| 539 |
+
/**
|
| 540 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 541 |
+
* Constructor from \p unsigned \p long \p int data type, relies on \p
|
| 542 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 543 |
+
*/
|
| 544 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const unsigned long int val) {
|
| 545 |
+
__x = static_cast<__nv_fp6_e3m2>(static_cast<float>(val)).__x;
|
| 546 |
+
}
|
| 547 |
+
/**
|
| 548 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 549 |
+
* Constructor from \p unsigned \p long \p long \p int data type, relies on
|
| 550 |
+
* \p __NV_SATFINITE behavior for out-of-range values.
|
| 551 |
+
*/
|
| 552 |
+
explicit __CUDA_HOSTDEVICE_FP6__
|
| 553 |
+
__nv_fp6_e3m2(const unsigned long long int val) {
|
| 554 |
+
__x = static_cast<__nv_fp6_e3m2>(static_cast<float>(val)).__x;
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
/**
|
| 558 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 559 |
+
* Constructor from \p short \p int data type.
|
| 560 |
+
*/
|
| 561 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const short int val) {
|
| 562 |
+
__x = static_cast<__nv_fp6_e3m2>(static_cast<float>(val)).__x;
|
| 563 |
+
}
|
| 564 |
+
/**
|
| 565 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 566 |
+
* Constructor from \p int data type, relies on \p __NV_SATFINITE behavior
|
| 567 |
+
* for out-of-range values.
|
| 568 |
+
*/
|
| 569 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const int val) {
|
| 570 |
+
__x = static_cast<__nv_fp6_e3m2>(static_cast<float>(val)).__x;
|
| 571 |
+
}
|
| 572 |
+
/**
|
| 573 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 574 |
+
* Constructor from \p long \p int data type, relies on \p __NV_SATFINITE behavior
|
| 575 |
+
* for out-of-range values.
|
| 576 |
+
*/
|
| 577 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const long int val) {
|
| 578 |
+
__x = static_cast<__nv_fp6_e3m2>(static_cast<float>(val)).__x;
|
| 579 |
+
}
|
| 580 |
+
/**
|
| 581 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 582 |
+
* Constructor from \p long \p long \p int data type, relies on \p
|
| 583 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 584 |
+
*/
|
| 585 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e3m2(const long long int val) {
|
| 586 |
+
__x = static_cast<__nv_fp6_e3m2>(static_cast<float>(val)).__x;
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
#if !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__)
|
| 590 |
+
/* Widening FP converts */
|
| 591 |
+
/**
|
| 592 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 593 |
+
* Conversion operator to \p __half data type.
|
| 594 |
+
*/
|
| 595 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator __half() const {
|
| 596 |
+
return static_cast<__half>(__nv_cvt_fp6_to_halfraw(__x, __NV_E3M2));
|
| 597 |
+
}
|
| 598 |
+
/**
|
| 599 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 600 |
+
* Conversion operator to \p float data type.
|
| 601 |
+
*/
|
| 602 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator float() const {
|
| 603 |
+
return __internal_halfraw_to_float(
|
| 604 |
+
__nv_cvt_fp6_to_halfraw(__x, __NV_E3M2));
|
| 605 |
+
}
|
| 606 |
+
/**
|
| 607 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 608 |
+
* Conversion operator to \p __nv_bfloat16 data type.
|
| 609 |
+
*/
|
| 610 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator __nv_bfloat16() const {
|
| 611 |
+
return __float2bfloat16_rz(float(*this));
|
| 612 |
+
}
|
| 613 |
+
/**
|
| 614 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 615 |
+
* Conversion operator to \p double data type.
|
| 616 |
+
*/
|
| 617 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator double() const {
|
| 618 |
+
return static_cast<double>(float(*this));
|
| 619 |
+
}
|
| 620 |
+
|
| 621 |
+
/* Convert to integral */
|
| 622 |
+
|
| 623 |
+
/**
|
| 624 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 625 |
+
* Conversion operator to \p unsigned \p char data type.
|
| 626 |
+
* Clamps negative inputs to zero.
|
| 627 |
+
*/
|
| 628 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned char() const {
|
| 629 |
+
unsigned char i;
|
| 630 |
+
const float f = float(*this);
|
| 631 |
+
|
| 632 |
+
if (f < 0.0f) {
|
| 633 |
+
// saturate minimum
|
| 634 |
+
i = 0U;
|
| 635 |
+
} else {
|
| 636 |
+
// normal value
|
| 637 |
+
i = static_cast<unsigned char>(f);
|
| 638 |
+
}
|
| 639 |
+
return i;
|
| 640 |
+
}
|
| 641 |
+
/**
|
| 642 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 643 |
+
* Conversion operator to \p unsigned \p short \p int data type.
|
| 644 |
+
* Clamps negative inputs to zero.
|
| 645 |
+
*/
|
| 646 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned short int() const {
|
| 647 |
+
return __half2ushort_rz(__half(*this));
|
| 648 |
+
}
|
| 649 |
+
/**
|
| 650 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 651 |
+
* Conversion operator to \p unsigned \p int data type.
|
| 652 |
+
* Clamps negative inputs to zero.
|
| 653 |
+
*/
|
| 654 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned int() const {
|
| 655 |
+
return __half2uint_rz(__half(*this));
|
| 656 |
+
}
|
| 657 |
+
/**
|
| 658 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 659 |
+
* Conversion operator to \p unsigned \p long \p int data type.
|
| 660 |
+
* Clamps negative inputs to zero.
|
| 661 |
+
*/
|
| 662 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned long int() const {
|
| 663 |
+
unsigned long retval;
|
| 664 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 665 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 666 |
+
#pragma warning (push)
|
| 667 |
+
#pragma warning (disable: 4127)
|
| 668 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 669 |
+
if (sizeof(unsigned long) == sizeof(unsigned long long))
|
| 670 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 671 |
+
#pragma warning (pop)
|
| 672 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 673 |
+
{
|
| 674 |
+
retval = static_cast<unsigned long>(__half2ull_rz(__half(*this)));
|
| 675 |
+
}
|
| 676 |
+
else
|
| 677 |
+
{
|
| 678 |
+
retval = static_cast<unsigned long>(__half2uint_rz(__half(*this)));
|
| 679 |
+
}
|
| 680 |
+
return retval;
|
| 681 |
+
}
|
| 682 |
+
/**
|
| 683 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 684 |
+
* Conversion operator to \p unsigned \p long \p long \p int data type.
|
| 685 |
+
* Clamps negative inputs to zero.
|
| 686 |
+
*/
|
| 687 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned long long int() const {
|
| 688 |
+
return __half2ull_rz(__half(*this));
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
/**
|
| 692 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 693 |
+
* Conversion operator to \p signed \p char data type.
|
| 694 |
+
*/
|
| 695 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator signed char() const {
|
| 696 |
+
const float f = float(*this);
|
| 697 |
+
return static_cast<signed char>(f);
|
| 698 |
+
}
|
| 699 |
+
|
| 700 |
+
/**
|
| 701 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 702 |
+
* Conversion operator to an implementation defined \p char data type.
|
| 703 |
+
*
|
| 704 |
+
* Detects signedness of the \p char type and proceeds accordingly, see
|
| 705 |
+
* further details in signed and unsigned char operators.
|
| 706 |
+
*
|
| 707 |
+
* Clamps inputs to the output range.
|
| 708 |
+
*/
|
| 709 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator char() const {
|
| 710 |
+
char value;
|
| 711 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 712 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 713 |
+
#pragma warning (push)
|
| 714 |
+
#pragma warning (disable: 4127)
|
| 715 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 716 |
+
if (((char)-1) < (char)0)
|
| 717 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 718 |
+
#pragma warning (pop)
|
| 719 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 720 |
+
{
|
| 721 |
+
value = static_cast<char>(static_cast<signed char>(*this));
|
| 722 |
+
}
|
| 723 |
+
else
|
| 724 |
+
{
|
| 725 |
+
value = static_cast<char>(static_cast<unsigned char>(*this));
|
| 726 |
+
}
|
| 727 |
+
return value;
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
/**
|
| 731 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 732 |
+
* Conversion operator to \p short \p int data type.
|
| 733 |
+
*/
|
| 734 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator short int() const {
|
| 735 |
+
return __half2short_rz(__half(*this));
|
| 736 |
+
}
|
| 737 |
+
/**
|
| 738 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 739 |
+
* Conversion operator to \p int data type.
|
| 740 |
+
*/
|
| 741 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator int() const {
|
| 742 |
+
return __half2int_rz(__half(*this));
|
| 743 |
+
}
|
| 744 |
+
/**
|
| 745 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 746 |
+
* Conversion operator to \p long \p int data type.
|
| 747 |
+
*/
|
| 748 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator long int() const {
|
| 749 |
+
long retval;
|
| 750 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 751 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 752 |
+
#pragma warning (push)
|
| 753 |
+
#pragma warning (disable: 4127)
|
| 754 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 755 |
+
if (sizeof(long) == sizeof(long long))
|
| 756 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 757 |
+
#pragma warning (pop)
|
| 758 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 759 |
+
{
|
| 760 |
+
retval = static_cast<long>(__half2ll_rz(__half(*this)));
|
| 761 |
+
}
|
| 762 |
+
else
|
| 763 |
+
{
|
| 764 |
+
retval = static_cast<long>(__half2int_rz(__half(*this)));
|
| 765 |
+
}
|
| 766 |
+
return retval;
|
| 767 |
+
}
|
| 768 |
+
/**
|
| 769 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 770 |
+
* Conversion operator to \p long \p long \p int data type.
|
| 771 |
+
*/
|
| 772 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator long long int() const {
|
| 773 |
+
return __half2ll_rz(__half(*this));
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
/**
|
| 777 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 778 |
+
* Conversion operator to \p bool data type.
|
| 779 |
+
* +0 and -0 inputs convert to \p false.
|
| 780 |
+
* Non-zero inputs convert to \p true.
|
| 781 |
+
*/
|
| 782 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator bool() const {
|
| 783 |
+
return (__x & 0x1FU) != 0U;
|
| 784 |
+
}
|
| 785 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__) */
|
| 786 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSIONS__) */
|
| 787 |
+
};
|
| 788 |
+
|
| 789 |
+
/**
|
| 790 |
+
* \defgroup CUDA_MATH_FP6X2_E3M2_STRUCT C++ struct for handling vector type of two fp6 values of e3m2 kind.
|
| 791 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP6
|
| 792 |
+
*/
|
| 793 |
+
|
| 794 |
+
/**
|
| 795 |
+
* \ingroup CUDA_MATH_FP6X2_E3M2_STRUCT
|
| 796 |
+
* \brief __nv_fp6x2_e3m2 datatype
|
| 797 |
+
*
|
| 798 |
+
* \details This structure implements the datatype for handling two
|
| 799 |
+
* \p fp6 floating-point numbers of \p e3m2 kind each.
|
| 800 |
+
*
|
| 801 |
+
* The structure implements converting constructors and operators.
|
| 802 |
+
*/
|
| 803 |
+
struct __CUDA_ALIGN__(2) __nv_fp6x2_e3m2 {
|
| 804 |
+
public:
|
| 805 |
+
/**
|
| 806 |
+
* \ingroup CUDA_MATH_FP6X2_E3M2_STRUCT
|
| 807 |
+
* Storage variable contains the vector of two \p fp6 floating-point data
|
| 808 |
+
* values.
|
| 809 |
+
*/
|
| 810 |
+
__nv_fp6x2_storage_t __x;
|
| 811 |
+
|
| 812 |
+
/**
|
| 813 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 814 |
+
* Constructor by default.
|
| 815 |
+
*/
|
| 816 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP6)
|
| 817 |
+
__nv_fp6x2_e3m2() = default;
|
| 818 |
+
#else
|
| 819 |
+
__CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e3m2() {}
|
| 820 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP6) */
|
| 821 |
+
|
| 822 |
+
#if !defined(__CUDA_NO_FP6_CONVERSIONS__)
|
| 823 |
+
|
| 824 |
+
/* Construct from wider types */
|
| 825 |
+
|
| 826 |
+
/**
|
| 827 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 828 |
+
* Constructor from \p __half2 data type, relies on \p __NV_SATFINITE
|
| 829 |
+
* behavior for out-of-range values.
|
| 830 |
+
*/
|
| 831 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e3m2(const __half2 f) {
|
| 832 |
+
__x = __nv_cvt_halfraw2_to_fp6x2(static_cast<__half2_raw>(f),
|
| 833 |
+
__NV_E3M2, cudaRoundNearest);
|
| 834 |
+
}
|
| 835 |
+
/**
|
| 836 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 837 |
+
* Constructor from \p __nv_bfloat162 data type, relies on \p __NV_SATFINITE
|
| 838 |
+
* behavior for out-of-range values.
|
| 839 |
+
*/
|
| 840 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e3m2(const __nv_bfloat162 f) {
|
| 841 |
+
__x = __nv_cvt_bfloat16raw2_to_fp6x2(static_cast<__nv_bfloat162_raw>(f),
|
| 842 |
+
__NV_E3M2, cudaRoundNearest);
|
| 843 |
+
}
|
| 844 |
+
/**
|
| 845 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 846 |
+
* Constructor from \p float2 data type, relies on \p __NV_SATFINITE
|
| 847 |
+
* behavior for out-of-range values.
|
| 848 |
+
*/
|
| 849 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e3m2(const float2 f) {
|
| 850 |
+
__x = __nv_cvt_float2_to_fp6x2(f, __NV_E3M2, cudaRoundNearest);
|
| 851 |
+
}
|
| 852 |
+
/**
|
| 853 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 854 |
+
* Constructor from \p double2 data type, relies on \p __NV_SATFINITE
|
| 855 |
+
* behavior for out-of-range values.
|
| 856 |
+
*/
|
| 857 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e3m2(const double2 f) {
|
| 858 |
+
__x = __nv_cvt_double2_to_fp6x2(f, __NV_E3M2, cudaRoundNearest);
|
| 859 |
+
}
|
| 860 |
+
|
| 861 |
+
#if !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__)
|
| 862 |
+
/* Widening converts */
|
| 863 |
+
/**
|
| 864 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 865 |
+
* Conversion operator to \p __half2 data type.
|
| 866 |
+
*/
|
| 867 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator __half2() const {
|
| 868 |
+
return static_cast<__half2>(__nv_cvt_fp6x2_to_halfraw2(__x, __NV_E3M2));
|
| 869 |
+
}
|
| 870 |
+
/**
|
| 871 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 872 |
+
* Conversion operator to \p float2 data type.
|
| 873 |
+
*/
|
| 874 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator float2() const {
|
| 875 |
+
return __internal_halfraw2_to_float2(
|
| 876 |
+
__nv_cvt_fp6x2_to_halfraw2(__x, __NV_E3M2));
|
| 877 |
+
}
|
| 878 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__) */
|
| 879 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSIONS__) */
|
| 880 |
+
};
|
| 881 |
+
|
| 882 |
+
/**
|
| 883 |
+
* \defgroup CUDA_MATH_FP6X4_E3M2_STRUCT C++ struct for handling vector type of four fp6 values of e3m2 kind.
|
| 884 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP6
|
| 885 |
+
*/
|
| 886 |
+
|
| 887 |
+
/**
|
| 888 |
+
* \ingroup CUDA_MATH_FP6X4_E3M2_STRUCT
|
| 889 |
+
* \brief __nv_fp6x4_e3m2 datatype
|
| 890 |
+
*
|
| 891 |
+
* \details This structure implements the datatype for handling four
|
| 892 |
+
* \p fp6 floating-point numbers of \p e3m2 kind each.
|
| 893 |
+
*
|
| 894 |
+
* The structure implements converting constructors and operators.
|
| 895 |
+
*/
|
| 896 |
+
struct __CUDA_ALIGN__(4) __nv_fp6x4_e3m2 {
|
| 897 |
+
public:
|
| 898 |
+
/**
|
| 899 |
+
* \ingroup CUDA_MATH_FP6X4_E3M2_STRUCT
|
| 900 |
+
* Storage variable contains the vector of four \p fp6 floating-point data
|
| 901 |
+
* values.
|
| 902 |
+
*/
|
| 903 |
+
__nv_fp6x4_storage_t __x;
|
| 904 |
+
|
| 905 |
+
/**
|
| 906 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 907 |
+
* Constructor by default.
|
| 908 |
+
*/
|
| 909 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP6)
|
| 910 |
+
__nv_fp6x4_e3m2() = default;
|
| 911 |
+
#else
|
| 912 |
+
__CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e3m2() {}
|
| 913 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP6) */
|
| 914 |
+
|
| 915 |
+
#if !defined(__CUDA_NO_FP6_CONVERSIONS__)
|
| 916 |
+
|
| 917 |
+
/* Construct from wider types */
|
| 918 |
+
|
| 919 |
+
/**
|
| 920 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 921 |
+
* Constructor from a pair of \p __half2 data type values,
|
| 922 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 923 |
+
*/
|
| 924 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e3m2(const __half2 flo,
|
| 925 |
+
const __half2 fhi) {
|
| 926 |
+
const __nv_fp6x2_storage_t rlo = __nv_cvt_halfraw2_to_fp6x2(
|
| 927 |
+
static_cast<__half2_raw>(flo), __NV_E3M2, cudaRoundNearest);
|
| 928 |
+
const __nv_fp6x2_storage_t rhi = __nv_cvt_halfraw2_to_fp6x2(
|
| 929 |
+
static_cast<__half2_raw>(fhi), __NV_E3M2, cudaRoundNearest);
|
| 930 |
+
__x = __internal_pack_u16x2_to_u32(rlo, rhi);
|
| 931 |
+
}
|
| 932 |
+
/**
|
| 933 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 934 |
+
* Constructor from a pair of \p __nv_bfloat162 data type values,
|
| 935 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 936 |
+
*/
|
| 937 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e3m2(const __nv_bfloat162 flo,
|
| 938 |
+
const __nv_bfloat162 fhi) {
|
| 939 |
+
const __nv_fp6x2_storage_t rlo = __nv_cvt_bfloat16raw2_to_fp6x2(
|
| 940 |
+
static_cast<__nv_bfloat162_raw>(flo), __NV_E3M2, cudaRoundNearest);
|
| 941 |
+
const __nv_fp6x2_storage_t rhi = __nv_cvt_bfloat16raw2_to_fp6x2(
|
| 942 |
+
static_cast<__nv_bfloat162_raw>(fhi), __NV_E3M2, cudaRoundNearest);
|
| 943 |
+
__x = __internal_pack_u16x2_to_u32(rlo, rhi);
|
| 944 |
+
}
|
| 945 |
+
/**
|
| 946 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 947 |
+
* Constructor from \p float4 vector data type,
|
| 948 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 949 |
+
*/
|
| 950 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e3m2(const float4 f) {
|
| 951 |
+
const float2 flo = {f.x, f.y};
|
| 952 |
+
const float2 fhi = {f.z, f.w};
|
| 953 |
+
const __nv_fp6x2_storage_t rlo =
|
| 954 |
+
__nv_cvt_float2_to_fp6x2(flo, __NV_E3M2, cudaRoundNearest);
|
| 955 |
+
const __nv_fp6x2_storage_t rhi =
|
| 956 |
+
__nv_cvt_float2_to_fp6x2(fhi, __NV_E3M2, cudaRoundNearest);
|
| 957 |
+
__x = __internal_pack_u16x2_to_u32(rlo, rhi);
|
| 958 |
+
}
|
| 959 |
+
/**
|
| 960 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 961 |
+
* Constructor from \p double4 vector data type,
|
| 962 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 963 |
+
*/
|
| 964 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e3m2(const double4 f) {
|
| 965 |
+
const double2 flo = {f.x, f.y};
|
| 966 |
+
const double2 fhi = {f.z, f.w};
|
| 967 |
+
const __nv_fp6x2_storage_t rlo =
|
| 968 |
+
__nv_cvt_double2_to_fp6x2(flo, __NV_E3M2, cudaRoundNearest);
|
| 969 |
+
const __nv_fp6x2_storage_t rhi =
|
| 970 |
+
__nv_cvt_double2_to_fp6x2(fhi, __NV_E3M2, cudaRoundNearest);
|
| 971 |
+
__x = __internal_pack_u16x2_to_u32(rlo, rhi);
|
| 972 |
+
}
|
| 973 |
+
|
| 974 |
+
#if !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__)
|
| 975 |
+
/* Widening converts */
|
| 976 |
+
|
| 977 |
+
/**
|
| 978 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 979 |
+
* Conversion operator to \p float4 vector data type.
|
| 980 |
+
*/
|
| 981 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator float4() const {
|
| 982 |
+
const __nv_fp6x2_storage_t slo = static_cast<__nv_fp6x2_storage_t>(__x);
|
| 983 |
+
const __nv_fp6x2_storage_t shi =
|
| 984 |
+
static_cast<__nv_fp6x2_storage_t>(__x >> 16U);
|
| 985 |
+
float2 rlo = __internal_halfraw2_to_float2(
|
| 986 |
+
__nv_cvt_fp6x2_to_halfraw2(slo, __NV_E3M2));
|
| 987 |
+
float2 rhi = __internal_halfraw2_to_float2(
|
| 988 |
+
__nv_cvt_fp6x2_to_halfraw2(shi, __NV_E3M2));
|
| 989 |
+
float4 res = {rlo.x, rlo.y, rhi.x, rhi.y};
|
| 990 |
+
return res;
|
| 991 |
+
}
|
| 992 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__) */
|
| 993 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSIONS__) */
|
| 994 |
+
};
|
| 995 |
+
|
| 996 |
+
/**
|
| 997 |
+
* \defgroup CUDA_MATH_FP6_E2M3_STRUCT C++ struct for handling fp6 data type of e2m3 kind.
|
| 998 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP6
|
| 999 |
+
*/
|
| 1000 |
+
|
| 1001 |
+
/**
|
| 1002 |
+
* \ingroup CUDA_MATH_FP6_E2M3_STRUCT
|
| 1003 |
+
* \brief __nv_fp6_e2m3 datatype
|
| 1004 |
+
*
|
| 1005 |
+
* \details This structure implements the datatype for storing
|
| 1006 |
+
* \p fp6 floating-point numbers of \p e2m3 kind:
|
| 1007 |
+
* with 1 sign, 2 exponent, 1 implicit and 3 explicit mantissa bits.
|
| 1008 |
+
* This encoding does not support Inf/NaN.
|
| 1009 |
+
*
|
| 1010 |
+
* The structure implements converting constructors and operators.
|
| 1011 |
+
*/
|
| 1012 |
+
struct __CUDA_ALIGN__(1) __nv_fp6_e2m3 {
|
| 1013 |
+
public:
|
| 1014 |
+
/**
|
| 1015 |
+
* \ingroup CUDA_MATH_FP6_E2M3_STRUCT
|
| 1016 |
+
* Storage variable contains the \p fp6 floating-point data.
|
| 1017 |
+
*/
|
| 1018 |
+
__nv_fp6_storage_t __x;
|
| 1019 |
+
|
| 1020 |
+
/**
|
| 1021 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1022 |
+
* Constructor by default.
|
| 1023 |
+
*/
|
| 1024 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP6)
|
| 1025 |
+
__nv_fp6_e2m3() = default;
|
| 1026 |
+
#else
|
| 1027 |
+
__CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3() {}
|
| 1028 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP6) */
|
| 1029 |
+
|
| 1030 |
+
#if !defined(__CUDA_NO_FP6_CONVERSIONS__)
|
| 1031 |
+
|
| 1032 |
+
/* Construct from wider FP types */
|
| 1033 |
+
/* Note we do avoid constructor init-list because of special host/device
|
| 1034 |
+
* compilation rules */
|
| 1035 |
+
|
| 1036 |
+
/**
|
| 1037 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1038 |
+
* Constructor from \p __half data type, relies on \p __NV_SATFINITE
|
| 1039 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 1040 |
+
*/
|
| 1041 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const __half f) {
|
| 1042 |
+
__x = __nv_cvt_halfraw_to_fp6(static_cast<__half_raw>(f),
|
| 1043 |
+
__NV_E2M3, cudaRoundNearest);
|
| 1044 |
+
}
|
| 1045 |
+
/**
|
| 1046 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1047 |
+
* Constructor from \p __nv_bfloat16 data type, relies on \p __NV_SATFINITE
|
| 1048 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 1049 |
+
*/
|
| 1050 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const __nv_bfloat16 f) {
|
| 1051 |
+
__x = __nv_cvt_bfloat16raw_to_fp6(static_cast<__nv_bfloat16_raw>(f),
|
| 1052 |
+
__NV_E2M3, cudaRoundNearest);
|
| 1053 |
+
}
|
| 1054 |
+
/**
|
| 1055 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1056 |
+
* Constructor from \p float data type, relies on \p __NV_SATFINITE
|
| 1057 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 1058 |
+
*/
|
| 1059 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const float f) {
|
| 1060 |
+
__x = __nv_cvt_float_to_fp6(f, __NV_E2M3, cudaRoundNearest);
|
| 1061 |
+
}
|
| 1062 |
+
/**
|
| 1063 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1064 |
+
* Constructor from \p double data type, relies on \p __NV_SATFINITE
|
| 1065 |
+
* behavior for out-of-range values and \p cudaRoundNearest rounding mode.
|
| 1066 |
+
*/
|
| 1067 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const double f) {
|
| 1068 |
+
__x = __nv_cvt_double_to_fp6(f, __NV_E2M3, cudaRoundNearest);
|
| 1069 |
+
}
|
| 1070 |
+
|
| 1071 |
+
/* Converts from integral */
|
| 1072 |
+
|
| 1073 |
+
/**
|
| 1074 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1075 |
+
* Constructor from \p unsigned \p short \p int data type, relies on \p
|
| 1076 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 1077 |
+
*/
|
| 1078 |
+
explicit __CUDA_HOSTDEVICE_FP6__
|
| 1079 |
+
__nv_fp6_e2m3(const unsigned short int val) {
|
| 1080 |
+
__x = static_cast<__nv_fp6_e2m3>(static_cast<float>(val)).__x;
|
| 1081 |
+
}
|
| 1082 |
+
/**
|
| 1083 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1084 |
+
* Constructor from \p unsigned \p int data type, relies on \p
|
| 1085 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 1086 |
+
*/
|
| 1087 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const unsigned int val) {
|
| 1088 |
+
__x = static_cast<__nv_fp6_e2m3>(static_cast<float>(val)).__x;
|
| 1089 |
+
}
|
| 1090 |
+
/**
|
| 1091 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1092 |
+
* Constructor from \p unsigned \p long \p int data type, relies on \p
|
| 1093 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 1094 |
+
*/
|
| 1095 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const unsigned long int val) {
|
| 1096 |
+
__x = static_cast<__nv_fp6_e2m3>(static_cast<float>(val)).__x;
|
| 1097 |
+
}
|
| 1098 |
+
/**
|
| 1099 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1100 |
+
* Constructor from \p unsigned \p long \p long \p int data type, relies on
|
| 1101 |
+
* \p __NV_SATFINITE behavior for out-of-range values.
|
| 1102 |
+
*/
|
| 1103 |
+
explicit __CUDA_HOSTDEVICE_FP6__
|
| 1104 |
+
__nv_fp6_e2m3(const unsigned long long int val) {
|
| 1105 |
+
__x = static_cast<__nv_fp6_e2m3>(static_cast<float>(val)).__x;
|
| 1106 |
+
}
|
| 1107 |
+
|
| 1108 |
+
/**
|
| 1109 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1110 |
+
* Constructor from \p short \p int data type.
|
| 1111 |
+
*/
|
| 1112 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const short int val) {
|
| 1113 |
+
__x = static_cast<__nv_fp6_e2m3>(static_cast<float>(val)).__x;
|
| 1114 |
+
}
|
| 1115 |
+
/**
|
| 1116 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1117 |
+
* Constructor from \p int data type, relies on \p __NV_SATFINITE behavior
|
| 1118 |
+
* for out-of-range values.
|
| 1119 |
+
*/
|
| 1120 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const int val) {
|
| 1121 |
+
__x = static_cast<__nv_fp6_e2m3>(static_cast<float>(val)).__x;
|
| 1122 |
+
}
|
| 1123 |
+
/**
|
| 1124 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1125 |
+
* Constructor from \p long \p int data type, relies on \p __NV_SATFINITE behavior
|
| 1126 |
+
* for out-of-range values.
|
| 1127 |
+
*/
|
| 1128 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const long int val) {
|
| 1129 |
+
__x = static_cast<__nv_fp6_e2m3>(static_cast<float>(val)).__x;
|
| 1130 |
+
}
|
| 1131 |
+
/**
|
| 1132 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1133 |
+
* Constructor from \p long \p long \p int data type, relies on \p
|
| 1134 |
+
* __NV_SATFINITE behavior for out-of-range values.
|
| 1135 |
+
*/
|
| 1136 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6_e2m3(const long long int val) {
|
| 1137 |
+
__x = static_cast<__nv_fp6_e2m3>(static_cast<float>(val)).__x;
|
| 1138 |
+
}
|
| 1139 |
+
|
| 1140 |
+
#if !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__)
|
| 1141 |
+
/* Widening FP converts */
|
| 1142 |
+
/**
|
| 1143 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1144 |
+
* Conversion operator to \p __half data type.
|
| 1145 |
+
*/
|
| 1146 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator __half() const {
|
| 1147 |
+
return static_cast<__half>(__nv_cvt_fp6_to_halfraw(__x, __NV_E2M3));
|
| 1148 |
+
}
|
| 1149 |
+
/**
|
| 1150 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1151 |
+
* Conversion operator to \p float data type.
|
| 1152 |
+
*/
|
| 1153 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator float() const {
|
| 1154 |
+
return __internal_halfraw_to_float(
|
| 1155 |
+
__nv_cvt_fp6_to_halfraw(__x, __NV_E2M3));
|
| 1156 |
+
}
|
| 1157 |
+
/**
|
| 1158 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1159 |
+
* Conversion operator to \p __nv_bfloat16 data type.
|
| 1160 |
+
*/
|
| 1161 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator __nv_bfloat16() const {
|
| 1162 |
+
return __float2bfloat16_rz(float(*this));
|
| 1163 |
+
}
|
| 1164 |
+
/**
|
| 1165 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1166 |
+
* Conversion operator to \p double data type.
|
| 1167 |
+
*/
|
| 1168 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator double() const {
|
| 1169 |
+
return static_cast<double>(float(*this));
|
| 1170 |
+
}
|
| 1171 |
+
|
| 1172 |
+
/* Convert to integral */
|
| 1173 |
+
|
| 1174 |
+
/**
|
| 1175 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1176 |
+
* Conversion operator to \p unsigned \p char data type.
|
| 1177 |
+
* Clamps negative inputs to zero.
|
| 1178 |
+
*/
|
| 1179 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned char() const {
|
| 1180 |
+
unsigned char i;
|
| 1181 |
+
const float f = float(*this);
|
| 1182 |
+
|
| 1183 |
+
if (f < 0.0f) {
|
| 1184 |
+
// saturate minimum
|
| 1185 |
+
i = 0U;
|
| 1186 |
+
} else {
|
| 1187 |
+
// normal value
|
| 1188 |
+
i = static_cast<unsigned char>(f);
|
| 1189 |
+
}
|
| 1190 |
+
return i;
|
| 1191 |
+
}
|
| 1192 |
+
/**
|
| 1193 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1194 |
+
* Conversion operator to \p unsigned \p short \p int data type.
|
| 1195 |
+
* Clamps negative inputs to zero.
|
| 1196 |
+
*/
|
| 1197 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned short int() const {
|
| 1198 |
+
return __half2ushort_rz(__half(*this));
|
| 1199 |
+
}
|
| 1200 |
+
/**
|
| 1201 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1202 |
+
* Conversion operator to \p unsigned \p int data type.
|
| 1203 |
+
* Clamps negative inputs to zero.
|
| 1204 |
+
*/
|
| 1205 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned int() const {
|
| 1206 |
+
return __half2uint_rz(__half(*this));
|
| 1207 |
+
}
|
| 1208 |
+
/**
|
| 1209 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1210 |
+
* Conversion operator to \p unsigned \p long \p int data type.
|
| 1211 |
+
* Clamps negative inputs to zero.
|
| 1212 |
+
*/
|
| 1213 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned long int() const {
|
| 1214 |
+
unsigned long retval;
|
| 1215 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 1216 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 1217 |
+
#pragma warning (push)
|
| 1218 |
+
#pragma warning (disable: 4127)
|
| 1219 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 1220 |
+
if (sizeof(unsigned long) == sizeof(unsigned long long))
|
| 1221 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 1222 |
+
#pragma warning (pop)
|
| 1223 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 1224 |
+
{
|
| 1225 |
+
retval = static_cast<unsigned long>(__half2ull_rz(__half(*this)));
|
| 1226 |
+
}
|
| 1227 |
+
else
|
| 1228 |
+
{
|
| 1229 |
+
retval = static_cast<unsigned long>(__half2uint_rz(__half(*this)));
|
| 1230 |
+
}
|
| 1231 |
+
return retval;
|
| 1232 |
+
}
|
| 1233 |
+
/**
|
| 1234 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1235 |
+
* Conversion operator to \p unsigned \p long \p long \p int data type.
|
| 1236 |
+
* Clamps negative inputs to zero.
|
| 1237 |
+
*/
|
| 1238 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator unsigned long long int() const {
|
| 1239 |
+
return __half2ull_rz(__half(*this));
|
| 1240 |
+
}
|
| 1241 |
+
|
| 1242 |
+
/**
|
| 1243 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1244 |
+
* Conversion operator to \p signed \p char data type.
|
| 1245 |
+
*/
|
| 1246 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator signed char() const {
|
| 1247 |
+
const float f = float(*this);
|
| 1248 |
+
return static_cast<signed char>(f);
|
| 1249 |
+
}
|
| 1250 |
+
|
| 1251 |
+
/**
|
| 1252 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1253 |
+
* Conversion operator to an implementation defined \p char data type.
|
| 1254 |
+
*
|
| 1255 |
+
* Detects signedness of the \p char type and proceeds accordingly, see
|
| 1256 |
+
* further details in signed and unsigned char operators.
|
| 1257 |
+
*
|
| 1258 |
+
* Clamps inputs to the output range.
|
| 1259 |
+
*/
|
| 1260 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator char() const {
|
| 1261 |
+
char value;
|
| 1262 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 1263 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 1264 |
+
#pragma warning (push)
|
| 1265 |
+
#pragma warning (disable: 4127)
|
| 1266 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 1267 |
+
if (((char)-1) < (char)0)
|
| 1268 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 1269 |
+
#pragma warning (pop)
|
| 1270 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 1271 |
+
{
|
| 1272 |
+
value = static_cast<char>(static_cast<signed char>(*this));
|
| 1273 |
+
}
|
| 1274 |
+
else
|
| 1275 |
+
{
|
| 1276 |
+
value = static_cast<char>(static_cast<unsigned char>(*this));
|
| 1277 |
+
}
|
| 1278 |
+
return value;
|
| 1279 |
+
}
|
| 1280 |
+
|
| 1281 |
+
/**
|
| 1282 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1283 |
+
* Conversion operator to \p short \p int data type.
|
| 1284 |
+
*/
|
| 1285 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator short int() const {
|
| 1286 |
+
return __half2short_rz(__half(*this));
|
| 1287 |
+
}
|
| 1288 |
+
/**
|
| 1289 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1290 |
+
* Conversion operator to \p int data type.
|
| 1291 |
+
*/
|
| 1292 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator int() const {
|
| 1293 |
+
return __half2int_rz(__half(*this));
|
| 1294 |
+
}
|
| 1295 |
+
/**
|
| 1296 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1297 |
+
* Conversion operator to \p long \p int data type.
|
| 1298 |
+
*/
|
| 1299 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator long int() const {
|
| 1300 |
+
long retval;
|
| 1301 |
+
/* Suppress VS warning: warning C4127: conditional expression is constant */
|
| 1302 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 1303 |
+
#pragma warning (push)
|
| 1304 |
+
#pragma warning (disable: 4127)
|
| 1305 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 1306 |
+
if (sizeof(long) == sizeof(long long))
|
| 1307 |
+
#if defined(_MSC_VER) && !defined(__CUDA_ARCH__)
|
| 1308 |
+
#pragma warning (pop)
|
| 1309 |
+
#endif /* _MSC_VER && !defined(__CUDA_ARCH__) */
|
| 1310 |
+
{
|
| 1311 |
+
retval = static_cast<long>(__half2ll_rz(__half(*this)));
|
| 1312 |
+
}
|
| 1313 |
+
else
|
| 1314 |
+
{
|
| 1315 |
+
retval = static_cast<long>(__half2int_rz(__half(*this)));
|
| 1316 |
+
}
|
| 1317 |
+
return retval;
|
| 1318 |
+
}
|
| 1319 |
+
/**
|
| 1320 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1321 |
+
* Conversion operator to \p long \p long \p int data type.
|
| 1322 |
+
*/
|
| 1323 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator long long int() const {
|
| 1324 |
+
return __half2ll_rz(__half(*this));
|
| 1325 |
+
}
|
| 1326 |
+
|
| 1327 |
+
/**
|
| 1328 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1329 |
+
* Conversion operator to \p bool data type.
|
| 1330 |
+
* +0 and -0 inputs convert to \p false.
|
| 1331 |
+
* Non-zero inputs convert to \p true.
|
| 1332 |
+
*/
|
| 1333 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator bool() const {
|
| 1334 |
+
return (__x & 0x1FU) != 0U;
|
| 1335 |
+
}
|
| 1336 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__) */
|
| 1337 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSIONS__) */
|
| 1338 |
+
};
|
| 1339 |
+
|
| 1340 |
+
/**
|
| 1341 |
+
* \defgroup CUDA_MATH_FP6X2_E2M3_STRUCT C++ struct for handling vector type of two fp6 values of e2m3 kind.
|
| 1342 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP6
|
| 1343 |
+
*/
|
| 1344 |
+
|
| 1345 |
+
/**
|
| 1346 |
+
* \ingroup CUDA_MATH_FP6X2_E2M3_STRUCT
|
| 1347 |
+
* \brief __nv_fp6x2_e2m3 datatype
|
| 1348 |
+
*
|
| 1349 |
+
* \details This structure implements the datatype for handling two
|
| 1350 |
+
* \p fp6 floating-point numbers of \p e2m3 kind each.
|
| 1351 |
+
*
|
| 1352 |
+
* The structure implements converting constructors and operators.
|
| 1353 |
+
*/
|
| 1354 |
+
struct __CUDA_ALIGN__(2) __nv_fp6x2_e2m3 {
|
| 1355 |
+
public:
|
| 1356 |
+
/**
|
| 1357 |
+
* \ingroup CUDA_MATH_FP6X2_E2M3_STRUCT
|
| 1358 |
+
* Storage variable contains the vector of two \p fp6 floating-point data
|
| 1359 |
+
* values.
|
| 1360 |
+
*/
|
| 1361 |
+
__nv_fp6x2_storage_t __x;
|
| 1362 |
+
|
| 1363 |
+
/**
|
| 1364 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1365 |
+
* Constructor by default.
|
| 1366 |
+
*/
|
| 1367 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP6)
|
| 1368 |
+
__nv_fp6x2_e2m3() = default;
|
| 1369 |
+
#else
|
| 1370 |
+
__CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e2m3() {}
|
| 1371 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP6) */
|
| 1372 |
+
|
| 1373 |
+
#if !defined(__CUDA_NO_FP6_CONVERSIONS__)
|
| 1374 |
+
|
| 1375 |
+
/* Construct from wider types */
|
| 1376 |
+
|
| 1377 |
+
/**
|
| 1378 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1379 |
+
* Constructor from \p __half2 data type, relies on \p __NV_SATFINITE
|
| 1380 |
+
* behavior for out-of-range values.
|
| 1381 |
+
*/
|
| 1382 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e2m3(const __half2 f) {
|
| 1383 |
+
__x = __nv_cvt_halfraw2_to_fp6x2(static_cast<__half2_raw>(f),
|
| 1384 |
+
__NV_E2M3, cudaRoundNearest);
|
| 1385 |
+
}
|
| 1386 |
+
/**
|
| 1387 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1388 |
+
* Constructor from \p __nv_bfloat162 data type, relies on \p __NV_SATFINITE
|
| 1389 |
+
* behavior for out-of-range values.
|
| 1390 |
+
*/
|
| 1391 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e2m3(const __nv_bfloat162 f) {
|
| 1392 |
+
__x = __nv_cvt_bfloat16raw2_to_fp6x2(static_cast<__nv_bfloat162_raw>(f),
|
| 1393 |
+
__NV_E2M3, cudaRoundNearest);
|
| 1394 |
+
}
|
| 1395 |
+
/**
|
| 1396 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1397 |
+
* Constructor from \p float2 data type, relies on \p __NV_SATFINITE
|
| 1398 |
+
* behavior for out-of-range values.
|
| 1399 |
+
*/
|
| 1400 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e2m3(const float2 f) {
|
| 1401 |
+
__x = __nv_cvt_float2_to_fp6x2(f, __NV_E2M3, cudaRoundNearest);
|
| 1402 |
+
}
|
| 1403 |
+
/**
|
| 1404 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1405 |
+
* Constructor from \p double2 data type, relies on \p __NV_SATFINITE
|
| 1406 |
+
* behavior for out-of-range values.
|
| 1407 |
+
*/
|
| 1408 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x2_e2m3(const double2 f) {
|
| 1409 |
+
__x = __nv_cvt_double2_to_fp6x2(f, __NV_E2M3, cudaRoundNearest);
|
| 1410 |
+
}
|
| 1411 |
+
|
| 1412 |
+
#if !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__)
|
| 1413 |
+
/* Widening converts */
|
| 1414 |
+
/**
|
| 1415 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1416 |
+
* Conversion operator to \p __half2 data type.
|
| 1417 |
+
*/
|
| 1418 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator __half2() const {
|
| 1419 |
+
return static_cast<__half2>(__nv_cvt_fp6x2_to_halfraw2(__x, __NV_E2M3));
|
| 1420 |
+
}
|
| 1421 |
+
/**
|
| 1422 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1423 |
+
* Conversion operator to \p float2 data type.
|
| 1424 |
+
*/
|
| 1425 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator float2() const {
|
| 1426 |
+
return __internal_halfraw2_to_float2(
|
| 1427 |
+
__nv_cvt_fp6x2_to_halfraw2(__x, __NV_E2M3));
|
| 1428 |
+
}
|
| 1429 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__) */
|
| 1430 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSIONS__) */
|
| 1431 |
+
};
|
| 1432 |
+
|
| 1433 |
+
/**
|
| 1434 |
+
* \defgroup CUDA_MATH_FP6X4_E2M3_STRUCT C++ struct for handling vector type of four fp6 values of e2m3 kind.
|
| 1435 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP6
|
| 1436 |
+
*/
|
| 1437 |
+
|
| 1438 |
+
/**
|
| 1439 |
+
* \ingroup CUDA_MATH_FP6X4_E2M3_STRUCT
|
| 1440 |
+
* \brief __nv_fp6x4_e2m3 datatype
|
| 1441 |
+
*
|
| 1442 |
+
* \details This structure implements the datatype for handling four
|
| 1443 |
+
* \p fp6 floating-point numbers of \p e2m3 kind each.
|
| 1444 |
+
*
|
| 1445 |
+
* The structure implements converting constructors and operators.
|
| 1446 |
+
*/
|
| 1447 |
+
struct __CUDA_ALIGN__(4) __nv_fp6x4_e2m3 {
|
| 1448 |
+
public:
|
| 1449 |
+
/**
|
| 1450 |
+
* \ingroup CUDA_MATH_FP6X4_E2M3_STRUCT
|
| 1451 |
+
* Storage variable contains the vector of four \p fp6 floating-point data
|
| 1452 |
+
* values.
|
| 1453 |
+
*/
|
| 1454 |
+
__nv_fp6x4_storage_t __x;
|
| 1455 |
+
|
| 1456 |
+
/**
|
| 1457 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1458 |
+
* Constructor by default.
|
| 1459 |
+
*/
|
| 1460 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP6)
|
| 1461 |
+
__nv_fp6x4_e2m3() = default;
|
| 1462 |
+
#else
|
| 1463 |
+
__CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e2m3() {}
|
| 1464 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP6) */
|
| 1465 |
+
|
| 1466 |
+
#if !defined(__CUDA_NO_FP6_CONVERSIONS__)
|
| 1467 |
+
|
| 1468 |
+
/* Construct from wider types */
|
| 1469 |
+
|
| 1470 |
+
/**
|
| 1471 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1472 |
+
* Constructor from a pair of \p __half2 data type values,
|
| 1473 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 1474 |
+
*/
|
| 1475 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e2m3(const __half2 flo,
|
| 1476 |
+
const __half2 fhi) {
|
| 1477 |
+
const __nv_fp6x2_storage_t rlo = __nv_cvt_halfraw2_to_fp6x2(
|
| 1478 |
+
static_cast<__half2_raw>(flo), __NV_E2M3, cudaRoundNearest);
|
| 1479 |
+
const __nv_fp6x2_storage_t rhi = __nv_cvt_halfraw2_to_fp6x2(
|
| 1480 |
+
static_cast<__half2_raw>(fhi), __NV_E2M3, cudaRoundNearest);
|
| 1481 |
+
__x = __internal_pack_u16x2_to_u32(rlo, rhi);
|
| 1482 |
+
}
|
| 1483 |
+
/**
|
| 1484 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1485 |
+
* Constructor from a pair of \p __nv_bfloat162 data type values,
|
| 1486 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 1487 |
+
*/
|
| 1488 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e2m3(const __nv_bfloat162 flo,
|
| 1489 |
+
const __nv_bfloat162 fhi) {
|
| 1490 |
+
const __nv_fp6x2_storage_t rlo = __nv_cvt_bfloat16raw2_to_fp6x2(
|
| 1491 |
+
static_cast<__nv_bfloat162_raw>(flo), __NV_E2M3, cudaRoundNearest);
|
| 1492 |
+
const __nv_fp6x2_storage_t rhi = __nv_cvt_bfloat16raw2_to_fp6x2(
|
| 1493 |
+
static_cast<__nv_bfloat162_raw>(fhi), __NV_E2M3, cudaRoundNearest);
|
| 1494 |
+
__x = __internal_pack_u16x2_to_u32(rlo, rhi);
|
| 1495 |
+
}
|
| 1496 |
+
/**
|
| 1497 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1498 |
+
* Constructor from \p float4 vector data type,
|
| 1499 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 1500 |
+
*/
|
| 1501 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e2m3(const float4 f) {
|
| 1502 |
+
const float2 flo = {f.x, f.y};
|
| 1503 |
+
const float2 fhi = {f.z, f.w};
|
| 1504 |
+
const __nv_fp6x2_storage_t rlo =
|
| 1505 |
+
__nv_cvt_float2_to_fp6x2(flo, __NV_E2M3, cudaRoundNearest);
|
| 1506 |
+
const __nv_fp6x2_storage_t rhi =
|
| 1507 |
+
__nv_cvt_float2_to_fp6x2(fhi, __NV_E2M3, cudaRoundNearest);
|
| 1508 |
+
__x = __internal_pack_u16x2_to_u32(rlo, rhi);
|
| 1509 |
+
}
|
| 1510 |
+
/**
|
| 1511 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1512 |
+
* Constructor from \p double4 vector data type,
|
| 1513 |
+
* relies on \p __NV_SATFINITE behavior for out-of-range values.
|
| 1514 |
+
*/
|
| 1515 |
+
explicit __CUDA_HOSTDEVICE_FP6__ __nv_fp6x4_e2m3(const double4 f) {
|
| 1516 |
+
const double2 flo = {f.x, f.y};
|
| 1517 |
+
const double2 fhi = {f.z, f.w};
|
| 1518 |
+
const __nv_fp6x2_storage_t rlo =
|
| 1519 |
+
__nv_cvt_double2_to_fp6x2(flo, __NV_E2M3, cudaRoundNearest);
|
| 1520 |
+
const __nv_fp6x2_storage_t rhi =
|
| 1521 |
+
__nv_cvt_double2_to_fp6x2(fhi, __NV_E2M3, cudaRoundNearest);
|
| 1522 |
+
__x = __internal_pack_u16x2_to_u32(rlo, rhi);
|
| 1523 |
+
}
|
| 1524 |
+
|
| 1525 |
+
#if !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__)
|
| 1526 |
+
/* Widening converts */
|
| 1527 |
+
|
| 1528 |
+
/**
|
| 1529 |
+
* \ingroup CUDA_MATH_FP6_MISC
|
| 1530 |
+
* Conversion operator to \p float4 vector data type.
|
| 1531 |
+
*/
|
| 1532 |
+
explicit __CUDA_HOSTDEVICE_FP6__ operator float4() const {
|
| 1533 |
+
const __nv_fp6x2_storage_t slo = static_cast<__nv_fp6x2_storage_t>(__x);
|
| 1534 |
+
const __nv_fp6x2_storage_t shi =
|
| 1535 |
+
static_cast<__nv_fp6x2_storage_t>(__x >> 16U);
|
| 1536 |
+
float2 rlo = __internal_halfraw2_to_float2(
|
| 1537 |
+
__nv_cvt_fp6x2_to_halfraw2(slo, __NV_E2M3));
|
| 1538 |
+
float2 rhi = __internal_halfraw2_to_float2(
|
| 1539 |
+
__nv_cvt_fp6x2_to_halfraw2(shi, __NV_E2M3));
|
| 1540 |
+
float4 res = {rlo.x, rlo.y, rhi.x, rhi.y};
|
| 1541 |
+
return res;
|
| 1542 |
+
}
|
| 1543 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSION_OPERATORS__) */
|
| 1544 |
+
#endif /* !defined(__CUDA_NO_FP6_CONVERSIONS__) */
|
| 1545 |
+
};
|
|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
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef __CUDA_FP8_H__
|
| 51 |
+
#define __CUDA_FP8_H__
|
| 52 |
+
|
| 53 |
+
/* Set up function decorations */
|
| 54 |
+
#if defined(__CUDACC__)
|
| 55 |
+
#define __CUDA_FP8_DECL__ static __device__ __inline__
|
| 56 |
+
#define __CUDA_HOSTDEVICE_FP8__ __host__ __device__
|
| 57 |
+
#define __CUDA_HOSTDEVICE_FP8_DECL__ static __host__ __device__ __inline__
|
| 58 |
+
#else /* !defined(__CUDACC__) */
|
| 59 |
+
#if defined(__GNUC__)
|
| 60 |
+
#define __CUDA_HOSTDEVICE_FP8_DECL__ static __attribute__((unused))
|
| 61 |
+
#else
|
| 62 |
+
#define __CUDA_HOSTDEVICE_FP8_DECL__ static
|
| 63 |
+
#endif /* defined(__GNUC__) */
|
| 64 |
+
#define __CUDA_HOSTDEVICE_FP8__
|
| 65 |
+
#endif /* defined(__CUDACC_) */
|
| 66 |
+
|
| 67 |
+
#if !defined(_MSC_VER) && __cplusplus >= 201103L
|
| 68 |
+
#define __CPP_VERSION_AT_LEAST_11_FP8
|
| 69 |
+
#elif _MSC_FULL_VER >= 190024210 && _MSVC_LANG >= 201103L
|
| 70 |
+
#define __CPP_VERSION_AT_LEAST_11_FP8
|
| 71 |
+
#endif
|
| 72 |
+
|
| 73 |
+
// implicitly provided by NVRTC
|
| 74 |
+
#if !defined(__CUDACC_RTC__)
|
| 75 |
+
/* bring in enum cudaRoundMode */
|
| 76 |
+
#include "device_types.h"
|
| 77 |
+
#endif /* !defined(__CUDACC_RTC__) */
|
| 78 |
+
|
| 79 |
+
/* bring in __half_raw data type */
|
| 80 |
+
#include "cuda_fp16.h"
|
| 81 |
+
/* bring in __nv_bfloat16_raw data type */
|
| 82 |
+
#include "cuda_bf16.h"
|
| 83 |
+
|
| 84 |
+
// implicitly provided by NVRTC
|
| 85 |
+
#if !defined(__CUDACC_RTC__)
|
| 86 |
+
/* bring in float2, double4, etc vector types */
|
| 87 |
+
#include "vector_types.h"
|
| 88 |
+
#endif /* !defined(__CUDACC_RTC__) */
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* \defgroup CUDA_MATH_INTRINSIC_FP8 FP8 Intrinsics
|
| 92 |
+
* This section describes fp8 intrinsic functions.
|
| 93 |
+
* To use these functions, include the header file \p cuda_fp8.h in your
|
| 94 |
+
* program.
|
| 95 |
+
* The following macros are available to help users selectively enable/disable
|
| 96 |
+
* various definitions present in the header file:
|
| 97 |
+
* - \p __CUDA_NO_FP8_CONVERSIONS__ - If defined, this macro will prevent any
|
| 98 |
+
* use of the C++ type conversions (converting constructors and conversion
|
| 99 |
+
* operators) defined in the header.
|
| 100 |
+
* - \p __CUDA_NO_FP8_CONVERSION_OPERATORS__ - If defined, this macro will
|
| 101 |
+
* prevent any use of the C++ conversion operators from \p fp8 to other types.
|
| 102 |
+
*/
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* \defgroup CUDA_MATH_FP8_MISC FP8 Conversion and Data Movement
|
| 106 |
+
* \ingroup CUDA_MATH_INTRINSIC_FP8
|
| 107 |
+
* To use these functions, include the header file \p cuda_fp8.h in your
|
| 108 |
+
* program.
|
| 109 |
+
*/
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 113 |
+
* \brief 8-bit \p unsigned \p integer
|
| 114 |
+
* type abstraction used for \p fp8 floating-point
|
| 115 |
+
* numbers storage.
|
| 116 |
+
*/
|
| 117 |
+
typedef unsigned char __nv_fp8_storage_t;
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 121 |
+
* \brief 16-bit \p unsigned \p integer
|
| 122 |
+
* type abstraction used for storage of pairs of
|
| 123 |
+
* \p fp8 floating-point numbers.
|
| 124 |
+
*/
|
| 125 |
+
typedef unsigned short int __nv_fp8x2_storage_t;
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 129 |
+
* \brief 32-bit \p unsigned \p integer
|
| 130 |
+
* type abstraction used for storage of tetrads of
|
| 131 |
+
* \p fp8 floating-point numbers.
|
| 132 |
+
*/
|
| 133 |
+
typedef unsigned int __nv_fp8x4_storage_t;
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 137 |
+
* \brief Enumerates the modes applicable when
|
| 138 |
+
* performing a narrowing conversion to \p fp8 destination types.
|
| 139 |
+
*/
|
| 140 |
+
typedef enum __nv_saturation_t {
|
| 141 |
+
/**
|
| 142 |
+
* Means no saturation to finite is performed when conversion
|
| 143 |
+
* results in rounding values outside the range of destination
|
| 144 |
+
* type.
|
| 145 |
+
* NOTE: for fp8 type of e4m3 kind, the results that are larger
|
| 146 |
+
* than the maximum representable finite number of the target
|
| 147 |
+
* format become NaN.
|
| 148 |
+
*/
|
| 149 |
+
__NV_NOSAT,
|
| 150 |
+
/**
|
| 151 |
+
* Means input larger than the maximum representable
|
| 152 |
+
* finite number MAXNORM of the target format round to the
|
| 153 |
+
* MAXNORM of the same sign as input.
|
| 154 |
+
*/
|
| 155 |
+
__NV_SATFINITE,
|
| 156 |
+
} __nv_saturation_t;
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 160 |
+
* \brief Enumerates the possible
|
| 161 |
+
* interpretations of the 8-bit values when referring to them as
|
| 162 |
+
* \p fp8 types.
|
| 163 |
+
*/
|
| 164 |
+
typedef enum __nv_fp8_interpretation_t {
|
| 165 |
+
__NV_E4M3, /**< Stands for \p fp8 numbers of \p e4m3 kind. */
|
| 166 |
+
__NV_E5M2, /**< Stands for \p fp8 numbers of \p e5m2 kind. */
|
| 167 |
+
} __nv_fp8_interpretation_t;
|
| 168 |
+
|
| 169 |
+
/* Forward-declaration of C-style APIs */
|
| 170 |
+
|
| 171 |
+
/**
|
| 172 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 173 |
+
* \brief Converts input \p double precision \p x to \p fp8 type of the
|
| 174 |
+
* requested kind using round-to-nearest-even rounding and requested saturation
|
| 175 |
+
* mode.
|
| 176 |
+
*
|
| 177 |
+
* \details Converts input \p x to \p fp8 type of the kind specified by
|
| 178 |
+
* \p fp8_interpretation parameter,
|
| 179 |
+
* using round-to-nearest-even rounding and
|
| 180 |
+
* saturation mode specified by \p saturate parameter.
|
| 181 |
+
*
|
| 182 |
+
* \returns
|
| 183 |
+
* - The \p __nv_fp8_storage_t value holds the result of conversion.
|
| 184 |
+
*/
|
| 185 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
|
| 186 |
+
__nv_cvt_double_to_fp8(const double x, const __nv_saturation_t saturate,
|
| 187 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 188 |
+
|
| 189 |
+
/**
|
| 190 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 191 |
+
* \brief Converts input vector of two \p double precision numbers packed
|
| 192 |
+
* in \p double2 \p x into a vector of two values of \p fp8 type of
|
| 193 |
+
* the requested kind using round-to-nearest-even rounding and requested
|
| 194 |
+
* saturation mode.
|
| 195 |
+
*
|
| 196 |
+
* \details Converts input vector \p x to a vector of two \p fp8 values of the
|
| 197 |
+
* kind specified by \p fp8_interpretation parameter, using
|
| 198 |
+
* round-to-nearest-even rounding and saturation mode specified by \p saturate
|
| 199 |
+
* parameter.
|
| 200 |
+
*
|
| 201 |
+
* \returns
|
| 202 |
+
* - The \p __nv_fp8x2_storage_t value holds the result of conversion.
|
| 203 |
+
*/
|
| 204 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
|
| 205 |
+
__nv_cvt_double2_to_fp8x2(const double2 x, const __nv_saturation_t saturate,
|
| 206 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 207 |
+
|
| 208 |
+
/**
|
| 209 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 210 |
+
* \brief Converts input \p single precision \p x to \p fp8 type of the
|
| 211 |
+
* requested kind using round-to-nearest-even rounding and requested saturation
|
| 212 |
+
* mode.
|
| 213 |
+
*
|
| 214 |
+
* \details Converts input \p x to \p fp8 type of the kind specified by
|
| 215 |
+
* \p fp8_interpretation parameter,
|
| 216 |
+
* using round-to-nearest-even rounding and
|
| 217 |
+
* saturation mode specified by \p saturate parameter.
|
| 218 |
+
*
|
| 219 |
+
* \returns
|
| 220 |
+
* - The \p __nv_fp8_storage_t value holds the result of conversion.
|
| 221 |
+
*/
|
| 222 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
|
| 223 |
+
__nv_cvt_float_to_fp8(const float x, const __nv_saturation_t saturate,
|
| 224 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 225 |
+
|
| 226 |
+
/**
|
| 227 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 228 |
+
* \brief Converts input vector of two \p single precision numbers packed
|
| 229 |
+
* in \p float2 \p x into a vector of two values of \p fp8 type of
|
| 230 |
+
* the requested kind using round-to-nearest-even rounding and requested
|
| 231 |
+
* saturation mode.
|
| 232 |
+
*
|
| 233 |
+
* \details Converts input vector \p x to a vector of two \p fp8 values of the
|
| 234 |
+
* kind specified by \p fp8_interpretation parameter, using
|
| 235 |
+
* round-to-nearest-even rounding and saturation mode specified by \p saturate
|
| 236 |
+
* parameter.
|
| 237 |
+
*
|
| 238 |
+
* \returns
|
| 239 |
+
* - The \p __nv_fp8x2_storage_t value holds the result of conversion.
|
| 240 |
+
*/
|
| 241 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
|
| 242 |
+
__nv_cvt_float2_to_fp8x2(const float2 x, const __nv_saturation_t saturate,
|
| 243 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 244 |
+
|
| 245 |
+
/**
|
| 246 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 247 |
+
* \brief Converts input \p half precision \p x to \p fp8 type of the requested
|
| 248 |
+
* kind using round-to-nearest-even rounding and requested saturation mode.
|
| 249 |
+
*
|
| 250 |
+
* \details Converts input \p x to \p fp8 type of the kind specified by
|
| 251 |
+
* \p fp8_interpretation parameter,
|
| 252 |
+
* using round-to-nearest-even rounding and
|
| 253 |
+
* saturation mode specified by \p saturate parameter.
|
| 254 |
+
*
|
| 255 |
+
* \returns
|
| 256 |
+
* - The \p __nv_fp8_storage_t value holds the result of conversion.
|
| 257 |
+
*/
|
| 258 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t
|
| 259 |
+
__nv_cvt_halfraw_to_fp8(const __half_raw x, const __nv_saturation_t saturate,
|
| 260 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 264 |
+
* \brief Converts input vector of two \p half precision numbers packed
|
| 265 |
+
* in \p __half2_raw \p x into a vector of two values of \p fp8 type of
|
| 266 |
+
* the requested kind using round-to-nearest-even rounding and requested
|
| 267 |
+
* saturation mode.
|
| 268 |
+
*
|
| 269 |
+
* \details Converts input vector \p x to a vector of two \p fp8 values of the
|
| 270 |
+
* kind specified by \p fp8_interpretation parameter, using
|
| 271 |
+
* round-to-nearest-even rounding and saturation mode specified by \p saturate
|
| 272 |
+
* parameter.
|
| 273 |
+
*
|
| 274 |
+
* \returns
|
| 275 |
+
* - The \p __nv_fp8x2_storage_t value holds the result of conversion.
|
| 276 |
+
*/
|
| 277 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t __nv_cvt_halfraw2_to_fp8x2(
|
| 278 |
+
const __half2_raw x, const __nv_saturation_t saturate,
|
| 279 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 283 |
+
* \brief Converts input \p nv_bfloat16 precision \p x to \p fp8 type of the
|
| 284 |
+
* requested kind using round-to-nearest-even rounding and requested saturation
|
| 285 |
+
* mode.
|
| 286 |
+
*
|
| 287 |
+
* \details Converts input \p x to \p fp8 type of the kind specified by
|
| 288 |
+
* \p fp8_interpretation parameter,
|
| 289 |
+
* using round-to-nearest-even rounding and
|
| 290 |
+
* saturation mode specified by \p saturate parameter.
|
| 291 |
+
*
|
| 292 |
+
* \returns
|
| 293 |
+
* - The \p __nv_fp8_storage_t value holds the result of conversion.
|
| 294 |
+
*/
|
| 295 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t __nv_cvt_bfloat16raw_to_fp8(
|
| 296 |
+
const __nv_bfloat16_raw x, const __nv_saturation_t saturate,
|
| 297 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 301 |
+
* \brief Converts input vector of two \p nv_bfloat16 precision numbers packed
|
| 302 |
+
* in \p __nv_bfloat162_raw \p x into a vector of two values of \p fp8 type of
|
| 303 |
+
* the requested kind using round-to-nearest-even rounding and requested
|
| 304 |
+
* saturation mode.
|
| 305 |
+
*
|
| 306 |
+
* \details Converts input vector \p x to a vector of two \p fp8 values of the
|
| 307 |
+
* kind specified by \p fp8_interpretation parameter, using
|
| 308 |
+
* round-to-nearest-even rounding and saturation mode specified by \p saturate
|
| 309 |
+
* parameter.
|
| 310 |
+
*
|
| 311 |
+
* \returns
|
| 312 |
+
* - The \p __nv_fp8x2_storage_t value holds the result of conversion.
|
| 313 |
+
*/
|
| 314 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t
|
| 315 |
+
__nv_cvt_bfloat16raw2_to_fp8x2(
|
| 316 |
+
const __nv_bfloat162_raw x, const __nv_saturation_t saturate,
|
| 317 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 318 |
+
|
| 319 |
+
/**
|
| 320 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 321 |
+
* \brief Converts input \p fp8 \p x of the specified kind
|
| 322 |
+
* to \p half precision.
|
| 323 |
+
*
|
| 324 |
+
* \details Converts input \p x of \p fp8 type of the kind specified by
|
| 325 |
+
* \p fp8_interpretation parameter
|
| 326 |
+
* to \p half precision.
|
| 327 |
+
*
|
| 328 |
+
* \returns
|
| 329 |
+
* - The \p __half_raw value holds the result of conversion.
|
| 330 |
+
*/
|
| 331 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __half_raw
|
| 332 |
+
__nv_cvt_fp8_to_halfraw(const __nv_fp8_storage_t x,
|
| 333 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 334 |
+
/**
|
| 335 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 336 |
+
* \brief Converts input vector of two \p fp8 values of the specified kind
|
| 337 |
+
* to a vector of two \p half precision values packed in \p __half2_raw
|
| 338 |
+
* structure.
|
| 339 |
+
*
|
| 340 |
+
* \details Converts input vector \p x of \p fp8 type of the kind specified by
|
| 341 |
+
* \p fp8_interpretation parameter
|
| 342 |
+
* to a vector of two \p half precision values and returns as \p __half2_raw
|
| 343 |
+
* structure.
|
| 344 |
+
*
|
| 345 |
+
* \returns
|
| 346 |
+
* - The \p __half2_raw value holds the result of conversion.
|
| 347 |
+
*/
|
| 348 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __half2_raw
|
| 349 |
+
__nv_cvt_fp8x2_to_halfraw2(const __nv_fp8x2_storage_t x,
|
| 350 |
+
const __nv_fp8_interpretation_t fp8_interpretation);
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
/**
|
| 354 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 355 |
+
* \brief Converts input \p bfloat16 input into a scaling factor of \p e8m0 kind.
|
| 356 |
+
*
|
| 357 |
+
* \details Input number's absolute value is rounded to the closest power of two in the
|
| 358 |
+
* direction specified via \p rounding parameter. Rounded results that are
|
| 359 |
+
* smaller than the smallest representable target format number 2^-127 are then
|
| 360 |
+
* clipped to 2^-127. Results that are larger than the largest representable
|
| 361 |
+
* target format number 2^127 are either clipped to 2^127 if \p saturate equals
|
| 362 |
+
* to \p __NV_SATFINITE, or convert to \p NaN otherwise. \p NaN inputs convert
|
| 363 |
+
* into \p NaN output, encoded as \p 0xFF in the target format.
|
| 364 |
+
*
|
| 365 |
+
* \returns
|
| 366 |
+
* - The \p __nv_fp8_storage_t value holds the result of conversion.
|
| 367 |
+
*/
|
| 368 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t __nv_cvt_bfloat16raw_to_e8m0(const __nv_bfloat16_raw x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding);
|
| 369 |
+
|
| 370 |
+
/**
|
| 371 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 372 |
+
* \brief Converts a pair of \p bfloat16 values into a pair of scaling factors of \p e8m0 kind.
|
| 373 |
+
*
|
| 374 |
+
* \see __nv_cvt_bfloat16raw_to_e8m0() for details of conversion.
|
| 375 |
+
*
|
| 376 |
+
* \returns
|
| 377 |
+
* - The \p __nv_fp8x2_storage_t value holds the result of conversion.
|
| 378 |
+
*/
|
| 379 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t __nv_cvt_bfloat162raw_to_e8m0x2(const __nv_bfloat162_raw x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding);
|
| 380 |
+
|
| 381 |
+
/**
|
| 382 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 383 |
+
* \brief Converts input \p float value into a scaling factor of \p e8m0 kind.
|
| 384 |
+
*
|
| 385 |
+
* \see __nv_cvt_bfloat16raw_to_e8m0() for details of conversion.
|
| 386 |
+
*
|
| 387 |
+
* \returns
|
| 388 |
+
* - The \p __nv_fp8_storage_t value holds the result of conversion.
|
| 389 |
+
*/
|
| 390 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t __nv_cvt_float_to_e8m0(const float x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding);
|
| 391 |
+
|
| 392 |
+
/**
|
| 393 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 394 |
+
* \brief Converts a pair of \p float values into a pair of scaling factors of \p e8m0 kind.
|
| 395 |
+
*
|
| 396 |
+
* \see __nv_cvt_bfloat16raw_to_e8m0() for details of conversion.
|
| 397 |
+
*
|
| 398 |
+
* \returns
|
| 399 |
+
* - The \p __nv_fp8x2_storage_t value holds the result of conversion.
|
| 400 |
+
*/
|
| 401 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t __nv_cvt_float2_to_e8m0x2(const float2 x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding);
|
| 402 |
+
|
| 403 |
+
/**
|
| 404 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 405 |
+
* \brief Converts input \p double value into a scaling factor of \p e8m0 kind.
|
| 406 |
+
*
|
| 407 |
+
* \see __nv_cvt_bfloat16raw_to_e8m0() for details of conversion.
|
| 408 |
+
*
|
| 409 |
+
* \returns
|
| 410 |
+
* - The \p __nv_fp8_storage_t value holds the result of conversion.
|
| 411 |
+
*/
|
| 412 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8_storage_t __nv_cvt_double_to_e8m0(const double x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding);
|
| 413 |
+
|
| 414 |
+
/**
|
| 415 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 416 |
+
* \brief Converts a pair of \p double values into a pair of scaling factors of \p e8m0 kind.
|
| 417 |
+
*
|
| 418 |
+
* \see __nv_cvt_bfloat16raw_to_e8m0() for details of conversion.
|
| 419 |
+
*
|
| 420 |
+
* \returns
|
| 421 |
+
* - The \p __nv_fp8x2_storage_t value holds the result of conversion.
|
| 422 |
+
*/
|
| 423 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_fp8x2_storage_t __nv_cvt_double2_to_e8m0x2(const double2 x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding);
|
| 424 |
+
|
| 425 |
+
/**
|
| 426 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 427 |
+
* \brief Converts input scaling factor value of \p e8m0 kind into \p bfloat16.
|
| 428 |
+
*
|
| 429 |
+
* \details Input scales are exact powers of two or a \p NaN value,
|
| 430 |
+
* also representable in the target format.
|
| 431 |
+
*
|
| 432 |
+
* \returns
|
| 433 |
+
* - The \p __nv_bfloat16_raw value holds the result of conversion.
|
| 434 |
+
*/
|
| 435 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_bfloat16_raw __nv_cvt_e8m0_to_bf16raw(const __nv_fp8_storage_t x);
|
| 436 |
+
|
| 437 |
+
/**
|
| 438 |
+
* \ingroup CUDA_MATH_FP8_MISC
|
| 439 |
+
* \brief Converts input pair of scaling factors of \p e8m0 kind into a pair of \p bfloat16 values.
|
| 440 |
+
*
|
| 441 |
+
* \returns
|
| 442 |
+
* - The \p __nv_bfloat162_raw value holds the result of conversion.
|
| 443 |
+
*/
|
| 444 |
+
__CUDA_HOSTDEVICE_FP8_DECL__ __nv_bfloat162_raw __nv_cvt_e8m0x2_to_bf162raw(const __nv_fp8x2_storage_t x);
|
| 445 |
+
|
| 446 |
+
#if defined(__cplusplus)
|
| 447 |
+
|
| 448 |
+
#define __CUDA_FP8_TYPES_EXIST__
|
| 449 |
+
|
| 450 |
+
/* Forward-declaration of structures defined in "cuda_fp8.hpp" */
|
| 451 |
+
struct __nv_fp8_e5m2;
|
| 452 |
+
struct __nv_fp8x2_e5m2;
|
| 453 |
+
struct __nv_fp8x4_e5m2;
|
| 454 |
+
|
| 455 |
+
struct __nv_fp8_e4m3;
|
| 456 |
+
struct __nv_fp8x2_e4m3;
|
| 457 |
+
struct __nv_fp8x4_e4m3;
|
| 458 |
+
|
| 459 |
+
struct __nv_fp8_e8m0;
|
| 460 |
+
struct __nv_fp8x2_e8m0;
|
| 461 |
+
struct __nv_fp8x4_e8m0;
|
| 462 |
+
|
| 463 |
+
#endif /* defined(__cplusplus) */
|
| 464 |
+
|
| 465 |
+
#include "cuda_fp8.hpp"
|
| 466 |
+
|
| 467 |
+
#undef __CUDA_FP8_DECL__
|
| 468 |
+
#undef __CUDA_HOSTDEVICE_FP8__
|
| 469 |
+
#undef __CUDA_HOSTDEVICE_FP8_DECL__
|
| 470 |
+
|
| 471 |
+
#if defined(__CPP_VERSION_AT_LEAST_11_FP8)
|
| 472 |
+
#undef __CPP_VERSION_AT_LEAST_11_FP8
|
| 473 |
+
#endif /* defined(__CPP_VERSION_AT_LEAST_11_FP8) */
|
| 474 |
+
|
| 475 |
+
#endif /* end of include guard: __CUDA_FP8_H__ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_fp8.hpp
ADDED
|
The diff for this file is too large to render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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_GL_INTEROP_H__)
|
| 51 |
+
#define __CUDA_GL_INTEROP_H__
|
| 52 |
+
|
| 53 |
+
#include "cuda_runtime_api.h"
|
| 54 |
+
|
| 55 |
+
#if defined(__APPLE__)
|
| 56 |
+
|
| 57 |
+
#include <OpenGL/gl.h>
|
| 58 |
+
|
| 59 |
+
#else /* __APPLE__ */
|
| 60 |
+
|
| 61 |
+
#if defined(__arm__) || defined(__aarch64__)
|
| 62 |
+
#ifndef GL_VERSION
|
| 63 |
+
#error Please include the appropriate gl headers before including cuda_gl_interop.h
|
| 64 |
+
#endif
|
| 65 |
+
#else
|
| 66 |
+
#include <GL/gl.h>
|
| 67 |
+
#endif
|
| 68 |
+
|
| 69 |
+
#endif /* __APPLE__ */
|
| 70 |
+
|
| 71 |
+
/** \cond impl_private */
|
| 72 |
+
#if defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
|
| 73 |
+
#define __CUDA_DEPRECATED
|
| 74 |
+
#elif defined(_MSC_VER)
|
| 75 |
+
#define __CUDA_DEPRECATED __declspec(deprecated)
|
| 76 |
+
#elif defined(__GNUC__)
|
| 77 |
+
#define __CUDA_DEPRECATED __attribute__((deprecated))
|
| 78 |
+
#else
|
| 79 |
+
#define __CUDA_DEPRECATED
|
| 80 |
+
#endif
|
| 81 |
+
/** \endcond impl_private */
|
| 82 |
+
|
| 83 |
+
#if defined(__cplusplus)
|
| 84 |
+
extern "C" {
|
| 85 |
+
#endif /* __cplusplus */
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* \addtogroup CUDART_OPENGL OpenGL Interoperability
|
| 89 |
+
* This section describes the OpenGL interoperability functions of the CUDA
|
| 90 |
+
* runtime application programming interface. Note that mapping of OpenGL
|
| 91 |
+
* resources is performed with the graphics API agnostic, resource mapping
|
| 92 |
+
* interface described in \ref CUDART_INTEROP "Graphics Interopability".
|
| 93 |
+
*
|
| 94 |
+
* @{
|
| 95 |
+
*/
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* CUDA devices corresponding to the current OpenGL context
|
| 99 |
+
*/
|
| 100 |
+
enum cudaGLDeviceList
|
| 101 |
+
{
|
| 102 |
+
cudaGLDeviceListAll = 1, /**< The CUDA devices for all GPUs used by the current OpenGL context */
|
| 103 |
+
cudaGLDeviceListCurrentFrame = 2, /**< The CUDA devices for the GPUs used by the current OpenGL context in its currently rendering frame */
|
| 104 |
+
cudaGLDeviceListNextFrame = 3 /**< The CUDA devices for the GPUs to be used by the current OpenGL context in the next frame */
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* \brief Gets the CUDA devices associated with the current OpenGL context
|
| 109 |
+
*
|
| 110 |
+
* Returns in \p *pCudaDeviceCount the number of CUDA-compatible devices
|
| 111 |
+
* corresponding to the current OpenGL context. Also returns in \p *pCudaDevices
|
| 112 |
+
* at most \p cudaDeviceCount of the CUDA-compatible devices corresponding to
|
| 113 |
+
* the current OpenGL context. If any of the GPUs being used by the current OpenGL
|
| 114 |
+
* context are not CUDA capable then the call will return ::cudaErrorNoDevice.
|
| 115 |
+
*
|
| 116 |
+
* \param pCudaDeviceCount - Returned number of CUDA devices corresponding to the
|
| 117 |
+
* current OpenGL context
|
| 118 |
+
* \param pCudaDevices - Returned CUDA devices corresponding to the current
|
| 119 |
+
* OpenGL context
|
| 120 |
+
* \param cudaDeviceCount - The size of the output device array \p pCudaDevices
|
| 121 |
+
* \param deviceList - The set of devices to return. This set may be
|
| 122 |
+
* ::cudaGLDeviceListAll for all devices,
|
| 123 |
+
* ::cudaGLDeviceListCurrentFrame for the devices used to
|
| 124 |
+
* render the current frame (in SLI), or
|
| 125 |
+
* ::cudaGLDeviceListNextFrame for the devices used to
|
| 126 |
+
* render the next frame (in SLI).
|
| 127 |
+
*
|
| 128 |
+
* \return
|
| 129 |
+
* ::cudaSuccess,
|
| 130 |
+
* ::cudaErrorNoDevice,
|
| 131 |
+
* ::cudaErrorInvalidGraphicsContext,
|
| 132 |
+
* ::cudaErrorOperatingSystem,
|
| 133 |
+
* ::cudaErrorUnknown
|
| 134 |
+
*
|
| 135 |
+
* \note This function is not supported on Mac OS X.
|
| 136 |
+
* \notefnerr
|
| 137 |
+
*
|
| 138 |
+
* \sa
|
| 139 |
+
* ::cudaGraphicsUnregisterResource,
|
| 140 |
+
* ::cudaGraphicsMapResources,
|
| 141 |
+
* ::cudaGraphicsSubResourceGetMappedArray,
|
| 142 |
+
* ::cudaGraphicsResourceGetMappedPointer,
|
| 143 |
+
* ::cuGLGetDevices
|
| 144 |
+
*/
|
| 145 |
+
extern __host__ cudaError_t CUDARTAPI cudaGLGetDevices(unsigned int *pCudaDeviceCount, int *pCudaDevices, unsigned int cudaDeviceCount, enum cudaGLDeviceList deviceList);
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* \brief Register an OpenGL texture or renderbuffer object
|
| 149 |
+
*
|
| 150 |
+
* Registers the texture or renderbuffer object specified by \p image for access by CUDA.
|
| 151 |
+
* A handle to the registered object is returned as \p resource.
|
| 152 |
+
*
|
| 153 |
+
* \p target must match the type of the object, and must be one of ::GL_TEXTURE_2D,
|
| 154 |
+
* ::GL_TEXTURE_RECTANGLE, ::GL_TEXTURE_CUBE_MAP, ::GL_TEXTURE_3D, ::GL_TEXTURE_2D_ARRAY,
|
| 155 |
+
* or ::GL_RENDERBUFFER.
|
| 156 |
+
*
|
| 157 |
+
* The register flags \p flags specify the intended usage, as follows:
|
| 158 |
+
* - ::cudaGraphicsRegisterFlagsNone: Specifies no hints about how this
|
| 159 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 160 |
+
* read from and written to by CUDA. This is the default value.
|
| 161 |
+
* - ::cudaGraphicsRegisterFlagsReadOnly: Specifies that CUDA
|
| 162 |
+
* will not write to this resource.
|
| 163 |
+
* - ::cudaGraphicsRegisterFlagsWriteDiscard: Specifies that
|
| 164 |
+
* CUDA will not read from this resource and will write over the
|
| 165 |
+
* entire contents of the resource, so none of the data previously
|
| 166 |
+
* stored in the resource will be preserved.
|
| 167 |
+
* - ::cudaGraphicsRegisterFlagsSurfaceLoadStore: Specifies that CUDA will
|
| 168 |
+
* bind this resource to a surface reference.
|
| 169 |
+
* - ::cudaGraphicsRegisterFlagsTextureGather: Specifies that CUDA will perform
|
| 170 |
+
* texture gather operations on this resource.
|
| 171 |
+
*
|
| 172 |
+
* The following image formats are supported. For brevity's sake, the list is abbreviated.
|
| 173 |
+
* For ex., {GL_R, GL_RG} X {8, 16} would expand to the following 4 formats
|
| 174 |
+
* {GL_R8, GL_R16, GL_RG8, GL_RG16} :
|
| 175 |
+
* - GL_RED, GL_RG, GL_RGBA, GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY
|
| 176 |
+
* - {GL_R, GL_RG, GL_RGBA} X {8, 16, 16F, 32F, 8UI, 16UI, 32UI, 8I, 16I, 32I}
|
| 177 |
+
* - {GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY} X
|
| 178 |
+
* {8, 16, 16F_ARB, 32F_ARB, 8UI_EXT, 16UI_EXT, 32UI_EXT, 8I_EXT, 16I_EXT, 32I_EXT}
|
| 179 |
+
*
|
| 180 |
+
* The following image classes are currently disallowed:
|
| 181 |
+
* - Textures with borders
|
| 182 |
+
* - Multisampled renderbuffers
|
| 183 |
+
*
|
| 184 |
+
* \param resource - Pointer to the returned object handle
|
| 185 |
+
* \param image - name of texture or renderbuffer object to be registered
|
| 186 |
+
* \param target - Identifies the type of object specified by \p image
|
| 187 |
+
* \param flags - Register flags
|
| 188 |
+
*
|
| 189 |
+
* \return
|
| 190 |
+
* ::cudaSuccess,
|
| 191 |
+
* ::cudaErrorInvalidDevice,
|
| 192 |
+
* ::cudaErrorInvalidValue,
|
| 193 |
+
* ::cudaErrorInvalidResourceHandle,
|
| 194 |
+
* ::cudaErrorOperatingSystem,
|
| 195 |
+
* ::cudaErrorUnknown
|
| 196 |
+
* \notefnerr
|
| 197 |
+
*
|
| 198 |
+
* \sa
|
| 199 |
+
* ::cudaGraphicsUnregisterResource,
|
| 200 |
+
* ::cudaGraphicsMapResources,
|
| 201 |
+
* ::cudaGraphicsSubResourceGetMappedArray,
|
| 202 |
+
* ::cuGraphicsGLRegisterImage
|
| 203 |
+
*/
|
| 204 |
+
extern __host__ cudaError_t CUDARTAPI cudaGraphicsGLRegisterImage(struct cudaGraphicsResource **resource, GLuint image, GLenum target, unsigned int flags);
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* \brief Registers an OpenGL buffer object
|
| 208 |
+
*
|
| 209 |
+
* Registers the buffer object specified by \p buffer for access by
|
| 210 |
+
* CUDA. A handle to the registered object is returned as \p
|
| 211 |
+
* resource. The register flags \p flags specify the intended usage,
|
| 212 |
+
* as follows:
|
| 213 |
+
*
|
| 214 |
+
* - ::cudaGraphicsRegisterFlagsNone: Specifies no hints about how this
|
| 215 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 216 |
+
* read from and written to by CUDA. This is the default value.
|
| 217 |
+
* - ::cudaGraphicsRegisterFlagsReadOnly: Specifies that CUDA
|
| 218 |
+
* will not write to this resource.
|
| 219 |
+
* - ::cudaGraphicsRegisterFlagsWriteDiscard: Specifies that
|
| 220 |
+
* CUDA will not read from this resource and will write over the
|
| 221 |
+
* entire contents of the resource, so none of the data previously
|
| 222 |
+
* stored in the resource will be preserved.
|
| 223 |
+
*
|
| 224 |
+
* \param resource - Pointer to the returned object handle
|
| 225 |
+
* \param buffer - name of buffer object to be registered
|
| 226 |
+
* \param flags - Register flags
|
| 227 |
+
*
|
| 228 |
+
* \return
|
| 229 |
+
* ::cudaSuccess,
|
| 230 |
+
* ::cudaErrorInvalidDevice,
|
| 231 |
+
* ::cudaErrorInvalidValue,
|
| 232 |
+
* ::cudaErrorInvalidResourceHandle,
|
| 233 |
+
* ::cudaErrorOperatingSystem,
|
| 234 |
+
* ::cudaErrorUnknown
|
| 235 |
+
* \notefnerr
|
| 236 |
+
*
|
| 237 |
+
* \sa
|
| 238 |
+
* ::cudaGraphicsUnregisterResource,
|
| 239 |
+
* ::cudaGraphicsMapResources,
|
| 240 |
+
* ::cudaGraphicsResourceGetMappedPointer,
|
| 241 |
+
* ::cuGraphicsGLRegisterBuffer
|
| 242 |
+
*/
|
| 243 |
+
extern __host__ cudaError_t CUDARTAPI cudaGraphicsGLRegisterBuffer(struct cudaGraphicsResource **resource, GLuint buffer, unsigned int flags);
|
| 244 |
+
|
| 245 |
+
#ifdef _WIN32
|
| 246 |
+
#ifndef WGL_NV_gpu_affinity
|
| 247 |
+
typedef void* HGPUNV;
|
| 248 |
+
#endif
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* \brief Gets the CUDA device associated with hGpu
|
| 252 |
+
*
|
| 253 |
+
* Returns the CUDA device associated with a hGpu, if applicable.
|
| 254 |
+
*
|
| 255 |
+
* \param device - Returns the device associated with hGpu, or -1 if hGpu is
|
| 256 |
+
* not a compute device.
|
| 257 |
+
* \param hGpu - Handle to a GPU, as queried via WGL_NV_gpu_affinity
|
| 258 |
+
*
|
| 259 |
+
* \return
|
| 260 |
+
* ::cudaSuccess
|
| 261 |
+
* \notefnerr
|
| 262 |
+
*
|
| 263 |
+
* \sa
|
| 264 |
+
* ::WGL_NV_gpu_affinity,
|
| 265 |
+
* ::cuWGLGetDevice
|
| 266 |
+
*/
|
| 267 |
+
extern __host__ cudaError_t CUDARTAPI cudaWGLGetDevice(int *device, HGPUNV hGpu);
|
| 268 |
+
#endif
|
| 269 |
+
|
| 270 |
+
/** @} */ /* END CUDART_OPENGL */
|
| 271 |
+
|
| 272 |
+
/**
|
| 273 |
+
* \addtogroup CUDART_OPENGL_DEPRECATED OpenGL Interoperability [DEPRECATED]
|
| 274 |
+
* This section describes deprecated OpenGL interoperability functionality.
|
| 275 |
+
*
|
| 276 |
+
* @{
|
| 277 |
+
*/
|
| 278 |
+
|
| 279 |
+
/**
|
| 280 |
+
* CUDA GL Map Flags
|
| 281 |
+
*/
|
| 282 |
+
enum cudaGLMapFlags
|
| 283 |
+
{
|
| 284 |
+
cudaGLMapFlagsNone = 0, /**< Default; Assume resource can be read/written */
|
| 285 |
+
cudaGLMapFlagsReadOnly = 1, /**< CUDA kernels will not write to this resource */
|
| 286 |
+
cudaGLMapFlagsWriteDiscard = 2 /**< CUDA kernels will only write to and will not read from this resource */
|
| 287 |
+
};
|
| 288 |
+
|
| 289 |
+
/**
|
| 290 |
+
* \brief Sets a CUDA device to use OpenGL interoperability
|
| 291 |
+
*
|
| 292 |
+
* \deprecated This function is deprecated as of CUDA 5.0.
|
| 293 |
+
*
|
| 294 |
+
* This function is deprecated and should no longer be used. It is
|
| 295 |
+
* no longer necessary to associate a CUDA device with an OpenGL
|
| 296 |
+
* context in order to achieve maximum interoperability performance.
|
| 297 |
+
*
|
| 298 |
+
* This function will immediately initialize the primary context on
|
| 299 |
+
* \p device if needed.
|
| 300 |
+
*
|
| 301 |
+
* \param device - Device to use for OpenGL interoperability
|
| 302 |
+
*
|
| 303 |
+
* \return
|
| 304 |
+
* ::cudaSuccess,
|
| 305 |
+
* ::cudaErrorInvalidDevice,
|
| 306 |
+
* ::cudaErrorSetOnActiveProcess
|
| 307 |
+
* \notefnerr
|
| 308 |
+
*
|
| 309 |
+
* \sa ::cudaGraphicsGLRegisterBuffer, ::cudaGraphicsGLRegisterImage
|
| 310 |
+
*/
|
| 311 |
+
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLSetGLDevice(int device);
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* \brief Registers a buffer object for access by CUDA
|
| 315 |
+
*
|
| 316 |
+
* \deprecated This function is deprecated as of CUDA 3.0.
|
| 317 |
+
*
|
| 318 |
+
* Registers the buffer object of ID \p bufObj for access by
|
| 319 |
+
* CUDA. This function must be called before CUDA can map the buffer
|
| 320 |
+
* object. The OpenGL context used to create the buffer, or another
|
| 321 |
+
* context from the same share group, must be bound to the current
|
| 322 |
+
* thread when this is called.
|
| 323 |
+
*
|
| 324 |
+
* \param bufObj - Buffer object ID to register
|
| 325 |
+
*
|
| 326 |
+
* \return
|
| 327 |
+
* ::cudaSuccess,
|
| 328 |
+
* ::cudaErrorInitializationError
|
| 329 |
+
* \notefnerr
|
| 330 |
+
*
|
| 331 |
+
* \sa ::cudaGraphicsGLRegisterBuffer
|
| 332 |
+
*/
|
| 333 |
+
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLRegisterBufferObject(GLuint bufObj);
|
| 334 |
+
|
| 335 |
+
/**
|
| 336 |
+
* \brief Maps a buffer object for access by CUDA
|
| 337 |
+
*
|
| 338 |
+
* \deprecated This function is deprecated as of CUDA 3.0.
|
| 339 |
+
*
|
| 340 |
+
* Maps the buffer object of ID \p bufObj into the address space of
|
| 341 |
+
* CUDA and returns in \p *devPtr the base pointer of the resulting
|
| 342 |
+
* mapping. The buffer must have previously been registered by
|
| 343 |
+
* calling ::cudaGLRegisterBufferObject(). While a buffer is mapped
|
| 344 |
+
* by CUDA, any OpenGL operation which references the buffer will
|
| 345 |
+
* result in undefined behavior. The OpenGL context used to create
|
| 346 |
+
* the buffer, or another context from the same share group, must be
|
| 347 |
+
* bound to the current thread when this is called.
|
| 348 |
+
*
|
| 349 |
+
* All streams in the current thread are synchronized with the current
|
| 350 |
+
* GL context.
|
| 351 |
+
*
|
| 352 |
+
* \param devPtr - Returned device pointer to CUDA object
|
| 353 |
+
* \param bufObj - Buffer object ID to map
|
| 354 |
+
*
|
| 355 |
+
* \return
|
| 356 |
+
* ::cudaSuccess,
|
| 357 |
+
* ::cudaErrorMapBufferObjectFailed
|
| 358 |
+
* \notefnerr
|
| 359 |
+
*
|
| 360 |
+
* \sa ::cudaGraphicsMapResources
|
| 361 |
+
*/
|
| 362 |
+
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLMapBufferObject(void **devPtr, GLuint bufObj);
|
| 363 |
+
|
| 364 |
+
/**
|
| 365 |
+
* \brief Unmaps a buffer object for access by CUDA
|
| 366 |
+
*
|
| 367 |
+
* \deprecated This function is deprecated as of CUDA 3.0.
|
| 368 |
+
*
|
| 369 |
+
* Unmaps the buffer object of ID \p bufObj for access by CUDA. When
|
| 370 |
+
* a buffer is unmapped, the base address returned by
|
| 371 |
+
* ::cudaGLMapBufferObject() is invalid and subsequent references to
|
| 372 |
+
* the address result in undefined behavior. The OpenGL context used
|
| 373 |
+
* to create the buffer, or another context from the same share group,
|
| 374 |
+
* must be bound to the current thread when this is called.
|
| 375 |
+
*
|
| 376 |
+
* All streams in the current thread are synchronized with the current
|
| 377 |
+
* GL context.
|
| 378 |
+
*
|
| 379 |
+
* \param bufObj - Buffer object to unmap
|
| 380 |
+
*
|
| 381 |
+
* \return
|
| 382 |
+
* ::cudaSuccess,
|
| 383 |
+
* ::cudaErrorUnmapBufferObjectFailed
|
| 384 |
+
* \notefnerr
|
| 385 |
+
*
|
| 386 |
+
* \sa ::cudaGraphicsUnmapResources
|
| 387 |
+
*/
|
| 388 |
+
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLUnmapBufferObject(GLuint bufObj);
|
| 389 |
+
|
| 390 |
+
/**
|
| 391 |
+
* \brief Unregisters a buffer object for access by CUDA
|
| 392 |
+
*
|
| 393 |
+
* \deprecated This function is deprecated as of CUDA 3.0.
|
| 394 |
+
*
|
| 395 |
+
* Unregisters the buffer object of ID \p bufObj for access by CUDA
|
| 396 |
+
* and releases any CUDA resources associated with the buffer. Once a
|
| 397 |
+
* buffer is unregistered, it may no longer be mapped by CUDA. The GL
|
| 398 |
+
* context used to create the buffer, or another context from the
|
| 399 |
+
* same share group, must be bound to the current thread when this is
|
| 400 |
+
* called.
|
| 401 |
+
*
|
| 402 |
+
* \param bufObj - Buffer object to unregister
|
| 403 |
+
*
|
| 404 |
+
* \return
|
| 405 |
+
* ::cudaSuccess
|
| 406 |
+
* \notefnerr
|
| 407 |
+
*
|
| 408 |
+
* \sa ::cudaGraphicsUnregisterResource
|
| 409 |
+
*/
|
| 410 |
+
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLUnregisterBufferObject(GLuint bufObj);
|
| 411 |
+
|
| 412 |
+
/**
|
| 413 |
+
* \brief Set usage flags for mapping an OpenGL buffer
|
| 414 |
+
*
|
| 415 |
+
* \deprecated This function is deprecated as of CUDA 3.0.
|
| 416 |
+
*
|
| 417 |
+
* Set flags for mapping the OpenGL buffer \p bufObj
|
| 418 |
+
*
|
| 419 |
+
* Changes to flags will take effect the next time \p bufObj is mapped.
|
| 420 |
+
* The \p flags argument may be any of the following:
|
| 421 |
+
*
|
| 422 |
+
* - ::cudaGLMapFlagsNone: Specifies no hints about how this buffer will
|
| 423 |
+
* be used. It is therefore assumed that this buffer will be read from and
|
| 424 |
+
* written to by CUDA kernels. This is the default value.
|
| 425 |
+
* - ::cudaGLMapFlagsReadOnly: Specifies that CUDA kernels which access this
|
| 426 |
+
* buffer will not write to the buffer.
|
| 427 |
+
* - ::cudaGLMapFlagsWriteDiscard: Specifies that CUDA kernels which access
|
| 428 |
+
* this buffer will not read from the buffer and will write over the
|
| 429 |
+
* entire contents of the buffer, so none of the data previously stored in
|
| 430 |
+
* the buffer will be preserved.
|
| 431 |
+
*
|
| 432 |
+
* If \p bufObj has not been registered for use with CUDA, then
|
| 433 |
+
* ::cudaErrorInvalidResourceHandle is returned. If \p bufObj is presently
|
| 434 |
+
* mapped for access by CUDA, then ::cudaErrorUnknown is returned.
|
| 435 |
+
*
|
| 436 |
+
* \param bufObj - Registered buffer object to set flags for
|
| 437 |
+
* \param flags - Parameters for buffer mapping
|
| 438 |
+
*
|
| 439 |
+
* \return
|
| 440 |
+
* ::cudaSuccess,
|
| 441 |
+
* ::cudaErrorInvalidValue,
|
| 442 |
+
* ::cudaErrorInvalidResourceHandle,
|
| 443 |
+
* ::cudaErrorUnknown
|
| 444 |
+
* \notefnerr
|
| 445 |
+
*
|
| 446 |
+
* \sa ::cudaGraphicsResourceSetMapFlags
|
| 447 |
+
*/
|
| 448 |
+
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLSetBufferObjectMapFlags(GLuint bufObj, unsigned int flags);
|
| 449 |
+
|
| 450 |
+
/**
|
| 451 |
+
* \brief Maps a buffer object for access by CUDA
|
| 452 |
+
*
|
| 453 |
+
* \deprecated This function is deprecated as of CUDA 3.0.
|
| 454 |
+
*
|
| 455 |
+
* Maps the buffer object of ID \p bufObj into the address space of
|
| 456 |
+
* CUDA and returns in \p *devPtr the base pointer of the resulting
|
| 457 |
+
* mapping. The buffer must have previously been registered by
|
| 458 |
+
* calling ::cudaGLRegisterBufferObject(). While a buffer is mapped
|
| 459 |
+
* by CUDA, any OpenGL operation which references the buffer will
|
| 460 |
+
* result in undefined behavior. The OpenGL context used to create
|
| 461 |
+
* the buffer, or another context from the same share group, must be
|
| 462 |
+
* bound to the current thread when this is called.
|
| 463 |
+
*
|
| 464 |
+
* Stream /p stream is synchronized with the current GL context.
|
| 465 |
+
*
|
| 466 |
+
* \param devPtr - Returned device pointer to CUDA object
|
| 467 |
+
* \param bufObj - Buffer object ID to map
|
| 468 |
+
* \param stream - Stream to synchronize
|
| 469 |
+
*
|
| 470 |
+
* \return
|
| 471 |
+
* ::cudaSuccess,
|
| 472 |
+
* ::cudaErrorMapBufferObjectFailed
|
| 473 |
+
* \notefnerr
|
| 474 |
+
*
|
| 475 |
+
* \sa ::cudaGraphicsMapResources
|
| 476 |
+
*/
|
| 477 |
+
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLMapBufferObjectAsync(void **devPtr, GLuint bufObj, cudaStream_t stream);
|
| 478 |
+
|
| 479 |
+
/**
|
| 480 |
+
* \brief Unmaps a buffer object for access by CUDA
|
| 481 |
+
*
|
| 482 |
+
* \deprecated This function is deprecated as of CUDA 3.0.
|
| 483 |
+
*
|
| 484 |
+
* Unmaps the buffer object of ID \p bufObj for access by CUDA. When
|
| 485 |
+
* a buffer is unmapped, the base address returned by
|
| 486 |
+
* ::cudaGLMapBufferObject() is invalid and subsequent references to
|
| 487 |
+
* the address result in undefined behavior. The OpenGL context used
|
| 488 |
+
* to create the buffer, or another context from the same share group,
|
| 489 |
+
* must be bound to the current thread when this is called.
|
| 490 |
+
*
|
| 491 |
+
* Stream /p stream is synchronized with the current GL context.
|
| 492 |
+
*
|
| 493 |
+
* \param bufObj - Buffer object to unmap
|
| 494 |
+
* \param stream - Stream to synchronize
|
| 495 |
+
*
|
| 496 |
+
* \return
|
| 497 |
+
* ::cudaSuccess,
|
| 498 |
+
* ::cudaErrorUnmapBufferObjectFailed
|
| 499 |
+
* \notefnerr
|
| 500 |
+
*
|
| 501 |
+
* \sa ::cudaGraphicsUnmapResources
|
| 502 |
+
*/
|
| 503 |
+
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLUnmapBufferObjectAsync(GLuint bufObj, cudaStream_t stream);
|
| 504 |
+
|
| 505 |
+
/** @} */ /* END CUDART_OPENGL_DEPRECATED */
|
| 506 |
+
|
| 507 |
+
#if defined(__cplusplus)
|
| 508 |
+
}
|
| 509 |
+
#endif /* __cplusplus */
|
| 510 |
+
|
| 511 |
+
#undef __CUDA_DEPRECATED
|
| 512 |
+
|
| 513 |
+
#endif /* __CUDA_GL_INTEROP_H__ */
|
| 514 |
+
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_occupancy.h
ADDED
|
@@ -0,0 +1,2094 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2017 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* CUDA Occupancy Calculator
|
| 52 |
+
*
|
| 53 |
+
* NAME
|
| 54 |
+
*
|
| 55 |
+
* cudaOccMaxActiveBlocksPerMultiprocessor,
|
| 56 |
+
* cudaOccMaxPotentialOccupancyBlockSize,
|
| 57 |
+
* cudaOccMaxPotentialOccupancyBlockSizeVariableSMem
|
| 58 |
+
* cudaOccAvailableDynamicSMemPerBlock
|
| 59 |
+
*
|
| 60 |
+
* DESCRIPTION
|
| 61 |
+
*
|
| 62 |
+
* The CUDA occupancy calculator provides a standalone, programmatical
|
| 63 |
+
* interface to compute the occupancy of a function on a device. It can also
|
| 64 |
+
* provide occupancy-oriented launch configuration suggestions.
|
| 65 |
+
*
|
| 66 |
+
* The function and device are defined by the user through
|
| 67 |
+
* cudaOccFuncAttributes, cudaOccDeviceProp, and cudaOccDeviceState
|
| 68 |
+
* structures. All APIs require all 3 of them.
|
| 69 |
+
*
|
| 70 |
+
* See the structure definition for more details about the device / function
|
| 71 |
+
* descriptors.
|
| 72 |
+
*
|
| 73 |
+
* See each API's prototype for API usage.
|
| 74 |
+
*
|
| 75 |
+
* COMPATIBILITY
|
| 76 |
+
*
|
| 77 |
+
* The occupancy calculator will be updated on each major CUDA toolkit
|
| 78 |
+
* release. It does not provide forward compatibility, i.e. new hardwares
|
| 79 |
+
* released after this implementation's release will not be supported.
|
| 80 |
+
*
|
| 81 |
+
* NOTE
|
| 82 |
+
*
|
| 83 |
+
* If there is access to CUDA runtime, and the sole intent is to calculate
|
| 84 |
+
* occupancy related values on one of the accessible CUDA devices, using CUDA
|
| 85 |
+
* runtime's occupancy calculation APIs is recommended.
|
| 86 |
+
*
|
| 87 |
+
*/
|
| 88 |
+
|
| 89 |
+
#ifndef __cuda_occupancy_h__
|
| 90 |
+
#define __cuda_occupancy_h__
|
| 91 |
+
|
| 92 |
+
#include <stddef.h>
|
| 93 |
+
#include <limits.h>
|
| 94 |
+
#include <string.h>
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
// __OCC_INLINE will be undefined at the end of this header
|
| 98 |
+
//
|
| 99 |
+
#ifdef __CUDACC__
|
| 100 |
+
#define __OCC_INLINE inline __host__ __device__
|
| 101 |
+
#elif defined _MSC_VER
|
| 102 |
+
#define __OCC_INLINE __inline
|
| 103 |
+
#else // GNUCC assumed
|
| 104 |
+
#define __OCC_INLINE inline
|
| 105 |
+
#endif
|
| 106 |
+
|
| 107 |
+
enum cudaOccError_enum {
|
| 108 |
+
CUDA_OCC_SUCCESS = 0, // no error encountered
|
| 109 |
+
CUDA_OCC_ERROR_INVALID_INPUT = 1, // input parameter is invalid
|
| 110 |
+
CUDA_OCC_ERROR_UNKNOWN_DEVICE = 2, // requested device is not supported in
|
| 111 |
+
// current implementation or device is
|
| 112 |
+
// invalid
|
| 113 |
+
};
|
| 114 |
+
typedef enum cudaOccError_enum cudaOccError;
|
| 115 |
+
|
| 116 |
+
typedef struct cudaOccResult cudaOccResult;
|
| 117 |
+
typedef struct cudaOccDeviceProp cudaOccDeviceProp;
|
| 118 |
+
typedef struct cudaOccFuncAttributes cudaOccFuncAttributes;
|
| 119 |
+
typedef struct cudaOccDeviceState cudaOccDeviceState;
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* The CUDA occupancy calculator computes the occupancy of the function
|
| 123 |
+
* described by attributes with the given block size (blockSize), static device
|
| 124 |
+
* properties (properties), dynamic device states (states) and per-block dynamic
|
| 125 |
+
* shared memory allocation (dynamicSMemSize) in bytes, and output it through
|
| 126 |
+
* result along with other useful information. The occupancy is computed in
|
| 127 |
+
* terms of the maximum number of active blocks per multiprocessor. The user can
|
| 128 |
+
* then convert it to other metrics, such as number of active warps.
|
| 129 |
+
*
|
| 130 |
+
* RETURN VALUE
|
| 131 |
+
*
|
| 132 |
+
* The occupancy and related information is returned through result.
|
| 133 |
+
*
|
| 134 |
+
* If result->activeBlocksPerMultiprocessor is 0, then the given parameter
|
| 135 |
+
* combination cannot run on the device.
|
| 136 |
+
*
|
| 137 |
+
* ERRORS
|
| 138 |
+
*
|
| 139 |
+
* CUDA_OCC_ERROR_INVALID_INPUT input parameter is invalid.
|
| 140 |
+
* CUDA_OCC_ERROR_UNKNOWN_DEVICE requested device is not supported in
|
| 141 |
+
* current implementation or device is invalid
|
| 142 |
+
*/
|
| 143 |
+
static __OCC_INLINE
|
| 144 |
+
cudaOccError cudaOccMaxActiveBlocksPerMultiprocessor(
|
| 145 |
+
cudaOccResult *result, // out
|
| 146 |
+
const cudaOccDeviceProp *properties, // in
|
| 147 |
+
const cudaOccFuncAttributes *attributes, // in
|
| 148 |
+
const cudaOccDeviceState *state, // in
|
| 149 |
+
int blockSize, // in
|
| 150 |
+
size_t dynamicSmemSize); // in
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* The CUDA launch configurator C API suggests a grid / block size pair (in
|
| 154 |
+
* minGridSize and blockSize) that achieves the best potential occupancy
|
| 155 |
+
* (i.e. maximum number of active warps with the smallest number of blocks) for
|
| 156 |
+
* the given function described by attributes, on a device described by
|
| 157 |
+
* properties with settings in state.
|
| 158 |
+
*
|
| 159 |
+
* If per-block dynamic shared memory allocation is not needed, the user should
|
| 160 |
+
* leave both blockSizeToDynamicSMemSize and dynamicSMemSize as 0.
|
| 161 |
+
*
|
| 162 |
+
* If per-block dynamic shared memory allocation is needed, then if the dynamic
|
| 163 |
+
* shared memory size is constant regardless of block size, the size should be
|
| 164 |
+
* passed through dynamicSMemSize, and blockSizeToDynamicSMemSize should be
|
| 165 |
+
* NULL.
|
| 166 |
+
*
|
| 167 |
+
* Otherwise, if the per-block dynamic shared memory size varies with different
|
| 168 |
+
* block sizes, the user needs to provide a pointer to an unary function through
|
| 169 |
+
* blockSizeToDynamicSMemSize that computes the dynamic shared memory needed by
|
| 170 |
+
* a block of the function for any given block size. dynamicSMemSize is
|
| 171 |
+
* ignored. An example signature is:
|
| 172 |
+
*
|
| 173 |
+
* // Take block size, returns dynamic shared memory needed
|
| 174 |
+
* size_t blockToSmem(int blockSize);
|
| 175 |
+
*
|
| 176 |
+
* RETURN VALUE
|
| 177 |
+
*
|
| 178 |
+
* The suggested block size and the minimum number of blocks needed to achieve
|
| 179 |
+
* the maximum occupancy are returned through blockSize and minGridSize.
|
| 180 |
+
*
|
| 181 |
+
* If *blockSize is 0, then the given combination cannot run on the device.
|
| 182 |
+
*
|
| 183 |
+
* ERRORS
|
| 184 |
+
*
|
| 185 |
+
* CUDA_OCC_ERROR_INVALID_INPUT input parameter is invalid.
|
| 186 |
+
* CUDA_OCC_ERROR_UNKNOWN_DEVICE requested device is not supported in
|
| 187 |
+
* current implementation or device is invalid
|
| 188 |
+
*
|
| 189 |
+
*/
|
| 190 |
+
static __OCC_INLINE
|
| 191 |
+
cudaOccError cudaOccMaxPotentialOccupancyBlockSize(
|
| 192 |
+
int *minGridSize, // out
|
| 193 |
+
int *blockSize, // out
|
| 194 |
+
const cudaOccDeviceProp *properties, // in
|
| 195 |
+
const cudaOccFuncAttributes *attributes, // in
|
| 196 |
+
const cudaOccDeviceState *state, // in
|
| 197 |
+
size_t (*blockSizeToDynamicSMemSize)(int), // in
|
| 198 |
+
size_t dynamicSMemSize); // in
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* The CUDA launch configurator C++ API suggests a grid / block size pair (in
|
| 202 |
+
* minGridSize and blockSize) that achieves the best potential occupancy
|
| 203 |
+
* (i.e. the maximum number of active warps with the smallest number of blocks)
|
| 204 |
+
* for the given function described by attributes, on a device described by
|
| 205 |
+
* properties with settings in state.
|
| 206 |
+
*
|
| 207 |
+
* If per-block dynamic shared memory allocation is 0 or constant regardless of
|
| 208 |
+
* block size, the user can use cudaOccMaxPotentialOccupancyBlockSize to
|
| 209 |
+
* configure the launch. A constant dynamic shared memory allocation size in
|
| 210 |
+
* bytes can be passed through dynamicSMemSize.
|
| 211 |
+
*
|
| 212 |
+
* Otherwise, if the per-block dynamic shared memory size varies with different
|
| 213 |
+
* block sizes, the user needs to use
|
| 214 |
+
* cudaOccMaxPotentialOccupancyBlockSizeVariableSmem instead, and provide a
|
| 215 |
+
* functor / pointer to an unary function (blockSizeToDynamicSMemSize) that
|
| 216 |
+
* computes the dynamic shared memory needed by func for any given block
|
| 217 |
+
* size. An example signature is:
|
| 218 |
+
*
|
| 219 |
+
* // Take block size, returns per-block dynamic shared memory needed
|
| 220 |
+
* size_t blockToSmem(int blockSize);
|
| 221 |
+
*
|
| 222 |
+
* RETURN VALUE
|
| 223 |
+
*
|
| 224 |
+
* The suggested block size and the minimum number of blocks needed to achieve
|
| 225 |
+
* the maximum occupancy are returned through blockSize and minGridSize.
|
| 226 |
+
*
|
| 227 |
+
* If *blockSize is 0, then the given combination cannot run on the device.
|
| 228 |
+
*
|
| 229 |
+
* ERRORS
|
| 230 |
+
*
|
| 231 |
+
* CUDA_OCC_ERROR_INVALID_INPUT input parameter is invalid.
|
| 232 |
+
* CUDA_OCC_ERROR_UNKNOWN_DEVICE requested device is not supported in
|
| 233 |
+
* current implementation or device is invalid
|
| 234 |
+
*
|
| 235 |
+
*/
|
| 236 |
+
|
| 237 |
+
#if defined(__cplusplus)
|
| 238 |
+
namespace {
|
| 239 |
+
|
| 240 |
+
__OCC_INLINE
|
| 241 |
+
cudaOccError cudaOccMaxPotentialOccupancyBlockSize(
|
| 242 |
+
int *minGridSize, // out
|
| 243 |
+
int *blockSize, // out
|
| 244 |
+
const cudaOccDeviceProp *properties, // in
|
| 245 |
+
const cudaOccFuncAttributes *attributes, // in
|
| 246 |
+
const cudaOccDeviceState *state, // in
|
| 247 |
+
size_t dynamicSMemSize = 0); // in
|
| 248 |
+
|
| 249 |
+
template <typename UnaryFunction>
|
| 250 |
+
__OCC_INLINE
|
| 251 |
+
cudaOccError cudaOccMaxPotentialOccupancyBlockSizeVariableSMem(
|
| 252 |
+
int *minGridSize, // out
|
| 253 |
+
int *blockSize, // out
|
| 254 |
+
const cudaOccDeviceProp *properties, // in
|
| 255 |
+
const cudaOccFuncAttributes *attributes, // in
|
| 256 |
+
const cudaOccDeviceState *state, // in
|
| 257 |
+
UnaryFunction blockSizeToDynamicSMemSize); // in
|
| 258 |
+
|
| 259 |
+
} // namespace anonymous
|
| 260 |
+
#endif // defined(__cplusplus)
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
*
|
| 264 |
+
* The CUDA dynamic shared memory calculator computes the maximum size of
|
| 265 |
+
* per-block dynamic shared memory if we want to place numBlocks blocks
|
| 266 |
+
* on an SM.
|
| 267 |
+
*
|
| 268 |
+
* RETURN VALUE
|
| 269 |
+
*
|
| 270 |
+
* Returns in *dynamicSmemSize the maximum size of dynamic shared memory to allow
|
| 271 |
+
* numBlocks blocks per SM.
|
| 272 |
+
*
|
| 273 |
+
* ERRORS
|
| 274 |
+
*
|
| 275 |
+
* CUDA_OCC_ERROR_INVALID_INPUT input parameter is invalid.
|
| 276 |
+
* CUDA_OCC_ERROR_UNKNOWN_DEVICE requested device is not supported in
|
| 277 |
+
* current implementation or device is invalid
|
| 278 |
+
*
|
| 279 |
+
*/
|
| 280 |
+
static __OCC_INLINE
|
| 281 |
+
cudaOccError cudaOccAvailableDynamicSMemPerBlock(
|
| 282 |
+
size_t *dynamicSmemSize,
|
| 283 |
+
const cudaOccDeviceProp *properties,
|
| 284 |
+
const cudaOccFuncAttributes *attributes,
|
| 285 |
+
const cudaOccDeviceState *state,
|
| 286 |
+
int numBlocks,
|
| 287 |
+
int blockSize);
|
| 288 |
+
|
| 289 |
+
/**
|
| 290 |
+
* Data structures
|
| 291 |
+
*
|
| 292 |
+
* These structures are subject to change for future architecture and CUDA
|
| 293 |
+
* releases. C users should initialize the structure as {0}.
|
| 294 |
+
*
|
| 295 |
+
*/
|
| 296 |
+
|
| 297 |
+
/**
|
| 298 |
+
* Device descriptor
|
| 299 |
+
*
|
| 300 |
+
* This structure describes a device.
|
| 301 |
+
*/
|
| 302 |
+
struct cudaOccDeviceProp {
|
| 303 |
+
int computeMajor; // Compute capability major version
|
| 304 |
+
int computeMinor; // Compute capability minor
|
| 305 |
+
// version. None supported minor version
|
| 306 |
+
// may cause error
|
| 307 |
+
int maxThreadsPerBlock; // Maximum number of threads per block
|
| 308 |
+
int maxThreadsPerMultiprocessor; // Maximum number of threads per SM
|
| 309 |
+
// i.e. (Max. number of warps) x (warp
|
| 310 |
+
// size)
|
| 311 |
+
int regsPerBlock; // Maximum number of registers per block
|
| 312 |
+
int regsPerMultiprocessor; // Maximum number of registers per SM
|
| 313 |
+
int warpSize; // Warp size
|
| 314 |
+
size_t sharedMemPerBlock; // Maximum shared memory size per block
|
| 315 |
+
size_t sharedMemPerMultiprocessor; // Maximum shared memory size per SM
|
| 316 |
+
int numSms; // Number of SMs available
|
| 317 |
+
size_t sharedMemPerBlockOptin; // Maximum optin shared memory size per block
|
| 318 |
+
size_t reservedSharedMemPerBlock; // Shared memory per block reserved by driver
|
| 319 |
+
|
| 320 |
+
#ifdef __cplusplus
|
| 321 |
+
// This structure can be converted from a cudaDeviceProp structure for users
|
| 322 |
+
// that use this header in their CUDA applications.
|
| 323 |
+
//
|
| 324 |
+
// If the application have access to the CUDA Runtime API, the application
|
| 325 |
+
// can obtain the device properties of a CUDA device through
|
| 326 |
+
// cudaGetDeviceProperties, and initialize a cudaOccDeviceProp with the
|
| 327 |
+
// cudaDeviceProp structure.
|
| 328 |
+
//
|
| 329 |
+
// Example:
|
| 330 |
+
/*
|
| 331 |
+
{
|
| 332 |
+
cudaDeviceProp prop;
|
| 333 |
+
|
| 334 |
+
cudaGetDeviceProperties(&prop, ...);
|
| 335 |
+
|
| 336 |
+
cudaOccDeviceProp occProp = prop;
|
| 337 |
+
|
| 338 |
+
...
|
| 339 |
+
|
| 340 |
+
cudaOccMaxPotentialOccupancyBlockSize(..., &occProp, ...);
|
| 341 |
+
}
|
| 342 |
+
*/
|
| 343 |
+
//
|
| 344 |
+
template<typename DeviceProp>
|
| 345 |
+
__OCC_INLINE
|
| 346 |
+
cudaOccDeviceProp(const DeviceProp &props)
|
| 347 |
+
: computeMajor (props.major),
|
| 348 |
+
computeMinor (props.minor),
|
| 349 |
+
maxThreadsPerBlock (props.maxThreadsPerBlock),
|
| 350 |
+
maxThreadsPerMultiprocessor (props.maxThreadsPerMultiProcessor),
|
| 351 |
+
regsPerBlock (props.regsPerBlock),
|
| 352 |
+
regsPerMultiprocessor (props.regsPerMultiprocessor),
|
| 353 |
+
warpSize (props.warpSize),
|
| 354 |
+
sharedMemPerBlock (props.sharedMemPerBlock),
|
| 355 |
+
sharedMemPerMultiprocessor (props.sharedMemPerMultiprocessor),
|
| 356 |
+
numSms (props.multiProcessorCount),
|
| 357 |
+
sharedMemPerBlockOptin (props.sharedMemPerBlockOptin),
|
| 358 |
+
reservedSharedMemPerBlock (props.reservedSharedMemPerBlock)
|
| 359 |
+
{}
|
| 360 |
+
|
| 361 |
+
__OCC_INLINE
|
| 362 |
+
cudaOccDeviceProp()
|
| 363 |
+
: computeMajor (0),
|
| 364 |
+
computeMinor (0),
|
| 365 |
+
maxThreadsPerBlock (0),
|
| 366 |
+
maxThreadsPerMultiprocessor (0),
|
| 367 |
+
regsPerBlock (0),
|
| 368 |
+
regsPerMultiprocessor (0),
|
| 369 |
+
warpSize (0),
|
| 370 |
+
sharedMemPerBlock (0),
|
| 371 |
+
sharedMemPerMultiprocessor (0),
|
| 372 |
+
numSms (0),
|
| 373 |
+
sharedMemPerBlockOptin (0),
|
| 374 |
+
reservedSharedMemPerBlock (0)
|
| 375 |
+
{}
|
| 376 |
+
#endif // __cplusplus
|
| 377 |
+
};
|
| 378 |
+
|
| 379 |
+
/**
|
| 380 |
+
* Partitioned global caching option
|
| 381 |
+
*/
|
| 382 |
+
typedef enum cudaOccPartitionedGCConfig_enum {
|
| 383 |
+
PARTITIONED_GC_OFF, // Disable partitioned global caching
|
| 384 |
+
PARTITIONED_GC_ON, // Prefer partitioned global caching
|
| 385 |
+
PARTITIONED_GC_ON_STRICT // Force partitioned global caching
|
| 386 |
+
} cudaOccPartitionedGCConfig;
|
| 387 |
+
|
| 388 |
+
/**
|
| 389 |
+
* Per function opt in maximum dynamic shared memory limit
|
| 390 |
+
*/
|
| 391 |
+
typedef enum cudaOccFuncShmemConfig_enum {
|
| 392 |
+
FUNC_SHMEM_LIMIT_DEFAULT, // Default shmem limit
|
| 393 |
+
FUNC_SHMEM_LIMIT_OPTIN, // Use the optin shmem limit
|
| 394 |
+
} cudaOccFuncShmemConfig;
|
| 395 |
+
|
| 396 |
+
/**
|
| 397 |
+
* Function descriptor
|
| 398 |
+
*
|
| 399 |
+
* This structure describes a CUDA function.
|
| 400 |
+
*/
|
| 401 |
+
struct cudaOccFuncAttributes {
|
| 402 |
+
int maxThreadsPerBlock; // Maximum block size the function can work with. If
|
| 403 |
+
// unlimited, use INT_MAX or any value greater than
|
| 404 |
+
// or equal to maxThreadsPerBlock of the device
|
| 405 |
+
int numRegs; // Number of registers used. When the function is
|
| 406 |
+
// launched on device, the register count may change
|
| 407 |
+
// due to internal tools requirements.
|
| 408 |
+
size_t sharedSizeBytes; // Number of static shared memory used
|
| 409 |
+
|
| 410 |
+
cudaOccPartitionedGCConfig partitionedGCConfig;
|
| 411 |
+
// Partitioned global caching is required to enable
|
| 412 |
+
// caching on certain chips, such as sm_52
|
| 413 |
+
// devices. Partitioned global caching can be
|
| 414 |
+
// automatically disabled if the occupancy
|
| 415 |
+
// requirement of the launch cannot support caching.
|
| 416 |
+
//
|
| 417 |
+
// To override this behavior with caching on and
|
| 418 |
+
// calculate occupancy strictly according to the
|
| 419 |
+
// preference, set partitionedGCConfig to
|
| 420 |
+
// PARTITIONED_GC_ON_STRICT. This is especially
|
| 421 |
+
// useful for experimenting and finding launch
|
| 422 |
+
// configurations (MaxPotentialOccupancyBlockSize)
|
| 423 |
+
// that allow global caching to take effect.
|
| 424 |
+
//
|
| 425 |
+
// This flag only affects the occupancy calculation.
|
| 426 |
+
|
| 427 |
+
cudaOccFuncShmemConfig shmemLimitConfig;
|
| 428 |
+
// Certain chips like sm_70 allow a user to opt into
|
| 429 |
+
// a higher per block limit of dynamic shared memory
|
| 430 |
+
// This optin is performed on a per function basis
|
| 431 |
+
// using the cuFuncSetAttribute function
|
| 432 |
+
|
| 433 |
+
size_t maxDynamicSharedSizeBytes;
|
| 434 |
+
// User set limit on maximum dynamic shared memory
|
| 435 |
+
// usable by the kernel
|
| 436 |
+
// This limit is set using the cuFuncSetAttribute
|
| 437 |
+
// function.
|
| 438 |
+
|
| 439 |
+
int numBlockBarriers; // Number of block barriers used (default to 1)
|
| 440 |
+
#ifdef __cplusplus
|
| 441 |
+
// This structure can be converted from a cudaFuncAttributes structure for
|
| 442 |
+
// users that use this header in their CUDA applications.
|
| 443 |
+
//
|
| 444 |
+
// If the application have access to the CUDA Runtime API, the application
|
| 445 |
+
// can obtain the function attributes of a CUDA kernel function through
|
| 446 |
+
// cudaFuncGetAttributes, and initialize a cudaOccFuncAttributes with the
|
| 447 |
+
// cudaFuncAttributes structure.
|
| 448 |
+
//
|
| 449 |
+
// Example:
|
| 450 |
+
/*
|
| 451 |
+
__global__ void foo() {...}
|
| 452 |
+
|
| 453 |
+
...
|
| 454 |
+
|
| 455 |
+
{
|
| 456 |
+
cudaFuncAttributes attr;
|
| 457 |
+
|
| 458 |
+
cudaFuncGetAttributes(&attr, foo);
|
| 459 |
+
|
| 460 |
+
cudaOccFuncAttributes occAttr = attr;
|
| 461 |
+
|
| 462 |
+
...
|
| 463 |
+
|
| 464 |
+
cudaOccMaxPotentialOccupancyBlockSize(..., &occAttr, ...);
|
| 465 |
+
}
|
| 466 |
+
*/
|
| 467 |
+
//
|
| 468 |
+
template<typename FuncAttributes>
|
| 469 |
+
__OCC_INLINE
|
| 470 |
+
cudaOccFuncAttributes(const FuncAttributes &attr)
|
| 471 |
+
: maxThreadsPerBlock (attr.maxThreadsPerBlock),
|
| 472 |
+
numRegs (attr.numRegs),
|
| 473 |
+
sharedSizeBytes (attr.sharedSizeBytes),
|
| 474 |
+
partitionedGCConfig (PARTITIONED_GC_OFF),
|
| 475 |
+
shmemLimitConfig (FUNC_SHMEM_LIMIT_OPTIN),
|
| 476 |
+
maxDynamicSharedSizeBytes (attr.maxDynamicSharedSizeBytes),
|
| 477 |
+
numBlockBarriers (1)
|
| 478 |
+
{}
|
| 479 |
+
|
| 480 |
+
__OCC_INLINE
|
| 481 |
+
cudaOccFuncAttributes()
|
| 482 |
+
: maxThreadsPerBlock (0),
|
| 483 |
+
numRegs (0),
|
| 484 |
+
sharedSizeBytes (0),
|
| 485 |
+
partitionedGCConfig (PARTITIONED_GC_OFF),
|
| 486 |
+
shmemLimitConfig (FUNC_SHMEM_LIMIT_DEFAULT),
|
| 487 |
+
maxDynamicSharedSizeBytes (0),
|
| 488 |
+
numBlockBarriers (0)
|
| 489 |
+
{}
|
| 490 |
+
#endif
|
| 491 |
+
};
|
| 492 |
+
|
| 493 |
+
typedef enum cudaOccCacheConfig_enum {
|
| 494 |
+
CACHE_PREFER_NONE = 0x00, // no preference for shared memory or L1 (default)
|
| 495 |
+
CACHE_PREFER_SHARED = 0x01, // prefer larger shared memory and smaller L1 cache
|
| 496 |
+
CACHE_PREFER_L1 = 0x02, // prefer larger L1 cache and smaller shared memory
|
| 497 |
+
CACHE_PREFER_EQUAL = 0x03 // prefer equal sized L1 cache and shared memory
|
| 498 |
+
} cudaOccCacheConfig;
|
| 499 |
+
|
| 500 |
+
typedef enum cudaOccCarveoutConfig_enum {
|
| 501 |
+
SHAREDMEM_CARVEOUT_DEFAULT = -1, // no preference for shared memory or L1 (default)
|
| 502 |
+
SHAREDMEM_CARVEOUT_MAX_SHARED = 100, // prefer maximum available shared memory, minimum L1 cache
|
| 503 |
+
SHAREDMEM_CARVEOUT_MAX_L1 = 0, // prefer maximum available L1 cache, minimum shared memory
|
| 504 |
+
SHAREDMEM_CARVEOUT_HALF = 50 // prefer half of maximum available shared memory, with the rest as L1 cache
|
| 505 |
+
} cudaOccCarveoutConfig;
|
| 506 |
+
|
| 507 |
+
/**
|
| 508 |
+
* Device state descriptor
|
| 509 |
+
*
|
| 510 |
+
* This structure describes device settings that affect occupancy calculation.
|
| 511 |
+
*/
|
| 512 |
+
struct cudaOccDeviceState
|
| 513 |
+
{
|
| 514 |
+
// Cache / shared memory split preference. Deprecated on Volta
|
| 515 |
+
cudaOccCacheConfig cacheConfig;
|
| 516 |
+
// Shared memory / L1 split preference. Supported on only Volta
|
| 517 |
+
int carveoutConfig;
|
| 518 |
+
|
| 519 |
+
#ifdef __cplusplus
|
| 520 |
+
__OCC_INLINE
|
| 521 |
+
cudaOccDeviceState()
|
| 522 |
+
: cacheConfig (CACHE_PREFER_NONE),
|
| 523 |
+
carveoutConfig (SHAREDMEM_CARVEOUT_DEFAULT)
|
| 524 |
+
{}
|
| 525 |
+
#endif
|
| 526 |
+
};
|
| 527 |
+
|
| 528 |
+
typedef enum cudaOccLimitingFactor_enum {
|
| 529 |
+
// Occupancy limited due to:
|
| 530 |
+
OCC_LIMIT_WARPS = 0x01, // - warps available
|
| 531 |
+
OCC_LIMIT_REGISTERS = 0x02, // - registers available
|
| 532 |
+
OCC_LIMIT_SHARED_MEMORY = 0x04, // - shared memory available
|
| 533 |
+
OCC_LIMIT_BLOCKS = 0x08, // - blocks available
|
| 534 |
+
OCC_LIMIT_BARRIERS = 0x10 // - barrier available
|
| 535 |
+
} cudaOccLimitingFactor;
|
| 536 |
+
|
| 537 |
+
/**
|
| 538 |
+
* Occupancy output
|
| 539 |
+
*
|
| 540 |
+
* This structure contains occupancy calculator's output.
|
| 541 |
+
*/
|
| 542 |
+
struct cudaOccResult {
|
| 543 |
+
int activeBlocksPerMultiprocessor; // Occupancy
|
| 544 |
+
unsigned int limitingFactors; // Factors that limited occupancy. A bit
|
| 545 |
+
// field that counts the limiting
|
| 546 |
+
// factors, see cudaOccLimitingFactor
|
| 547 |
+
int blockLimitRegs; // Occupancy due to register
|
| 548 |
+
// usage, INT_MAX if the kernel does not
|
| 549 |
+
// use any register.
|
| 550 |
+
int blockLimitSharedMem; // Occupancy due to shared memory
|
| 551 |
+
// usage, INT_MAX if the kernel does not
|
| 552 |
+
// use shared memory.
|
| 553 |
+
int blockLimitWarps; // Occupancy due to block size limit
|
| 554 |
+
int blockLimitBlocks; // Occupancy due to maximum number of blocks
|
| 555 |
+
// managable per SM
|
| 556 |
+
int blockLimitBarriers; // Occupancy due to block barrier usage
|
| 557 |
+
int allocatedRegistersPerBlock; // Actual number of registers allocated per
|
| 558 |
+
// block
|
| 559 |
+
size_t allocatedSharedMemPerBlock; // Actual size of shared memory allocated
|
| 560 |
+
// per block
|
| 561 |
+
cudaOccPartitionedGCConfig partitionedGCConfig;
|
| 562 |
+
// Report if partitioned global caching
|
| 563 |
+
// is actually enabled.
|
| 564 |
+
};
|
| 565 |
+
|
| 566 |
+
/**
|
| 567 |
+
* Partitioned global caching support
|
| 568 |
+
*
|
| 569 |
+
* See cudaOccPartitionedGlobalCachingModeSupport
|
| 570 |
+
*/
|
| 571 |
+
typedef enum cudaOccPartitionedGCSupport_enum {
|
| 572 |
+
PARTITIONED_GC_NOT_SUPPORTED, // Partitioned global caching is not supported
|
| 573 |
+
PARTITIONED_GC_SUPPORTED, // Partitioned global caching is supported
|
| 574 |
+
} cudaOccPartitionedGCSupport;
|
| 575 |
+
|
| 576 |
+
/**
|
| 577 |
+
* Implementation
|
| 578 |
+
*/
|
| 579 |
+
|
| 580 |
+
/**
|
| 581 |
+
* Max compute capability supported
|
| 582 |
+
*/
|
| 583 |
+
|
| 584 |
+
#define __CUDA_OCC_MAJOR__ 12
|
| 585 |
+
#define __CUDA_OCC_MINOR__ 0
|
| 586 |
+
|
| 587 |
+
//////////////////////////////////////////
|
| 588 |
+
// Mathematical Helper Functions //
|
| 589 |
+
//////////////////////////////////////////
|
| 590 |
+
|
| 591 |
+
static __OCC_INLINE int __occMin(int lhs, int rhs)
|
| 592 |
+
{
|
| 593 |
+
return rhs < lhs ? rhs : lhs;
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
static __OCC_INLINE int __occDivideRoundUp(int x, int y)
|
| 597 |
+
{
|
| 598 |
+
return (x + (y - 1)) / y;
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
static __OCC_INLINE int __occRoundUp(int x, int y)
|
| 602 |
+
{
|
| 603 |
+
return y * __occDivideRoundUp(x, y);
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
//////////////////////////////////////////
|
| 607 |
+
// Architectural Properties //
|
| 608 |
+
//////////////////////////////////////////
|
| 609 |
+
|
| 610 |
+
/**
|
| 611 |
+
* Granularity of shared memory allocation
|
| 612 |
+
*/
|
| 613 |
+
static __OCC_INLINE cudaOccError cudaOccSMemAllocationGranularity(int *limit, const cudaOccDeviceProp *properties)
|
| 614 |
+
{
|
| 615 |
+
int value;
|
| 616 |
+
|
| 617 |
+
switch(properties->computeMajor) {
|
| 618 |
+
case 3:
|
| 619 |
+
case 5:
|
| 620 |
+
case 6:
|
| 621 |
+
case 7:
|
| 622 |
+
value = 256;
|
| 623 |
+
break;
|
| 624 |
+
case 8:
|
| 625 |
+
case 9:
|
| 626 |
+
case 10:
|
| 627 |
+
case 12:
|
| 628 |
+
value = 128;
|
| 629 |
+
break;
|
| 630 |
+
default:
|
| 631 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
*limit = value;
|
| 635 |
+
|
| 636 |
+
return CUDA_OCC_SUCCESS;
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
/**
|
| 640 |
+
* Maximum number of registers per thread
|
| 641 |
+
*/
|
| 642 |
+
static __OCC_INLINE cudaOccError cudaOccRegAllocationMaxPerThread(int *limit, const cudaOccDeviceProp *properties)
|
| 643 |
+
{
|
| 644 |
+
int value;
|
| 645 |
+
|
| 646 |
+
switch(properties->computeMajor) {
|
| 647 |
+
case 3:
|
| 648 |
+
case 5:
|
| 649 |
+
case 6:
|
| 650 |
+
value = 255;
|
| 651 |
+
break;
|
| 652 |
+
case 7:
|
| 653 |
+
case 8:
|
| 654 |
+
case 9:
|
| 655 |
+
case 10:
|
| 656 |
+
case 12:
|
| 657 |
+
value = 256;
|
| 658 |
+
break;
|
| 659 |
+
default:
|
| 660 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
*limit = value;
|
| 664 |
+
|
| 665 |
+
return CUDA_OCC_SUCCESS;
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
/**
|
| 669 |
+
* Granularity of register allocation
|
| 670 |
+
*/
|
| 671 |
+
static __OCC_INLINE cudaOccError cudaOccRegAllocationGranularity(int *limit, const cudaOccDeviceProp *properties)
|
| 672 |
+
{
|
| 673 |
+
int value;
|
| 674 |
+
|
| 675 |
+
switch(properties->computeMajor) {
|
| 676 |
+
case 3:
|
| 677 |
+
case 5:
|
| 678 |
+
case 6:
|
| 679 |
+
case 7:
|
| 680 |
+
case 8:
|
| 681 |
+
case 9:
|
| 682 |
+
case 10:
|
| 683 |
+
case 12:
|
| 684 |
+
value = 256;
|
| 685 |
+
break;
|
| 686 |
+
default:
|
| 687 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
*limit = value;
|
| 691 |
+
|
| 692 |
+
return CUDA_OCC_SUCCESS;
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
/**
|
| 696 |
+
* Number of sub-partitions
|
| 697 |
+
*/
|
| 698 |
+
static __OCC_INLINE cudaOccError cudaOccSubPartitionsPerMultiprocessor(int *limit, const cudaOccDeviceProp *properties)
|
| 699 |
+
{
|
| 700 |
+
int value;
|
| 701 |
+
|
| 702 |
+
switch(properties->computeMajor) {
|
| 703 |
+
case 3:
|
| 704 |
+
case 5:
|
| 705 |
+
case 7:
|
| 706 |
+
case 8:
|
| 707 |
+
case 9:
|
| 708 |
+
case 10:
|
| 709 |
+
case 12:
|
| 710 |
+
value = 4;
|
| 711 |
+
break;
|
| 712 |
+
case 6:
|
| 713 |
+
value = properties->computeMinor ? 4 : 2;
|
| 714 |
+
break;
|
| 715 |
+
default:
|
| 716 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
*limit = value;
|
| 720 |
+
|
| 721 |
+
return CUDA_OCC_SUCCESS;
|
| 722 |
+
}
|
| 723 |
+
|
| 724 |
+
|
| 725 |
+
/**
|
| 726 |
+
* Maximum number of blocks that can run simultaneously on a multiprocessor
|
| 727 |
+
*/
|
| 728 |
+
static __OCC_INLINE cudaOccError cudaOccMaxBlocksPerMultiprocessor(int* limit, const cudaOccDeviceProp *properties)
|
| 729 |
+
{
|
| 730 |
+
int value;
|
| 731 |
+
|
| 732 |
+
switch(properties->computeMajor) {
|
| 733 |
+
case 3:
|
| 734 |
+
value = 16;
|
| 735 |
+
break;
|
| 736 |
+
case 5:
|
| 737 |
+
case 6:
|
| 738 |
+
value = 32;
|
| 739 |
+
break;
|
| 740 |
+
case 7: {
|
| 741 |
+
int isTuring = properties->computeMinor == 5;
|
| 742 |
+
value = (isTuring) ? 16 : 32;
|
| 743 |
+
break;
|
| 744 |
+
}
|
| 745 |
+
case 8:
|
| 746 |
+
if (properties->computeMinor == 0) {
|
| 747 |
+
value = 32;
|
| 748 |
+
}
|
| 749 |
+
else if (properties->computeMinor == 9) {
|
| 750 |
+
value = 24;
|
| 751 |
+
}
|
| 752 |
+
else {
|
| 753 |
+
value = 16;
|
| 754 |
+
}
|
| 755 |
+
break;
|
| 756 |
+
case 9:
|
| 757 |
+
value = 32;
|
| 758 |
+
break;
|
| 759 |
+
case 10:
|
| 760 |
+
switch(properties->computeMinor) {
|
| 761 |
+
case 1 :
|
| 762 |
+
value = 24;
|
| 763 |
+
break;
|
| 764 |
+
case 0 : /* explicitly added to avoid build failure in WDDM driver components */
|
| 765 |
+
default :
|
| 766 |
+
value = 32;
|
| 767 |
+
}
|
| 768 |
+
break;
|
| 769 |
+
case 12:
|
| 770 |
+
value = 24;
|
| 771 |
+
break;
|
| 772 |
+
default:
|
| 773 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
*limit = value;
|
| 777 |
+
|
| 778 |
+
return CUDA_OCC_SUCCESS;
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
/**
|
| 782 |
+
* Align up shared memory based on compute major configurations
|
| 783 |
+
*/
|
| 784 |
+
static __OCC_INLINE cudaOccError cudaOccAlignUpShmemSizeVoltaPlus(size_t *shMemSize, const cudaOccDeviceProp *properties)
|
| 785 |
+
{
|
| 786 |
+
// Volta and Turing have shared L1 cache / shared memory, and support cache
|
| 787 |
+
// configuration to trade one for the other. These values are needed to
|
| 788 |
+
// map carveout config ratio to the next available architecture size
|
| 789 |
+
size_t size = *shMemSize;
|
| 790 |
+
|
| 791 |
+
switch (properties->computeMajor) {
|
| 792 |
+
case 7: {
|
| 793 |
+
// Turing supports 32KB and 64KB shared mem.
|
| 794 |
+
int isTuring = properties->computeMinor == 5;
|
| 795 |
+
if (isTuring) {
|
| 796 |
+
if (size <= 32 * 1024) {
|
| 797 |
+
*shMemSize = 32 * 1024;
|
| 798 |
+
}
|
| 799 |
+
else if (size <= 64 * 1024) {
|
| 800 |
+
*shMemSize = 64 * 1024;
|
| 801 |
+
}
|
| 802 |
+
else {
|
| 803 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 804 |
+
}
|
| 805 |
+
}
|
| 806 |
+
// Volta supports 0KB, 8KB, 16KB, 32KB, 64KB, and 96KB shared mem.
|
| 807 |
+
else {
|
| 808 |
+
if (size == 0) {
|
| 809 |
+
*shMemSize = 0;
|
| 810 |
+
}
|
| 811 |
+
else if (size <= 8 * 1024) {
|
| 812 |
+
*shMemSize = 8 * 1024;
|
| 813 |
+
}
|
| 814 |
+
else if (size <= 16 * 1024) {
|
| 815 |
+
*shMemSize = 16 * 1024;
|
| 816 |
+
}
|
| 817 |
+
else if (size <= 32 * 1024) {
|
| 818 |
+
*shMemSize = 32 * 1024;
|
| 819 |
+
}
|
| 820 |
+
else if (size <= 64 * 1024) {
|
| 821 |
+
*shMemSize = 64 * 1024;
|
| 822 |
+
}
|
| 823 |
+
else if (size <= 96 * 1024) {
|
| 824 |
+
*shMemSize = 96 * 1024;
|
| 825 |
+
}
|
| 826 |
+
else {
|
| 827 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 828 |
+
}
|
| 829 |
+
}
|
| 830 |
+
break;
|
| 831 |
+
}
|
| 832 |
+
case 8:
|
| 833 |
+
if (properties->computeMinor == 0 || properties->computeMinor == 7) {
|
| 834 |
+
if (size == 0) {
|
| 835 |
+
*shMemSize = 0;
|
| 836 |
+
}
|
| 837 |
+
else if (size <= 8 * 1024) {
|
| 838 |
+
*shMemSize = 8 * 1024;
|
| 839 |
+
}
|
| 840 |
+
else if (size <= 16 * 1024) {
|
| 841 |
+
*shMemSize = 16 * 1024;
|
| 842 |
+
}
|
| 843 |
+
else if (size <= 32 * 1024) {
|
| 844 |
+
*shMemSize = 32 * 1024;
|
| 845 |
+
}
|
| 846 |
+
else if (size <= 64 * 1024) {
|
| 847 |
+
*shMemSize = 64 * 1024;
|
| 848 |
+
}
|
| 849 |
+
else if (size <= 100 * 1024) {
|
| 850 |
+
*shMemSize = 100 * 1024;
|
| 851 |
+
}
|
| 852 |
+
else if (size <= 132 * 1024) {
|
| 853 |
+
*shMemSize = 132 * 1024;
|
| 854 |
+
}
|
| 855 |
+
else if (size <= 164 * 1024) {
|
| 856 |
+
*shMemSize = 164 * 1024;
|
| 857 |
+
}
|
| 858 |
+
else {
|
| 859 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 860 |
+
}
|
| 861 |
+
}
|
| 862 |
+
else {
|
| 863 |
+
if (size == 0) {
|
| 864 |
+
*shMemSize = 0;
|
| 865 |
+
}
|
| 866 |
+
else if (size <= 8 * 1024) {
|
| 867 |
+
*shMemSize = 8 * 1024;
|
| 868 |
+
}
|
| 869 |
+
else if (size <= 16 * 1024) {
|
| 870 |
+
*shMemSize = 16 * 1024;
|
| 871 |
+
}
|
| 872 |
+
else if (size <= 32 * 1024) {
|
| 873 |
+
*shMemSize = 32 * 1024;
|
| 874 |
+
}
|
| 875 |
+
else if (size <= 64 * 1024) {
|
| 876 |
+
*shMemSize = 64 * 1024;
|
| 877 |
+
}
|
| 878 |
+
else if (size <= 100 * 1024) {
|
| 879 |
+
*shMemSize = 100 * 1024;
|
| 880 |
+
}
|
| 881 |
+
else {
|
| 882 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 883 |
+
}
|
| 884 |
+
}
|
| 885 |
+
break;
|
| 886 |
+
case 9: {
|
| 887 |
+
if (size == 0) {
|
| 888 |
+
*shMemSize = 0;
|
| 889 |
+
}
|
| 890 |
+
else if (size <= 8 * 1024) {
|
| 891 |
+
*shMemSize = 8 * 1024;
|
| 892 |
+
}
|
| 893 |
+
else if (size <= 16 * 1024) {
|
| 894 |
+
*shMemSize = 16 * 1024;
|
| 895 |
+
}
|
| 896 |
+
else if (size <= 32 * 1024) {
|
| 897 |
+
*shMemSize = 32 * 1024;
|
| 898 |
+
}
|
| 899 |
+
else if (size <= 64 * 1024) {
|
| 900 |
+
*shMemSize = 64 * 1024;
|
| 901 |
+
}
|
| 902 |
+
else if (size <= 100 * 1024) {
|
| 903 |
+
*shMemSize = 100 * 1024;
|
| 904 |
+
}
|
| 905 |
+
else if (size <= 132 * 1024) {
|
| 906 |
+
*shMemSize = 132 * 1024;
|
| 907 |
+
}
|
| 908 |
+
else if (size <= 164 * 1024) {
|
| 909 |
+
*shMemSize = 164 * 1024;
|
| 910 |
+
}
|
| 911 |
+
else if (size <= 196 * 1024) {
|
| 912 |
+
*shMemSize = 196 * 1024;
|
| 913 |
+
}
|
| 914 |
+
else if (size <= 228 * 1024) {
|
| 915 |
+
*shMemSize = 228 * 1024;
|
| 916 |
+
}
|
| 917 |
+
else {
|
| 918 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 919 |
+
}
|
| 920 |
+
break;
|
| 921 |
+
}
|
| 922 |
+
case 10: {
|
| 923 |
+
switch (properties->computeMinor) {
|
| 924 |
+
// GB10x GPUs in Blackwell family have the below compute minors and corresponding
|
| 925 |
+
// shared memory configs
|
| 926 |
+
case 0:
|
| 927 |
+
case 1:
|
| 928 |
+
if (size == 0) {
|
| 929 |
+
*shMemSize = 0;
|
| 930 |
+
}
|
| 931 |
+
else if (size <= 8 * 1024) {
|
| 932 |
+
*shMemSize = 8 * 1024;
|
| 933 |
+
}
|
| 934 |
+
else if (size <= 16 * 1024) {
|
| 935 |
+
*shMemSize = 16 * 1024;
|
| 936 |
+
}
|
| 937 |
+
else if (size <= 32 * 1024) {
|
| 938 |
+
*shMemSize = 32 * 1024;
|
| 939 |
+
}
|
| 940 |
+
else if (size <= 64 * 1024) {
|
| 941 |
+
*shMemSize = 64 * 1024;
|
| 942 |
+
}
|
| 943 |
+
else if (size <= 100 * 1024) {
|
| 944 |
+
*shMemSize = 100 * 1024;
|
| 945 |
+
}
|
| 946 |
+
else if (size <= 132 * 1024) {
|
| 947 |
+
*shMemSize = 132 * 1024;
|
| 948 |
+
}
|
| 949 |
+
else if (size <= 164 * 1024) {
|
| 950 |
+
*shMemSize = 164 * 1024;
|
| 951 |
+
}
|
| 952 |
+
else if (size <= 196 * 1024) {
|
| 953 |
+
*shMemSize = 196 * 1024;
|
| 954 |
+
}
|
| 955 |
+
else if (size <= 228 * 1024) {
|
| 956 |
+
*shMemSize = 228 * 1024;
|
| 957 |
+
}
|
| 958 |
+
else {
|
| 959 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 960 |
+
}
|
| 961 |
+
break;
|
| 962 |
+
default:
|
| 963 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 964 |
+
}
|
| 965 |
+
break;
|
| 966 |
+
}
|
| 967 |
+
case 12: {
|
| 968 |
+
switch (properties->computeMinor) {
|
| 969 |
+
case 0:
|
| 970 |
+
if (size == 0) {
|
| 971 |
+
*shMemSize = 0;
|
| 972 |
+
}
|
| 973 |
+
else if (size <= 8 * 1024) {
|
| 974 |
+
*shMemSize = 8 * 1024;
|
| 975 |
+
}
|
| 976 |
+
else if (size <= 16 * 1024) {
|
| 977 |
+
*shMemSize = 16 * 1024;
|
| 978 |
+
}
|
| 979 |
+
else if (size <= 32 * 1024) {
|
| 980 |
+
*shMemSize = 32 * 1024;
|
| 981 |
+
}
|
| 982 |
+
else if (size <= 64 * 1024) {
|
| 983 |
+
*shMemSize = 64 * 1024;
|
| 984 |
+
}
|
| 985 |
+
else if (size <= 100 * 1024) {
|
| 986 |
+
*shMemSize = 100 * 1024;
|
| 987 |
+
}
|
| 988 |
+
else {
|
| 989 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 990 |
+
}
|
| 991 |
+
break;
|
| 992 |
+
default:
|
| 993 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 994 |
+
}
|
| 995 |
+
break;
|
| 996 |
+
}
|
| 997 |
+
break;
|
| 998 |
+
default:
|
| 999 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 1000 |
+
}
|
| 1001 |
+
|
| 1002 |
+
return CUDA_OCC_SUCCESS;
|
| 1003 |
+
}
|
| 1004 |
+
|
| 1005 |
+
/**
|
| 1006 |
+
* Shared memory based on the new carveoutConfig API introduced with Volta
|
| 1007 |
+
*/
|
| 1008 |
+
static __OCC_INLINE cudaOccError cudaOccSMemPreferenceVoltaPlus(size_t *limit, const cudaOccDeviceProp *properties, const cudaOccDeviceState *state)
|
| 1009 |
+
{
|
| 1010 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1011 |
+
size_t preferenceShmemSize;
|
| 1012 |
+
|
| 1013 |
+
// CUDA 9.0 introduces a new API to set shared memory - L1 configuration on supported
|
| 1014 |
+
// devices. This preference will take precedence over the older cacheConfig setting.
|
| 1015 |
+
// Map cacheConfig to its effective preference value.
|
| 1016 |
+
int effectivePreference = state->carveoutConfig;
|
| 1017 |
+
if ((effectivePreference < SHAREDMEM_CARVEOUT_DEFAULT) || (effectivePreference > SHAREDMEM_CARVEOUT_MAX_SHARED)) {
|
| 1018 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 1019 |
+
}
|
| 1020 |
+
|
| 1021 |
+
if (effectivePreference == SHAREDMEM_CARVEOUT_DEFAULT) {
|
| 1022 |
+
switch (state->cacheConfig)
|
| 1023 |
+
{
|
| 1024 |
+
case CACHE_PREFER_L1:
|
| 1025 |
+
effectivePreference = SHAREDMEM_CARVEOUT_MAX_L1;
|
| 1026 |
+
break;
|
| 1027 |
+
case CACHE_PREFER_SHARED:
|
| 1028 |
+
effectivePreference = SHAREDMEM_CARVEOUT_MAX_SHARED;
|
| 1029 |
+
break;
|
| 1030 |
+
case CACHE_PREFER_EQUAL:
|
| 1031 |
+
effectivePreference = SHAREDMEM_CARVEOUT_HALF;
|
| 1032 |
+
break;
|
| 1033 |
+
default:
|
| 1034 |
+
effectivePreference = SHAREDMEM_CARVEOUT_DEFAULT;
|
| 1035 |
+
break;
|
| 1036 |
+
}
|
| 1037 |
+
}
|
| 1038 |
+
|
| 1039 |
+
if (effectivePreference == SHAREDMEM_CARVEOUT_DEFAULT) {
|
| 1040 |
+
preferenceShmemSize = properties->sharedMemPerMultiprocessor;
|
| 1041 |
+
}
|
| 1042 |
+
else {
|
| 1043 |
+
preferenceShmemSize = (size_t) (effectivePreference * properties->sharedMemPerMultiprocessor) / 100;
|
| 1044 |
+
}
|
| 1045 |
+
|
| 1046 |
+
status = cudaOccAlignUpShmemSizeVoltaPlus(&preferenceShmemSize, properties);
|
| 1047 |
+
*limit = preferenceShmemSize;
|
| 1048 |
+
return status;
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
+
/**
|
| 1052 |
+
* Shared memory based on the cacheConfig
|
| 1053 |
+
*/
|
| 1054 |
+
static __OCC_INLINE cudaOccError cudaOccSMemPreference(size_t *limit, const cudaOccDeviceProp *properties, const cudaOccDeviceState *state)
|
| 1055 |
+
{
|
| 1056 |
+
size_t bytes = 0;
|
| 1057 |
+
size_t sharedMemPerMultiprocessorHigh = properties->sharedMemPerMultiprocessor;
|
| 1058 |
+
cudaOccCacheConfig cacheConfig = state->cacheConfig;
|
| 1059 |
+
|
| 1060 |
+
// Kepler has shared L1 cache / shared memory, and support cache
|
| 1061 |
+
// configuration to trade one for the other. These values are needed to
|
| 1062 |
+
// calculate the correct shared memory size for user requested cache
|
| 1063 |
+
// configuration.
|
| 1064 |
+
//
|
| 1065 |
+
size_t minCacheSize = 16384;
|
| 1066 |
+
size_t maxCacheSize = 49152;
|
| 1067 |
+
size_t cacheAndSharedTotal = sharedMemPerMultiprocessorHigh + minCacheSize;
|
| 1068 |
+
size_t sharedMemPerMultiprocessorLow = cacheAndSharedTotal - maxCacheSize;
|
| 1069 |
+
|
| 1070 |
+
switch (properties->computeMajor) {
|
| 1071 |
+
case 3:
|
| 1072 |
+
// Kepler supports 16KB, 32KB, or 48KB partitions for L1. The rest
|
| 1073 |
+
// is shared memory.
|
| 1074 |
+
//
|
| 1075 |
+
switch (cacheConfig) {
|
| 1076 |
+
default :
|
| 1077 |
+
case CACHE_PREFER_NONE:
|
| 1078 |
+
case CACHE_PREFER_SHARED:
|
| 1079 |
+
bytes = sharedMemPerMultiprocessorHigh;
|
| 1080 |
+
break;
|
| 1081 |
+
case CACHE_PREFER_L1:
|
| 1082 |
+
bytes = sharedMemPerMultiprocessorLow;
|
| 1083 |
+
break;
|
| 1084 |
+
case CACHE_PREFER_EQUAL:
|
| 1085 |
+
// Equal is the mid-point between high and low. It should be
|
| 1086 |
+
// equivalent to low + 16KB.
|
| 1087 |
+
//
|
| 1088 |
+
bytes = (sharedMemPerMultiprocessorHigh + sharedMemPerMultiprocessorLow) / 2;
|
| 1089 |
+
break;
|
| 1090 |
+
}
|
| 1091 |
+
break;
|
| 1092 |
+
case 5:
|
| 1093 |
+
case 6:
|
| 1094 |
+
// Maxwell and Pascal have dedicated shared memory.
|
| 1095 |
+
//
|
| 1096 |
+
bytes = sharedMemPerMultiprocessorHigh;
|
| 1097 |
+
break;
|
| 1098 |
+
default:
|
| 1099 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 1100 |
+
}
|
| 1101 |
+
|
| 1102 |
+
*limit = bytes;
|
| 1103 |
+
|
| 1104 |
+
return CUDA_OCC_SUCCESS;
|
| 1105 |
+
}
|
| 1106 |
+
|
| 1107 |
+
/**
|
| 1108 |
+
* Shared memory based on config requested by User
|
| 1109 |
+
*/
|
| 1110 |
+
static __OCC_INLINE cudaOccError cudaOccSMemPerMultiprocessor(size_t *limit, const cudaOccDeviceProp *properties, const cudaOccDeviceState *state)
|
| 1111 |
+
{
|
| 1112 |
+
// Volta introduces a new API that allows for shared memory carveout preference. Because it is a shared memory preference,
|
| 1113 |
+
// it is handled separately from the cache config preference.
|
| 1114 |
+
if (properties->computeMajor >= 7) {
|
| 1115 |
+
return cudaOccSMemPreferenceVoltaPlus(limit, properties, state);
|
| 1116 |
+
}
|
| 1117 |
+
return cudaOccSMemPreference(limit, properties, state);
|
| 1118 |
+
}
|
| 1119 |
+
|
| 1120 |
+
/**
|
| 1121 |
+
* Return the per block shared memory limit based on function config
|
| 1122 |
+
*/
|
| 1123 |
+
static __OCC_INLINE cudaOccError cudaOccSMemPerBlock(size_t *limit, const cudaOccDeviceProp *properties, cudaOccFuncShmemConfig shmemLimitConfig, size_t smemPerCta)
|
| 1124 |
+
{
|
| 1125 |
+
switch (properties->computeMajor) {
|
| 1126 |
+
case 2:
|
| 1127 |
+
case 3:
|
| 1128 |
+
case 4:
|
| 1129 |
+
case 5:
|
| 1130 |
+
case 6:
|
| 1131 |
+
*limit = properties->sharedMemPerBlock;
|
| 1132 |
+
break;
|
| 1133 |
+
case 7:
|
| 1134 |
+
case 8:
|
| 1135 |
+
case 9:
|
| 1136 |
+
case 10:
|
| 1137 |
+
case 12:
|
| 1138 |
+
switch (shmemLimitConfig) {
|
| 1139 |
+
default:
|
| 1140 |
+
case FUNC_SHMEM_LIMIT_DEFAULT:
|
| 1141 |
+
*limit = properties->sharedMemPerBlock;
|
| 1142 |
+
break;
|
| 1143 |
+
case FUNC_SHMEM_LIMIT_OPTIN:
|
| 1144 |
+
if (smemPerCta > properties->sharedMemPerBlock) {
|
| 1145 |
+
*limit = properties->sharedMemPerBlockOptin;
|
| 1146 |
+
}
|
| 1147 |
+
else {
|
| 1148 |
+
*limit = properties->sharedMemPerBlock;
|
| 1149 |
+
}
|
| 1150 |
+
break;
|
| 1151 |
+
}
|
| 1152 |
+
break;
|
| 1153 |
+
default:
|
| 1154 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 1155 |
+
}
|
| 1156 |
+
|
| 1157 |
+
// Starting Ampere, CUDA driver reserves additional shared memory per block
|
| 1158 |
+
if (properties->computeMajor >= 8) {
|
| 1159 |
+
*limit += properties->reservedSharedMemPerBlock;
|
| 1160 |
+
}
|
| 1161 |
+
|
| 1162 |
+
return CUDA_OCC_SUCCESS;
|
| 1163 |
+
}
|
| 1164 |
+
|
| 1165 |
+
/**
|
| 1166 |
+
* Partitioned global caching mode support
|
| 1167 |
+
*/
|
| 1168 |
+
static __OCC_INLINE cudaOccError cudaOccPartitionedGlobalCachingModeSupport(cudaOccPartitionedGCSupport *limit, const cudaOccDeviceProp *properties)
|
| 1169 |
+
{
|
| 1170 |
+
*limit = PARTITIONED_GC_NOT_SUPPORTED;
|
| 1171 |
+
|
| 1172 |
+
if ((properties->computeMajor == 5 && (properties->computeMinor == 2 || properties->computeMinor == 3)) ||
|
| 1173 |
+
properties->computeMajor == 6) {
|
| 1174 |
+
*limit = PARTITIONED_GC_SUPPORTED;
|
| 1175 |
+
}
|
| 1176 |
+
|
| 1177 |
+
if (properties->computeMajor == 6 && properties->computeMinor == 0) {
|
| 1178 |
+
*limit = PARTITIONED_GC_NOT_SUPPORTED;
|
| 1179 |
+
}
|
| 1180 |
+
|
| 1181 |
+
return CUDA_OCC_SUCCESS;
|
| 1182 |
+
}
|
| 1183 |
+
|
| 1184 |
+
///////////////////////////////////////////////
|
| 1185 |
+
// User Input Sanity //
|
| 1186 |
+
///////////////////////////////////////////////
|
| 1187 |
+
|
| 1188 |
+
static __OCC_INLINE cudaOccError cudaOccDevicePropCheck(const cudaOccDeviceProp *properties)
|
| 1189 |
+
{
|
| 1190 |
+
// Verify device properties
|
| 1191 |
+
//
|
| 1192 |
+
// Each of these limits must be a positive number.
|
| 1193 |
+
//
|
| 1194 |
+
// Compute capacity is checked during the occupancy calculation
|
| 1195 |
+
//
|
| 1196 |
+
if (properties->maxThreadsPerBlock <= 0 ||
|
| 1197 |
+
properties->maxThreadsPerMultiprocessor <= 0 ||
|
| 1198 |
+
properties->regsPerBlock <= 0 ||
|
| 1199 |
+
properties->regsPerMultiprocessor <= 0 ||
|
| 1200 |
+
properties->warpSize <= 0 ||
|
| 1201 |
+
properties->sharedMemPerBlock <= 0 ||
|
| 1202 |
+
properties->sharedMemPerMultiprocessor <= 0 ||
|
| 1203 |
+
properties->numSms <= 0) {
|
| 1204 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 1205 |
+
}
|
| 1206 |
+
|
| 1207 |
+
return CUDA_OCC_SUCCESS;
|
| 1208 |
+
}
|
| 1209 |
+
|
| 1210 |
+
static __OCC_INLINE cudaOccError cudaOccFuncAttributesCheck(const cudaOccFuncAttributes *attributes)
|
| 1211 |
+
{
|
| 1212 |
+
// Verify function attributes
|
| 1213 |
+
//
|
| 1214 |
+
if (attributes->maxThreadsPerBlock <= 0 ||
|
| 1215 |
+
attributes->numRegs < 0) { // Compiler may choose not to use
|
| 1216 |
+
// any register (empty kernels,
|
| 1217 |
+
// etc.)
|
| 1218 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 1219 |
+
}
|
| 1220 |
+
|
| 1221 |
+
return CUDA_OCC_SUCCESS;
|
| 1222 |
+
}
|
| 1223 |
+
|
| 1224 |
+
static __OCC_INLINE cudaOccError cudaOccDeviceStateCheck(const cudaOccDeviceState *state)
|
| 1225 |
+
{
|
| 1226 |
+
(void)state; // silence unused-variable warning
|
| 1227 |
+
// Placeholder
|
| 1228 |
+
//
|
| 1229 |
+
|
| 1230 |
+
return CUDA_OCC_SUCCESS;
|
| 1231 |
+
}
|
| 1232 |
+
|
| 1233 |
+
static __OCC_INLINE cudaOccError cudaOccInputCheck(
|
| 1234 |
+
const cudaOccDeviceProp *properties,
|
| 1235 |
+
const cudaOccFuncAttributes *attributes,
|
| 1236 |
+
const cudaOccDeviceState *state)
|
| 1237 |
+
{
|
| 1238 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1239 |
+
|
| 1240 |
+
status = cudaOccDevicePropCheck(properties);
|
| 1241 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1242 |
+
return status;
|
| 1243 |
+
}
|
| 1244 |
+
|
| 1245 |
+
status = cudaOccFuncAttributesCheck(attributes);
|
| 1246 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1247 |
+
return status;
|
| 1248 |
+
}
|
| 1249 |
+
|
| 1250 |
+
status = cudaOccDeviceStateCheck(state);
|
| 1251 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1252 |
+
return status;
|
| 1253 |
+
}
|
| 1254 |
+
|
| 1255 |
+
return status;
|
| 1256 |
+
}
|
| 1257 |
+
|
| 1258 |
+
///////////////////////////////////////////////
|
| 1259 |
+
// Occupancy calculation Functions //
|
| 1260 |
+
///////////////////////////////////////////////
|
| 1261 |
+
|
| 1262 |
+
static __OCC_INLINE cudaOccPartitionedGCConfig cudaOccPartitionedGCExpected(
|
| 1263 |
+
const cudaOccDeviceProp *properties,
|
| 1264 |
+
const cudaOccFuncAttributes *attributes)
|
| 1265 |
+
{
|
| 1266 |
+
cudaOccPartitionedGCSupport gcSupport;
|
| 1267 |
+
cudaOccPartitionedGCConfig gcConfig;
|
| 1268 |
+
|
| 1269 |
+
cudaOccPartitionedGlobalCachingModeSupport(&gcSupport, properties);
|
| 1270 |
+
|
| 1271 |
+
gcConfig = attributes->partitionedGCConfig;
|
| 1272 |
+
|
| 1273 |
+
if (gcSupport == PARTITIONED_GC_NOT_SUPPORTED) {
|
| 1274 |
+
gcConfig = PARTITIONED_GC_OFF;
|
| 1275 |
+
}
|
| 1276 |
+
|
| 1277 |
+
return gcConfig;
|
| 1278 |
+
}
|
| 1279 |
+
|
| 1280 |
+
// Warp limit
|
| 1281 |
+
//
|
| 1282 |
+
static __OCC_INLINE cudaOccError cudaOccMaxBlocksPerSMWarpsLimit(
|
| 1283 |
+
int *limit,
|
| 1284 |
+
cudaOccPartitionedGCConfig gcConfig,
|
| 1285 |
+
const cudaOccDeviceProp *properties,
|
| 1286 |
+
const cudaOccFuncAttributes *attributes,
|
| 1287 |
+
int blockSize)
|
| 1288 |
+
{
|
| 1289 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1290 |
+
int maxWarpsPerSm;
|
| 1291 |
+
int warpsAllocatedPerCTA;
|
| 1292 |
+
int maxBlocks;
|
| 1293 |
+
(void)attributes; // silence unused-variable warning
|
| 1294 |
+
|
| 1295 |
+
if (blockSize > properties->maxThreadsPerBlock) {
|
| 1296 |
+
maxBlocks = 0;
|
| 1297 |
+
}
|
| 1298 |
+
else {
|
| 1299 |
+
maxWarpsPerSm = properties->maxThreadsPerMultiprocessor / properties->warpSize;
|
| 1300 |
+
warpsAllocatedPerCTA = __occDivideRoundUp(blockSize, properties->warpSize);
|
| 1301 |
+
maxBlocks = 0;
|
| 1302 |
+
|
| 1303 |
+
if (gcConfig != PARTITIONED_GC_OFF) {
|
| 1304 |
+
int maxBlocksPerSmPartition;
|
| 1305 |
+
int maxWarpsPerSmPartition;
|
| 1306 |
+
|
| 1307 |
+
// If partitioned global caching is on, then a CTA can only use a SM
|
| 1308 |
+
// partition (a half SM), and thus a half of the warp slots
|
| 1309 |
+
// available per SM
|
| 1310 |
+
//
|
| 1311 |
+
maxWarpsPerSmPartition = maxWarpsPerSm / 2;
|
| 1312 |
+
maxBlocksPerSmPartition = maxWarpsPerSmPartition / warpsAllocatedPerCTA;
|
| 1313 |
+
maxBlocks = maxBlocksPerSmPartition * 2;
|
| 1314 |
+
}
|
| 1315 |
+
// On hardware that supports partitioned global caching, each half SM is
|
| 1316 |
+
// guaranteed to support at least 32 warps (maximum number of warps of a
|
| 1317 |
+
// CTA), so caching will not cause 0 occupancy due to insufficient warp
|
| 1318 |
+
// allocation slots.
|
| 1319 |
+
//
|
| 1320 |
+
else {
|
| 1321 |
+
maxBlocks = maxWarpsPerSm / warpsAllocatedPerCTA;
|
| 1322 |
+
}
|
| 1323 |
+
}
|
| 1324 |
+
|
| 1325 |
+
*limit = maxBlocks;
|
| 1326 |
+
|
| 1327 |
+
return status;
|
| 1328 |
+
}
|
| 1329 |
+
|
| 1330 |
+
// Shared memory limit
|
| 1331 |
+
//
|
| 1332 |
+
static __OCC_INLINE cudaOccError cudaOccMaxBlocksPerSMSmemLimit(
|
| 1333 |
+
int *limit,
|
| 1334 |
+
cudaOccResult *result,
|
| 1335 |
+
const cudaOccDeviceProp *properties,
|
| 1336 |
+
const cudaOccFuncAttributes *attributes,
|
| 1337 |
+
const cudaOccDeviceState *state,
|
| 1338 |
+
int blockSize,
|
| 1339 |
+
size_t dynamicSmemSize)
|
| 1340 |
+
{
|
| 1341 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1342 |
+
int allocationGranularity;
|
| 1343 |
+
size_t userSmemPreference = 0;
|
| 1344 |
+
size_t totalSmemUsagePerCTA;
|
| 1345 |
+
size_t maxSmemUsagePerCTA;
|
| 1346 |
+
size_t smemAllocatedPerCTA;
|
| 1347 |
+
size_t staticSmemSize;
|
| 1348 |
+
size_t sharedMemPerMultiprocessor;
|
| 1349 |
+
size_t smemLimitPerCTA;
|
| 1350 |
+
int maxBlocks;
|
| 1351 |
+
int dynamicSmemSizeExceeded = 0;
|
| 1352 |
+
int totalSmemSizeExceeded = 0;
|
| 1353 |
+
(void)blockSize; // silence unused-variable warning
|
| 1354 |
+
|
| 1355 |
+
status = cudaOccSMemAllocationGranularity(&allocationGranularity, properties);
|
| 1356 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1357 |
+
return status;
|
| 1358 |
+
}
|
| 1359 |
+
|
| 1360 |
+
// Obtain the user preferred shared memory size. This setting is ignored if
|
| 1361 |
+
// user requests more shared memory than preferred.
|
| 1362 |
+
//
|
| 1363 |
+
status = cudaOccSMemPerMultiprocessor(&userSmemPreference, properties, state);
|
| 1364 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1365 |
+
return status;
|
| 1366 |
+
}
|
| 1367 |
+
|
| 1368 |
+
staticSmemSize = attributes->sharedSizeBytes + properties->reservedSharedMemPerBlock;
|
| 1369 |
+
totalSmemUsagePerCTA = staticSmemSize + dynamicSmemSize;
|
| 1370 |
+
smemAllocatedPerCTA = __occRoundUp((int)totalSmemUsagePerCTA, (int)allocationGranularity);
|
| 1371 |
+
|
| 1372 |
+
maxSmemUsagePerCTA = staticSmemSize + attributes->maxDynamicSharedSizeBytes;
|
| 1373 |
+
|
| 1374 |
+
dynamicSmemSizeExceeded = 0;
|
| 1375 |
+
totalSmemSizeExceeded = 0;
|
| 1376 |
+
|
| 1377 |
+
// Obtain the user set maximum dynamic size if it exists
|
| 1378 |
+
// If so, the current launch dynamic shared memory must not
|
| 1379 |
+
// exceed the set limit
|
| 1380 |
+
if (attributes->shmemLimitConfig != FUNC_SHMEM_LIMIT_DEFAULT &&
|
| 1381 |
+
dynamicSmemSize > attributes->maxDynamicSharedSizeBytes) {
|
| 1382 |
+
dynamicSmemSizeExceeded = 1;
|
| 1383 |
+
}
|
| 1384 |
+
|
| 1385 |
+
status = cudaOccSMemPerBlock(&smemLimitPerCTA, properties, attributes->shmemLimitConfig, maxSmemUsagePerCTA);
|
| 1386 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1387 |
+
return status;
|
| 1388 |
+
}
|
| 1389 |
+
|
| 1390 |
+
if (smemAllocatedPerCTA > smemLimitPerCTA) {
|
| 1391 |
+
totalSmemSizeExceeded = 1;
|
| 1392 |
+
}
|
| 1393 |
+
|
| 1394 |
+
if (dynamicSmemSizeExceeded || totalSmemSizeExceeded) {
|
| 1395 |
+
maxBlocks = 0;
|
| 1396 |
+
}
|
| 1397 |
+
else {
|
| 1398 |
+
// User requested shared memory limit is used as long as it is greater
|
| 1399 |
+
// than the total shared memory used per CTA, i.e. as long as at least
|
| 1400 |
+
// one CTA can be launched.
|
| 1401 |
+
if (userSmemPreference >= smemAllocatedPerCTA) {
|
| 1402 |
+
sharedMemPerMultiprocessor = userSmemPreference;
|
| 1403 |
+
}
|
| 1404 |
+
else {
|
| 1405 |
+
// On Volta+, user requested shared memory will limit occupancy
|
| 1406 |
+
// if it's less than shared memory per CTA. Otherwise, the
|
| 1407 |
+
// maximum shared memory limit is used.
|
| 1408 |
+
if (properties->computeMajor >= 7) {
|
| 1409 |
+
sharedMemPerMultiprocessor = smemAllocatedPerCTA;
|
| 1410 |
+
status = cudaOccAlignUpShmemSizeVoltaPlus(&sharedMemPerMultiprocessor, properties);
|
| 1411 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1412 |
+
return status;
|
| 1413 |
+
}
|
| 1414 |
+
}
|
| 1415 |
+
else {
|
| 1416 |
+
sharedMemPerMultiprocessor = properties->sharedMemPerMultiprocessor;
|
| 1417 |
+
}
|
| 1418 |
+
}
|
| 1419 |
+
|
| 1420 |
+
if (smemAllocatedPerCTA > 0) {
|
| 1421 |
+
maxBlocks = (int)(sharedMemPerMultiprocessor / smemAllocatedPerCTA);
|
| 1422 |
+
}
|
| 1423 |
+
else {
|
| 1424 |
+
maxBlocks = INT_MAX;
|
| 1425 |
+
}
|
| 1426 |
+
}
|
| 1427 |
+
|
| 1428 |
+
result->allocatedSharedMemPerBlock = smemAllocatedPerCTA;
|
| 1429 |
+
|
| 1430 |
+
*limit = maxBlocks;
|
| 1431 |
+
|
| 1432 |
+
return status;
|
| 1433 |
+
}
|
| 1434 |
+
|
| 1435 |
+
static __OCC_INLINE
|
| 1436 |
+
cudaOccError cudaOccMaxBlocksPerSMRegsLimit(
|
| 1437 |
+
int *limit,
|
| 1438 |
+
cudaOccPartitionedGCConfig *gcConfig,
|
| 1439 |
+
cudaOccResult *result,
|
| 1440 |
+
const cudaOccDeviceProp *properties,
|
| 1441 |
+
const cudaOccFuncAttributes *attributes,
|
| 1442 |
+
int blockSize)
|
| 1443 |
+
{
|
| 1444 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1445 |
+
int allocationGranularity;
|
| 1446 |
+
int warpsAllocatedPerCTA;
|
| 1447 |
+
int regsAllocatedPerCTA;
|
| 1448 |
+
int regsAssumedPerCTA;
|
| 1449 |
+
int regsPerWarp;
|
| 1450 |
+
int regsAllocatedPerWarp;
|
| 1451 |
+
int numSubPartitions;
|
| 1452 |
+
int numRegsPerSubPartition;
|
| 1453 |
+
int numWarpsPerSubPartition;
|
| 1454 |
+
int numWarpsPerSM;
|
| 1455 |
+
int maxBlocks;
|
| 1456 |
+
int maxRegsPerThread;
|
| 1457 |
+
|
| 1458 |
+
status = cudaOccRegAllocationGranularity(
|
| 1459 |
+
&allocationGranularity,
|
| 1460 |
+
properties);
|
| 1461 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1462 |
+
return status;
|
| 1463 |
+
}
|
| 1464 |
+
|
| 1465 |
+
status = cudaOccRegAllocationMaxPerThread(
|
| 1466 |
+
&maxRegsPerThread,
|
| 1467 |
+
properties);
|
| 1468 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1469 |
+
return status;
|
| 1470 |
+
}
|
| 1471 |
+
|
| 1472 |
+
status = cudaOccSubPartitionsPerMultiprocessor(&numSubPartitions, properties);
|
| 1473 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1474 |
+
return status;
|
| 1475 |
+
}
|
| 1476 |
+
|
| 1477 |
+
warpsAllocatedPerCTA = __occDivideRoundUp(blockSize, properties->warpSize);
|
| 1478 |
+
|
| 1479 |
+
// GPUs of compute capability 2.x and higher allocate registers to warps
|
| 1480 |
+
//
|
| 1481 |
+
// Number of regs per warp is regs per thread x warp size, rounded up to
|
| 1482 |
+
// register allocation granularity
|
| 1483 |
+
//
|
| 1484 |
+
regsPerWarp = attributes->numRegs * properties->warpSize;
|
| 1485 |
+
regsAllocatedPerWarp = __occRoundUp(regsPerWarp, allocationGranularity);
|
| 1486 |
+
regsAllocatedPerCTA = regsAllocatedPerWarp * warpsAllocatedPerCTA;
|
| 1487 |
+
|
| 1488 |
+
// Hardware verifies if a launch fits the per-CTA register limit. For
|
| 1489 |
+
// historical reasons, the verification logic assumes register
|
| 1490 |
+
// allocations are made to all partitions simultaneously. Therefore, to
|
| 1491 |
+
// simulate the hardware check, the warp allocation needs to be rounded
|
| 1492 |
+
// up to the number of partitions.
|
| 1493 |
+
//
|
| 1494 |
+
regsAssumedPerCTA = regsAllocatedPerWarp * __occRoundUp(warpsAllocatedPerCTA, numSubPartitions);
|
| 1495 |
+
|
| 1496 |
+
if (properties->regsPerBlock < regsAssumedPerCTA || // Hardware check
|
| 1497 |
+
properties->regsPerBlock < regsAllocatedPerCTA || // Software check
|
| 1498 |
+
attributes->numRegs > maxRegsPerThread) { // Per thread limit check
|
| 1499 |
+
maxBlocks = 0;
|
| 1500 |
+
}
|
| 1501 |
+
else {
|
| 1502 |
+
if (regsAllocatedPerWarp > 0) {
|
| 1503 |
+
// Registers are allocated in each sub-partition. The max number
|
| 1504 |
+
// of warps that can fit on an SM is equal to the max number of
|
| 1505 |
+
// warps per sub-partition x number of sub-partitions.
|
| 1506 |
+
//
|
| 1507 |
+
numRegsPerSubPartition = properties->regsPerMultiprocessor / numSubPartitions;
|
| 1508 |
+
numWarpsPerSubPartition = numRegsPerSubPartition / regsAllocatedPerWarp;
|
| 1509 |
+
|
| 1510 |
+
maxBlocks = 0;
|
| 1511 |
+
|
| 1512 |
+
if (*gcConfig != PARTITIONED_GC_OFF) {
|
| 1513 |
+
int numSubPartitionsPerSmPartition;
|
| 1514 |
+
int numWarpsPerSmPartition;
|
| 1515 |
+
int maxBlocksPerSmPartition;
|
| 1516 |
+
|
| 1517 |
+
// If partitioned global caching is on, then a CTA can only
|
| 1518 |
+
// use a half SM, and thus a half of the registers available
|
| 1519 |
+
// per SM
|
| 1520 |
+
//
|
| 1521 |
+
numSubPartitionsPerSmPartition = numSubPartitions / 2;
|
| 1522 |
+
numWarpsPerSmPartition = numWarpsPerSubPartition * numSubPartitionsPerSmPartition;
|
| 1523 |
+
maxBlocksPerSmPartition = numWarpsPerSmPartition / warpsAllocatedPerCTA;
|
| 1524 |
+
maxBlocks = maxBlocksPerSmPartition * 2;
|
| 1525 |
+
}
|
| 1526 |
+
|
| 1527 |
+
// Try again if partitioned global caching is not enabled, or if
|
| 1528 |
+
// the CTA cannot fit on the SM with caching on (maxBlocks == 0). In the latter
|
| 1529 |
+
// case, the device will automatically turn off caching, except
|
| 1530 |
+
// if the user forces enablement via PARTITIONED_GC_ON_STRICT to calculate
|
| 1531 |
+
// occupancy and launch configuration.
|
| 1532 |
+
//
|
| 1533 |
+
if (maxBlocks == 0 && *gcConfig != PARTITIONED_GC_ON_STRICT) {
|
| 1534 |
+
// In case *gcConfig was PARTITIONED_GC_ON flip it OFF since
|
| 1535 |
+
// this is what it will be if we spread CTA across partitions.
|
| 1536 |
+
//
|
| 1537 |
+
*gcConfig = PARTITIONED_GC_OFF;
|
| 1538 |
+
numWarpsPerSM = numWarpsPerSubPartition * numSubPartitions;
|
| 1539 |
+
maxBlocks = numWarpsPerSM / warpsAllocatedPerCTA;
|
| 1540 |
+
}
|
| 1541 |
+
}
|
| 1542 |
+
else {
|
| 1543 |
+
maxBlocks = INT_MAX;
|
| 1544 |
+
}
|
| 1545 |
+
}
|
| 1546 |
+
|
| 1547 |
+
|
| 1548 |
+
result->allocatedRegistersPerBlock = regsAllocatedPerCTA;
|
| 1549 |
+
|
| 1550 |
+
*limit = maxBlocks;
|
| 1551 |
+
|
| 1552 |
+
return status;
|
| 1553 |
+
}
|
| 1554 |
+
|
| 1555 |
+
// Barrier limit
|
| 1556 |
+
//
|
| 1557 |
+
static __OCC_INLINE cudaOccError cudaOccMaxBlocksPerSMBlockBarrierLimit(
|
| 1558 |
+
int *limit,
|
| 1559 |
+
int ctaLimitBlocks,
|
| 1560 |
+
const cudaOccDeviceProp *properties,
|
| 1561 |
+
const cudaOccFuncAttributes *attributes)
|
| 1562 |
+
{
|
| 1563 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1564 |
+
int numBarriersAvailable = 0;
|
| 1565 |
+
int numBarriersUsed = attributes->numBlockBarriers;
|
| 1566 |
+
int maxBlocks = INT_MAX;
|
| 1567 |
+
|
| 1568 |
+
switch(properties->computeMajor) {
|
| 1569 |
+
case 5:
|
| 1570 |
+
case 6:
|
| 1571 |
+
case 7:
|
| 1572 |
+
numBarriersAvailable = ctaLimitBlocks * 2;
|
| 1573 |
+
break;
|
| 1574 |
+
case 8:
|
| 1575 |
+
if (properties->computeMinor == 0) {
|
| 1576 |
+
numBarriersAvailable = ctaLimitBlocks * 2;
|
| 1577 |
+
}
|
| 1578 |
+
else {
|
| 1579 |
+
numBarriersAvailable = ctaLimitBlocks;
|
| 1580 |
+
}
|
| 1581 |
+
break;
|
| 1582 |
+
case 9:
|
| 1583 |
+
numBarriersAvailable = ctaLimitBlocks * 2;
|
| 1584 |
+
break;
|
| 1585 |
+
case 10:
|
| 1586 |
+
switch(properties->computeMinor) {
|
| 1587 |
+
case 1 :
|
| 1588 |
+
numBarriersAvailable = ctaLimitBlocks;
|
| 1589 |
+
break;
|
| 1590 |
+
case 0 : /* explicitly added to avoid build failure in WDDM driver components. */
|
| 1591 |
+
default :
|
| 1592 |
+
numBarriersAvailable = ctaLimitBlocks * 2;
|
| 1593 |
+
}
|
| 1594 |
+
|
| 1595 |
+
break;
|
| 1596 |
+
case 12:
|
| 1597 |
+
numBarriersAvailable = ctaLimitBlocks;
|
| 1598 |
+
break;
|
| 1599 |
+
default:
|
| 1600 |
+
return CUDA_OCC_ERROR_UNKNOWN_DEVICE;
|
| 1601 |
+
}
|
| 1602 |
+
|
| 1603 |
+
if (numBarriersUsed) {
|
| 1604 |
+
maxBlocks = numBarriersAvailable / numBarriersUsed;
|
| 1605 |
+
}
|
| 1606 |
+
|
| 1607 |
+
*limit = maxBlocks;
|
| 1608 |
+
|
| 1609 |
+
return status;
|
| 1610 |
+
}
|
| 1611 |
+
|
| 1612 |
+
///////////////////////////////////
|
| 1613 |
+
// API Implementations //
|
| 1614 |
+
///////////////////////////////////
|
| 1615 |
+
|
| 1616 |
+
static __OCC_INLINE
|
| 1617 |
+
cudaOccError cudaOccMaxActiveBlocksPerMultiprocessor(
|
| 1618 |
+
cudaOccResult *result,
|
| 1619 |
+
const cudaOccDeviceProp *properties,
|
| 1620 |
+
const cudaOccFuncAttributes *attributes,
|
| 1621 |
+
const cudaOccDeviceState *state,
|
| 1622 |
+
int blockSize,
|
| 1623 |
+
size_t dynamicSmemSize)
|
| 1624 |
+
{
|
| 1625 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1626 |
+
int ctaLimitWarps = 0;
|
| 1627 |
+
int ctaLimitBlocks = 0;
|
| 1628 |
+
int ctaLimitSMem = 0;
|
| 1629 |
+
int ctaLimitRegs = 0;
|
| 1630 |
+
int ctaLimitBars = 0;
|
| 1631 |
+
int ctaLimit = 0;
|
| 1632 |
+
unsigned int limitingFactors = 0;
|
| 1633 |
+
|
| 1634 |
+
cudaOccPartitionedGCConfig gcConfig = PARTITIONED_GC_OFF;
|
| 1635 |
+
|
| 1636 |
+
if (!result || !properties || !attributes || !state || blockSize <= 0) {
|
| 1637 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 1638 |
+
}
|
| 1639 |
+
|
| 1640 |
+
///////////////////////////
|
| 1641 |
+
// Check user input
|
| 1642 |
+
///////////////////////////
|
| 1643 |
+
|
| 1644 |
+
status = cudaOccInputCheck(properties, attributes, state);
|
| 1645 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1646 |
+
return status;
|
| 1647 |
+
}
|
| 1648 |
+
|
| 1649 |
+
///////////////////////////
|
| 1650 |
+
// Initialization
|
| 1651 |
+
///////////////////////////
|
| 1652 |
+
|
| 1653 |
+
gcConfig = cudaOccPartitionedGCExpected(properties, attributes);
|
| 1654 |
+
|
| 1655 |
+
///////////////////////////
|
| 1656 |
+
// Compute occupancy
|
| 1657 |
+
///////////////////////////
|
| 1658 |
+
|
| 1659 |
+
// Limits due to registers/SM
|
| 1660 |
+
// Also compute if partitioned global caching has to be turned off
|
| 1661 |
+
//
|
| 1662 |
+
status = cudaOccMaxBlocksPerSMRegsLimit(&ctaLimitRegs, &gcConfig, result, properties, attributes, blockSize);
|
| 1663 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1664 |
+
return status;
|
| 1665 |
+
}
|
| 1666 |
+
|
| 1667 |
+
// SMs on GP100 (6.0) have 2 subpartitions, while those on GP10x have 4.
|
| 1668 |
+
// As a result, an SM on GP100 may be able to run more CTAs than the one on GP10x.
|
| 1669 |
+
// For forward compatibility within Pascal family, if a function cannot run on GP10x (maxBlock == 0),
|
| 1670 |
+
// we do not let it run on any Pascal processor, even though it may be able to run on GP100.
|
| 1671 |
+
// Therefore, we check the occupancy on GP10x when it can run on GP100
|
| 1672 |
+
//
|
| 1673 |
+
if (properties->computeMajor == 6 && properties->computeMinor == 0 && ctaLimitRegs) {
|
| 1674 |
+
cudaOccDeviceProp propertiesGP10x;
|
| 1675 |
+
cudaOccPartitionedGCConfig gcConfigGP10x = gcConfig;
|
| 1676 |
+
int ctaLimitRegsGP10x = 0;
|
| 1677 |
+
|
| 1678 |
+
// Set up properties for GP10x
|
| 1679 |
+
memcpy(&propertiesGP10x, properties, sizeof(propertiesGP10x));
|
| 1680 |
+
propertiesGP10x.computeMinor = 1;
|
| 1681 |
+
|
| 1682 |
+
status = cudaOccMaxBlocksPerSMRegsLimit(&ctaLimitRegsGP10x, &gcConfigGP10x, result, &propertiesGP10x, attributes, blockSize);
|
| 1683 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1684 |
+
return status;
|
| 1685 |
+
}
|
| 1686 |
+
|
| 1687 |
+
if (ctaLimitRegsGP10x == 0) {
|
| 1688 |
+
ctaLimitRegs = 0;
|
| 1689 |
+
}
|
| 1690 |
+
}
|
| 1691 |
+
|
| 1692 |
+
// Limits due to warps/SM
|
| 1693 |
+
//
|
| 1694 |
+
status = cudaOccMaxBlocksPerSMWarpsLimit(&ctaLimitWarps, gcConfig, properties, attributes, blockSize);
|
| 1695 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1696 |
+
return status;
|
| 1697 |
+
}
|
| 1698 |
+
|
| 1699 |
+
// Limits due to blocks/SM
|
| 1700 |
+
//
|
| 1701 |
+
status = cudaOccMaxBlocksPerMultiprocessor(&ctaLimitBlocks, properties);
|
| 1702 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1703 |
+
return status;
|
| 1704 |
+
}
|
| 1705 |
+
|
| 1706 |
+
// Limits due to shared memory/SM
|
| 1707 |
+
//
|
| 1708 |
+
status = cudaOccMaxBlocksPerSMSmemLimit(&ctaLimitSMem, result, properties, attributes, state, blockSize, dynamicSmemSize);
|
| 1709 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1710 |
+
return status;
|
| 1711 |
+
}
|
| 1712 |
+
|
| 1713 |
+
///////////////////////////
|
| 1714 |
+
// Overall occupancy
|
| 1715 |
+
///////////////////////////
|
| 1716 |
+
|
| 1717 |
+
// Overall limit is min() of limits due to above reasons
|
| 1718 |
+
//
|
| 1719 |
+
ctaLimit = __occMin(ctaLimitRegs, __occMin(ctaLimitSMem, __occMin(ctaLimitWarps, ctaLimitBlocks)));
|
| 1720 |
+
|
| 1721 |
+
// Determine occupancy limiting factors
|
| 1722 |
+
//
|
| 1723 |
+
if (ctaLimit == ctaLimitWarps) {
|
| 1724 |
+
limitingFactors |= OCC_LIMIT_WARPS;
|
| 1725 |
+
}
|
| 1726 |
+
if (ctaLimit == ctaLimitRegs) {
|
| 1727 |
+
limitingFactors |= OCC_LIMIT_REGISTERS;
|
| 1728 |
+
}
|
| 1729 |
+
if (ctaLimit == ctaLimitSMem) {
|
| 1730 |
+
limitingFactors |= OCC_LIMIT_SHARED_MEMORY;
|
| 1731 |
+
}
|
| 1732 |
+
if (ctaLimit == ctaLimitBlocks) {
|
| 1733 |
+
limitingFactors |= OCC_LIMIT_BLOCKS;
|
| 1734 |
+
}
|
| 1735 |
+
|
| 1736 |
+
// For Hopper onwards compute the limits to occupancy based on block barrier count
|
| 1737 |
+
//
|
| 1738 |
+
if (properties->computeMajor >= 9 && attributes->numBlockBarriers > 0) {
|
| 1739 |
+
// Limits due to barrier/SM
|
| 1740 |
+
//
|
| 1741 |
+
status = cudaOccMaxBlocksPerSMBlockBarrierLimit(&ctaLimitBars, ctaLimitBlocks, properties, attributes);
|
| 1742 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1743 |
+
return status;
|
| 1744 |
+
}
|
| 1745 |
+
|
| 1746 |
+
// Recompute overall limit based on barrier/SM
|
| 1747 |
+
//
|
| 1748 |
+
ctaLimit = __occMin(ctaLimitBars, ctaLimit);
|
| 1749 |
+
|
| 1750 |
+
// Determine if this is occupancy limiting factor
|
| 1751 |
+
//
|
| 1752 |
+
if (ctaLimit == ctaLimitBars) {
|
| 1753 |
+
limitingFactors |= OCC_LIMIT_BARRIERS;
|
| 1754 |
+
}
|
| 1755 |
+
}
|
| 1756 |
+
else {
|
| 1757 |
+
ctaLimitBars = INT_MAX;
|
| 1758 |
+
}
|
| 1759 |
+
|
| 1760 |
+
// Fill in the return values
|
| 1761 |
+
//
|
| 1762 |
+
result->limitingFactors = limitingFactors;
|
| 1763 |
+
|
| 1764 |
+
result->blockLimitRegs = ctaLimitRegs;
|
| 1765 |
+
result->blockLimitSharedMem = ctaLimitSMem;
|
| 1766 |
+
result->blockLimitWarps = ctaLimitWarps;
|
| 1767 |
+
result->blockLimitBlocks = ctaLimitBlocks;
|
| 1768 |
+
result->blockLimitBarriers = ctaLimitBars;
|
| 1769 |
+
result->partitionedGCConfig = gcConfig;
|
| 1770 |
+
|
| 1771 |
+
// Final occupancy
|
| 1772 |
+
result->activeBlocksPerMultiprocessor = ctaLimit;
|
| 1773 |
+
|
| 1774 |
+
return CUDA_OCC_SUCCESS;
|
| 1775 |
+
}
|
| 1776 |
+
|
| 1777 |
+
static __OCC_INLINE
|
| 1778 |
+
cudaOccError cudaOccAvailableDynamicSMemPerBlock(
|
| 1779 |
+
size_t *bytesAvailable,
|
| 1780 |
+
const cudaOccDeviceProp *properties,
|
| 1781 |
+
const cudaOccFuncAttributes *attributes,
|
| 1782 |
+
const cudaOccDeviceState *state,
|
| 1783 |
+
int numBlocks,
|
| 1784 |
+
int blockSize)
|
| 1785 |
+
{
|
| 1786 |
+
int allocationGranularity;
|
| 1787 |
+
size_t smemLimitPerBlock;
|
| 1788 |
+
size_t smemAvailableForDynamic;
|
| 1789 |
+
size_t userSmemPreference = 0;
|
| 1790 |
+
size_t sharedMemPerMultiprocessor;
|
| 1791 |
+
cudaOccResult result;
|
| 1792 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1793 |
+
|
| 1794 |
+
if (numBlocks <= 0)
|
| 1795 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 1796 |
+
|
| 1797 |
+
// First compute occupancy of potential kernel launch.
|
| 1798 |
+
//
|
| 1799 |
+
status = cudaOccMaxActiveBlocksPerMultiprocessor(&result, properties, attributes, state, blockSize, 0);
|
| 1800 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1801 |
+
return status;
|
| 1802 |
+
}
|
| 1803 |
+
// Check if occupancy is achievable given user requested number of blocks.
|
| 1804 |
+
//
|
| 1805 |
+
if (result.activeBlocksPerMultiprocessor < numBlocks) {
|
| 1806 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 1807 |
+
}
|
| 1808 |
+
|
| 1809 |
+
status = cudaOccSMemAllocationGranularity(&allocationGranularity, properties);
|
| 1810 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1811 |
+
return status;
|
| 1812 |
+
}
|
| 1813 |
+
|
| 1814 |
+
// Return the per block shared memory limit based on function config.
|
| 1815 |
+
//
|
| 1816 |
+
status = cudaOccSMemPerBlock(&smemLimitPerBlock, properties, attributes->shmemLimitConfig, properties->sharedMemPerMultiprocessor);
|
| 1817 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1818 |
+
return status;
|
| 1819 |
+
}
|
| 1820 |
+
|
| 1821 |
+
// If there is only a single block needed per SM, then the user preference can be ignored and the fully SW
|
| 1822 |
+
// limit is allowed to be used as shared memory otherwise if more than one block is needed, then the user
|
| 1823 |
+
// preference sets the total limit of available shared memory.
|
| 1824 |
+
//
|
| 1825 |
+
cudaOccSMemPerMultiprocessor(&userSmemPreference, properties, state);
|
| 1826 |
+
if (numBlocks == 1) {
|
| 1827 |
+
sharedMemPerMultiprocessor = smemLimitPerBlock;
|
| 1828 |
+
}
|
| 1829 |
+
else {
|
| 1830 |
+
if (!userSmemPreference) {
|
| 1831 |
+
userSmemPreference = 1 ;
|
| 1832 |
+
status = cudaOccAlignUpShmemSizeVoltaPlus(&userSmemPreference, properties);
|
| 1833 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1834 |
+
return status;
|
| 1835 |
+
}
|
| 1836 |
+
}
|
| 1837 |
+
sharedMemPerMultiprocessor = userSmemPreference;
|
| 1838 |
+
}
|
| 1839 |
+
|
| 1840 |
+
// Compute total shared memory available per SM
|
| 1841 |
+
//
|
| 1842 |
+
smemAvailableForDynamic = sharedMemPerMultiprocessor / numBlocks;
|
| 1843 |
+
smemAvailableForDynamic = (smemAvailableForDynamic / allocationGranularity) * allocationGranularity;
|
| 1844 |
+
|
| 1845 |
+
// Cap shared memory
|
| 1846 |
+
//
|
| 1847 |
+
if (smemAvailableForDynamic > smemLimitPerBlock) {
|
| 1848 |
+
smemAvailableForDynamic = smemLimitPerBlock;
|
| 1849 |
+
}
|
| 1850 |
+
|
| 1851 |
+
// Now compute dynamic shared memory size
|
| 1852 |
+
smemAvailableForDynamic = smemAvailableForDynamic - attributes->sharedSizeBytes;
|
| 1853 |
+
|
| 1854 |
+
// Cap computed dynamic SM by user requested limit specified via cuFuncSetAttribute()
|
| 1855 |
+
//
|
| 1856 |
+
if (smemAvailableForDynamic > attributes->maxDynamicSharedSizeBytes)
|
| 1857 |
+
smemAvailableForDynamic = attributes->maxDynamicSharedSizeBytes;
|
| 1858 |
+
|
| 1859 |
+
*bytesAvailable = smemAvailableForDynamic;
|
| 1860 |
+
return CUDA_OCC_SUCCESS;
|
| 1861 |
+
}
|
| 1862 |
+
|
| 1863 |
+
static __OCC_INLINE
|
| 1864 |
+
cudaOccError cudaOccMaxPotentialOccupancyBlockSize(
|
| 1865 |
+
int *minGridSize,
|
| 1866 |
+
int *blockSize,
|
| 1867 |
+
const cudaOccDeviceProp *properties,
|
| 1868 |
+
const cudaOccFuncAttributes *attributes,
|
| 1869 |
+
const cudaOccDeviceState *state,
|
| 1870 |
+
size_t (*blockSizeToDynamicSMemSize)(int),
|
| 1871 |
+
size_t dynamicSMemSize)
|
| 1872 |
+
{
|
| 1873 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 1874 |
+
cudaOccResult result;
|
| 1875 |
+
|
| 1876 |
+
// Limits
|
| 1877 |
+
int occupancyLimit;
|
| 1878 |
+
int granularity;
|
| 1879 |
+
int blockSizeLimit;
|
| 1880 |
+
|
| 1881 |
+
// Recorded maximum
|
| 1882 |
+
int maxBlockSize = 0;
|
| 1883 |
+
int numBlocks = 0;
|
| 1884 |
+
int maxOccupancy = 0;
|
| 1885 |
+
|
| 1886 |
+
// Temporary
|
| 1887 |
+
int blockSizeToTryAligned;
|
| 1888 |
+
int blockSizeToTry;
|
| 1889 |
+
int blockSizeLimitAligned;
|
| 1890 |
+
int occupancyInBlocks;
|
| 1891 |
+
int occupancyInThreads;
|
| 1892 |
+
|
| 1893 |
+
///////////////////////////
|
| 1894 |
+
// Check user input
|
| 1895 |
+
///////////////////////////
|
| 1896 |
+
|
| 1897 |
+
if (!minGridSize || !blockSize || !properties || !attributes || !state) {
|
| 1898 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 1899 |
+
}
|
| 1900 |
+
|
| 1901 |
+
status = cudaOccInputCheck(properties, attributes, state);
|
| 1902 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1903 |
+
return status;
|
| 1904 |
+
}
|
| 1905 |
+
|
| 1906 |
+
/////////////////////////////////////////////////////////////////////////////////
|
| 1907 |
+
// Try each block size, and pick the block size with maximum occupancy
|
| 1908 |
+
/////////////////////////////////////////////////////////////////////////////////
|
| 1909 |
+
|
| 1910 |
+
occupancyLimit = properties->maxThreadsPerMultiprocessor;
|
| 1911 |
+
granularity = properties->warpSize;
|
| 1912 |
+
|
| 1913 |
+
blockSizeLimit = __occMin(properties->maxThreadsPerBlock, attributes->maxThreadsPerBlock);
|
| 1914 |
+
blockSizeLimitAligned = __occRoundUp(blockSizeLimit, granularity);
|
| 1915 |
+
|
| 1916 |
+
for (blockSizeToTryAligned = blockSizeLimitAligned; blockSizeToTryAligned > 0; blockSizeToTryAligned -= granularity) {
|
| 1917 |
+
blockSizeToTry = __occMin(blockSizeLimit, blockSizeToTryAligned);
|
| 1918 |
+
|
| 1919 |
+
// Ignore dynamicSMemSize if the user provides a mapping
|
| 1920 |
+
//
|
| 1921 |
+
if (blockSizeToDynamicSMemSize) {
|
| 1922 |
+
dynamicSMemSize = (*blockSizeToDynamicSMemSize)(blockSizeToTry);
|
| 1923 |
+
}
|
| 1924 |
+
|
| 1925 |
+
status = cudaOccMaxActiveBlocksPerMultiprocessor(
|
| 1926 |
+
&result,
|
| 1927 |
+
properties,
|
| 1928 |
+
attributes,
|
| 1929 |
+
state,
|
| 1930 |
+
blockSizeToTry,
|
| 1931 |
+
dynamicSMemSize);
|
| 1932 |
+
|
| 1933 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 1934 |
+
return status;
|
| 1935 |
+
}
|
| 1936 |
+
|
| 1937 |
+
occupancyInBlocks = result.activeBlocksPerMultiprocessor;
|
| 1938 |
+
occupancyInThreads = blockSizeToTry * occupancyInBlocks;
|
| 1939 |
+
|
| 1940 |
+
if (occupancyInThreads > maxOccupancy) {
|
| 1941 |
+
maxBlockSize = blockSizeToTry;
|
| 1942 |
+
numBlocks = occupancyInBlocks;
|
| 1943 |
+
maxOccupancy = occupancyInThreads;
|
| 1944 |
+
}
|
| 1945 |
+
|
| 1946 |
+
// Early out if we have reached the maximum
|
| 1947 |
+
//
|
| 1948 |
+
if (occupancyLimit == maxOccupancy) {
|
| 1949 |
+
break;
|
| 1950 |
+
}
|
| 1951 |
+
}
|
| 1952 |
+
|
| 1953 |
+
///////////////////////////
|
| 1954 |
+
// Return best available
|
| 1955 |
+
///////////////////////////
|
| 1956 |
+
|
| 1957 |
+
// Suggested min grid size to achieve a full machine launch
|
| 1958 |
+
//
|
| 1959 |
+
*minGridSize = numBlocks * properties->numSms;
|
| 1960 |
+
*blockSize = maxBlockSize;
|
| 1961 |
+
|
| 1962 |
+
return status;
|
| 1963 |
+
}
|
| 1964 |
+
|
| 1965 |
+
|
| 1966 |
+
#if defined(__cplusplus)
|
| 1967 |
+
|
| 1968 |
+
namespace {
|
| 1969 |
+
|
| 1970 |
+
__OCC_INLINE
|
| 1971 |
+
cudaOccError cudaOccMaxPotentialOccupancyBlockSize(
|
| 1972 |
+
int *minGridSize,
|
| 1973 |
+
int *blockSize,
|
| 1974 |
+
const cudaOccDeviceProp *properties,
|
| 1975 |
+
const cudaOccFuncAttributes *attributes,
|
| 1976 |
+
const cudaOccDeviceState *state,
|
| 1977 |
+
size_t dynamicSMemSize)
|
| 1978 |
+
{
|
| 1979 |
+
return cudaOccMaxPotentialOccupancyBlockSize(
|
| 1980 |
+
minGridSize,
|
| 1981 |
+
blockSize,
|
| 1982 |
+
properties,
|
| 1983 |
+
attributes,
|
| 1984 |
+
state,
|
| 1985 |
+
NULL,
|
| 1986 |
+
dynamicSMemSize);
|
| 1987 |
+
}
|
| 1988 |
+
|
| 1989 |
+
template <typename UnaryFunction>
|
| 1990 |
+
__OCC_INLINE
|
| 1991 |
+
cudaOccError cudaOccMaxPotentialOccupancyBlockSizeVariableSMem(
|
| 1992 |
+
int *minGridSize,
|
| 1993 |
+
int *blockSize,
|
| 1994 |
+
const cudaOccDeviceProp *properties,
|
| 1995 |
+
const cudaOccFuncAttributes *attributes,
|
| 1996 |
+
const cudaOccDeviceState *state,
|
| 1997 |
+
UnaryFunction blockSizeToDynamicSMemSize)
|
| 1998 |
+
{
|
| 1999 |
+
cudaOccError status = CUDA_OCC_SUCCESS;
|
| 2000 |
+
cudaOccResult result;
|
| 2001 |
+
|
| 2002 |
+
// Limits
|
| 2003 |
+
int occupancyLimit;
|
| 2004 |
+
int granularity;
|
| 2005 |
+
int blockSizeLimit;
|
| 2006 |
+
|
| 2007 |
+
// Recorded maximum
|
| 2008 |
+
int maxBlockSize = 0;
|
| 2009 |
+
int numBlocks = 0;
|
| 2010 |
+
int maxOccupancy = 0;
|
| 2011 |
+
|
| 2012 |
+
// Temporary
|
| 2013 |
+
int blockSizeToTryAligned;
|
| 2014 |
+
int blockSizeToTry;
|
| 2015 |
+
int blockSizeLimitAligned;
|
| 2016 |
+
int occupancyInBlocks;
|
| 2017 |
+
int occupancyInThreads;
|
| 2018 |
+
size_t dynamicSMemSize;
|
| 2019 |
+
|
| 2020 |
+
///////////////////////////
|
| 2021 |
+
// Check user input
|
| 2022 |
+
///////////////////////////
|
| 2023 |
+
|
| 2024 |
+
if (!minGridSize || !blockSize || !properties || !attributes || !state) {
|
| 2025 |
+
return CUDA_OCC_ERROR_INVALID_INPUT;
|
| 2026 |
+
}
|
| 2027 |
+
|
| 2028 |
+
status = cudaOccInputCheck(properties, attributes, state);
|
| 2029 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 2030 |
+
return status;
|
| 2031 |
+
}
|
| 2032 |
+
|
| 2033 |
+
/////////////////////////////////////////////////////////////////////////////////
|
| 2034 |
+
// Try each block size, and pick the block size with maximum occupancy
|
| 2035 |
+
/////////////////////////////////////////////////////////////////////////////////
|
| 2036 |
+
|
| 2037 |
+
occupancyLimit = properties->maxThreadsPerMultiprocessor;
|
| 2038 |
+
granularity = properties->warpSize;
|
| 2039 |
+
blockSizeLimit = __occMin(properties->maxThreadsPerBlock, attributes->maxThreadsPerBlock);
|
| 2040 |
+
blockSizeLimitAligned = __occRoundUp(blockSizeLimit, granularity);
|
| 2041 |
+
|
| 2042 |
+
for (blockSizeToTryAligned = blockSizeLimitAligned; blockSizeToTryAligned > 0; blockSizeToTryAligned -= granularity) {
|
| 2043 |
+
blockSizeToTry = __occMin(blockSizeLimit, blockSizeToTryAligned);
|
| 2044 |
+
|
| 2045 |
+
dynamicSMemSize = blockSizeToDynamicSMemSize(blockSizeToTry);
|
| 2046 |
+
|
| 2047 |
+
status = cudaOccMaxActiveBlocksPerMultiprocessor(
|
| 2048 |
+
&result,
|
| 2049 |
+
properties,
|
| 2050 |
+
attributes,
|
| 2051 |
+
state,
|
| 2052 |
+
blockSizeToTry,
|
| 2053 |
+
dynamicSMemSize);
|
| 2054 |
+
|
| 2055 |
+
if (status != CUDA_OCC_SUCCESS) {
|
| 2056 |
+
return status;
|
| 2057 |
+
}
|
| 2058 |
+
|
| 2059 |
+
occupancyInBlocks = result.activeBlocksPerMultiprocessor;
|
| 2060 |
+
|
| 2061 |
+
occupancyInThreads = blockSizeToTry * occupancyInBlocks;
|
| 2062 |
+
|
| 2063 |
+
if (occupancyInThreads > maxOccupancy) {
|
| 2064 |
+
maxBlockSize = blockSizeToTry;
|
| 2065 |
+
numBlocks = occupancyInBlocks;
|
| 2066 |
+
maxOccupancy = occupancyInThreads;
|
| 2067 |
+
}
|
| 2068 |
+
|
| 2069 |
+
// Early out if we have reached the maximum
|
| 2070 |
+
//
|
| 2071 |
+
if (occupancyLimit == maxOccupancy) {
|
| 2072 |
+
break;
|
| 2073 |
+
}
|
| 2074 |
+
}
|
| 2075 |
+
|
| 2076 |
+
///////////////////////////
|
| 2077 |
+
// Return best available
|
| 2078 |
+
///////////////////////////
|
| 2079 |
+
|
| 2080 |
+
// Suggested min grid size to achieve a full machine launch
|
| 2081 |
+
//
|
| 2082 |
+
*minGridSize = numBlocks * properties->numSms;
|
| 2083 |
+
*blockSize = maxBlockSize;
|
| 2084 |
+
|
| 2085 |
+
return status;
|
| 2086 |
+
}
|
| 2087 |
+
|
| 2088 |
+
} // namespace anonymous
|
| 2089 |
+
|
| 2090 |
+
#endif /*__cplusplus */
|
| 2091 |
+
|
| 2092 |
+
#undef __OCC_INLINE
|
| 2093 |
+
|
| 2094 |
+
#endif /*__cuda_occupancy_h__*/
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_pipeline.h
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef _CUDA_PIPELINE_H_
|
| 51 |
+
# define _CUDA_PIPELINE_H_
|
| 52 |
+
|
| 53 |
+
# include "cuda_pipeline_primitives.h"
|
| 54 |
+
|
| 55 |
+
# if !defined(_CUDA_PIPELINE_CPLUSPLUS_11_OR_LATER)
|
| 56 |
+
# error This file requires compiler support for the ISO C++ 2011 standard. This support must be enabled with the \
|
| 57 |
+
-std=c++11 compiler option.
|
| 58 |
+
# endif
|
| 59 |
+
|
| 60 |
+
# if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
|
| 61 |
+
# include "cuda_awbarrier.h"
|
| 62 |
+
# endif
|
| 63 |
+
|
| 64 |
+
// Integration with libcu++'s cuda::barrier<cuda::thread_scope_block>.
|
| 65 |
+
|
| 66 |
+
# if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
|
| 67 |
+
# if defined(_LIBCUDACXX_CUDA_ABI_VERSION)
|
| 68 |
+
# define _LIBCUDACXX_PIPELINE_ASSUMED_ABI_VERSION _LIBCUDACXX_CUDA_ABI_VERSION
|
| 69 |
+
# else
|
| 70 |
+
# define _LIBCUDACXX_PIPELINE_ASSUMED_ABI_VERSION 4
|
| 71 |
+
# endif
|
| 72 |
+
|
| 73 |
+
# define _LIBCUDACXX_PIPELINE_CONCAT(X, Y) X ## Y
|
| 74 |
+
# define _LIBCUDACXX_PIPELINE_CONCAT2(X, Y) _LIBCUDACXX_PIPELINE_CONCAT(X, Y)
|
| 75 |
+
# define _LIBCUDACXX_PIPELINE_INLINE_NAMESPACE _LIBCUDACXX_PIPELINE_CONCAT2(__, _LIBCUDACXX_PIPELINE_ASSUMED_ABI_VERSION)
|
| 76 |
+
|
| 77 |
+
namespace cuda { inline namespace _LIBCUDACXX_PIPELINE_INLINE_NAMESPACE {
|
| 78 |
+
struct __block_scope_barrier_base;
|
| 79 |
+
}}
|
| 80 |
+
|
| 81 |
+
# endif
|
| 82 |
+
|
| 83 |
+
_CUDA_PIPELINE_BEGIN_NAMESPACE
|
| 84 |
+
|
| 85 |
+
template<size_t N, typename T>
|
| 86 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 87 |
+
auto segment(T* ptr) -> T(*)[N];
|
| 88 |
+
|
| 89 |
+
class pipeline {
|
| 90 |
+
public:
|
| 91 |
+
pipeline(const pipeline&) = delete;
|
| 92 |
+
pipeline(pipeline&&) = delete;
|
| 93 |
+
pipeline& operator=(const pipeline&) = delete;
|
| 94 |
+
pipeline& operator=(pipeline&&) = delete;
|
| 95 |
+
|
| 96 |
+
_CUDA_PIPELINE_QUALIFIER pipeline();
|
| 97 |
+
_CUDA_PIPELINE_QUALIFIER size_t commit();
|
| 98 |
+
_CUDA_PIPELINE_QUALIFIER void commit_and_wait();
|
| 99 |
+
_CUDA_PIPELINE_QUALIFIER void wait(size_t batch);
|
| 100 |
+
template<unsigned N>
|
| 101 |
+
_CUDA_PIPELINE_QUALIFIER void wait_prior();
|
| 102 |
+
|
| 103 |
+
# if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
|
| 104 |
+
_CUDA_PIPELINE_QUALIFIER void arrive_on(awbarrier& barrier);
|
| 105 |
+
_CUDA_PIPELINE_QUALIFIER void arrive_on(cuda::__block_scope_barrier_base& barrier);
|
| 106 |
+
# endif
|
| 107 |
+
|
| 108 |
+
private:
|
| 109 |
+
size_t current_batch;
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
template<class T>
|
| 113 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 114 |
+
void memcpy_async(T& dst, const T& src, pipeline& pipe);
|
| 115 |
+
|
| 116 |
+
template<class T, size_t DstN, size_t SrcN>
|
| 117 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 118 |
+
void memcpy_async(T(*dst)[DstN], const T(*src)[SrcN], pipeline& pipe);
|
| 119 |
+
|
| 120 |
+
template<size_t N, typename T>
|
| 121 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 122 |
+
auto segment(T* ptr) -> T(*)[N]
|
| 123 |
+
{
|
| 124 |
+
return (T(*)[N])ptr;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 128 |
+
pipeline::pipeline()
|
| 129 |
+
: current_batch(0)
|
| 130 |
+
{
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 134 |
+
size_t pipeline::commit()
|
| 135 |
+
{
|
| 136 |
+
_CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_commit();
|
| 137 |
+
return this->current_batch++;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 141 |
+
void pipeline::commit_and_wait()
|
| 142 |
+
{
|
| 143 |
+
(void)pipeline::commit();
|
| 144 |
+
pipeline::wait_prior<0>();
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 148 |
+
void pipeline::wait(size_t batch)
|
| 149 |
+
{
|
| 150 |
+
const size_t prior = this->current_batch > batch ? this->current_batch - batch : 0;
|
| 151 |
+
|
| 152 |
+
switch (prior) {
|
| 153 |
+
case 0 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<0>(); break;
|
| 154 |
+
case 1 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<1>(); break;
|
| 155 |
+
case 2 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<2>(); break;
|
| 156 |
+
case 3 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<3>(); break;
|
| 157 |
+
case 4 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<4>(); break;
|
| 158 |
+
case 5 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<5>(); break;
|
| 159 |
+
case 6 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<6>(); break;
|
| 160 |
+
case 7 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<7>(); break;
|
| 161 |
+
default : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<8>(); break;
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
template<unsigned N>
|
| 166 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 167 |
+
void pipeline::wait_prior()
|
| 168 |
+
{
|
| 169 |
+
_CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<N>();
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
# if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
|
| 173 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 174 |
+
void pipeline::arrive_on(awbarrier& barrier)
|
| 175 |
+
{
|
| 176 |
+
_CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_arrive_on(&barrier.barrier);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 180 |
+
void pipeline::arrive_on(cuda::__block_scope_barrier_base & barrier)
|
| 181 |
+
{
|
| 182 |
+
_CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_arrive_on(reinterpret_cast<uint64_t *>(&barrier));
|
| 183 |
+
}
|
| 184 |
+
# endif
|
| 185 |
+
|
| 186 |
+
template<class T>
|
| 187 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 188 |
+
void memcpy_async(T& dst, const T& src, pipeline& pipe)
|
| 189 |
+
{
|
| 190 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(&src) & (alignof(T) - 1)));
|
| 191 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(&dst) & (alignof(T) - 1)));
|
| 192 |
+
|
| 193 |
+
if (__is_trivially_copyable(T)) {
|
| 194 |
+
_CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_copy_relaxed<sizeof(T), alignof(T)>(
|
| 195 |
+
reinterpret_cast<void*>(&dst), reinterpret_cast<const void*>(&src));
|
| 196 |
+
} else {
|
| 197 |
+
dst = src;
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
template<class T, size_t DstN, size_t SrcN>
|
| 202 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 203 |
+
void memcpy_async(T(*dst)[DstN], const T(*src)[SrcN], pipeline& pipe)
|
| 204 |
+
{
|
| 205 |
+
constexpr size_t dst_size = sizeof(*dst);
|
| 206 |
+
constexpr size_t src_size = sizeof(*src);
|
| 207 |
+
static_assert(dst_size == 4 || dst_size == 8 || dst_size == 16, "Unsupported copy size.");
|
| 208 |
+
static_assert(src_size <= dst_size, "Source size must be less than or equal to destination size.");
|
| 209 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (dst_size - 1)));
|
| 210 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (dst_size - 1)));
|
| 211 |
+
|
| 212 |
+
if (__is_trivially_copyable(T)) {
|
| 213 |
+
_CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_copy_strict<sizeof(*dst), sizeof(*src)>(
|
| 214 |
+
reinterpret_cast<void*>(*dst), reinterpret_cast<const void*>(*src));
|
| 215 |
+
} else {
|
| 216 |
+
for (size_t i = 0; i < DstN; ++i) {
|
| 217 |
+
(*dst)[i] = (i < SrcN) ? (*src)[i] : T();
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
_CUDA_PIPELINE_END_NAMESPACE
|
| 223 |
+
|
| 224 |
+
#endif /* !_CUDA_PIPELINE_H_ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_pipeline_helpers.h
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef _CUDA_PIPELINE_HELPERS_H_
|
| 51 |
+
# define _CUDA_PIPELINE_HELPERS_H_
|
| 52 |
+
|
| 53 |
+
# define _CUDA_PIPELINE_NAMESPACE nvcuda::experimental
|
| 54 |
+
# define _CUDA_PIPELINE_BEGIN_NAMESPACE namespace nvcuda { namespace experimental {
|
| 55 |
+
# define _CUDA_PIPELINE_END_NAMESPACE } }
|
| 56 |
+
|
| 57 |
+
# define _CUDA_PIPELINE_INTERNAL_NAMESPACE _CUDA_PIPELINE_NAMESPACE::__pipeline_internal
|
| 58 |
+
# define _CUDA_PIPELINE_BEGIN_INTERNAL_NAMESPACE _CUDA_PIPELINE_BEGIN_NAMESPACE namespace __pipeline_internal {
|
| 59 |
+
# define _CUDA_PIPELINE_END_INTERNAL_NAMESPACE } _CUDA_PIPELINE_END_NAMESPACE
|
| 60 |
+
|
| 61 |
+
# if !defined(_CUDA_PIPELINE_QUALIFIER)
|
| 62 |
+
# define _CUDA_PIPELINE_QUALIFIER inline __device__
|
| 63 |
+
# endif
|
| 64 |
+
# if !defined(_CUDA_PIPELINE_STATIC_QUALIFIER)
|
| 65 |
+
# define _CUDA_PIPELINE_STATIC_QUALIFIER static inline __device__
|
| 66 |
+
# endif
|
| 67 |
+
|
| 68 |
+
# if defined(_NVHPC_CUDA) || !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 700)
|
| 69 |
+
# define _CUDA_PIPELINE_ARCH_700_OR_LATER
|
| 70 |
+
# endif
|
| 71 |
+
|
| 72 |
+
# if (__CUDA_ARCH__ >= 800)
|
| 73 |
+
# define _CUDA_PIPELINE_HAS_ASYNC_COPY 1
|
| 74 |
+
# else
|
| 75 |
+
# define _CUDA_PIPELINE_HAS_ASYNC_COPY 0
|
| 76 |
+
# endif
|
| 77 |
+
|
| 78 |
+
# if !defined(_CUDA_PIPELINE_MAX_STAGES)
|
| 79 |
+
# define _CUDA_PIPELINE_MAX_STAGES 8
|
| 80 |
+
# endif
|
| 81 |
+
|
| 82 |
+
# if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1900)))
|
| 83 |
+
# define _CUDA_PIPELINE_CPLUSPLUS_11_OR_LATER
|
| 84 |
+
# endif
|
| 85 |
+
|
| 86 |
+
# if !defined(_CUDA_PIPELINE_DEBUG)
|
| 87 |
+
# if defined(__CUDACC_DEBUG__)
|
| 88 |
+
# define _CUDA_PIPELINE_DEBUG 1
|
| 89 |
+
# else
|
| 90 |
+
# define _CUDA_PIPELINE_DEBUG 0
|
| 91 |
+
# endif
|
| 92 |
+
# endif
|
| 93 |
+
|
| 94 |
+
# if defined(_CUDA_PIPELINE_DEBUG) && (_CUDA_PIPELINE_DEBUG == 1) && !defined(NDEBUG)
|
| 95 |
+
# if !defined(__CUDACC_RTC__)
|
| 96 |
+
# include <cassert>
|
| 97 |
+
# endif
|
| 98 |
+
# define _CUDA_PIPELINE_ASSERT(x) assert((x));
|
| 99 |
+
# define _CUDA_PIPELINE_ABORT() assert(0);
|
| 100 |
+
# else
|
| 101 |
+
# define _CUDA_PIPELINE_ASSERT(x)
|
| 102 |
+
# define _CUDA_PIPELINE_ABORT() __trap();
|
| 103 |
+
# endif
|
| 104 |
+
|
| 105 |
+
# if defined(_CUDA_PIPELINE_CPLUSPLUS_11_OR_LATER)
|
| 106 |
+
# define _CUDA_PIPELINE_STATIC_ASSERT(c, m) static_assert(c, m)
|
| 107 |
+
# else
|
| 108 |
+
# define _CUDA_PIPELINE_STATIC_ASSERT(c, m)
|
| 109 |
+
# endif
|
| 110 |
+
|
| 111 |
+
# if (defined(_MSC_VER) && !defined(_WIN64)) || defined(__arm__)
|
| 112 |
+
# define _CUDA_PIPELINE_ASM_PTR_CONSTRAINT "r"
|
| 113 |
+
# else
|
| 114 |
+
# define _CUDA_PIPELINE_ASM_PTR_CONSTRAINT "l"
|
| 115 |
+
# endif
|
| 116 |
+
|
| 117 |
+
# if defined(__CUDACC_RTC__)
|
| 118 |
+
typedef unsigned int uint32_t;
|
| 119 |
+
typedef unsigned long long uint64_t;
|
| 120 |
+
typedef uint64_t uintptr_t;
|
| 121 |
+
# else
|
| 122 |
+
# include <stdint.h>
|
| 123 |
+
# endif
|
| 124 |
+
|
| 125 |
+
_CUDA_PIPELINE_BEGIN_INTERNAL_NAMESPACE
|
| 126 |
+
|
| 127 |
+
_CUDA_PIPELINE_STATIC_ASSERT(sizeof(short) == 2, "Size mismatch for type 'short'");
|
| 128 |
+
_CUDA_PIPELINE_STATIC_ASSERT(sizeof(int) == 4, "Size mismatch for type 'int'");
|
| 129 |
+
_CUDA_PIPELINE_STATIC_ASSERT(sizeof(int2) == 8, "Size mismatch for type 'int2'");
|
| 130 |
+
_CUDA_PIPELINE_STATIC_ASSERT(sizeof(int4) == 16, "Size mismatch for type 'int4'");
|
| 131 |
+
|
| 132 |
+
extern "C" __device__ uint32_t __nvvm_get_smem_pointer(void *);
|
| 133 |
+
|
| 134 |
+
template<size_t CopySize, size_t SourceSize>
|
| 135 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 136 |
+
void pipeline_memcpy_sync(void* __restrict__ dst, const void* __restrict__ src)
|
| 137 |
+
{
|
| 138 |
+
_CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
|
| 139 |
+
_CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size");
|
| 140 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
|
| 141 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
|
| 142 |
+
|
| 143 |
+
char* const d = reinterpret_cast<char*>(dst);
|
| 144 |
+
const char* const s = reinterpret_cast<const char*>(src);
|
| 145 |
+
|
| 146 |
+
size_t copy_step_size;
|
| 147 |
+
if (SourceSize == 0) {
|
| 148 |
+
copy_step_size = CopySize;
|
| 149 |
+
} else if (SourceSize == 2 || SourceSize == 4 || SourceSize == 8 || SourceSize == 16) {
|
| 150 |
+
copy_step_size = SourceSize;
|
| 151 |
+
} else {
|
| 152 |
+
copy_step_size = 1;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
for (size_t i = 0; i < CopySize; i += copy_step_size) {
|
| 156 |
+
const bool copy_source = SourceSize && (i < SourceSize);
|
| 157 |
+
|
| 158 |
+
switch (copy_step_size) {
|
| 159 |
+
case 1:
|
| 160 |
+
d[i] = copy_source ? s[i] : char();
|
| 161 |
+
break;
|
| 162 |
+
case 2:
|
| 163 |
+
*reinterpret_cast<short*>(d + i) = copy_source ? *reinterpret_cast<const short*>(s + i) : short();
|
| 164 |
+
break;
|
| 165 |
+
case 4:
|
| 166 |
+
*reinterpret_cast<int*>(d + i) = copy_source ? *reinterpret_cast<const int*>(s + i) : int();
|
| 167 |
+
break;
|
| 168 |
+
case 8:
|
| 169 |
+
*reinterpret_cast<int2*>(d + i) = copy_source ? *reinterpret_cast<const int2*>(s + i) : int2();
|
| 170 |
+
break;
|
| 171 |
+
case 16:
|
| 172 |
+
*reinterpret_cast<int4*>(d + i) = copy_source ? *reinterpret_cast<const int4*>(s + i) : int4();
|
| 173 |
+
break;
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
template<bool UseHwAsyncCopy>
|
| 179 |
+
struct ImplementationChooser;
|
| 180 |
+
|
| 181 |
+
template<>
|
| 182 |
+
struct ImplementationChooser<true> {
|
| 183 |
+
template<size_t CopySize, size_t SourceSize>
|
| 184 |
+
struct CpAsyncChooser {
|
| 185 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 186 |
+
void cp_async(void* __restrict__ dst, const void* __restrict__ src)
|
| 187 |
+
{
|
| 188 |
+
asm volatile ("cp.async.ca.shared.global [%0], [%1], %2, %3;"
|
| 189 |
+
:
|
| 190 |
+
: "r"(__nvvm_get_smem_pointer(dst)), _CUDA_PIPELINE_ASM_PTR_CONSTRAINT(src), "n"(CopySize),
|
| 191 |
+
"n"(SourceSize)
|
| 192 |
+
: "memory");
|
| 193 |
+
}
|
| 194 |
+
};
|
| 195 |
+
|
| 196 |
+
template<size_t SourceSize>
|
| 197 |
+
struct CpAsyncChooser<16, SourceSize> {
|
| 198 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 199 |
+
void cp_async(void* __restrict__ dst, const void* __restrict__ src)
|
| 200 |
+
{
|
| 201 |
+
asm volatile ("cp.async.cg.shared.global [%0], [%1], %2, %3;"
|
| 202 |
+
:
|
| 203 |
+
: "r"(__nvvm_get_smem_pointer(dst)), _CUDA_PIPELINE_ASM_PTR_CONSTRAINT(src), "n"(16), "n"(SourceSize)
|
| 204 |
+
: "memory");
|
| 205 |
+
}
|
| 206 |
+
};
|
| 207 |
+
|
| 208 |
+
template<size_t CopySize, size_t SourceSize>
|
| 209 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 210 |
+
void pipeline_memcpy_async(void* __restrict__ dst, const void* __restrict__ src)
|
| 211 |
+
{
|
| 212 |
+
_CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
|
| 213 |
+
_CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size");
|
| 214 |
+
_CUDA_PIPELINE_ASSERT(__isShared(dst));
|
| 215 |
+
_CUDA_PIPELINE_ASSERT(__isGlobal(src));
|
| 216 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
|
| 217 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
|
| 218 |
+
|
| 219 |
+
CpAsyncChooser<CopySize, SourceSize>::cp_async(dst, src);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 223 |
+
void pipeline_commit()
|
| 224 |
+
{
|
| 225 |
+
asm volatile ("cp.async.commit_group;");
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
template<unsigned N>
|
| 229 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 230 |
+
void pipeline_wait_prior()
|
| 231 |
+
{
|
| 232 |
+
asm volatile ("cp.async.wait_group %0;"
|
| 233 |
+
:
|
| 234 |
+
: "n"(N < _CUDA_PIPELINE_MAX_STAGES ? N : _CUDA_PIPELINE_MAX_STAGES));
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 238 |
+
void pipeline_arrive_on(uint64_t* barrier)
|
| 239 |
+
{
|
| 240 |
+
_CUDA_PIPELINE_ASSERT(__isShared(barrier));
|
| 241 |
+
|
| 242 |
+
asm volatile ("cp.async.mbarrier.arrive.shared.b64 [%0];"
|
| 243 |
+
:
|
| 244 |
+
: "r"(__nvvm_get_smem_pointer(barrier)));
|
| 245 |
+
}
|
| 246 |
+
};
|
| 247 |
+
|
| 248 |
+
template<>
|
| 249 |
+
struct ImplementationChooser<false> {
|
| 250 |
+
template<size_t CopySize, size_t SourceSize>
|
| 251 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 252 |
+
void pipeline_memcpy_async(void* __restrict__ dst, const void* __restrict__ src)
|
| 253 |
+
{
|
| 254 |
+
_CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
|
| 255 |
+
_CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size");
|
| 256 |
+
_CUDA_PIPELINE_ASSERT(__isShared(dst));
|
| 257 |
+
_CUDA_PIPELINE_ASSERT(__isGlobal(src));
|
| 258 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
|
| 259 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
|
| 260 |
+
|
| 261 |
+
pipeline_memcpy_sync<CopySize, SourceSize>(dst, src);
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 265 |
+
void pipeline_commit()
|
| 266 |
+
{
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
template<unsigned N>
|
| 270 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 271 |
+
void pipeline_wait_prior()
|
| 272 |
+
{
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 276 |
+
void pipeline_arrive_on(uint64_t* barrier)
|
| 277 |
+
{
|
| 278 |
+
}
|
| 279 |
+
};
|
| 280 |
+
|
| 281 |
+
template<size_t CopySize, size_t SourceSize>
|
| 282 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 283 |
+
void pipeline_memcpy_async(void* __restrict__ dst, const void* __restrict__ src)
|
| 284 |
+
{
|
| 285 |
+
_CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
|
| 286 |
+
_CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size");
|
| 287 |
+
_CUDA_PIPELINE_ASSERT(__isShared(dst));
|
| 288 |
+
_CUDA_PIPELINE_ASSERT(__isGlobal(src));
|
| 289 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
|
| 290 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
|
| 291 |
+
|
| 292 |
+
ImplementationChooser<_CUDA_PIPELINE_HAS_ASYNC_COPY>::pipeline_memcpy_async<CopySize, SourceSize>(dst, src);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 296 |
+
void pipeline_commit()
|
| 297 |
+
{
|
| 298 |
+
ImplementationChooser<_CUDA_PIPELINE_HAS_ASYNC_COPY>::pipeline_commit();
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
template<unsigned N>
|
| 302 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 303 |
+
void pipeline_wait_prior()
|
| 304 |
+
{
|
| 305 |
+
ImplementationChooser<_CUDA_PIPELINE_HAS_ASYNC_COPY>::pipeline_wait_prior<N>();
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 309 |
+
void pipeline_arrive_on(uint64_t* barrier)
|
| 310 |
+
{
|
| 311 |
+
ImplementationChooser<_CUDA_PIPELINE_HAS_ASYNC_COPY>::pipeline_arrive_on(barrier);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
template<size_t CopySize, size_t SourceSize>
|
| 315 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 316 |
+
void pipeline_copy_strict(void* __restrict__ dst, const void* __restrict__ src)
|
| 317 |
+
{
|
| 318 |
+
_CUDA_PIPELINE_STATIC_ASSERT(CopySize == 4 || CopySize == 8 || CopySize == 16, "Unsupported copy size.");
|
| 319 |
+
_CUDA_PIPELINE_STATIC_ASSERT(SourceSize <= CopySize, "Source size must be less than or equal to copy size.");
|
| 320 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (CopySize - 1)));
|
| 321 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (CopySize - 1)));
|
| 322 |
+
|
| 323 |
+
if (__isGlobal(src) && __isShared(dst)) {
|
| 324 |
+
pipeline_memcpy_async<CopySize, SourceSize>(dst, src);
|
| 325 |
+
} else {
|
| 326 |
+
pipeline_memcpy_sync<CopySize, SourceSize>(dst, src);
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
template<size_t CopySize, size_t Align>
|
| 331 |
+
_CUDA_PIPELINE_QUALIFIER
|
| 332 |
+
void pipeline_copy_relaxed(void* __restrict__ dst, const void* __restrict__ src)
|
| 333 |
+
{
|
| 334 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src) & (Align - 1)));
|
| 335 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst) & (Align - 1)));
|
| 336 |
+
|
| 337 |
+
const char* s = reinterpret_cast<const char*>(src);
|
| 338 |
+
char* d = reinterpret_cast<char*>(dst);
|
| 339 |
+
size_t remaining = CopySize;
|
| 340 |
+
|
| 341 |
+
while (remaining) {
|
| 342 |
+
if ((Align >= 16) && (remaining >= 16)) {
|
| 343 |
+
pipeline_copy_strict<16, 16>(dst, src);
|
| 344 |
+
d += 16;
|
| 345 |
+
s += 16;
|
| 346 |
+
remaining -= 16;
|
| 347 |
+
} else if ((Align >= 8) && (remaining >= 8)) {
|
| 348 |
+
pipeline_copy_strict<8, 8>(dst, src);
|
| 349 |
+
d += 8;
|
| 350 |
+
s += 8;
|
| 351 |
+
remaining -= 8;
|
| 352 |
+
} else if ((Align >= 4) && (remaining >= 4)) {
|
| 353 |
+
pipeline_copy_strict<4, 4>(dst, src);
|
| 354 |
+
d += 4;
|
| 355 |
+
s += 4;
|
| 356 |
+
remaining -= 4;
|
| 357 |
+
} else if ((Align >= 2) && (remaining >= 2)) {
|
| 358 |
+
*reinterpret_cast<short*>(d) = *reinterpret_cast<const short*>(s);
|
| 359 |
+
d += 2;
|
| 360 |
+
s += 2;
|
| 361 |
+
remaining -= 2;
|
| 362 |
+
} else {
|
| 363 |
+
*d = *s;
|
| 364 |
+
d += 1;
|
| 365 |
+
s += 1;
|
| 366 |
+
remaining -= 1;
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
_CUDA_PIPELINE_END_INTERNAL_NAMESPACE
|
| 372 |
+
|
| 373 |
+
#endif /* !_CUDA_PIPELINE_HELPERS_H_ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_pipeline_primitives.h
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef _CUDA_PIPELINE_PRIMITIVES_H_
|
| 51 |
+
# define _CUDA_PIPELINE_PRIMITIVES_H_
|
| 52 |
+
|
| 53 |
+
# include "cuda_pipeline_helpers.h"
|
| 54 |
+
|
| 55 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 56 |
+
void __pipeline_memcpy_async(void* __restrict__ dst_shared, const void* __restrict__ src_global, size_t size_and_align,
|
| 57 |
+
size_t zfill = 0)
|
| 58 |
+
{
|
| 59 |
+
_CUDA_PIPELINE_ASSERT(size_and_align == 4 || size_and_align == 8 || size_and_align == 16);
|
| 60 |
+
_CUDA_PIPELINE_ASSERT(zfill <= size_and_align);
|
| 61 |
+
_CUDA_PIPELINE_ASSERT(__isShared(dst_shared));
|
| 62 |
+
_CUDA_PIPELINE_ASSERT(__isGlobal(src_global));
|
| 63 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(dst_shared) & (size_and_align - 1)));
|
| 64 |
+
_CUDA_PIPELINE_ASSERT(!(reinterpret_cast<uintptr_t>(src_global) & (size_and_align - 1)));
|
| 65 |
+
|
| 66 |
+
switch (size_and_align) {
|
| 67 |
+
case 16:
|
| 68 |
+
switch (zfill) {
|
| 69 |
+
case 0: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 16>(dst_shared, src_global); return;
|
| 70 |
+
case 1: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 15>(dst_shared, src_global); return;
|
| 71 |
+
case 2: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 14>(dst_shared, src_global); return;
|
| 72 |
+
case 3: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 13>(dst_shared, src_global); return;
|
| 73 |
+
case 4: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 12>(dst_shared, src_global); return;
|
| 74 |
+
case 5: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 11>(dst_shared, src_global); return;
|
| 75 |
+
case 6: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 10>(dst_shared, src_global); return;
|
| 76 |
+
case 7: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 9>(dst_shared, src_global); return;
|
| 77 |
+
case 8: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 8>(dst_shared, src_global); return;
|
| 78 |
+
case 9: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 7>(dst_shared, src_global); return;
|
| 79 |
+
case 10: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 6>(dst_shared, src_global); return;
|
| 80 |
+
case 11: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 5>(dst_shared, src_global); return;
|
| 81 |
+
case 12: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 4>(dst_shared, src_global); return;
|
| 82 |
+
case 13: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 3>(dst_shared, src_global); return;
|
| 83 |
+
case 14: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 2>(dst_shared, src_global); return;
|
| 84 |
+
case 15: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 1>(dst_shared, src_global); return;
|
| 85 |
+
case 16: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async<16, 0>(dst_shared, src_global); return;
|
| 86 |
+
default: _CUDA_PIPELINE_ABORT(); return;
|
| 87 |
+
}
|
| 88 |
+
case 8:
|
| 89 |
+
switch (zfill) {
|
| 90 |
+
case 0: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 8>(dst_shared, src_global); return;
|
| 91 |
+
case 1: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 7>(dst_shared, src_global); return;
|
| 92 |
+
case 2: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 6>(dst_shared, src_global); return;
|
| 93 |
+
case 3: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 5>(dst_shared, src_global); return;
|
| 94 |
+
case 4: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 4>(dst_shared, src_global); return;
|
| 95 |
+
case 5: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 3>(dst_shared, src_global); return;
|
| 96 |
+
case 6: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 2>(dst_shared, src_global); return;
|
| 97 |
+
case 7: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 1>(dst_shared, src_global); return;
|
| 98 |
+
case 8: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 8, 0>(dst_shared, src_global); return;
|
| 99 |
+
default: _CUDA_PIPELINE_ABORT(); return;
|
| 100 |
+
}
|
| 101 |
+
case 4:
|
| 102 |
+
switch (zfill) {
|
| 103 |
+
case 0: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 4>(dst_shared, src_global); return;
|
| 104 |
+
case 1: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 3>(dst_shared, src_global); return;
|
| 105 |
+
case 2: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 2>(dst_shared, src_global); return;
|
| 106 |
+
case 3: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 1>(dst_shared, src_global); return;
|
| 107 |
+
case 4: _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_memcpy_async< 4, 0>(dst_shared, src_global); return;
|
| 108 |
+
default: _CUDA_PIPELINE_ABORT(); return;
|
| 109 |
+
}
|
| 110 |
+
default:
|
| 111 |
+
_CUDA_PIPELINE_ABORT();
|
| 112 |
+
return;
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 117 |
+
void __pipeline_commit()
|
| 118 |
+
{
|
| 119 |
+
_CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_commit();
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 123 |
+
void __pipeline_wait_prior(size_t prior)
|
| 124 |
+
{
|
| 125 |
+
switch (prior) {
|
| 126 |
+
case 0 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<0>(); return;
|
| 127 |
+
case 1 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<1>(); return;
|
| 128 |
+
case 2 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<2>(); return;
|
| 129 |
+
case 3 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<3>(); return;
|
| 130 |
+
case 4 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<4>(); return;
|
| 131 |
+
case 5 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<5>(); return;
|
| 132 |
+
case 6 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<6>(); return;
|
| 133 |
+
case 7 : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<7>(); return;
|
| 134 |
+
default : _CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_wait_prior<8>(); return;
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
# if defined(_CUDA_PIPELINE_ARCH_700_OR_LATER)
|
| 139 |
+
# include "cuda_awbarrier_primitives.h"
|
| 140 |
+
|
| 141 |
+
_CUDA_PIPELINE_STATIC_QUALIFIER
|
| 142 |
+
void __pipeline_arrive_on(__mbarrier_t* barrier)
|
| 143 |
+
{
|
| 144 |
+
_CUDA_PIPELINE_INTERNAL_NAMESPACE::pipeline_arrive_on(barrier);
|
| 145 |
+
}
|
| 146 |
+
# endif
|
| 147 |
+
|
| 148 |
+
#endif /* !_CUDA_PIPELINE_PRIMITIVES_H_ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_runtime.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_runtime_api.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_surface_types.h
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_SURFACE_TYPES_H__)
|
| 51 |
+
#define __CUDA_SURFACE_TYPES_H__
|
| 52 |
+
|
| 53 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 54 |
+
|
| 55 |
+
/*******************************************************************************
|
| 56 |
+
* *
|
| 57 |
+
* *
|
| 58 |
+
* *
|
| 59 |
+
*******************************************************************************/
|
| 60 |
+
|
| 61 |
+
#if !defined(__CUDACC_RTC__)
|
| 62 |
+
#define EXCLUDE_FROM_RTC
|
| 63 |
+
#include "channel_descriptor.h"
|
| 64 |
+
#undef EXCLUDE_FROM_RTC
|
| 65 |
+
#endif /* !__CUDACC_RTC__ */
|
| 66 |
+
#include "cuda_runtime_api.h"
|
| 67 |
+
|
| 68 |
+
/*******************************************************************************
|
| 69 |
+
* *
|
| 70 |
+
* *
|
| 71 |
+
* *
|
| 72 |
+
*******************************************************************************/
|
| 73 |
+
|
| 74 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 75 |
+
|
| 76 |
+
#endif /* !__CUDA_SURFACE_TYPES_H__ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_texture_types.h
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_TEXTURE_TYPES_H__)
|
| 51 |
+
#define __CUDA_TEXTURE_TYPES_H__
|
| 52 |
+
|
| 53 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 54 |
+
|
| 55 |
+
/*******************************************************************************
|
| 56 |
+
* *
|
| 57 |
+
* *
|
| 58 |
+
* *
|
| 59 |
+
*******************************************************************************/
|
| 60 |
+
|
| 61 |
+
#if !defined(__CUDACC_RTC__)
|
| 62 |
+
#define EXCLUDE_FROM_RTC
|
| 63 |
+
#include "channel_descriptor.h"
|
| 64 |
+
#undef EXCLUDE_FROM_RTC
|
| 65 |
+
#endif /* !__CUDACC_RTC__ */
|
| 66 |
+
#include "cuda_runtime_api.h"
|
| 67 |
+
|
| 68 |
+
/*******************************************************************************
|
| 69 |
+
* *
|
| 70 |
+
* *
|
| 71 |
+
* *
|
| 72 |
+
*******************************************************************************/
|
| 73 |
+
|
| 74 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 75 |
+
|
| 76 |
+
#endif /* !__CUDA_TEXTURE_TYPES_H__ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_vdpau_interop.h
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_VDPAU_INTEROP_H__)
|
| 51 |
+
#define __CUDA_VDPAU_INTEROP_H__
|
| 52 |
+
|
| 53 |
+
#include "cuda_runtime_api.h"
|
| 54 |
+
|
| 55 |
+
#include <vdpau/vdpau.h>
|
| 56 |
+
|
| 57 |
+
#if defined(__cplusplus)
|
| 58 |
+
extern "C" {
|
| 59 |
+
#endif /* __cplusplus */
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* \addtogroup CUDART_VDPAU VDPAU Interoperability
|
| 63 |
+
* This section describes the VDPAU interoperability functions of the CUDA
|
| 64 |
+
* runtime application programming interface.
|
| 65 |
+
*
|
| 66 |
+
* @{
|
| 67 |
+
*/
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* \brief Gets the CUDA device associated with a VdpDevice.
|
| 71 |
+
*
|
| 72 |
+
* Returns the CUDA device associated with a VdpDevice, if applicable.
|
| 73 |
+
*
|
| 74 |
+
* \param device - Returns the device associated with vdpDevice, or -1 if
|
| 75 |
+
* the device associated with vdpDevice is not a compute device.
|
| 76 |
+
* \param vdpDevice - A VdpDevice handle
|
| 77 |
+
* \param vdpGetProcAddress - VDPAU's VdpGetProcAddress function pointer
|
| 78 |
+
*
|
| 79 |
+
* \return
|
| 80 |
+
* ::cudaSuccess
|
| 81 |
+
* \notefnerr
|
| 82 |
+
*
|
| 83 |
+
* \sa
|
| 84 |
+
* ::cudaVDPAUSetVDPAUDevice,
|
| 85 |
+
* ::cuVDPAUGetDevice
|
| 86 |
+
*/
|
| 87 |
+
extern __host__ cudaError_t CUDARTAPI cudaVDPAUGetDevice(int *device, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* \brief Sets a CUDA device to use VDPAU interoperability
|
| 91 |
+
*
|
| 92 |
+
* Records \p vdpDevice as the VdpDevice for VDPAU interoperability
|
| 93 |
+
* with the CUDA device \p device and sets \p device as the current
|
| 94 |
+
* device for the calling host thread.
|
| 95 |
+
*
|
| 96 |
+
* This function will immediately initialize the primary context on
|
| 97 |
+
* \p device if needed.
|
| 98 |
+
*
|
| 99 |
+
* If \p device has already been initialized then this call will fail
|
| 100 |
+
* with the error ::cudaErrorSetOnActiveProcess. In this case it is
|
| 101 |
+
* necessary to reset \p device using ::cudaDeviceReset() before
|
| 102 |
+
* VDPAU interoperability on \p device may be enabled.
|
| 103 |
+
*
|
| 104 |
+
* \param device - Device to use for VDPAU interoperability
|
| 105 |
+
* \param vdpDevice - The VdpDevice to interoperate with
|
| 106 |
+
* \param vdpGetProcAddress - VDPAU's VdpGetProcAddress function pointer
|
| 107 |
+
*
|
| 108 |
+
* \return
|
| 109 |
+
* ::cudaSuccess,
|
| 110 |
+
* ::cudaErrorInvalidDevice,
|
| 111 |
+
* ::cudaErrorSetOnActiveProcess
|
| 112 |
+
* \notefnerr
|
| 113 |
+
*
|
| 114 |
+
* \sa ::cudaGraphicsVDPAURegisterVideoSurface,
|
| 115 |
+
* ::cudaGraphicsVDPAURegisterOutputSurface,
|
| 116 |
+
* ::cudaDeviceReset
|
| 117 |
+
*/
|
| 118 |
+
extern __host__ cudaError_t CUDARTAPI cudaVDPAUSetVDPAUDevice(int device, VdpDevice vdpDevice, VdpGetProcAddress *vdpGetProcAddress);
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* \brief Register a VdpVideoSurface object
|
| 122 |
+
*
|
| 123 |
+
* Registers the VdpVideoSurface specified by \p vdpSurface for access by CUDA.
|
| 124 |
+
* A handle to the registered object is returned as \p resource.
|
| 125 |
+
* The surface's intended usage is specified using \p flags, as follows:
|
| 126 |
+
*
|
| 127 |
+
* - ::cudaGraphicsMapFlagsNone: Specifies no hints about how this
|
| 128 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 129 |
+
* read from and written to by CUDA. This is the default value.
|
| 130 |
+
* - ::cudaGraphicsMapFlagsReadOnly: Specifies that CUDA
|
| 131 |
+
* will not write to this resource.
|
| 132 |
+
* - ::cudaGraphicsMapFlagsWriteDiscard: Specifies that
|
| 133 |
+
* CUDA will not read from this resource and will write over the
|
| 134 |
+
* entire contents of the resource, so none of the data previously
|
| 135 |
+
* stored in the resource will be preserved.
|
| 136 |
+
*
|
| 137 |
+
* \param resource - Pointer to the returned object handle
|
| 138 |
+
* \param vdpSurface - VDPAU object to be registered
|
| 139 |
+
* \param flags - Map flags
|
| 140 |
+
*
|
| 141 |
+
* \return
|
| 142 |
+
* ::cudaSuccess,
|
| 143 |
+
* ::cudaErrorInvalidDevice,
|
| 144 |
+
* ::cudaErrorInvalidValue,
|
| 145 |
+
* ::cudaErrorInvalidResourceHandle,
|
| 146 |
+
* ::cudaErrorUnknown
|
| 147 |
+
* \notefnerr
|
| 148 |
+
*
|
| 149 |
+
* \sa
|
| 150 |
+
* ::cudaVDPAUSetVDPAUDevice,
|
| 151 |
+
* ::cudaGraphicsUnregisterResource,
|
| 152 |
+
* ::cudaGraphicsSubResourceGetMappedArray,
|
| 153 |
+
* ::cuGraphicsVDPAURegisterVideoSurface
|
| 154 |
+
*/
|
| 155 |
+
extern __host__ cudaError_t CUDARTAPI cudaGraphicsVDPAURegisterVideoSurface(struct cudaGraphicsResource **resource, VdpVideoSurface vdpSurface, unsigned int flags);
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* \brief Register a VdpOutputSurface object
|
| 159 |
+
*
|
| 160 |
+
* Registers the VdpOutputSurface specified by \p vdpSurface for access by CUDA.
|
| 161 |
+
* A handle to the registered object is returned as \p resource.
|
| 162 |
+
* The surface's intended usage is specified using \p flags, as follows:
|
| 163 |
+
*
|
| 164 |
+
* - ::cudaGraphicsMapFlagsNone: Specifies no hints about how this
|
| 165 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 166 |
+
* read from and written to by CUDA. This is the default value.
|
| 167 |
+
* - ::cudaGraphicsMapFlagsReadOnly: Specifies that CUDA
|
| 168 |
+
* will not write to this resource.
|
| 169 |
+
* - ::cudaGraphicsMapFlagsWriteDiscard: Specifies that
|
| 170 |
+
* CUDA will not read from this resource and will write over the
|
| 171 |
+
* entire contents of the resource, so none of the data previously
|
| 172 |
+
* stored in the resource will be preserved.
|
| 173 |
+
*
|
| 174 |
+
* \param resource - Pointer to the returned object handle
|
| 175 |
+
* \param vdpSurface - VDPAU object to be registered
|
| 176 |
+
* \param flags - Map flags
|
| 177 |
+
*
|
| 178 |
+
* \return
|
| 179 |
+
* ::cudaSuccess,
|
| 180 |
+
* ::cudaErrorInvalidDevice,
|
| 181 |
+
* ::cudaErrorInvalidValue,
|
| 182 |
+
* ::cudaErrorInvalidResourceHandle,
|
| 183 |
+
* ::cudaErrorUnknown
|
| 184 |
+
* \notefnerr
|
| 185 |
+
*
|
| 186 |
+
* \sa
|
| 187 |
+
* ::cudaVDPAUSetVDPAUDevice,
|
| 188 |
+
* ::cudaGraphicsUnregisterResource,
|
| 189 |
+
* ::cudaGraphicsSubResourceGetMappedArray,
|
| 190 |
+
* ::cuGraphicsVDPAURegisterOutputSurface
|
| 191 |
+
*/
|
| 192 |
+
extern __host__ cudaError_t CUDARTAPI cudaGraphicsVDPAURegisterOutputSurface(struct cudaGraphicsResource **resource, VdpOutputSurface vdpSurface, unsigned int flags);
|
| 193 |
+
|
| 194 |
+
/** @} */ /* END CUDART_VDPAU */
|
| 195 |
+
|
| 196 |
+
#if defined(__cplusplus)
|
| 197 |
+
}
|
| 198 |
+
#endif /* __cplusplus */
|
| 199 |
+
|
| 200 |
+
#endif /* __CUDA_VDPAU_INTEROP_H__ */
|
| 201 |
+
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudart_platform.h
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2016 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef __CUDART_PLATFORM_H__
|
| 51 |
+
#define __CUDART_PLATFORM_H__
|
| 52 |
+
|
| 53 |
+
#if ((defined(__linux__) || defined(__QNX__)) && (defined(__arm__) || defined(__a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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2023 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__DEVICE_ATOMIC_FUNCTIONS_H__)
|
| 51 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_H__
|
| 52 |
+
|
| 53 |
+
//NOTE: For NVRTC, these declarations have been moved into the compiler (to reduce compile time)
|
| 54 |
+
#define EXCLUDE_FROM_RTC
|
| 55 |
+
|
| 56 |
+
#if defined(__CUDACC_RTC__)
|
| 57 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_DECL__ __device__
|
| 58 |
+
#elif defined(_NVHPC_CUDA)
|
| 59 |
+
# define __DEVICE_ATOMIC_FUNCTIONS_DECL__ extern __device__ __cudart_builtin__
|
| 60 |
+
#else /* __CUDACC_RTC__ */
|
| 61 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_DECL__ static __inline__ __device__
|
| 62 |
+
#endif /* __CUDACC_RTC__ */
|
| 63 |
+
|
| 64 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 65 |
+
|
| 66 |
+
/*******************************************************************************
|
| 67 |
+
* *
|
| 68 |
+
* *
|
| 69 |
+
* *
|
| 70 |
+
*******************************************************************************/
|
| 71 |
+
|
| 72 |
+
#include "cuda_runtime_api.h"
|
| 73 |
+
|
| 74 |
+
/* Add !defined(_NVHPC_CUDA) to avoid empty function definition in PGI CUDA
|
| 75 |
+
* C++ compiler where the macro __CUDA_ARCH__ is not defined. */
|
| 76 |
+
#if !defined(__CUDA_ARCH__) && !defined(_NVHPC_CUDA)
|
| 77 |
+
#define __DEF_IF_HOST { }
|
| 78 |
+
#else /* !__CUDA_ARCH__ */
|
| 79 |
+
#define __DEF_IF_HOST ;
|
| 80 |
+
#endif /* __CUDA_ARCH__ */
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
/*******************************************************************************
|
| 84 |
+
* *
|
| 85 |
+
* *
|
| 86 |
+
* *
|
| 87 |
+
*******************************************************************************/
|
| 88 |
+
|
| 89 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicAdd(int *address, int val) __DEF_IF_HOST
|
| 90 |
+
|
| 91 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicAdd(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 92 |
+
|
| 93 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicSub(int *address, int val) __DEF_IF_HOST
|
| 94 |
+
|
| 95 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicSub(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 96 |
+
|
| 97 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicExch(int *address, int val) __DEF_IF_HOST
|
| 98 |
+
|
| 99 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicExch(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 100 |
+
|
| 101 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ float atomicExch(float *address, float val) __DEF_IF_HOST
|
| 102 |
+
|
| 103 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicMin(int *address, int val) __DEF_IF_HOST
|
| 104 |
+
|
| 105 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicMin(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 106 |
+
|
| 107 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicMax(int *address, int val) __DEF_IF_HOST
|
| 108 |
+
|
| 109 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicMax(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 110 |
+
|
| 111 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicInc(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 112 |
+
|
| 113 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicDec(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 114 |
+
|
| 115 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicAnd(int *address, int val) __DEF_IF_HOST
|
| 116 |
+
|
| 117 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicAnd(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 118 |
+
|
| 119 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicOr(int *address, int val) __DEF_IF_HOST
|
| 120 |
+
|
| 121 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicOr(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 122 |
+
|
| 123 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicXor(int *address, int val) __DEF_IF_HOST
|
| 124 |
+
|
| 125 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicXor(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 126 |
+
|
| 127 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicCAS(int *address, int compare, int val) __DEF_IF_HOST
|
| 128 |
+
|
| 129 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicCAS(unsigned int *address, unsigned int compare, unsigned int val) __DEF_IF_HOST
|
| 130 |
+
|
| 131 |
+
/*******************************************************************************
|
| 132 |
+
* *
|
| 133 |
+
* *
|
| 134 |
+
* *
|
| 135 |
+
*******************************************************************************/
|
| 136 |
+
|
| 137 |
+
#include "cuda_runtime_api.h"
|
| 138 |
+
|
| 139 |
+
#if defined(_WIN32)
|
| 140 |
+
# define __DEPRECATED__(msg) __declspec(deprecated(msg))
|
| 141 |
+
#elif (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5 && !defined(__clang__))))
|
| 142 |
+
# define __DEPRECATED__(msg) __attribute__((deprecated))
|
| 143 |
+
#else
|
| 144 |
+
# define __DEPRECATED__(msg) __attribute__((deprecated(msg)))
|
| 145 |
+
#endif
|
| 146 |
+
|
| 147 |
+
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700
|
| 148 |
+
#define __WSB_DEPRECATION_MESSAGE(x) #x"() is not valid on compute_70 and above, and should be replaced with "#x"_sync()."\
|
| 149 |
+
"To continue using "#x"(), specify virtual architecture compute_60 when targeting sm_70 and above, for example, using the pair of compiler options: -arch=compute_60 -code=sm_70."
|
| 150 |
+
#elif defined(_NVHPC_CUDA)
|
| 151 |
+
#define __WSB_DEPRECATION_MESSAGE(x) #x"() is not valid on cc70 and above, and should be replaced with "#x"_sync()."
|
| 152 |
+
#else
|
| 153 |
+
#define __WSB_DEPRECATION_MESSAGE(x) #x"() is deprecated in favor of "#x"_sync() and may be removed in a future release (Use -Wno-deprecated-declarations to suppress this warning)."
|
| 154 |
+
#endif
|
| 155 |
+
|
| 156 |
+
extern "C"
|
| 157 |
+
{
|
| 158 |
+
extern __device__ __device_builtin__ __DEPRECATED__(__WSB_DEPRECATION_MESSAGE(__any)) int __any(int cond);
|
| 159 |
+
extern __device__ __device_builtin__ __DEPRECATED__(__WSB_DEPRECATION_MESSAGE(__all)) int __all(int cond);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
/*******************************************************************************
|
| 164 |
+
* *
|
| 165 |
+
* *
|
| 166 |
+
* *
|
| 167 |
+
*******************************************************************************/
|
| 168 |
+
|
| 169 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicAdd(unsigned long long int *address, unsigned long long int val) __DEF_IF_HOST
|
| 170 |
+
|
| 171 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicExch(unsigned long long int *address, unsigned long long int val) __DEF_IF_HOST
|
| 172 |
+
|
| 173 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicCAS(unsigned long long int *address, unsigned long long int compare, unsigned long long int val) __DEF_IF_HOST
|
| 174 |
+
|
| 175 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ __DEPRECATED__(__WSB_DEPRECATION_MESSAGE(__any)) bool any(bool cond) __DEF_IF_HOST
|
| 176 |
+
|
| 177 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ __DEPRECATED__(__WSB_DEPRECATION_MESSAGE(__all)) bool all(bool cond) __DEF_IF_HOST
|
| 178 |
+
|
| 179 |
+
#undef __DEPRECATED__
|
| 180 |
+
#undef __WSB_DEPRECATION_MESSAGE
|
| 181 |
+
|
| 182 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 183 |
+
|
| 184 |
+
#undef __DEF_IF_HOST
|
| 185 |
+
#undef __DEVICE_ATOMIC_FUNCTIONS_DECL__
|
| 186 |
+
|
| 187 |
+
#if !defined(__CUDACC_RTC__) && defined(__CUDA_ARCH__)
|
| 188 |
+
#include "device_atomic_functions.hpp"
|
| 189 |
+
#endif /* !__CUDACC_RTC__ && defined(__CUDA_ARCH__) */
|
| 190 |
+
|
| 191 |
+
#undef EXCLUDE_FROM_RTC
|
| 192 |
+
|
| 193 |
+
#endif /* !__DEVICE_ATOMIC_FUNCTIONS_H__ */
|
.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/device_atomic_functions.hpp
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2023 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__DEVICE_ATOMIC_FUNCTIONS_HPP__)
|
| 51 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_HPP__
|
| 52 |
+
|
| 53 |
+
#if defined(__CUDACC_RTC__)
|
| 54 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_DECL__ __device__
|
| 55 |
+
#else /* __CUDACC_RTC__ */
|
| 56 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_DECL__ static __inline__ __device__
|
| 57 |
+
#endif /* __CUDACC_RTC__ */
|
| 58 |
+
|
| 59 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
extern "C"
|
| 63 |
+
{
|
| 64 |
+
extern __device__ __device_builtin__ int __iAtomicAdd(int *address, int val);
|
| 65 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicAdd(unsigned int *address, unsigned int val);
|
| 66 |
+
extern __device__ __device_builtin__ int __iAtomicExch(int *address, int val);
|
| 67 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicExch(unsigned int *address, unsigned int val);
|
| 68 |
+
extern __device__ __device_builtin__ float __fAtomicExch(float *address, float val);
|
| 69 |
+
extern __device__ __device_builtin__ int __iAtomicMin(int *address, int val);
|
| 70 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicMin(unsigned int *address, unsigned int val);
|
| 71 |
+
extern __device__ __device_builtin__ int __iAtomicMax(int *address, int val);
|
| 72 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicMax(unsigned int *address, unsigned int val);
|
| 73 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicInc(unsigned int *address, unsigned int val);
|
| 74 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicDec(unsigned int *address, unsigned int val);
|
| 75 |
+
extern __device__ __device_builtin__ int __iAtomicAnd(int *address, int val);
|
| 76 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicAnd(unsigned int *address, unsigned int val);
|
| 77 |
+
extern __device__ __device_builtin__ int __iAtomicOr(int *address, int val);
|
| 78 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicOr(unsigned int *address, unsigned int val);
|
| 79 |
+
extern __device__ __device_builtin__ int __iAtomicXor(int *address, int val);
|
| 80 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicXor(unsigned int *address, unsigned int val);
|
| 81 |
+
extern __device__ __device_builtin__ int __iAtomicCAS(int *address, int compare, int val);
|
| 82 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicCAS(unsigned int *address, unsigned int compare, unsigned int val);
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
extern __device__ __device_builtin__ unsigned long long int __ullAtomicAdd(unsigned long long int *address, unsigned long long int val);
|
| 86 |
+
extern __device__ __device_builtin__ unsigned long long int __ullAtomicExch(unsigned long long int *address, unsigned long long int val);
|
| 87 |
+
extern __device__ __device_builtin__ unsigned long long int __ullAtomicCAS(unsigned long long int *address, unsigned long long int compare, unsigned long long int val);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
/*******************************************************************************
|
| 92 |
+
* *
|
| 93 |
+
* *
|
| 94 |
+
* *
|
| 95 |
+
*******************************************************************************/
|
| 96 |
+
|
| 97 |
+
#include "cuda_runtime_api.h"
|
| 98 |
+
|
| 99 |
+
/*******************************************************************************
|
| 100 |
+
* *
|
| 101 |
+
* *
|
| 102 |
+
* *
|
| 103 |
+
*******************************************************************************/
|
| 104 |
+
|
| 105 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicAdd(int *address, int val)
|
| 106 |
+
{
|
| 107 |
+
return __iAtomicAdd(address, val);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicAdd(unsigned int *address, unsigned int val)
|
| 111 |
+
{
|
| 112 |
+
return __uAtomicAdd(address, val);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicSub(int *address, int val)
|
| 116 |
+
{
|
| 117 |
+
return __iAtomicAdd(address, (unsigned int)-(int)val);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicSub(unsigned int *address, unsigned int val)
|
| 121 |
+
{
|
| 122 |
+
return __uAtomicAdd(address, (unsigned int)-(int)val);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicExch(int *address, int val)
|
| 126 |
+
{
|
| 127 |
+
return __iAtomicExch(address, val);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicExch(unsigned int *address, unsigned int val)
|
| 131 |
+
{
|
| 132 |
+
return __uAtomicExch(address, val);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ float atomicExch(float *address, float val)
|
| 136 |
+
{
|
| 137 |
+
return __fAtomicExch(address, val);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicMin(int *address, int val)
|
| 141 |
+
{
|
| 142 |
+
return __iAtomicMin(address, val);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicMin(unsigned int *address, unsigned int val)
|
| 146 |
+
{
|
| 147 |
+
return __uAtomicMin(address, val);
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicMax(int *address, int val)
|
| 151 |
+
{
|
| 152 |
+
return __iAtomicMax(address, val);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicMax(unsigned int *address, unsigned int val)
|
| 156 |
+
{
|
| 157 |
+
return __uAtomicMax(address, val);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicInc(unsigned int *address, unsigned int val)
|
| 161 |
+
{
|
| 162 |
+
return __uAtomicInc(address, val);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicDec(unsigned int *address, unsigned int val)
|
| 166 |
+
{
|
| 167 |
+
return __uAtomicDec(address, val);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicAnd(int *address, int val)
|
| 171 |
+
{
|
| 172 |
+
return __iAtomicAnd(address, val);
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicAnd(unsigned int *address, unsigned int val)
|
| 176 |
+
{
|
| 177 |
+
return __uAtomicAnd(address, val);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicOr(int *address, int val)
|
| 181 |
+
{
|
| 182 |
+
return __iAtomicOr(address, val);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicOr(unsigned int *address, unsigned int val)
|
| 186 |
+
{
|
| 187 |
+
return __uAtomicOr(address, val);
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicXor(int *address, int val)
|
| 191 |
+
{
|
| 192 |
+
return __iAtomicXor(address, val);
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicXor(unsigned int *address, unsigned int val)
|
| 196 |
+
{
|
| 197 |
+
return __uAtomicXor(address, val);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicCAS(int *address, int compare, int val)
|
| 201 |
+
{
|
| 202 |
+
return __iAtomicCAS(address, compare, val);
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicCAS(unsigned int *address, unsigned int compare, unsigned int val)
|
| 206 |
+
{
|
| 207 |
+
return __uAtomicCAS(address, compare, val);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/*******************************************************************************
|
| 211 |
+
* *
|
| 212 |
+
* *
|
| 213 |
+
* *
|
| 214 |
+
*******************************************************************************/
|
| 215 |
+
|
| 216 |
+
#include "cuda_runtime_api.h"
|
| 217 |
+
|
| 218 |
+
/*******************************************************************************
|
| 219 |
+
* *
|
| 220 |
+
* *
|
| 221 |
+
* *
|
| 222 |
+
*******************************************************************************/
|
| 223 |
+
|
| 224 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicAdd(unsigned long long int *address, unsigned long long int val)
|
| 225 |
+
{
|
| 226 |
+
return __ullAtomicAdd(address, val);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicExch(unsigned long long int *address, unsigned long long int val)
|
| 230 |
+
{
|
| 231 |
+
return __ullAtomicExch(address, val);
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicCAS(unsigned long long int *address, unsigned long long int compare, unsigned long long int val)
|
| 235 |
+
{
|
| 236 |
+
return __ullAtomicCAS(address, compare, val);
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ bool any(bool cond)
|
| 240 |
+
{
|
| 241 |
+
return (bool)__any((int)cond);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ bool all(bool cond)
|
| 245 |
+
{
|
| 246 |
+
return (bool)__all((int)cond);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 250 |
+
|
| 251 |
+
#undef __DEVICE_ATOMIC_FUNCTIONS_DECL__
|
| 252 |
+
|
| 253 |
+
#endif /* !__DEVICE_ATOMIC_FUNCTIONS_HPP__ */
|
| 254 |
+
|