mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-10-25 22:28:17 +08:00
Merge branch 'master' into cuda_a_dev
This commit is contained in:
@@ -99,8 +99,21 @@ static void childProcess(int id)
|
||||
std::vector<void *> ptrs;
|
||||
std::vector<cudaEvent_t> events;
|
||||
std::vector<char> verification_buffer(DATA_SIZE);
|
||||
char pidString[20] = {0};
|
||||
char lshmName[40] = {0};
|
||||
|
||||
if (sharedMemoryOpen(shmName, sizeof(shmStruct), &info) != 0) {
|
||||
// Use parent process ID to create a unique shared memory name for Linux multi-process
|
||||
#ifdef __linux__
|
||||
pid_t pid;
|
||||
pid = getppid();
|
||||
snprintf(pidString, sizeof(pidString), "%d", pid);
|
||||
#endif
|
||||
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");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -195,10 +208,23 @@ static void parentProcess(char *app)
|
||||
std::vector<void *> ptrs;
|
||||
std::vector<cudaEvent_t> events;
|
||||
std::vector<Process> processes;
|
||||
char pidString[20] = {0};
|
||||
char lshmName[40] = {0};
|
||||
|
||||
// Use current process ID to create a unique shared memory name for Linux multi-process
|
||||
#ifdef __linux__
|
||||
pid_t pid;
|
||||
pid = getpid();
|
||||
snprintf(pidString, sizeof(pidString), "%d", pid);
|
||||
#endif
|
||||
strcat(lshmName, shmName);
|
||||
strcat(lshmName, pidString);
|
||||
|
||||
printf("PP: lshmName = %s\n", lshmName);
|
||||
|
||||
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");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user