mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-11-18 01:48:16 +08:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4526d5229 | ||
|
|
f69622b6b6 | ||
|
|
722c5dd069 | ||
|
|
e32d17e67e | ||
|
|
5cf83b5a98 | ||
|
|
191900a7b4 | ||
|
|
338df69d0f | ||
|
|
9b7a6f907a | ||
|
|
5bbae96fd3 | ||
|
|
ce9407c240 | ||
|
|
cdedff42d2 | ||
|
|
6c4d183ba3 | ||
|
|
af49216f0c | ||
|
|
17113ea87e | ||
|
|
70fcdd353f | ||
|
|
5b2dd19a21 | ||
|
|
37dcb9b61d | ||
|
|
1bc6774795 |
@@ -1,5 +1,8 @@
|
|||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### CUDA 13.2
|
||||||
|
* Added the MSVC compile flag `-Xcompiler=/Zc:preprocessor` in CMakeLists.txt to comply with CUDA13.2 CCCL. Previously, using the traditional preprocessor triggered the warning “MSVC/cl.exe with traditional preprocessor is used…”, which now leads to a build error.
|
||||||
|
|
||||||
### CUDA 13.1
|
### CUDA 13.1
|
||||||
* Minor bug fixes and enhancements, no structural or functional changes
|
* Minor bug fixes and enhancements, no structural or functional changes
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ endif()
|
|||||||
|
|
||||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda")
|
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda")
|
||||||
|
|
||||||
|
# Add MSVC-specific flags for standard-conforming preprocessor (required for CCCL)
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zc:preprocessor>)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Include installation configuration before processing samples
|
# Include installation configuration before processing samples
|
||||||
include(cmake/InstallSamples.cmake)
|
include(cmake/InstallSamples.cmake)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# CUDA Samples
|
# CUDA Samples
|
||||||
|
|
||||||
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 13.1](https://developer.nvidia.com/cuda-downloads).
|
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 13.2](https://developer.nvidia.com/cuda-downloads).
|
||||||
|
|
||||||
## Release Notes
|
## Release Notes
|
||||||
|
|
||||||
@@ -604,6 +604,11 @@ NVJPEG library provides high-performance, GPU accelerated JPEG decoding function
|
|||||||
|
|
||||||
NVRTC (CUDA RunTime Compilation) is a runtime compilation library for CUDA C++.
|
NVRTC (CUDA RunTime Compilation) is a runtime compilation library for CUDA C++.
|
||||||
|
|
||||||
|
#### NVJITLINK
|
||||||
|
|
||||||
|
NVJITLINK is a CUDA runtime library that links multiple GPU device code objects at runtime and enables just‑in‑time link‑time optimization (JIT LTO).
|
||||||
|
It can take device code from tools such as NVCC and NVRTC, link and optimize it on the fly, and produce the final GPU binary.For more details, see: https://docs.nvidia.com/cuda/nvjitlink/index.html
|
||||||
|
|
||||||
#### Stream Priorities
|
#### Stream Priorities
|
||||||
|
|
||||||
Stream Priorities allows the creation of streams with specified priorities. Stream Priorities is only available on GPUs with SM architecture of 3.5 or above.
|
Stream Priorities allows the creation of streams with specified priorities. Stream Priorities is only available on GPUs with SM architecture of 3.5 or above.
|
||||||
@@ -636,7 +641,7 @@ Answers to frequently asked questions about CUDA can be found at http://develope
|
|||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
* [CUDA Programming Guide](http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html)
|
* [CUDA Programming Guide](https://docs.nvidia.com/cuda/cuda-programming-guide/index.html)
|
||||||
* [Accelerated Computing Blog](https://developer.nvidia.com/blog/?tags=accelerated-computing)
|
* [Accelerated Computing Blog](https://developer.nvidia.com/blog/?tags=accelerated-computing)
|
||||||
|
|
||||||
## Attributions
|
## Attributions
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l
|
|||||||
cudaStreamDestroy, cudaFree, cudaMallocManaged, cudaStreamAttachMemAsync, cudaSetDevice, cudaDeviceSynchronize, cudaStreamSynchronize, cudaStreamCreate, cudaGetDeviceProperties
|
cudaStreamDestroy, cudaFree, cudaMallocManaged, cudaStreamAttachMemAsync, cudaSetDevice, cudaDeviceSynchronize, cudaStreamSynchronize, cudaStreamCreate, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[OpenMP](../../../README.md#openmp), [UVM](../../../README.md#uvm), [CUBLAS](../../../README.md#cublas)
|
[OpenMP](../../../README.md#openmp), [UVM](../../../README.md#unified-virtual-memory), [CUBLAS](../../../README.md#cublas)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaMemcpy, cudaFree, cudaMallocHost, cudaFreeHost, cudaMalloc, cudaGetDeviceProperties
|
cudaMemcpy, cudaFree, cudaMallocHost, cudaFreeHost, cudaMalloc, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[FP16](../../../README.md#fp16)
|
[FP16](../../../README.md#16-bit-floating-point)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ scalarProductKernel_intrinsics(half2 const *const a, half2 const *const b, float
|
|||||||
shArray[threadIdx.x] = __float2half2_rn(0.f);
|
shArray[threadIdx.x] = __float2half2_rn(0.f);
|
||||||
half2 value = __float2half2_rn(0.f);
|
half2 value = __float2half2_rn(0.f);
|
||||||
|
|
||||||
for (int i = threadIdx.x + blockDim.x + blockIdx.x; i < size; i += stride) {
|
for (int i = threadIdx.x + blockDim.x * blockIdx.x; i < size; i += stride) {
|
||||||
value = __hfma2(a[i], b[i], value);
|
value = __hfma2(a[i], b[i], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ scalarProductKernel_native(half2 const *const a, half2 const *const b, float *co
|
|||||||
half2 value(0.f, 0.f);
|
half2 value(0.f, 0.f);
|
||||||
shArray[threadIdx.x] = value;
|
shArray[threadIdx.x] = value;
|
||||||
|
|
||||||
for (int i = threadIdx.x + blockDim.x + blockIdx.x; i < size; i += stride) {
|
for (int i = threadIdx.x + blockDim.x * blockIdx.x; i < size; i += stride) {
|
||||||
value = a[i] * b[i] + value;
|
value = a[i] * b[i] + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ void runTest(int argc, char **argv)
|
|||||||
checkCudaErrors(cuMemFree(d_A));
|
checkCudaErrors(cuMemFree(d_A));
|
||||||
checkCudaErrors(cuMemFree(d_B));
|
checkCudaErrors(cuMemFree(d_B));
|
||||||
checkCudaErrors(cuMemFree(d_C));
|
checkCudaErrors(cuMemFree(d_C));
|
||||||
|
checkCudaErrors(cuModuleUnload(cuModule));
|
||||||
checkCudaErrors(cuCtxDestroy(cuContext));
|
checkCudaErrors(cuCtxDestroy(cuContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ extern "C" void computeGold(float *, const float *, const float *, unsigned int,
|
|||||||
// Globals
|
// Globals
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CUcontext g_cuContext;
|
CUcontext g_cuContext;
|
||||||
|
CUmodule g_cuModule;
|
||||||
bool noprompt = false;
|
bool noprompt = false;
|
||||||
|
|
||||||
static const char *sSDKsample = "matrixMulDynlinkJIT (CUDA dynamic linking)";
|
static const char *sSDKsample = "matrixMulDynlinkJIT (CUDA dynamic linking)";
|
||||||
@@ -90,7 +91,6 @@ CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul, int *block_size
|
|||||||
{
|
{
|
||||||
CUresult status;
|
CUresult status;
|
||||||
CUdevice cuDevice;
|
CUdevice cuDevice;
|
||||||
CUmodule cuModule;
|
|
||||||
CUfunction cuFunction;
|
CUfunction cuFunction;
|
||||||
int major, minor, block_size, devID = 0;
|
int major, minor, block_size, devID = 0;
|
||||||
char deviceName[256];
|
char deviceName[256];
|
||||||
@@ -184,11 +184,11 @@ CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul, int *block_size
|
|||||||
printf("> Compiling CUDA module\n");
|
printf("> Compiling CUDA module\n");
|
||||||
|
|
||||||
#if defined(_WIN64) || defined(__LP64__)
|
#if defined(_WIN64) || defined(__LP64__)
|
||||||
status =
|
status = cuModuleLoadDataEx(
|
||||||
cuModuleLoadDataEx(&cuModule, matrixMul_kernel_64_ptxdump, jitNumOptions, jitOptions, (void **)jitOptVals);
|
&g_cuModule, matrixMul_kernel_64_ptxdump, jitNumOptions, jitOptions, (void **)jitOptVals);
|
||||||
#else
|
#else
|
||||||
status =
|
status = cuModuleLoadDataEx(
|
||||||
cuModuleLoadDataEx(&cuModule, matrixMul_kernel_32_ptxdump, jitNumOptions, jitOptions, (void **)jitOptVals);
|
&g_cuModule, matrixMul_kernel_32_ptxdump, jitNumOptions, jitOptions, (void **)jitOptVals);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("> PTX JIT log:\n%s\n", jitLogBuffer);
|
printf("> PTX JIT log:\n%s\n", jitLogBuffer);
|
||||||
@@ -206,9 +206,10 @@ CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul, int *block_size
|
|||||||
|
|
||||||
// retrieve CUDA function from the compiled module
|
// retrieve CUDA function from the compiled module
|
||||||
status = cuModuleGetFunction(
|
status = cuModuleGetFunction(
|
||||||
&cuFunction, cuModule, (block_size == 16) ? "matrixMul_bs16_32bit" : "matrixMul_bs32_32bit");
|
&cuFunction, g_cuModule, (block_size == 16) ? "matrixMul_bs16_32bit" : "matrixMul_bs32_32bit");
|
||||||
|
|
||||||
if (CUDA_SUCCESS != status) {
|
if (CUDA_SUCCESS != status) {
|
||||||
|
cuModuleUnload(g_cuModule);
|
||||||
cuCtxDestroy(g_cuContext);
|
cuCtxDestroy(g_cuContext);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -337,6 +338,7 @@ int main(int argc, char **argv)
|
|||||||
checkCudaErrors(cuMemFree(d_A));
|
checkCudaErrors(cuMemFree(d_A));
|
||||||
checkCudaErrors(cuMemFree(d_B));
|
checkCudaErrors(cuMemFree(d_B));
|
||||||
checkCudaErrors(cuMemFree(d_C));
|
checkCudaErrors(cuMemFree(d_C));
|
||||||
|
checkCudaErrors(cuModuleUnload(g_cuModule));
|
||||||
checkCudaErrors(cuCtxDestroy(g_cuContext));
|
checkCudaErrors(cuCtxDestroy(g_cuContext));
|
||||||
|
|
||||||
printf("Test run %s\n", (1 == res) ? "success!" : "failed!");
|
printf("Test run %s\n", (1 == res) ? "success!" : "failed!");
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l, aarch64
|
|||||||
cudaStreamCreateWithFlags, cudaFree, cudaDeviceGetAttribute, cudaMallocHost, cudaFreeHost, cudaStreamSynchronize, cudaLaunchCooperativeKernel, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaMemcpyAsync, cudaOccupancyMaxPotentialBlockSize
|
cudaStreamCreateWithFlags, cudaFree, cudaDeviceGetAttribute, cudaMallocHost, cudaFreeHost, cudaStreamSynchronize, cudaLaunchCooperativeKernel, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaMemcpyAsync, cudaOccupancyMaxPotentialBlockSize
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CPP11](../../../README.md#cpp11), [MBCG](../../../README.md#mbcg)
|
[C++11 CUDA](../../../README.md#c11-cuda), [MBCG](../../../README.md#multi-block-cooperative-groups)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64
|
|||||||
cudaHostAlloc, cudaGraphicsUnmapResources, cudaMalloc, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaMemcpyToArray, cudaDeviceSynchronize, cudaProcess, cudaGraphicsUnregisterResource, cudaGraphicsSubResourceGetMappedArray, cudaGraphicsGLRegisterBuffer, cudaGraphicsGLRegisterImage
|
cudaHostAlloc, cudaGraphicsUnmapResources, cudaMalloc, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaMemcpyToArray, cudaDeviceSynchronize, cudaProcess, cudaGraphicsUnregisterResource, cudaGraphicsSubResourceGetMappedArray, cudaGraphicsGLRegisterBuffer, cudaGraphicsGLRegisterImage
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, ppc64le
|
|||||||
cudaSetDevice, cudaIpcCloseMemHandle, cudaEventDestroy, cudaGetDeviceCount, cudaMemcpyAsync, cudaDeviceCanAccessPeer, cudaStreamCreateWithFlags, cudaStreamDestroy, cudaGetLastError, cudaIpcOpenEventHandle, cudaIpcOpenMemHandle, cudaIpcGetEventHandle, cudaStreamWaitEvent, cudaEventCreate, cudaFree, cudaEventSynchronize, cudaEventRecord, cudaIpcGetMemHandle, cudaStreamSynchronize, cudaDeviceEnablePeerAccess, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties
|
cudaSetDevice, cudaIpcCloseMemHandle, cudaEventDestroy, cudaGetDeviceCount, cudaMemcpyAsync, cudaDeviceCanAccessPeer, cudaStreamCreateWithFlags, cudaStreamDestroy, cudaGetLastError, cudaIpcOpenEventHandle, cudaIpcOpenMemHandle, cudaIpcGetEventHandle, cudaStreamWaitEvent, cudaEventCreate, cudaFree, cudaEventSynchronize, cudaEventRecord, cudaIpcGetMemHandle, cudaStreamSynchronize, cudaDeviceEnablePeerAccess, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[IPC](../../../README.md#ipc)
|
[IPC](../../../README.md#cuda-interprocess-communication)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaMalloc, cudaGetLastError, cudaMemcpy, cudaFree
|
cudaMalloc, cudaGetLastError, cudaMemcpy, cudaFree
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[MPI](../../../README.md#mpi)
|
[MPI](../../../README.md#message-passing-interface)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <helper_cuda.h> // helper functions for CUDA error check
|
#include <helper_cuda.h> // helper functions for CUDA error check
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ const int manualBlockSize = 32;
|
|||||||
// execution configuration, including anything the launch configurator
|
// execution configuration, including anything the launch configurator
|
||||||
// API suggests.
|
// API suggests.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
__global__ void square(int *array, int arrayCount)
|
__global__ void square(uint32_t *array, int arrayCount)
|
||||||
{
|
{
|
||||||
extern __shared__ int dynamicSmem[];
|
extern __shared__ int dynamicSmem[];
|
||||||
int idx = threadIdx.x + blockIdx.x * blockDim.x;
|
int idx = threadIdx.x + blockIdx.x * blockDim.x;
|
||||||
@@ -99,7 +100,7 @@ static double reportPotentialOccupancy(void *kernel, int blockSize, size_t dynam
|
|||||||
// This function configures the launch based on the "automatic"
|
// This function configures the launch based on the "automatic"
|
||||||
// argument, records the runtime, and reports occupancy and runtime.
|
// argument, records the runtime, and reports occupancy and runtime.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static int launchConfig(int *array, int arrayCount, bool automatic)
|
static int launchConfig(uint32_t *array, int arrayCount, bool automatic)
|
||||||
{
|
{
|
||||||
int blockSize;
|
int blockSize;
|
||||||
int minGridSize;
|
int minGridSize;
|
||||||
@@ -166,20 +167,20 @@ static int launchConfig(int *array, int arrayCount, bool automatic)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static int test(bool automaticLaunchConfig, const int count = 1000000)
|
static int test(bool automaticLaunchConfig, const int count = 1000000)
|
||||||
{
|
{
|
||||||
int *array;
|
uint32_t *array;
|
||||||
int *dArray;
|
uint32_t *dArray;
|
||||||
int size = count * sizeof(int);
|
int size = count * sizeof(uint32_t);
|
||||||
|
|
||||||
array = new int[count];
|
array = new uint32_t[count];
|
||||||
|
|
||||||
for (int i = 0; i < count; i += 1) {
|
for (uint32_t i = 0; i < count; i += 1) {
|
||||||
array[i] = i;
|
array[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkCudaErrors(cudaMalloc(&dArray, size));
|
checkCudaErrors(cudaMalloc(&dArray, size));
|
||||||
checkCudaErrors(cudaMemcpy(dArray, array, size, cudaMemcpyHostToDevice));
|
checkCudaErrors(cudaMemcpy(dArray, array, size, cudaMemcpyHostToDevice));
|
||||||
|
|
||||||
for (int i = 0; i < count; i += 1) {
|
for (uint32_t i = 0; i < count; i += 1) {
|
||||||
array[i] = 0;
|
array[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,8 +190,9 @@ static int test(bool automaticLaunchConfig, const int count = 1000000)
|
|||||||
checkCudaErrors(cudaFree(dArray));
|
checkCudaErrors(cudaFree(dArray));
|
||||||
|
|
||||||
// Verify the return data
|
// Verify the return data
|
||||||
|
// Both GPU and CPU use uint32_t * uint32_t, which has well-defined overflow behavior (modulo 2^32)
|
||||||
//
|
//
|
||||||
for (int i = 0; i < count; i += 1) {
|
for (uint32_t i = 0; i < count; i += 1) {
|
||||||
if (array[i] != i * i) {
|
if (array[i] != i * i) {
|
||||||
std::cout << "element " << i << " expected " << i * i << " actual " << array[i] << std::endl;
|
std::cout << "element " << i << " expected " << i * i << " actual " << array[i] << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaFreeArray, cudaFree, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaExtent, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaFreeArray, cudaFree, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaExtent, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ void runTest(int argc, char **argv)
|
|||||||
free(image_path);
|
free(image_path);
|
||||||
free(ref_path);
|
free(ref_path);
|
||||||
|
|
||||||
|
checkCudaErrors(cuModuleUnload(cuModule));
|
||||||
checkCudaErrors(cuCtxDestroy(cuContext));
|
checkCudaErrors(cuCtxDestroy(cuContext));
|
||||||
|
|
||||||
exit(bTestResults ? EXIT_SUCCESS : EXIT_FAILURE);
|
exit(bTestResults ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, ppc64le
|
|||||||
cudaDeviceSynchronize, cudaMallocManaged, cudaGetDeviceProperties, cudaFree
|
cudaDeviceSynchronize, cudaMallocManaged, cudaGetDeviceProperties, cudaFree
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[UVM](../../../README.md#uvm)
|
[UVM](../../../README.md#unified-virtual-memory)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ int CleanupNoFailure()
|
|||||||
free(h_C);
|
free(h_C);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkCudaErrors(cuModuleUnload(cuModule));
|
||||||
checkCudaErrors(cuCtxDestroy(cuContext));
|
checkCudaErrors(cuCtxDestroy(cuContext));
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ int CleanupNoFailure()
|
|||||||
free(h_C);
|
free(h_C);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkCudaErrors(cuModuleUnload(cuModule));
|
||||||
checkCudaErrors(cuCtxDestroy(cuContext));
|
checkCudaErrors(cuCtxDestroy(cuContext));
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaMemcpyFromSymbol, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaMemcpyToSymbol, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaMemcpyFromSymbol, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaMemcpyToSymbol, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaCreateChannelDesc, cudaMallocArray, cudaFreeArray, cudaFree, cudaGetErrorString, cudaMemcpy, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGraphicsUnmapResources, cudaCreateChannelDesc, cudaMallocArray, cudaFreeArray, cudaFree, cudaGetErrorString, cudaMemcpy, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGLRegisterBufferObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGLRegisterBufferObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
Download and install the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
|||||||
@@ -39,10 +39,7 @@ if(${OpenGL_FOUND})
|
|||||||
# Add target for particles
|
# Add target for particles
|
||||||
add_executable(particles particleSystem.cpp particleSystem_cuda.cu particles.cpp render_particles.cpp shaders.cpp)
|
add_executable(particles particleSystem.cpp particleSystem_cuda.cu particles.cpp render_particles.cpp shaders.cpp)
|
||||||
|
|
||||||
target_compile_options(particles PRIVATE
|
target_compile_options(particles PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
||||||
$<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>
|
|
||||||
$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<BOOL:${MSVC}>>:-Xcompiler="/Zc:preprocessor">
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_features(particles PRIVATE cxx_std_17 cuda_std_17)
|
target_compile_features(particles PRIVATE cxx_std_17 cuda_std_17)
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaMemset, cudaMemcpyToSymbol, cudaGraphicsGLRegisterBuffer, cudaGraphicsUnregisterResource, cudaMalloc, cudaInit, cudaGLInit
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaMemset, cudaMemcpyToSymbol, cudaGraphicsGLRegisterBuffer, cudaGraphicsUnregisterResource, cudaMalloc, cudaInit, cudaGLInit
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ extern "C"
|
|||||||
thrust::device_ptr<float4> d_pos4((float4 *)pos);
|
thrust::device_ptr<float4> d_pos4((float4 *)pos);
|
||||||
thrust::device_ptr<float4> d_vel4((float4 *)vel);
|
thrust::device_ptr<float4> d_vel4((float4 *)vel);
|
||||||
|
|
||||||
thrust::for_each(thrust::make_zip_iterator(thrust::make_tuple(d_pos4, d_vel4)),
|
thrust::for_each(thrust::make_zip_iterator(d_pos4, d_vel4),
|
||||||
thrust::make_zip_iterator(thrust::make_tuple(d_pos4 + numParticles, d_vel4 + numParticles)),
|
thrust::make_zip_iterator(d_pos4 + numParticles, d_vel4 + numParticles),
|
||||||
integrate_functor(deltaTime));
|
integrate_functor(deltaTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
#include "thrust/iterator/zip_iterator.h"
|
#include "thrust/iterator/zip_iterator.h"
|
||||||
#include "thrust/sort.h"
|
#include "thrust/sort.h"
|
||||||
|
|
||||||
|
// for cuda::std::get
|
||||||
|
#include <cuda/std/utility>
|
||||||
|
|
||||||
namespace cg = cooperative_groups;
|
namespace cg = cooperative_groups;
|
||||||
#include "helper_math.h"
|
#include "helper_math.h"
|
||||||
#include "math_constants.h"
|
#include "math_constants.h"
|
||||||
@@ -60,8 +63,8 @@ struct integrate_functor
|
|||||||
|
|
||||||
template <typename Tuple> __device__ void operator()(Tuple t)
|
template <typename Tuple> __device__ void operator()(Tuple t)
|
||||||
{
|
{
|
||||||
volatile float4 posData = thrust::get<0>(t);
|
volatile float4 posData = cuda::std::get<0>(t);
|
||||||
volatile float4 velData = thrust::get<1>(t);
|
volatile float4 velData = cuda::std::get<1>(t);
|
||||||
float3 pos = make_float3(posData.x, posData.y, posData.z);
|
float3 pos = make_float3(posData.x, posData.y, posData.z);
|
||||||
float3 vel = make_float3(velData.x, velData.y, velData.z);
|
float3 vel = make_float3(velData.x, velData.y, velData.z);
|
||||||
|
|
||||||
@@ -107,8 +110,8 @@ struct integrate_functor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// store new position and velocity
|
// store new position and velocity
|
||||||
thrust::get<0>(t) = make_float4(pos, posData.w);
|
cuda::std::get<0>(t) = make_float4(pos, posData.w);
|
||||||
thrust::get<1>(t) = make_float4(vel, velData.w);
|
cuda::std::get<1>(t) = make_float4(vel, velData.w);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaMemcpy, cudaFree, cudaSetDevice, cudaDeviceSynchronize, cudaGetDevice, cudaMalloc, cudaGetDeviceProperties
|
cudaMemcpy, cudaFree, cudaSetDevice, cudaDeviceSynchronize, cudaGetDevice, cudaMalloc, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CPP11](../../../README.md#cpp11)
|
[C++11 CUDA](../../../README.md#c11-cuda)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaMemcpy, cudaFree, cudaSetDevice, cudaDeviceSynchronize, cudaLaunchCooperativeKernel, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties, cudaOccupancyMaxPotentialBlockSize
|
cudaMemcpy, cudaFree, cudaSetDevice, cudaDeviceSynchronize, cudaLaunchCooperativeKernel, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties, cudaOccupancyMaxPotentialBlockSize
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[MBCG](../../../README.md#mbcg), [CPP11](../../../README.md#cpp11)
|
[MBCG](../../../README.md#multi-block-cooperative-groups), [C++11 CUDA](../../../README.md#c11-cuda)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -505,13 +505,12 @@ private:
|
|||||||
thrust::device_ptr<uint> dMinScannedEdges = pools.uintEdges.get();
|
thrust::device_ptr<uint> dMinScannedEdges = pools.uintEdges.get();
|
||||||
thrust::device_ptr<float> dMinScannedWeights = pools.floatEdges.get();
|
thrust::device_ptr<float> dMinScannedWeights = pools.floatEdges.get();
|
||||||
|
|
||||||
thrust::inclusive_scan_by_key(
|
thrust::inclusive_scan_by_key(dEdgesFlags,
|
||||||
dEdgesFlags,
|
|
||||||
dEdgesFlags + edgesCount_,
|
dEdgesFlags + edgesCount_,
|
||||||
thrust::make_zip_iterator(thrust::make_tuple(dWeights_, dEdges_)),
|
thrust::make_zip_iterator(dWeights_, dEdges_),
|
||||||
thrust::make_zip_iterator(thrust::make_tuple(dMinScannedWeights, dMinScannedEdges)),
|
thrust::make_zip_iterator(dMinScannedWeights, dMinScannedEdges),
|
||||||
thrust::greater_equal<uint>(),
|
thrust::greater_equal<uint>(),
|
||||||
thrust::minimum<thrust::tuple<float, uint>>());
|
thrust::minimum<cuda::std::tuple<float, uint>>());
|
||||||
|
|
||||||
// To make things clear.
|
// To make things clear.
|
||||||
// Let "dEdgesFlags" denote groups of edges that
|
// Let "dEdgesFlags" denote groups of edges that
|
||||||
@@ -562,11 +561,10 @@ private:
|
|||||||
|
|
||||||
thrust::sequence(dClusteredVerticesIDs, dClusteredVerticesIDs + verticesCount_);
|
thrust::sequence(dClusteredVerticesIDs, dClusteredVerticesIDs + verticesCount_);
|
||||||
|
|
||||||
thrust::sort(thrust::make_zip_iterator(thrust::make_tuple(thrust::device_ptr<uint>(dSuccessors),
|
thrust::sort(thrust::make_zip_iterator(thrust::device_ptr<uint>(dSuccessors),
|
||||||
thrust::device_ptr<uint>(dClusteredVerticesIDs))),
|
thrust::device_ptr<uint>(dClusteredVerticesIDs)),
|
||||||
thrust::make_zip_iterator(
|
thrust::make_zip_iterator(thrust::device_ptr<uint>(dSuccessors + verticesCount_),
|
||||||
thrust::make_tuple(thrust::device_ptr<uint>(dSuccessors + verticesCount_),
|
thrust::device_ptr<uint>(dClusteredVerticesIDs + verticesCount_)));
|
||||||
thrust::device_ptr<uint>(dClusteredVerticesIDs + verticesCount_))));
|
|
||||||
|
|
||||||
// Mark those groups.
|
// Mark those groups.
|
||||||
thrust::device_ptr<uint> dVerticesFlags_ = pools.uintVertices.get();
|
thrust::device_ptr<uint> dVerticesFlags_ = pools.uintVertices.get();
|
||||||
@@ -653,9 +651,8 @@ private:
|
|||||||
// the step of the algorithm to that one. Hence we need to
|
// the step of the algorithm to that one. Hence we need to
|
||||||
// preserve the structure of the original graph: neighbours and
|
// preserve the structure of the original graph: neighbours and
|
||||||
// weights should be grouped by vertex.
|
// weights should be grouped by vertex.
|
||||||
thrust::sort(thrust::make_zip_iterator(thrust::make_tuple(dNewStartpoints, dSurvivedEdgesIDs)),
|
thrust::sort(thrust::make_zip_iterator(dNewStartpoints, dSurvivedEdgesIDs),
|
||||||
thrust::make_zip_iterator(
|
thrust::make_zip_iterator(dNewStartpoints + edgesCount_, dSurvivedEdgesIDs + edgesCount_));
|
||||||
thrust::make_tuple(dNewStartpoints + edgesCount_, dSurvivedEdgesIDs + edgesCount_)));
|
|
||||||
|
|
||||||
// Find the group of contracted edges.
|
// Find the group of contracted edges.
|
||||||
uint *invalidEdgesPtr =
|
uint *invalidEdgesPtr =
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l, aarch64
|
|||||||
cudaMemcpy, cudaFree, cudaMallocHost, cudaEventSynchronize, cudaEventRecord, cudaFreeHost, cudaGetDevice, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
cudaMemcpy, cudaFree, cudaMallocHost, cudaEventSynchronize, cudaEventRecord, cudaFreeHost, cudaGetDevice, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CPP11](../../../README.md#cpp11)
|
[C++11 CUDA](../../../README.md#c11-cuda)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaMemcpy, cudaFree, cudaGetErrorString, cudaGetLastError, cudaEventSynchronize, cudaFuncSetAttribute, cudaEventRecord, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
cudaMemcpy, cudaFree, cudaGetErrorString, cudaGetLastError, cudaEventSynchronize, cudaFuncSetAttribute, cudaEventRecord, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CPP11](../../../README.md#cpp11)
|
[C++11 CUDA](../../../README.md#c11-cuda)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l
|
|||||||
cudaMemcpy, cudaGetMipmappedArrayLevel, cudaGraphicsMapResources, cudaDestroySurfaceObject, cudaExtent, cudaDeviceSynchronize, cudaCreateSurfaceObject, cudaMallocMipmappedArray, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaCreateTextureObject, cudaGraphicsUnmapResources, cudaMallocArray, cudaFreeArray, cudaArrayGetInfo, cudaGetLastError, cudaDestroyTextureObject, cudaGraphicsGLRegisterBuffer, cudaFreeMipmappedArray, cudaFree, cudaGraphicsUnregisterResource, cudaMalloc
|
cudaMemcpy, cudaGetMipmappedArrayLevel, cudaGraphicsMapResources, cudaDestroySurfaceObject, cudaExtent, cudaDeviceSynchronize, cudaCreateSurfaceObject, cudaMallocMipmappedArray, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaCreateTextureObject, cudaGraphicsUnmapResources, cudaMallocArray, cudaFreeArray, cudaArrayGetInfo, cudaGetLastError, cudaDestroyTextureObject, cudaGraphicsGLRegisterBuffer, cudaFreeMipmappedArray, cudaFree, cudaGraphicsUnregisterResource, cudaMalloc
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l
|
|||||||
cudaStreamCreateWithFlags, cudaMemcpy, cudaMemcpyAsync, cudaFree, cudaGetErrorString, cudaGetLastError, cudaPeekAtLastError, cudaDeviceSynchronize, cudaEventRecord, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
cudaStreamCreateWithFlags, cudaMemcpy, cudaMemcpyAsync, cudaFree, cudaGetErrorString, cudaGetLastError, cudaPeekAtLastError, cudaDeviceSynchronize, cudaEventRecord, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CDP](../../../README.md#cdp)
|
[CDP](../../../README.md#cuda-dynamic-parallellism)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l
|
|||||||
cudaMemcpy, cudaFree, cudaGetDeviceCount, cudaMalloc, cudaGetDeviceProperties
|
cudaMemcpy, cudaFree, cudaGetDeviceCount, cudaMalloc, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CDP](../../../README.md#cdp)
|
[CDP](../../../README.md#cuda-dynamic-parallellism)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l
|
|||||||
cudaMemcpy, cudaFree, cudaGetLastError, cudaDeviceSetLimit, cudaMalloc, cudaGetDeviceProperties
|
cudaMemcpy, cudaFree, cudaGetLastError, cudaDeviceSetLimit, cudaMalloc, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CDP](../../../README.md#cdp)
|
[CDP](../../../README.md#cuda-dynamic-parallellism)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
#include <thrust/host_vector.h>
|
#include <thrust/host_vector.h>
|
||||||
#include <thrust/random.h>
|
#include <thrust/random.h>
|
||||||
|
|
||||||
|
// for cuda::std::tuple
|
||||||
|
#include <cuda/std/tuple>
|
||||||
|
|
||||||
namespace cg = cooperative_groups;
|
namespace cg = cooperative_groups;
|
||||||
#include <helper_cuda.h>
|
#include <helper_cuda.h>
|
||||||
|
|
||||||
@@ -610,7 +613,7 @@ struct Random_generator
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
__host__ __device__ __forceinline__ thrust::tuple<float, float> operator()()
|
__host__ __device__ __forceinline__ cuda::std::tuple<float, float> operator()()
|
||||||
{
|
{
|
||||||
#ifdef __CUDA_ARCH__
|
#ifdef __CUDA_ARCH__
|
||||||
unsigned seed = hash(blockIdx.x * blockDim.x + threadIdx.x + count);
|
unsigned seed = hash(blockIdx.x * blockDim.x + threadIdx.x + count);
|
||||||
@@ -622,7 +625,7 @@ struct Random_generator
|
|||||||
#endif
|
#endif
|
||||||
thrust::default_random_engine rng(seed);
|
thrust::default_random_engine rng(seed);
|
||||||
thrust::random::uniform_real_distribution<float> distrib;
|
thrust::random::uniform_real_distribution<float> distrib;
|
||||||
return thrust::make_tuple(distrib(rng), distrib(rng));
|
return cuda::std::make_tuple(distrib(rng), distrib(rng));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -644,9 +647,8 @@ bool cdpQuadtree(int warp_size)
|
|||||||
|
|
||||||
// Generate random points.
|
// Generate random points.
|
||||||
Random_generator rnd;
|
Random_generator rnd;
|
||||||
thrust::generate(thrust::make_zip_iterator(thrust::make_tuple(x_d0.begin(), y_d0.begin())),
|
thrust::generate(
|
||||||
thrust::make_zip_iterator(thrust::make_tuple(x_d0.end(), y_d0.end())),
|
thrust::make_zip_iterator(x_d0.begin(), y_d0.begin()), thrust::make_zip_iterator(x_d0.end(), y_d0.end()), rnd);
|
||||||
rnd);
|
|
||||||
|
|
||||||
// Host structures to analyze the device ones.
|
// Host structures to analyze the device ones.
|
||||||
Points points_init[2];
|
Points points_init[2];
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l
|
|||||||
cudaDeviceSynchronize, cudaGetLastError, cudaGetDeviceProperties, cudaDeviceSetLimit
|
cudaDeviceSynchronize, cudaGetLastError, cudaGetDeviceProperties, cudaDeviceSetLimit
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CDP](../../../README.md#cdp)
|
[CDP](../../../README.md#cuda-dynamic-parallellism)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l
|
|||||||
cudaStreamCreateWithFlags, cudaMemcpy, cudaStreamDestroy, cudaFree, cudaDeviceSynchronize, cudaDeviceSetLimit, cudaMalloc, cudaGetDeviceProperties
|
cudaStreamCreateWithFlags, cudaMemcpy, cudaStreamDestroy, cudaFree, cudaDeviceSynchronize, cudaDeviceSetLimit, cudaMalloc, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CDP](../../../README.md#cdp)
|
[CDP](../../../README.md#cuda-dynamic-parallellism)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaMemcpy, cudaFree, cudaGetErrorString, cudaGetLastError, cudaEventSynchronize, cudaFuncSetAttribute, cudaEventRecord, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
cudaMemcpy, cudaFree, cudaGetErrorString, cudaGetLastError, cudaEventSynchronize, cudaFuncSetAttribute, cudaEventRecord, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CPP11](../../../README.md#cpp11)
|
[C++11 CUDA](../../../README.md#c11-cuda)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l, aarch64
|
|||||||
cudaStreamCreateWithFlags, cudaMalloc, cudaDeviceGetAttribute, cudaFree, cudaMallocHost, cudaEventSynchronize, cudaEventRecord, cudaFreeHost, cudaStreamSynchronize, cudaEventDestroy, cudaEventElapsedTime, cudaMemsetAsync, cudaMemcpyAsync, cudaEventCreate
|
cudaStreamCreateWithFlags, cudaMalloc, cudaDeviceGetAttribute, cudaFree, cudaMallocHost, cudaEventSynchronize, cudaEventRecord, cudaFreeHost, cudaStreamSynchronize, cudaEventDestroy, cudaEventElapsedTime, cudaMemsetAsync, cudaMemcpyAsync, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CPP11](../../../README.md#cpp11)
|
[C++11 CUDA](../../../README.md#c11-cuda)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l, aarch64
|
|||||||
cuDeviceCanAccessPeer, cuMemImportFromShareableHandle, cuModuleLoadDataEx, cuModuleGetFunction, cuMemSetAccess, cuModuleLoad, cuStreamCreate, cuMemRelease, cuInit, cuLaunchKernel, cuMemcpyDtoHAsync, cuMemCreate, cuDeviceGet, cuCtxDestroy, cuDeviceGetCount, cuMemMap, cuMemExportToShareableHandle, cuStreamSynchronize, cuCtxEnablePeerAccess, cuDeviceGetAttribute, cuOccupancyMaxActiveBlocksPerMultiprocessor, cuCtxSetCurrent, cuMemGetAllocationGranularity, cuMemAddressFree, cuMemUnmap, cuCtxCreate, cuStreamDestroy, cuMemAddressReserve
|
cuDeviceCanAccessPeer, cuMemImportFromShareableHandle, cuModuleLoadDataEx, cuModuleGetFunction, cuMemSetAccess, cuModuleLoad, cuStreamCreate, cuMemRelease, cuInit, cuLaunchKernel, cuMemcpyDtoHAsync, cuMemCreate, cuDeviceGet, cuCtxDestroy, cuDeviceGetCount, cuMemMap, cuMemExportToShareableHandle, cuStreamSynchronize, cuCtxEnablePeerAccess, cuDeviceGetAttribute, cuOccupancyMaxActiveBlocksPerMultiprocessor, cuCtxSetCurrent, cuMemGetAllocationGranularity, cuMemAddressFree, cuMemUnmap, cuCtxCreate, cuStreamDestroy, cuMemAddressReserve
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[IPC](../../../README.md#ipc)
|
[IPC](../../../README.md#cuda-interprocess-communication)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -419,6 +419,7 @@ static void childProcess(int devId, int id, char **argv)
|
|||||||
|
|
||||||
// Clean up!
|
// Clean up!
|
||||||
checkCudaErrors(cuStreamDestroy(stream));
|
checkCudaErrors(cuStreamDestroy(stream));
|
||||||
|
checkCudaErrors(cuModuleUnload(cuModule));
|
||||||
checkCudaErrors(cuCtxDestroy(ctx));
|
checkCudaErrors(cuCtxDestroy(ctx));
|
||||||
|
|
||||||
// Unmap the allocations from our address space. Unmapping will also free the
|
// Unmap the allocations from our address space. Unmapping will also free the
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaMemcpy, cudaFree, cudaGetErrorString, cudaGetLastError, cudaEventSynchronize, cudaFuncSetAttribute, cudaEventRecord, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
cudaMemcpy, cudaFree, cudaGetErrorString, cudaGetLastError, cudaEventSynchronize, cudaFuncSetAttribute, cudaEventRecord, cudaMemset, cudaMalloc, cudaEventElapsedTime, cudaGetDeviceProperties, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[CPP11](../../../README.md#cpp11)
|
[C++11 CUDA](../../../README.md#c11-cuda)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaFree, cudaMallocManaged, cudaDeviceSynchronize, cudaEventRecord, cudaLaunchCooperativeKernel, cudaEventDestroy, cudaEventElapsedTime, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties, cudaEventCreate
|
cudaFree, cudaMallocManaged, cudaDeviceSynchronize, cudaEventRecord, cudaLaunchCooperativeKernel, cudaEventDestroy, cudaEventElapsedTime, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[UVM](../../../README.md#uvm), [MBCG](../../../README.md#mbcg)
|
[UVM](../../../README.md#unified-virtual-memory), [MBCG](../../../README.md#multi-block-cooperative-groups)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaHostAlloc, cudaMemPrefetchAsync, cudaFree, cudaLaunchCooperativeKernel, cudaMallocManaged, cudaSetDevice, cudaGetDeviceCount, cudaGetDeviceProperties, cudaFreeHost, cudaMemset, cudaStreamCreate, cudaStreamSynchronize, cudaDeviceEnablePeerAccess, cudaMemAdvise, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaDeviceCanAccessPeer
|
cudaHostAlloc, cudaMemPrefetchAsync, cudaFree, cudaLaunchCooperativeKernel, cudaMallocManaged, cudaSetDevice, cudaGetDeviceCount, cudaGetDeviceProperties, cudaFreeHost, cudaMemset, cudaStreamCreate, cudaStreamSynchronize, cudaDeviceEnablePeerAccess, cudaMemAdvise, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaDeviceCanAccessPeer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[UVM](../../../README.md#uvm), [MDCG](../../../README.md#mdcg), [CPP11](../../../README.md#cpp11)
|
[UVM](../../../README.md#unified-virtual-memory), [MDCG](../../../README.md#multi-device-cooperative-groups), [C++11 CUDA](../../../README.md#c11-cuda)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l
|
|||||||
cudaFree, cudaMallocManaged, cudaDeviceSynchronize, cudaMalloc, cudaGetDeviceProperties
|
cudaFree, cudaMallocManaged, cudaDeviceSynchronize, cudaMalloc, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[UVM](../../../README.md#uvm), [CUBLAS](../../../README.md#cublas), [CUSPARSE](../../../README.md#cusparse)
|
[UVM](../../../README.md#unified-virtual-memory), [CUBLAS](../../../README.md#cublas), [CUSPARSE](../../../README.md#cusparse)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaMalloc, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaCalculateSlopeKernel, cudaGraphicsMapResources, cudaUpdateHeightmapKernel, cudaGraphicsUnregisterResource, cudaGenerateSpectrumKernel, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaMalloc, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaCalculateSlopeKernel, cudaGraphicsMapResources, cudaUpdateHeightmapKernel, cudaGraphicsUnregisterResource, cudaGenerateSpectrumKernel, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl), [CUFFT](../../../README.md#cufft)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew), [CUFFT](../../../README.md#cufft)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaMalloc, cudaGetErrorString, cudaMemcpy, cudaFree
|
cudaMalloc, cudaGetErrorString, cudaMemcpy, cudaFree
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl), [CURAND](../../../README.md#curand)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew), [CURAND](../../../README.md#curand)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaMemcpy, cudaFree, cudaMemcpyFromSymbol, cudaGetDevice, cudaMalloc, cudaGetDeviceProperties
|
cudaMemcpy, cudaFree, cudaMemcpyFromSymbol, cudaGetDevice, cudaMalloc, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[callback](../../../README.md#callback), [CUFFT](../../../README.md#cufft)
|
[CUFFT Callback Routines](../../../README.md#cufft-callback-routines), [CUFFT](../../../README.md#cufft)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGLUnmapBufferObject, cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGLMapBufferObject, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaGLUnregisterBufferObject, cudaDeviceSynchronize, cudaGLRegisterBufferObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
cudaGLUnmapBufferObject, cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGLMapBufferObject, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaGLUnregisterBufferObject, cudaDeviceSynchronize, cudaGLRegisterBufferObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaGetErrorString, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaGetErrorString, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaCreateChannelDesc, cudaMallocArray, cudaFreeArray, cudaFree, cudaMemcpy, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
cudaGraphicsUnmapResources, cudaCreateChannelDesc, cudaMallocArray, cudaFreeArray, cudaFree, cudaMemcpy, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaRuntimeGetVersion, cudaGraphicsUnmapResources, cudaMallocPitch, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaMemcpyToSymbol, cudaGraphicsUnregisterResource, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
cudaRuntimeGetVersion, cudaGraphicsUnmapResources, cudaMallocPitch, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaDeviceSynchronize, cudaCreateTextureObject, cudaMemcpyToSymbol, cudaGraphicsUnregisterResource, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaMallocPitch, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaMallocPitch, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl), [CUFFT](../../../README.md#cufft)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew), [CUFFT](../../../README.md#cufft)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGLUnmapBufferObject, cudaGraphicsUnmapResources, cudaCreateChannelDesc, cudaMemcpy, cudaFree, cudaGLMapBufferObject, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaGLUnregisterBufferObject, cudaCreateTextureObject, cudaGLRegisterBufferObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGLUnmapBufferObject, cudaGraphicsUnmapResources, cudaCreateChannelDesc, cudaMemcpy, cudaFree, cudaGLMapBufferObject, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaGLUnregisterBufferObject, cudaCreateTextureObject, cudaGLRegisterBufferObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaSetDeviceFlags, cudaGraphicsResourceSetMapFlags, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaSetDevice, cudaEventSynchronize, cudaGetDeviceCount, cudaGetDeviceProperties, cudaDeviceSynchronize, cudaEventRecord, cudaGetDevice, cudaMemcpyToSymbol, cudaStreamQuery, cudaEventDestroy, cudaEventElapsedTime, cudaDeviceCanAccessPeer, cudaEventCreate
|
cudaGraphicsUnmapResources, cudaSetDeviceFlags, cudaGraphicsResourceSetMapFlags, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaSetDevice, cudaEventSynchronize, cudaGetDeviceCount, cudaGetDeviceProperties, cudaDeviceSynchronize, cudaEventRecord, cudaGetDevice, cudaMemcpyToSymbol, cudaStreamQuery, cudaEventDestroy, cudaEventElapsedTime, cudaDeviceCanAccessPeer, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,64 @@ void printHelp(void)
|
|||||||
printf("--numElems=<NUM_OF_INT_ELEMS> Number of integer elements to be used in p2p copy.\n");
|
printf("--numElems=<NUM_OF_INT_ELEMS> Number of integer elements to be used in p2p copy.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Detect if cudaMemcpyPeerAsync will automatically fall back to
|
||||||
|
// host-staged copies when P2P is disabled.
|
||||||
|
//
|
||||||
|
// We probe a single representative pair (device 0 -> device 1).
|
||||||
|
// On a given system, confidential-computing (CC) and security
|
||||||
|
// policies are uniform across GPUs, so if this pair is blocked
|
||||||
|
// with cudaErrorNotSupported in P2P-off mode, it is reasonable
|
||||||
|
// to assume all cross-GPU pairs behave the same.
|
||||||
|
//
|
||||||
|
// For a production application that must handle heterogeneous
|
||||||
|
// environments, users may want to probe all device pairs.
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
bool detectFallback(int numGPUs)
|
||||||
|
{
|
||||||
|
if (numGPUs <= 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
cudaSetDevice(0);
|
||||||
|
int *tmp0 = nullptr, *tmp1 = nullptr;
|
||||||
|
cudaStream_t s;
|
||||||
|
cudaStreamCreateWithFlags(&s, cudaStreamNonBlocking);
|
||||||
|
|
||||||
|
size_t testElems = 1;
|
||||||
|
cudaMalloc(&tmp0, testElems * sizeof(int));
|
||||||
|
cudaSetDevice(1);
|
||||||
|
cudaMalloc(&tmp1, testElems * sizeof(int));
|
||||||
|
cudaCheckError();
|
||||||
|
|
||||||
|
// Explicitly ensure P2P is disabled for this test
|
||||||
|
// (Clear any pre-existing P2P access if it happens to be enabled)
|
||||||
|
cudaSetDevice(0);
|
||||||
|
cudaDeviceDisablePeerAccess(1);
|
||||||
|
cudaGetLastError(); // Clear error if peer access was not enabled
|
||||||
|
|
||||||
|
cudaSetDevice(1);
|
||||||
|
cudaDeviceDisablePeerAccess(0);
|
||||||
|
cudaGetLastError(); // Clear error if peer access was not enabled
|
||||||
|
|
||||||
|
bool needsFallback = false;
|
||||||
|
cudaError_t testErr = cudaMemcpyPeerAsync(tmp1, 1, tmp0, 0, testElems * sizeof(int), s);
|
||||||
|
|
||||||
|
if (testErr == cudaErrorPeerAccessNotEnabled || testErr == cudaErrorNotSupported) {
|
||||||
|
needsFallback = true;
|
||||||
|
printf("Note: cudaMemcpyPeerAsync reported '%s' - will use host-mediated copy when P2P is disabled\n",
|
||||||
|
cudaGetErrorString(testErr));
|
||||||
|
cudaGetLastError();
|
||||||
|
}
|
||||||
|
|
||||||
|
cudaStreamSynchronize(s);
|
||||||
|
cudaFree(tmp0);
|
||||||
|
cudaFree(tmp1);
|
||||||
|
cudaStreamDestroy(s);
|
||||||
|
cudaCheckError();
|
||||||
|
|
||||||
|
return needsFallback;
|
||||||
|
}
|
||||||
|
|
||||||
void checkP2Paccess(int numGPUs)
|
void checkP2Paccess(int numGPUs)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numGPUs; i++) {
|
for (int i = 0; i < numGPUs; i++) {
|
||||||
@@ -128,7 +186,9 @@ void performP2PCopy(int *dest,
|
|||||||
int num_elems,
|
int num_elems,
|
||||||
int repeat,
|
int repeat,
|
||||||
bool p2paccess,
|
bool p2paccess,
|
||||||
cudaStream_t streamToRun)
|
cudaStream_t streamToRun,
|
||||||
|
bool useFallback,
|
||||||
|
int *hostBuffer)
|
||||||
{
|
{
|
||||||
int blockSize = 0;
|
int blockSize = 0;
|
||||||
int numBlocks = 0;
|
int numBlocks = 0;
|
||||||
@@ -140,15 +200,33 @@ void performP2PCopy(int *dest,
|
|||||||
for (int r = 0; r < repeat; r++) {
|
for (int r = 0; r < repeat; r++) {
|
||||||
copyp2p<<<numBlocks, blockSize, 0, streamToRun>>>((int4 *)dest, (int4 *)src, num_elems / 4);
|
copyp2p<<<numBlocks, blockSize, 0, streamToRun>>>((int4 *)dest, (int4 *)src, num_elems / 4);
|
||||||
}
|
}
|
||||||
|
cudaCheckError();
|
||||||
|
}
|
||||||
|
else if (useFallback && srcDevice != destDevice) {
|
||||||
|
// Use host-mediated copy for cross-GPU transfers when cudaMemcpyPeerAsync is not supported
|
||||||
|
for (int r = 0; r < repeat; r++) {
|
||||||
|
cudaMemcpyAsync(hostBuffer, src, sizeof(int) * num_elems, cudaMemcpyDeviceToHost, streamToRun);
|
||||||
|
cudaMemcpyAsync(dest, hostBuffer, sizeof(int) * num_elems, cudaMemcpyHostToDevice, streamToRun);
|
||||||
|
}
|
||||||
|
cudaCheckError();
|
||||||
|
}
|
||||||
|
else if (useFallback && srcDevice == destDevice) {
|
||||||
|
// Same device copy
|
||||||
|
for (int r = 0; r < repeat; r++) {
|
||||||
|
cudaMemcpyAsync(dest, src, sizeof(int) * num_elems, cudaMemcpyDeviceToDevice, streamToRun);
|
||||||
|
}
|
||||||
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Use cudaMemcpyPeerAsync
|
||||||
for (int r = 0; r < repeat; r++) {
|
for (int r = 0; r < repeat; r++) {
|
||||||
cudaMemcpyPeerAsync(dest, destDevice, src, srcDevice, sizeof(int) * num_elems, streamToRun);
|
cudaMemcpyPeerAsync(dest, destDevice, src, srcDevice, sizeof(int) * num_elems, streamToRun);
|
||||||
}
|
}
|
||||||
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputBandwidthMatrix(int numElems, int numGPUs, bool p2p, P2PDataTransfer p2p_method)
|
void outputBandwidthMatrix(int numElems, int numGPUs, bool p2p, P2PDataTransfer p2p_method, bool needsFallback)
|
||||||
{
|
{
|
||||||
int repeat = 5;
|
int repeat = 5;
|
||||||
volatile int *flag = NULL;
|
volatile int *flag = NULL;
|
||||||
@@ -178,6 +256,16 @@ void outputBandwidthMatrix(int numElems, int numGPUs, bool p2p, P2PDataTransfer
|
|||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decide if fallback is needed based on global detection result and current test scenario
|
||||||
|
bool useFallback = (!p2p && needsFallback);
|
||||||
|
int *hostBuffer = nullptr;
|
||||||
|
|
||||||
|
if (useFallback) {
|
||||||
|
// Allocate hostBuffer for this function's numElems
|
||||||
|
cudaHostAlloc((void **)&hostBuffer, sizeof(int) * numElems, cudaHostAllocDefault);
|
||||||
|
cudaCheckError();
|
||||||
|
}
|
||||||
|
|
||||||
vector<double> bandwidthMatrix(numGPUs * numGPUs);
|
vector<double> bandwidthMatrix(numGPUs * numGPUs);
|
||||||
|
|
||||||
for (int i = 0; i < numGPUs; i++) {
|
for (int i = 0; i < numGPUs; i++) {
|
||||||
@@ -215,16 +303,20 @@ void outputBandwidthMatrix(int numElems, int numGPUs, bool p2p, P2PDataTransfer
|
|||||||
|
|
||||||
if (i == j) {
|
if (i == j) {
|
||||||
// Perform intra-GPU, D2D copies
|
// Perform intra-GPU, D2D copies
|
||||||
performP2PCopy(buffers[i], i, buffersD2D[i], i, numElems, repeat, access, stream[i]);
|
performP2PCopy(
|
||||||
|
buffers[i], i, buffersD2D[i], i, numElems, repeat, access, stream[i], useFallback, hostBuffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (p2p_method == P2P_WRITE) {
|
if (p2p_method == P2P_WRITE) {
|
||||||
performP2PCopy(buffers[j], j, buffers[i], i, numElems, repeat, access, stream[i]);
|
performP2PCopy(
|
||||||
|
buffers[j], j, buffers[i], i, numElems, repeat, access, stream[i], useFallback, hostBuffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
performP2PCopy(buffers[i], i, buffers[j], j, numElems, repeat, access, stream[i]);
|
performP2PCopy(
|
||||||
|
buffers[i], i, buffers[j], j, numElems, repeat, access, stream[i], useFallback, hostBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cudaCheckError();
|
||||||
|
|
||||||
cudaEventRecord(stop[i], stream[i]);
|
cudaEventRecord(stop[i], stream[i]);
|
||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
@@ -284,11 +376,16 @@ void outputBandwidthMatrix(int numElems, int numGPUs, bool p2p, P2PDataTransfer
|
|||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hostBuffer) {
|
||||||
|
cudaFreeHost(hostBuffer);
|
||||||
|
cudaCheckError();
|
||||||
|
}
|
||||||
|
|
||||||
cudaFreeHost((void *)flag);
|
cudaFreeHost((void *)flag);
|
||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputBidirectionalBandwidthMatrix(int numElems, int numGPUs, bool p2p)
|
void outputBidirectionalBandwidthMatrix(int numElems, int numGPUs, bool p2p, bool needsFallback)
|
||||||
{
|
{
|
||||||
int repeat = 5;
|
int repeat = 5;
|
||||||
volatile int *flag = NULL;
|
volatile int *flag = NULL;
|
||||||
@@ -319,6 +416,16 @@ void outputBidirectionalBandwidthMatrix(int numElems, int numGPUs, bool p2p)
|
|||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decide if fallback is needed based on global detection result and current test scenario
|
||||||
|
bool useFallback = (!p2p && needsFallback);
|
||||||
|
int *hostBuffer = nullptr;
|
||||||
|
|
||||||
|
if (useFallback) {
|
||||||
|
// Allocate hostBuffer for this function's numElems
|
||||||
|
cudaHostAlloc((void **)&hostBuffer, sizeof(int) * numElems, cudaHostAllocDefault);
|
||||||
|
cudaCheckError();
|
||||||
|
}
|
||||||
|
|
||||||
vector<double> bandwidthMatrix(numGPUs * numGPUs);
|
vector<double> bandwidthMatrix(numGPUs * numGPUs);
|
||||||
|
|
||||||
for (int i = 0; i < numGPUs; i++) {
|
for (int i = 0; i < numGPUs; i++) {
|
||||||
@@ -362,18 +469,22 @@ void outputBidirectionalBandwidthMatrix(int numElems, int numGPUs, bool p2p)
|
|||||||
|
|
||||||
if (i == j) {
|
if (i == j) {
|
||||||
// For intra-GPU perform 2 memcopies buffersD2D <-> buffers
|
// For intra-GPU perform 2 memcopies buffersD2D <-> buffers
|
||||||
performP2PCopy(buffers[i], i, buffersD2D[i], i, numElems, repeat, access, stream0[i]);
|
performP2PCopy(
|
||||||
performP2PCopy(buffersD2D[i], i, buffers[i], i, numElems, repeat, access, stream1[i]);
|
buffers[i], i, buffersD2D[i], i, numElems, repeat, access, stream0[i], useFallback, hostBuffer);
|
||||||
|
performP2PCopy(
|
||||||
|
buffersD2D[i], i, buffers[i], i, numElems, repeat, access, stream1[i], useFallback, hostBuffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (access && p2p_mechanism == SM) {
|
if (access && p2p_mechanism == SM) {
|
||||||
cudaSetDevice(j);
|
cudaSetDevice(j);
|
||||||
}
|
}
|
||||||
performP2PCopy(buffers[i], i, buffers[j], j, numElems, repeat, access, stream1[j]);
|
performP2PCopy(
|
||||||
|
buffers[i], i, buffers[j], j, numElems, repeat, access, stream1[j], useFallback, hostBuffer);
|
||||||
if (access && p2p_mechanism == SM) {
|
if (access && p2p_mechanism == SM) {
|
||||||
cudaSetDevice(i);
|
cudaSetDevice(i);
|
||||||
}
|
}
|
||||||
performP2PCopy(buffers[j], j, buffers[i], i, numElems, repeat, access, stream0[i]);
|
performP2PCopy(
|
||||||
|
buffers[j], j, buffers[i], i, numElems, repeat, access, stream0[i], useFallback, hostBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify stream0 that stream1 is complete and record the time of
|
// Notify stream0 that stream1 is complete and record the time of
|
||||||
@@ -439,11 +550,16 @@ void outputBidirectionalBandwidthMatrix(int numElems, int numGPUs, bool p2p)
|
|||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hostBuffer) {
|
||||||
|
cudaFreeHost(hostBuffer);
|
||||||
|
cudaCheckError();
|
||||||
|
}
|
||||||
|
|
||||||
cudaFreeHost((void *)flag);
|
cudaFreeHost((void *)flag);
|
||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputLatencyMatrix(int numGPUs, bool p2p, P2PDataTransfer p2p_method)
|
void outputLatencyMatrix(int numGPUs, bool p2p, P2PDataTransfer p2p_method, bool needsFallback)
|
||||||
{
|
{
|
||||||
int repeat = 100;
|
int repeat = 100;
|
||||||
int numElems = 4; // perform 1-int4 transfer.
|
int numElems = 4; // perform 1-int4 transfer.
|
||||||
@@ -478,6 +594,16 @@ void outputLatencyMatrix(int numGPUs, bool p2p, P2PDataTransfer p2p_method)
|
|||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decide if fallback is needed based on global detection result and current test scenario
|
||||||
|
bool useFallback = (!p2p && needsFallback);
|
||||||
|
int *hostBuffer = nullptr;
|
||||||
|
|
||||||
|
if (useFallback) {
|
||||||
|
// Allocate hostBuffer for this function's numElems
|
||||||
|
cudaHostAlloc((void **)&hostBuffer, sizeof(int) * numElems, cudaHostAllocDefault);
|
||||||
|
cudaCheckError();
|
||||||
|
}
|
||||||
|
|
||||||
vector<double> gpuLatencyMatrix(numGPUs * numGPUs);
|
vector<double> gpuLatencyMatrix(numGPUs * numGPUs);
|
||||||
vector<double> cpuLatencyMatrix(numGPUs * numGPUs);
|
vector<double> cpuLatencyMatrix(numGPUs * numGPUs);
|
||||||
|
|
||||||
@@ -513,14 +639,17 @@ void outputLatencyMatrix(int numGPUs, bool p2p, P2PDataTransfer p2p_method)
|
|||||||
sdkResetTimer(&stopWatch);
|
sdkResetTimer(&stopWatch);
|
||||||
if (i == j) {
|
if (i == j) {
|
||||||
// Perform intra-GPU, D2D copies
|
// Perform intra-GPU, D2D copies
|
||||||
performP2PCopy(buffers[i], i, buffersD2D[i], i, numElems, repeat, access, stream[i]);
|
performP2PCopy(
|
||||||
|
buffers[i], i, buffersD2D[i], i, numElems, repeat, access, stream[i], useFallback, hostBuffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (p2p_method == P2P_WRITE) {
|
if (p2p_method == P2P_WRITE) {
|
||||||
performP2PCopy(buffers[j], j, buffers[i], i, numElems, repeat, access, stream[i]);
|
performP2PCopy(
|
||||||
|
buffers[j], j, buffers[i], i, numElems, repeat, access, stream[i], useFallback, hostBuffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
performP2PCopy(buffers[i], i, buffers[j], j, numElems, repeat, access, stream[i]);
|
performP2PCopy(
|
||||||
|
buffers[i], i, buffers[j], j, numElems, repeat, access, stream[i], useFallback, hostBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float cpu_time_ms = sdkGetTimerValue(&stopWatch);
|
float cpu_time_ms = sdkGetTimerValue(&stopWatch);
|
||||||
@@ -597,6 +726,11 @@ void outputLatencyMatrix(int numGPUs, bool p2p, P2PDataTransfer p2p_method)
|
|||||||
|
|
||||||
sdkDeleteTimer(&stopWatch);
|
sdkDeleteTimer(&stopWatch);
|
||||||
|
|
||||||
|
if (hostBuffer) {
|
||||||
|
cudaFreeHost(hostBuffer);
|
||||||
|
cudaCheckError();
|
||||||
|
}
|
||||||
|
|
||||||
cudaFreeHost((void *)flag);
|
cudaFreeHost((void *)flag);
|
||||||
cudaCheckError();
|
cudaCheckError();
|
||||||
}
|
}
|
||||||
@@ -645,6 +779,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
checkP2Paccess(numGPUs);
|
checkP2Paccess(numGPUs);
|
||||||
|
|
||||||
|
// Environment detection: One-time check if cudaMemcpyPeerAsync is supported when P2P is disabled
|
||||||
|
bool needsFallback = detectFallback(numGPUs);
|
||||||
|
|
||||||
// Check peer-to-peer connectivity
|
// Check peer-to-peer connectivity
|
||||||
printf("P2P Connectivity Matrix\n");
|
printf("P2P Connectivity Matrix\n");
|
||||||
printf(" D\\D");
|
printf(" D\\D");
|
||||||
@@ -671,25 +808,25 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Unidirectional P2P=Disabled Bandwidth Matrix (GB/s)\n");
|
printf("Unidirectional P2P=Disabled Bandwidth Matrix (GB/s)\n");
|
||||||
outputBandwidthMatrix(numElems, numGPUs, false, P2P_WRITE);
|
outputBandwidthMatrix(numElems, numGPUs, false, P2P_WRITE, needsFallback);
|
||||||
printf("Unidirectional P2P=Enabled Bandwidth (P2P Writes) Matrix (GB/s)\n");
|
printf("Unidirectional P2P=Enabled Bandwidth (P2P Writes) Matrix (GB/s)\n");
|
||||||
outputBandwidthMatrix(numElems, numGPUs, true, P2P_WRITE);
|
outputBandwidthMatrix(numElems, numGPUs, true, P2P_WRITE, needsFallback);
|
||||||
if (p2p_method == P2P_READ) {
|
if (p2p_method == P2P_READ) {
|
||||||
printf("Unidirectional P2P=Enabled Bandwidth (P2P Reads) Matrix (GB/s)\n");
|
printf("Unidirectional P2P=Enabled Bandwidth (P2P Reads) Matrix (GB/s)\n");
|
||||||
outputBandwidthMatrix(numElems, numGPUs, true, p2p_method);
|
outputBandwidthMatrix(numElems, numGPUs, true, p2p_method, needsFallback);
|
||||||
}
|
}
|
||||||
printf("Bidirectional P2P=Disabled Bandwidth Matrix (GB/s)\n");
|
printf("Bidirectional P2P=Disabled Bandwidth Matrix (GB/s)\n");
|
||||||
outputBidirectionalBandwidthMatrix(numElems, numGPUs, false);
|
outputBidirectionalBandwidthMatrix(numElems, numGPUs, false, needsFallback);
|
||||||
printf("Bidirectional P2P=Enabled Bandwidth Matrix (GB/s)\n");
|
printf("Bidirectional P2P=Enabled Bandwidth Matrix (GB/s)\n");
|
||||||
outputBidirectionalBandwidthMatrix(numElems, numGPUs, true);
|
outputBidirectionalBandwidthMatrix(numElems, numGPUs, true, needsFallback);
|
||||||
|
|
||||||
printf("P2P=Disabled Latency Matrix (us)\n");
|
printf("P2P=Disabled Latency Matrix (us)\n");
|
||||||
outputLatencyMatrix(numGPUs, false, P2P_WRITE);
|
outputLatencyMatrix(numGPUs, false, P2P_WRITE, needsFallback);
|
||||||
printf("P2P=Enabled Latency (P2P Writes) Matrix (us)\n");
|
printf("P2P=Enabled Latency (P2P Writes) Matrix (us)\n");
|
||||||
outputLatencyMatrix(numGPUs, true, P2P_WRITE);
|
outputLatencyMatrix(numGPUs, true, P2P_WRITE, needsFallback);
|
||||||
if (p2p_method == P2P_READ) {
|
if (p2p_method == P2P_READ) {
|
||||||
printf("P2P=Enabled Latency (P2P Reads) Matrix (us)\n");
|
printf("P2P=Enabled Latency (P2P Reads) Matrix (us)\n");
|
||||||
outputLatencyMatrix(numGPUs, true, p2p_method);
|
outputLatencyMatrix(numGPUs, true, p2p_method, needsFallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nNOTE: The CUDA Samples are not meant for performance measurements. "
|
printf("\nNOTE: The CUDA Samples are not meant for performance measurements. "
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaHostAlloc, cudaGraphicsUnmapResources, cudaMalloc, cudaFree, cudaGetChannelDesc, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaMemcpyToArray, cudaDeviceSynchronize, cudaCreateTextureObject, cudaProcess, cudaGraphicsUnregisterResource, cudaGraphicsSubResourceGetMappedArray, cudaGraphicsGLRegisterBuffer, cudaGraphicsGLRegisterImage
|
cudaHostAlloc, cudaGraphicsUnmapResources, cudaMalloc, cudaFree, cudaGetChannelDesc, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaMemcpyToArray, cudaDeviceSynchronize, cudaCreateTextureObject, cudaProcess, cudaGraphicsUnregisterResource, cudaGraphicsSubResourceGetMappedArray, cudaGraphicsGLRegisterBuffer, cudaGraphicsGLRegisterImage
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaGetDevice, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaGetDevice, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaStreamCreateWithFlags, cudaExternalMemoryGetMappedBuffer, cudaSignalSemaphore, cudaWaitExternalSemaphoresAsync, cudaVertMem, cudaImportExternalSemaphore, cudaWaitSemaphore, cudaHeightMap, cudaSetDevice, cudaGetDeviceCount, cudaSignalExternalSemaphoresAsync, cudaTimelineSemaphore, cudaStreamSynchronize, cudaDestroyExternalMemory, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaImportExternalMemory, cudaGetDeviceProperties, cudaDestroyExternalSemaphore
|
cudaStreamCreateWithFlags, cudaExternalMemoryGetMappedBuffer, cudaSignalSemaphore, cudaWaitExternalSemaphoresAsync, cudaVertMem, cudaImportExternalSemaphore, cudaWaitSemaphore, cudaHeightMap, cudaSetDevice, cudaGetDeviceCount, cudaSignalExternalSemaphoresAsync, cudaTimelineSemaphore, cudaStreamSynchronize, cudaDestroyExternalMemory, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaImportExternalMemory, cudaGetDeviceProperties, cudaDestroyExternalSemaphore
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [VULKAN](../../../README.md#vulkan)
|
[X11](../../../README.md#x11), [VULKAN](../../../README.md#vulkan), [GLFW](../../../README.md#glfw)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -144,8 +144,9 @@ VulkanBaseApp::~VulkanBaseApp()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _VK_TIMELINE_SEMAPHORE
|
#ifdef _VK_TIMELINE_SEMAPHORE
|
||||||
if (m_vkPresentationSemaphore != VK_NULL_HANDLE) {
|
for (size_t i = 0; i < m_vkImageAcquiredSemaphores.size(); i++) {
|
||||||
vkDestroySemaphore(m_device, m_vkPresentationSemaphore, nullptr);
|
vkDestroySemaphore(m_device, m_vkImageAcquiredSemaphores[i], nullptr);
|
||||||
|
vkDestroySemaphore(m_device, m_vkRenderCompleteSemaphores[i], nullptr);
|
||||||
}
|
}
|
||||||
#endif /* _VK_TIMELINE_SEMAPHORE */
|
#endif /* _VK_TIMELINE_SEMAPHORE */
|
||||||
|
|
||||||
@@ -1351,8 +1352,15 @@ void VulkanBaseApp::createSyncObjects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _VK_TIMELINE_SEMAPHORE
|
#ifdef _VK_TIMELINE_SEMAPHORE
|
||||||
if (vkCreateSemaphore(m_device, &semaphoreInfo, nullptr, &m_vkPresentationSemaphore) != VK_SUCCESS) {
|
m_vkImageAcquiredSemaphores.resize(MAX_FRAMES_IN_FLIGHT);
|
||||||
throw std::runtime_error("Failed to create binary semaphore!");
|
m_vkRenderCompleteSemaphores.resize(MAX_FRAMES_IN_FLIGHT);
|
||||||
|
for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
|
||||||
|
if (vkCreateSemaphore(m_device, &semaphoreInfo, nullptr, &m_vkImageAcquiredSemaphores[i]) != VK_SUCCESS) {
|
||||||
|
throw std::runtime_error("Failed to create image acquired semaphore!");
|
||||||
|
}
|
||||||
|
if (vkCreateSemaphore(m_device, &semaphoreInfo, nullptr, &m_vkRenderCompleteSemaphores[i]) != VK_SUCCESS) {
|
||||||
|
throw std::runtime_error("Failed to create render complete semaphore!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* _VK_TIMELINE_SEMAPHORE */
|
#endif /* _VK_TIMELINE_SEMAPHORE */
|
||||||
}
|
}
|
||||||
@@ -1634,6 +1642,12 @@ void VulkanBaseApp::drawFrame()
|
|||||||
static uint64_t waitValue = 0;
|
static uint64_t waitValue = 0;
|
||||||
static uint64_t signalValue = 1;
|
static uint64_t signalValue = 1;
|
||||||
|
|
||||||
|
size_t currentFrameIdx = m_currentFrame % MAX_FRAMES_IN_FLIGHT;
|
||||||
|
|
||||||
|
// Wait for this frame's fence to avoid VUID-vkAcquireNextImageKHR-semaphore-01779
|
||||||
|
// Ensures previous frame's GPU work completes before reusing per-frame semaphores
|
||||||
|
vkWaitForFences(m_device, 1, &m_inFlightFences[currentFrameIdx], VK_TRUE, std::numeric_limits<uint64_t>::max());
|
||||||
|
|
||||||
VkSemaphoreWaitInfo semaphoreWaitInfo = {};
|
VkSemaphoreWaitInfo semaphoreWaitInfo = {};
|
||||||
semaphoreWaitInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
|
semaphoreWaitInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
|
||||||
semaphoreWaitInfo.pSemaphores = &m_vkTimelineSemaphore;
|
semaphoreWaitInfo.pSemaphores = &m_vkTimelineSemaphore;
|
||||||
@@ -1641,20 +1655,26 @@ void VulkanBaseApp::drawFrame()
|
|||||||
semaphoreWaitInfo.pValues = &waitValue;
|
semaphoreWaitInfo.pValues = &waitValue;
|
||||||
vkWaitSemaphores(m_device, &semaphoreWaitInfo, std::numeric_limits<uint64_t>::max());
|
vkWaitSemaphores(m_device, &semaphoreWaitInfo, std::numeric_limits<uint64_t>::max());
|
||||||
|
|
||||||
|
// Use separate binary semaphores for swapchain sync to avoid VUID-01779
|
||||||
|
// Timeline semaphore (m_vkTimelineSemaphore) is dedicated to Vulkan-CUDA interop
|
||||||
uint32_t imageIndex;
|
uint32_t imageIndex;
|
||||||
VkResult result = vkAcquireNextImageKHR(m_device,
|
VkResult result = vkAcquireNextImageKHR(m_device,
|
||||||
m_swapChain,
|
m_swapChain,
|
||||||
std::numeric_limits<uint64_t>::max(),
|
std::numeric_limits<uint64_t>::max(),
|
||||||
m_vkPresentationSemaphore,
|
m_vkImageAcquiredSemaphores[currentFrameIdx],
|
||||||
VK_NULL_HANDLE,
|
VK_NULL_HANDLE,
|
||||||
&imageIndex);
|
&imageIndex);
|
||||||
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
|
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||||
recreateSwapChain();
|
recreateSwapChain();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
|
else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
|
||||||
throw std::runtime_error("Failed to acquire swap chain image!");
|
throw std::runtime_error("Failed to acquire swap chain image!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset the fence for this frame
|
||||||
|
vkResetFences(m_device, 1, &m_inFlightFences[currentFrameIdx]);
|
||||||
|
|
||||||
updateUniformBuffer(imageIndex);
|
updateUniformBuffer(imageIndex);
|
||||||
|
|
||||||
VkSubmitInfo submitInfo = {};
|
VkSubmitInfo submitInfo = {};
|
||||||
@@ -1663,6 +1683,8 @@ void VulkanBaseApp::drawFrame()
|
|||||||
std::vector<VkSemaphore> waitSemaphores;
|
std::vector<VkSemaphore> waitSemaphores;
|
||||||
std::vector<VkPipelineStageFlags> waitStages;
|
std::vector<VkPipelineStageFlags> waitStages;
|
||||||
|
|
||||||
|
waitSemaphores.push_back(m_vkImageAcquiredSemaphores[currentFrameIdx]);
|
||||||
|
waitStages.push_back(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
|
||||||
waitSemaphores.push_back(m_vkTimelineSemaphore);
|
waitSemaphores.push_back(m_vkTimelineSemaphore);
|
||||||
waitStages.push_back(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
|
waitStages.push_back(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
|
||||||
|
|
||||||
@@ -1675,26 +1697,30 @@ void VulkanBaseApp::drawFrame()
|
|||||||
|
|
||||||
std::vector<VkSemaphore> signalSemaphores;
|
std::vector<VkSemaphore> signalSemaphores;
|
||||||
signalSemaphores.push_back(m_vkTimelineSemaphore);
|
signalSemaphores.push_back(m_vkTimelineSemaphore);
|
||||||
|
signalSemaphores.push_back(m_vkRenderCompleteSemaphores[currentFrameIdx]);
|
||||||
submitInfo.signalSemaphoreCount = (uint32_t)signalSemaphores.size();
|
submitInfo.signalSemaphoreCount = (uint32_t)signalSemaphores.size();
|
||||||
submitInfo.pSignalSemaphores = signalSemaphores.data();
|
submitInfo.pSignalSemaphores = signalSemaphores.data();
|
||||||
|
|
||||||
VkTimelineSemaphoreSubmitInfo timelineInfo = {};
|
VkTimelineSemaphoreSubmitInfo timelineInfo = {};
|
||||||
timelineInfo.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO;
|
timelineInfo.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO;
|
||||||
timelineInfo.waitSemaphoreValueCount = 1;
|
timelineInfo.waitSemaphoreValueCount = 2;
|
||||||
timelineInfo.pWaitSemaphoreValues = &waitValue;
|
uint64_t waitValues[] = {0, waitValue};
|
||||||
timelineInfo.signalSemaphoreValueCount = 1;
|
timelineInfo.pWaitSemaphoreValues = waitValues;
|
||||||
timelineInfo.pSignalSemaphoreValues = &signalValue;
|
timelineInfo.signalSemaphoreValueCount = 2;
|
||||||
|
uint64_t signalValues[] = {signalValue, 0};
|
||||||
|
timelineInfo.pSignalSemaphoreValues = signalValues;
|
||||||
|
|
||||||
submitInfo.pNext = &timelineInfo;
|
submitInfo.pNext = &timelineInfo;
|
||||||
|
|
||||||
if (vkQueueSubmit(m_graphicsQueue, 1, &submitInfo, VK_NULL_HANDLE) != VK_SUCCESS) {
|
// Submit with fence to track when this frame completes
|
||||||
|
if (vkQueueSubmit(m_graphicsQueue, 1, &submitInfo, m_inFlightFences[currentFrameIdx]) != VK_SUCCESS) {
|
||||||
throw std::runtime_error("failed to submit draw command buffer!");
|
throw std::runtime_error("failed to submit draw command buffer!");
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPresentInfoKHR presentInfo = {};
|
VkPresentInfoKHR presentInfo = {};
|
||||||
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
presentInfo.waitSemaphoreCount = 1;
|
presentInfo.waitSemaphoreCount = 1;
|
||||||
presentInfo.pWaitSemaphores = &m_vkPresentationSemaphore;
|
presentInfo.pWaitSemaphores = &m_vkRenderCompleteSemaphores[currentFrameIdx];
|
||||||
|
|
||||||
VkSwapchainKHR swapChains[] = {m_swapChain};
|
VkSwapchainKHR swapChains[] = {m_swapChain};
|
||||||
presentInfo.swapchainCount = 1;
|
presentInfo.swapchainCount = 1;
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ protected:
|
|||||||
std::vector<VkFence> m_inFlightFences;
|
std::vector<VkFence> m_inFlightFences;
|
||||||
std::vector<VkBuffer> m_uniformBuffers;
|
std::vector<VkBuffer> m_uniformBuffers;
|
||||||
std::vector<VkDeviceMemory> m_uniformMemory;
|
std::vector<VkDeviceMemory> m_uniformMemory;
|
||||||
VkSemaphore m_vkPresentationSemaphore;
|
std::vector<VkSemaphore> m_vkImageAcquiredSemaphores;
|
||||||
|
std::vector<VkSemaphore> m_vkRenderCompleteSemaphores;
|
||||||
VkSemaphore m_vkTimelineSemaphore;
|
VkSemaphore m_vkTimelineSemaphore;
|
||||||
VkDescriptorSetLayout m_descriptorSetLayout;
|
VkDescriptorSetLayout m_descriptorSetLayout;
|
||||||
VkDescriptorPool m_descriptorPool;
|
VkDescriptorPool m_descriptorPool;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
typedef float vec2[2];
|
typedef float vec2[2];
|
||||||
std::string execution_path;
|
std::string execution_path;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define ENABLE_VALIDATION (false)
|
#define ENABLE_VALIDATION (false)
|
||||||
#else
|
#else
|
||||||
#define ENABLE_VALIDATION (true)
|
#define ENABLE_VALIDATION (true)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ cuMemCreate, cuMemAddressReserve, cuMemGetAllocationGranularity, cuMemAddressFre
|
|||||||
cudaWaitExternalSemaphoresAsync, cudaImportExternalSemaphore, cudaDeviceGetAttribute, cudaSetDevice, cudaLaunchHostFunc, cudaMallocHost, cudaSignalExternalSemaphoresAsync, cudaFreeHost, cudaMemsetAsync, cudaMemcpyAsync, cudaGetDeviceCount, cudaStreamCreateWithFlags, cudaStreamDestroy, cudaDestroyExternalSemaphore, cudaSignalSemaphore, cudaWaitSemaphore, cudaFree, cudaStreamSynchronize, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties
|
cudaWaitExternalSemaphoresAsync, cudaImportExternalSemaphore, cudaDeviceGetAttribute, cudaSetDevice, cudaLaunchHostFunc, cudaMallocHost, cudaSignalExternalSemaphoresAsync, cudaFreeHost, cudaMemsetAsync, cudaMemcpyAsync, cudaGetDeviceCount, cudaStreamCreateWithFlags, cudaStreamDestroy, cudaDestroyExternalSemaphore, cudaSignalSemaphore, cudaWaitSemaphore, cudaFree, cudaStreamSynchronize, cudaMalloc, cudaOccupancyMaxActiveBlocksPerMultiprocessor, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [VULKAN](../../../README.md#vulkan)
|
[X11](../../../README.md#x11), [VULKAN](../../../README.md#vulkan), [GLFW](../../../README.md#glfw)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
#include "helper_multiprocess.h"
|
#include "helper_multiprocess.h"
|
||||||
|
|
||||||
// #define DEBUG
|
// #define DEBUG
|
||||||
#ifndef DEBUG
|
#ifdef NDEBUG
|
||||||
#define ENABLE_VALIDATION (false)
|
#define ENABLE_VALIDATION (false)
|
||||||
#else
|
#else
|
||||||
#define ENABLE_VALIDATION (true)
|
#define ENABLE_VALIDATION (true)
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ extern "C"
|
|||||||
thrust::device_ptr<float4> d_oldVel(oldVel);
|
thrust::device_ptr<float4> d_oldVel(oldVel);
|
||||||
|
|
||||||
thrust::for_each(
|
thrust::for_each(
|
||||||
thrust::make_zip_iterator(thrust::make_tuple(d_newPos, d_newVel, d_oldPos, d_oldVel)),
|
thrust::make_zip_iterator(d_newPos, d_newVel, d_oldPos, d_oldVel),
|
||||||
thrust::make_zip_iterator(thrust::make_tuple(
|
thrust::make_zip_iterator(
|
||||||
d_newPos + numParticles, d_newVel + numParticles, d_oldPos + numParticles, d_oldVel + numParticles)),
|
d_newPos + numParticles, d_newVel + numParticles, d_oldPos + numParticles, d_oldVel + numParticles),
|
||||||
integrate_functor(deltaTime, noiseTex));
|
integrate_functor(deltaTime, noiseTex));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,8 +143,8 @@ extern "C"
|
|||||||
thrust::device_ptr<float> d_keys(keys);
|
thrust::device_ptr<float> d_keys(keys);
|
||||||
thrust::device_ptr<uint> d_indices(indices);
|
thrust::device_ptr<uint> d_indices(indices);
|
||||||
|
|
||||||
thrust::for_each(thrust::make_zip_iterator(thrust::make_tuple(d_pos, d_keys)),
|
thrust::for_each(thrust::make_zip_iterator(d_pos, d_keys),
|
||||||
thrust::make_zip_iterator(thrust::make_tuple(d_pos + numParticles, d_keys + numParticles)),
|
thrust::make_zip_iterator(d_pos + numParticles, d_keys + numParticles),
|
||||||
calcDepth_functor(sortVector));
|
calcDepth_functor(sortVector));
|
||||||
|
|
||||||
thrust::sequence(d_indices, d_indices + numParticles);
|
thrust::sequence(d_indices, d_indices + numParticles);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaExtent, cudaPitchedPtr, cudaCreateTextureObject, cudaMemcpyToSymbol
|
cudaExtent, cudaPitchedPtr, cudaCreateTextureObject, cudaMemcpyToSymbol
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,9 @@
|
|||||||
#include "thrust/iterator/zip_iterator.h"
|
#include "thrust/iterator/zip_iterator.h"
|
||||||
#include "thrust/sort.h"
|
#include "thrust/sort.h"
|
||||||
|
|
||||||
|
// for cuda::std::get
|
||||||
|
#include <cuda/std/utility>
|
||||||
|
|
||||||
cudaTextureObject_t noiseTex;
|
cudaTextureObject_t noiseTex;
|
||||||
// simulation parameters
|
// simulation parameters
|
||||||
__constant__ SimParams cudaParams;
|
__constant__ SimParams cudaParams;
|
||||||
@@ -65,8 +68,8 @@ struct integrate_functor
|
|||||||
|
|
||||||
template <typename Tuple> __device__ void operator()(Tuple t)
|
template <typename Tuple> __device__ void operator()(Tuple t)
|
||||||
{
|
{
|
||||||
volatile float4 posData = thrust::get<2>(t);
|
volatile float4 posData = cuda::std::get<2>(t);
|
||||||
volatile float4 velData = thrust::get<3>(t);
|
volatile float4 velData = cuda::std::get<3>(t);
|
||||||
|
|
||||||
float3 pos = make_float3(posData.x, posData.y, posData.z);
|
float3 pos = make_float3(posData.x, posData.y, posData.z);
|
||||||
float3 vel = make_float3(velData.x, velData.y, velData.z);
|
float3 vel = make_float3(velData.x, velData.y, velData.z);
|
||||||
@@ -95,8 +98,8 @@ struct integrate_functor
|
|||||||
vel *= cudaParams.globalDamping;
|
vel *= cudaParams.globalDamping;
|
||||||
|
|
||||||
// store new position and velocity
|
// store new position and velocity
|
||||||
thrust::get<0>(t) = make_float4(pos, age);
|
cuda::std::get<0>(t) = make_float4(pos, age);
|
||||||
thrust::get<1>(t) = make_float4(vel, velData.w);
|
cuda::std::get<1>(t) = make_float4(vel, velData.w);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,10 +114,10 @@ struct calcDepth_functor
|
|||||||
|
|
||||||
template <typename Tuple> __host__ __device__ void operator()(Tuple t)
|
template <typename Tuple> __host__ __device__ void operator()(Tuple t)
|
||||||
{
|
{
|
||||||
volatile float4 p = thrust::get<0>(t);
|
volatile float4 p = cuda::std::get<0>(t);
|
||||||
float key = -dot(make_float3(p.x, p.y, p.z),
|
float key = -dot(make_float3(p.x, p.y, p.z),
|
||||||
sortVector); // project onto sort vector
|
sortVector); // project onto sort vector
|
||||||
thrust::get<1>(t) = key;
|
cuda::std::get<1>(t) = key;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaMemcpy, cudaGraphicsMapResources, cudaDestroySurfaceObject, cudaExtent, cudaDeviceSynchronize, cudaCreateSurfaceObject, cudaMemcpyToSymbol, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaCreateTextureObject, cudaGraphicsUnmapResources, cudaMallocArray, cudaFreeArray, cudaDestroyTextureObject, cudaMemset, cudaGraphicsGLRegisterBuffer, cudaFree, cudaGraphicsUnregisterResource, cudaMalloc
|
cudaMemcpy, cudaGraphicsMapResources, cudaDestroySurfaceObject, cudaExtent, cudaDeviceSynchronize, cudaCreateSurfaceObject, cudaMemcpyToSymbol, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaCreateTextureObject, cudaGraphicsUnmapResources, cudaMallocArray, cudaFreeArray, cudaDestroyTextureObject, cudaMemset, cudaGraphicsGLRegisterBuffer, cudaFree, cudaGraphicsUnregisterResource, cudaMalloc
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, armv7l
|
|||||||
cudaProfilerStop, cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaExtent, cudaDeviceSynchronize, cudaCreateTextureObject, cudaMemset, cudaMemcpyToSymbol, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaProfilerStop, cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaPitchedPtr, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaExtent, cudaDeviceSynchronize, cudaCreateTextureObject, cudaMemset, cudaMemcpyToSymbol, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GL](../../../README.md#gl)
|
[X11](../../../README.md#x11), [OpenGL](../../../README.md#opengl), [Freeglut](../../../README.md#freeglut), [GLEW](../../../README.md#glew)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ x86_64, aarch64
|
|||||||
cudaVkSemaphoreSignal, cudaWaitExternalSemaphoresAsync, cudaMemcpy, cudaVkImportSemaphore, cudaImportExternalSemaphore, cudaGetMipmappedArrayLevel, cudaSetDevice, cudaDestroySurfaceObject, cudaExtent, cudaMallocMipmappedArray, cudaCreateSurfaceObject, cudaStreamCreate, cudaSignalExternalSemaphoresAsync, cudaUpdateVkImage, cudaCreateTextureObject, cudaGetDeviceCount, cudaExternalMemoryGetMappedMipmappedArray, cudaDestroyTextureObject, cudaVkImportImageMem, cudaDestroyExternalMemory, cudaVkSemaphoreWait, cudaImportExternalMemory, cudaDestroyExternalSemaphore, cudaFreeMipmappedArray, cudaFree, cudaMalloc, cudaGetDeviceProperties
|
cudaVkSemaphoreSignal, cudaWaitExternalSemaphoresAsync, cudaMemcpy, cudaVkImportSemaphore, cudaImportExternalSemaphore, cudaGetMipmappedArrayLevel, cudaSetDevice, cudaDestroySurfaceObject, cudaExtent, cudaMallocMipmappedArray, cudaCreateSurfaceObject, cudaStreamCreate, cudaSignalExternalSemaphoresAsync, cudaUpdateVkImage, cudaCreateTextureObject, cudaGetDeviceCount, cudaExternalMemoryGetMappedMipmappedArray, cudaDestroyTextureObject, cudaVkImportImageMem, cudaDestroyExternalMemory, cudaVkSemaphoreWait, cudaImportExternalMemory, cudaDestroyExternalSemaphore, cudaFreeMipmappedArray, cudaFree, cudaMalloc, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [VULKAN](../../../README.md#vulkan)
|
[X11](../../../README.md#x11), [VULKAN](../../../README.md#vulkan), [GLFW](../../../README.md#glfw)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ const int MAX_FRAMES = 4;
|
|||||||
const std::vector<const char *> validationLayers = {"VK_LAYER_KHRONOS_validation"};
|
const std::vector<const char *> validationLayers = {"VK_LAYER_KHRONOS_validation"};
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
const bool enableValidationLayers = true;
|
|
||||||
#else
|
|
||||||
const bool enableValidationLayers = false;
|
const bool enableValidationLayers = false;
|
||||||
|
#else
|
||||||
|
const bool enableValidationLayers = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string execution_path;
|
std::string execution_path;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ x86_64, armv7l, aarch64
|
|||||||
cudaMemcpy, cudaStreamDestroy, cudaMemPrefetchAsync, cudaFree, cudaMallocHost, cudaMallocManaged, cudaStreamAttachMemAsync, cudaHostGetDevicePointer, cudaFreeHost, cudaStreamSynchronize, cudaMalloc, cudaMemcpyAsync, cudaStreamCreate, cudaGetDeviceProperties
|
cudaMemcpy, cudaStreamDestroy, cudaMemPrefetchAsync, cudaFree, cudaMallocHost, cudaMallocManaged, cudaStreamAttachMemAsync, cudaHostGetDevicePointer, cudaFreeHost, cudaStreamSynchronize, cudaMalloc, cudaMemcpyAsync, cudaStreamCreate, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[UVM](../../../README.md#uvm)
|
[UVM](../../../README.md#unified-virtual-memory)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -664,7 +664,17 @@ int main(int argc, char **argv)
|
|||||||
verboseResults = 1;
|
verboseResults = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set device
|
||||||
|
cudaDeviceProp device_prop;
|
||||||
int device_id = findCudaDevice(argc, (const char **)argv);
|
int device_id = findCudaDevice(argc, (const char **)argv);
|
||||||
|
checkCudaErrors(cudaGetDeviceProperties(&device_prop, device_id));
|
||||||
|
|
||||||
|
if (!device_prop.managedMemory) {
|
||||||
|
// This samples requires being run on a device that supports Unified Memory
|
||||||
|
fprintf(stderr, "Unified Memory not supported on this device\n");
|
||||||
|
|
||||||
|
exit(EXIT_WAIVED);
|
||||||
|
}
|
||||||
|
|
||||||
matrixMultiplyPerfRunner(reportAsBandwidth, print_launch_transfer_results, print_std_deviation, device_id);
|
matrixMultiplyPerfRunner(reportAsBandwidth, print_launch_transfer_results, print_std_deviation, device_id);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ cuEventRecord, cuDeviceGetAttribute, cuEventCreate, cuCtxSynchronize, cuEventDes
|
|||||||
cudaMemcpy, cudaGetErrorString, cudaFree, cudaDeviceSynchronize, cudaGetValueMismatch, cudaMalloc
|
cudaMemcpy, cudaGetErrorString, cudaFree, cudaDeviceSynchronize, cudaGetValueMismatch, cudaMalloc
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[EGL](../../../README.md#egl), [EGLSync](../../../README.md#eglsync), [X11](../../../README.md#x11), [GLES](../../../README.md#gles)
|
[EGL](../../../README.md#egl), [EGLSync](../../../README.md#eglsync), [X11](../../../README.md#x11), [OpenGL ES](../../../README.md#opengl-es)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaMallocPitch, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaMallocArray, cudaFreeArray, cudaFree, cudaMallocPitch, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDestroyTextureObject, cudaCreateTextureObject, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer, cudaGetDeviceProperties
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GLES](../../../README.md#gles), [CUFFT](../../../README.md#cufft)
|
[X11](../../../README.md#x11), [OpenGL ES](../../../README.md#opengl-es), [CUFFT](../../../README.md#cufft)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaSetDeviceFlags, cudaGraphicsResourceSetMapFlags, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaSetDevice, cudaEventSynchronize, cudaGetDeviceProperties, cudaDeviceSynchronize, cudaEventRecord, cudaGetDevice, cudaMemcpyToSymbol, cudaStreamQuery, cudaEventDestroy, cudaEventElapsedTime, cudaGetDeviceCount, cudaEventCreate
|
cudaGraphicsUnmapResources, cudaSetDeviceFlags, cudaGraphicsResourceSetMapFlags, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaSetDevice, cudaEventSynchronize, cudaGetDeviceProperties, cudaDeviceSynchronize, cudaEventRecord, cudaGetDevice, cudaMemcpyToSymbol, cudaStreamQuery, cudaEventDestroy, cudaEventElapsedTime, cudaGetDeviceCount, cudaEventCreate
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GLES](../../../README.md#gles)
|
[X11](../../../README.md#x11), [OpenGL ES](../../../README.md#opengl-es)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[X11](../../../README.md#x11), [GLES](../../../README.md#gles)
|
[X11](../../../README.md#x11), [OpenGL ES](../../../README.md#opengl-es)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ armv7l
|
|||||||
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
cudaGraphicsUnmapResources, cudaMemcpy, cudaFree, cudaGraphicsResourceGetMappedPointer, cudaGraphicsMapResources, cudaDeviceSynchronize, cudaGraphicsUnregisterResource, cudaMalloc, cudaGraphicsGLRegisterBuffer
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
## Dependencies needed to build/run
|
||||||
[EGLOutput](../../../README.md#egloutput), [GLES](../../../README.md#gles)
|
[EGLOutput](../../../README.md#egloutput), [OpenGL ES](../../../README.md#opengl-es)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -79,12 +79,22 @@ if(NOT CUDA_SAMPLES_INSTALL_CONFIGURED)
|
|||||||
if(NOT EXISTS "${ROOT_BINARY_DIR}/CMakeCache.txt")
|
if(NOT EXISTS "${ROOT_BINARY_DIR}/CMakeCache.txt")
|
||||||
set(ROOT_BINARY_DIR "${CMAKE_BINARY_DIR}")
|
set(ROOT_BINARY_DIR "${CMAKE_BINARY_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
# If user didn't specify CMAKE_INSTALL_PREFIX, default to build/bin
|
||||||
set(CMAKE_INSTALL_PREFIX "${ROOT_BINARY_DIR}/bin" CACHE PATH "Installation directory" FORCE)
|
set(CMAKE_INSTALL_PREFIX "${ROOT_BINARY_DIR}/bin" CACHE PATH "Installation directory" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create the installation path: bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
# Create the installation path: bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
# For multi-config generators, this will be evaluated at install time
|
# For multi-config generators, this will be evaluated at install time
|
||||||
set(CUDA_SAMPLES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${TARGET_OS}/${BUILD_TYPE_EXPR}" CACHE INTERNAL "Install directory for samples")
|
if(NOT DEFINED CUDA_SAMPLES_INSTALL_DIR)
|
||||||
|
set(CUDA_SAMPLES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${TARGET_OS}/${BUILD_TYPE_EXPR}" CACHE PATH "Install directory for samples")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check if we should use the default dynamic installation logic
|
||||||
|
if("${CUDA_SAMPLES_INSTALL_DIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${TARGET_OS}/${BUILD_TYPE_EXPR}")
|
||||||
|
set(CUDA_SAMPLES_INSTALL_USE_DEFAULT TRUE)
|
||||||
|
else()
|
||||||
|
set(CUDA_SAMPLES_INSTALL_USE_DEFAULT FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Print installation configuration
|
# Print installation configuration
|
||||||
message(STATUS "CUDA Samples installation configured:")
|
message(STATUS "CUDA Samples installation configured:")
|
||||||
@@ -102,10 +112,10 @@ endif()
|
|||||||
# Function to setup installation for regular samples
|
# Function to setup installation for regular samples
|
||||||
# This should be called after all targets are defined
|
# This should be called after all targets are defined
|
||||||
function(setup_samples_install)
|
function(setup_samples_install)
|
||||||
# Create an install script that will copy executables and specific file types
|
# Create an install script that copies executables, data files, and shared libraries
|
||||||
# All files are copied to flat root directory
|
# This script only installs - build must be done separately
|
||||||
# This script runs at install time, after the build is complete
|
|
||||||
install(CODE "
|
install(CODE "
|
||||||
|
if(\"${CUDA_SAMPLES_INSTALL_USE_DEFAULT}\" STREQUAL \"TRUE\")
|
||||||
# Determine the actual install directory based on the configuration
|
# Determine the actual install directory based on the configuration
|
||||||
# CMAKE_INSTALL_CONFIG_NAME is available at install time for multi-config generators
|
# CMAKE_INSTALL_CONFIG_NAME is available at install time for multi-config generators
|
||||||
if(DEFINED CMAKE_INSTALL_CONFIG_NAME)
|
if(DEFINED CMAKE_INSTALL_CONFIG_NAME)
|
||||||
@@ -114,6 +124,9 @@ function(setup_samples_install)
|
|||||||
set(INSTALL_BUILD_TYPE \"${BUILD_TYPE_EXPR}\")
|
set(INSTALL_BUILD_TYPE \"${BUILD_TYPE_EXPR}\")
|
||||||
endif()
|
endif()
|
||||||
set(INSTALL_DIR \"${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${TARGET_OS}/\${INSTALL_BUILD_TYPE}\")
|
set(INSTALL_DIR \"${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${TARGET_OS}/\${INSTALL_BUILD_TYPE}\")
|
||||||
|
else()
|
||||||
|
set(INSTALL_DIR \"${CUDA_SAMPLES_INSTALL_DIR}\")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Search in the current project's binary directory for built executables
|
# Search in the current project's binary directory for built executables
|
||||||
file(GLOB_RECURSE BINARY_FILES
|
file(GLOB_RECURSE BINARY_FILES
|
||||||
|
|||||||
Reference in New Issue
Block a user