mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2025-07-01 20:20:29 +08:00
Merge branch 'shawnz_bugs_fix' into 'master'
Change for fixing bugs: 5196977, 4914019, 4191696 and 5199167 . See merge request cuda-samples/cuda-samples!97
This commit is contained in:
commit
1fd22429c3
@ -99,8 +99,18 @@ static void childProcess(int id)
|
|||||||
std::vector<void *> ptrs;
|
std::vector<void *> ptrs;
|
||||||
std::vector<cudaEvent_t> events;
|
std::vector<cudaEvent_t> events;
|
||||||
std::vector<char> verification_buffer(DATA_SIZE);
|
std::vector<char> verification_buffer(DATA_SIZE);
|
||||||
|
pid_t pid;
|
||||||
|
char pidString[20] = {0};
|
||||||
|
char lshmName[40] = {0};
|
||||||
|
|
||||||
if (sharedMemoryOpen(shmName, sizeof(shmStruct), &info) != 0) {
|
pid = getppid();
|
||||||
|
snprintf(pidString, sizeof(pidString), "%d", pid);
|
||||||
|
strcat(lshmName, shmName);
|
||||||
|
strcat(lshmName, pidString);
|
||||||
|
|
||||||
|
printf("CP: lshmName = %s\n", lshmName);
|
||||||
|
|
||||||
|
if (sharedMemoryOpen(lshmName, sizeof(shmStruct), &info) != 0) {
|
||||||
printf("Failed to create shared memory slab\n");
|
printf("Failed to create shared memory slab\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -195,10 +205,20 @@ static void parentProcess(char *app)
|
|||||||
std::vector<void *> ptrs;
|
std::vector<void *> ptrs;
|
||||||
std::vector<cudaEvent_t> events;
|
std::vector<cudaEvent_t> events;
|
||||||
std::vector<Process> processes;
|
std::vector<Process> processes;
|
||||||
|
pid_t pid;
|
||||||
|
char pidString[20] = {0};
|
||||||
|
char lshmName[40] = {0};
|
||||||
|
|
||||||
|
pid = getpid();
|
||||||
|
snprintf(pidString, sizeof(pidString), "%d", pid);
|
||||||
|
strcat(lshmName, shmName);
|
||||||
|
strcat(lshmName, pidString);
|
||||||
|
|
||||||
|
printf("PP: lshmName = %s\n", lshmName);
|
||||||
|
|
||||||
checkCudaErrors(cudaGetDeviceCount(&devCount));
|
checkCudaErrors(cudaGetDeviceCount(&devCount));
|
||||||
|
|
||||||
if (sharedMemoryCreate(shmName, sizeof(*shm), &info) != 0) {
|
if (sharedMemoryCreate(lshmName, sizeof(*shm), &info) != 0) {
|
||||||
printf("Failed to create shared memory slab\n");
|
printf("Failed to create shared memory slab\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -102,13 +102,23 @@ static void childProcess(int id)
|
|||||||
int threads = 128;
|
int threads = 128;
|
||||||
cudaDeviceProp prop;
|
cudaDeviceProp prop;
|
||||||
std::vector<void *> ptrs;
|
std::vector<void *> ptrs;
|
||||||
|
pid_t pid;
|
||||||
|
char pidString[20] = {0};
|
||||||
|
char lshmName[40] = {0};
|
||||||
|
|
||||||
std::vector<char> verification_buffer(DATA_SIZE);
|
std::vector<char> verification_buffer(DATA_SIZE);
|
||||||
|
|
||||||
|
pid = getppid();
|
||||||
|
snprintf(pidString, sizeof(pidString), "%d", pid);
|
||||||
|
strcat(lshmName, shmName);
|
||||||
|
strcat(lshmName, pidString);
|
||||||
|
|
||||||
|
printf("CP: lshmName = %s\n", lshmName);
|
||||||
|
|
||||||
ipcHandle *ipcChildHandle = NULL;
|
ipcHandle *ipcChildHandle = NULL;
|
||||||
checkIpcErrors(ipcOpenSocket(ipcChildHandle));
|
checkIpcErrors(ipcOpenSocket(ipcChildHandle));
|
||||||
|
|
||||||
if (sharedMemoryOpen(shmName, sizeof(shmStruct), &info) != 0) {
|
if (sharedMemoryOpen(lshmName, sizeof(shmStruct), &info) != 0) {
|
||||||
printf("Failed to create shared memory slab\n");
|
printf("Failed to create shared memory slab\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -245,6 +255,16 @@ static void parentProcess(char *app)
|
|||||||
std::vector<void *> ptrs;
|
std::vector<void *> ptrs;
|
||||||
std::vector<Process> processes;
|
std::vector<Process> processes;
|
||||||
cudaMemAllocationHandleType handleType = cudaMemHandleTypeNone;
|
cudaMemAllocationHandleType handleType = cudaMemHandleTypeNone;
|
||||||
|
pid_t pid;
|
||||||
|
char pidString[20] = {0};
|
||||||
|
char lshmName[40] = {0};
|
||||||
|
|
||||||
|
pid = getpid();
|
||||||
|
snprintf(pidString, sizeof(pidString), "%d", pid);
|
||||||
|
strcat(lshmName, shmName);
|
||||||
|
strcat(lshmName, pidString);
|
||||||
|
|
||||||
|
printf("PP: lshmName = %s\n", lshmName);
|
||||||
|
|
||||||
checkCudaErrors(cudaGetDeviceCount(&devCount));
|
checkCudaErrors(cudaGetDeviceCount(&devCount));
|
||||||
std::vector<CUdevice> devices(devCount);
|
std::vector<CUdevice> devices(devCount);
|
||||||
@ -252,7 +272,7 @@ static void parentProcess(char *app)
|
|||||||
cuDeviceGet(&devices[i], i);
|
cuDeviceGet(&devices[i], i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sharedMemoryCreate(shmName, sizeof(*shm), &info) != 0) {
|
if (sharedMemoryCreate(lshmName, sizeof(*shm), &info) != 0) {
|
||||||
printf("Failed to create shared memory slab\n");
|
printf("Failed to create shared memory slab\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -310,10 +310,20 @@ static void childProcess(int devId, int id, char **argv)
|
|||||||
ipcHandle *ipcChildHandle = NULL;
|
ipcHandle *ipcChildHandle = NULL;
|
||||||
int blocks = 0;
|
int blocks = 0;
|
||||||
int threads = 128;
|
int threads = 128;
|
||||||
|
pid_t pid;
|
||||||
|
char pidString[20] = {0};
|
||||||
|
char lshmName[40] = {0};
|
||||||
|
|
||||||
|
pid = getppid();
|
||||||
|
snprintf(pidString, sizeof(pidString), "%d", pid);
|
||||||
|
strcat(lshmName, shmName);
|
||||||
|
strcat(lshmName, pidString);
|
||||||
|
|
||||||
|
printf("CP: lshmName = %s\n", lshmName);
|
||||||
|
|
||||||
checkIpcErrors(ipcOpenSocket(ipcChildHandle));
|
checkIpcErrors(ipcOpenSocket(ipcChildHandle));
|
||||||
|
|
||||||
if (sharedMemoryOpen(shmName, sizeof(shmStruct), &info) != 0) {
|
if (sharedMemoryOpen(lshmName, sizeof(shmStruct), &info) != 0) {
|
||||||
printf("Failed to create shared memory slab\n");
|
printf("Failed to create shared memory slab\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -421,11 +431,20 @@ static void parentProcess(char *app)
|
|||||||
volatile shmStruct *shm = NULL;
|
volatile shmStruct *shm = NULL;
|
||||||
sharedMemoryInfo info;
|
sharedMemoryInfo info;
|
||||||
std::vector<Process> processes;
|
std::vector<Process> processes;
|
||||||
|
pid_t pid;
|
||||||
|
char pidString[20] = {0};
|
||||||
|
char lshmName[40] = {0};
|
||||||
|
|
||||||
|
pid = getpid();
|
||||||
|
snprintf(pidString, sizeof(pidString), "%d", pid);
|
||||||
|
strcat(lshmName, shmName);
|
||||||
|
strcat(lshmName, pidString);
|
||||||
|
|
||||||
|
printf("PP: lshmName = %s\n", lshmName);
|
||||||
checkCudaErrors(cuDeviceGetCount(&devCount));
|
checkCudaErrors(cuDeviceGetCount(&devCount));
|
||||||
std::vector<CUdevice> devices(devCount);
|
std::vector<CUdevice> devices(devCount);
|
||||||
|
|
||||||
if (sharedMemoryCreate(shmName, sizeof(*shm), &info) != 0) {
|
if (sharedMemoryCreate(lshmName, sizeof(*shm), &info) != 0) {
|
||||||
printf("Failed to create shared memory slab\n");
|
printf("Failed to create shared memory slab\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
* 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 <cuda_runtime.h>
|
|
||||||
#include <cuda.h>
|
#include <cuda.h>
|
||||||
|
#include <cuda_runtime.h>
|
||||||
#include <helper_cuda.h>
|
#include <helper_cuda.h>
|
||||||
#include <helper_image.h>
|
#include <helper_image.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -45,13 +45,15 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// includes for OpenGL
|
||||||
|
#include <helper_gl.h>
|
||||||
|
|
||||||
// includes
|
// includes
|
||||||
#include <cuda_gl_interop.h>
|
#include <cuda_gl_interop.h>
|
||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
#include <cufft.h>
|
#include <cufft.h>
|
||||||
#include <helper_cuda.h>
|
#include <helper_cuda.h>
|
||||||
#include <helper_functions.h>
|
#include <helper_functions.h>
|
||||||
#include <helper_gl.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <math_constants.h>
|
#include <math_constants.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -86,12 +86,14 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// includes for OpenGL
|
||||||
|
#include <helper_gl.h>
|
||||||
|
|
||||||
// includes
|
// includes
|
||||||
#include <cuda_gl_interop.h>
|
#include <cuda_gl_interop.h>
|
||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
#include <helper_cuda.h> // includes cuda.h and cuda_runtime_api.h
|
#include <helper_cuda.h> // includes cuda.h and cuda_runtime_api.h
|
||||||
#include <helper_functions.h>
|
#include <helper_functions.h>
|
||||||
#include <helper_gl.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -27,12 +27,14 @@
|
|||||||
|
|
||||||
#include "render_particles.h"
|
#include "render_particles.h"
|
||||||
|
|
||||||
|
// includes for OpenGL
|
||||||
|
#include <helper_gl.h>
|
||||||
|
|
||||||
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
|
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <cuda_gl_interop.h>
|
#include <cuda_gl_interop.h>
|
||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
#include <helper_cuda.h>
|
#include <helper_cuda.h>
|
||||||
#include <helper_gl.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define GL_POINT_SPRITE_ARB 0x8861
|
#define GL_POINT_SPRITE_ARB 0x8861
|
||||||
|
@ -31,9 +31,12 @@
|
|||||||
|
|
||||||
#pragma warning(disable : 4312)
|
#pragma warning(disable : 4312)
|
||||||
|
|
||||||
#include <mmsystem.h>
|
// includes for Windows
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
// includes for multimedia
|
||||||
|
#include <mmsystem.h>
|
||||||
|
|
||||||
// This header inclues all the necessary D3D11 and CUDA includes
|
// This header inclues all the necessary D3D11 and CUDA includes
|
||||||
#include <cuda_d3d11_interop.h>
|
#include <cuda_d3d11_interop.h>
|
||||||
#include <cuda_runtime_api.h>
|
#include <cuda_runtime_api.h>
|
||||||
|
@ -31,9 +31,12 @@
|
|||||||
|
|
||||||
#pragma warning(disable : 4312)
|
#pragma warning(disable : 4312)
|
||||||
|
|
||||||
#include <mmsystem.h>
|
// includes for Windows
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
// includes for multimedia
|
||||||
|
#include <mmsystem.h>
|
||||||
|
|
||||||
// This header inclues all the necessary D3D11 and CUDA includes
|
// This header inclues all the necessary D3D11 and CUDA includes
|
||||||
#include <cuda_d3d11_interop.h>
|
#include <cuda_d3d11_interop.h>
|
||||||
#include <cuda_runtime_api.h>
|
#include <cuda_runtime_api.h>
|
||||||
|
@ -33,11 +33,15 @@
|
|||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
|
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
|
||||||
|
|
||||||
|
// includes for OpenGL
|
||||||
|
#include <helper_gl.h>
|
||||||
|
|
||||||
|
// includes
|
||||||
#include <cuda_gl_interop.h>
|
#include <cuda_gl_interop.h>
|
||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
#include <helper_cuda.h>
|
#include <helper_cuda.h>
|
||||||
#include <helper_functions.h>
|
#include <helper_functions.h>
|
||||||
#include <helper_gl.h>
|
|
||||||
|
|
||||||
#include "ParticleSystem.cuh"
|
#include "ParticleSystem.cuh"
|
||||||
#include "ParticleSystem.h"
|
#include "ParticleSystem.h"
|
||||||
|
@ -29,11 +29,15 @@
|
|||||||
This file contains simple wrapper functions that call the CUDA kernels
|
This file contains simple wrapper functions that call the CUDA kernels
|
||||||
*/
|
*/
|
||||||
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
|
#define HELPERGL_EXTERN_GL_FUNC_IMPLEMENTATION
|
||||||
|
|
||||||
|
// includes for OpenGL
|
||||||
|
#include <helper_gl.h>
|
||||||
|
|
||||||
|
// includes
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cuda_gl_interop.h>
|
#include <cuda_gl_interop.h>
|
||||||
#include <helper_cuda.h>
|
#include <helper_cuda.h>
|
||||||
#include <helper_gl.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "ParticleSystem.cuh"
|
#include "ParticleSystem.cuh"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user