Post v13.5 (#470)

This commit is contained in:
Dheemanth
2026-11-04 12:48:54 -08:00
committed by GitHub
parent 5443602d89
commit 0ec046d5e9
53 changed files with 1750 additions and 183 deletions

View File

@@ -2,7 +2,9 @@
## Description
Demonstrates CUDA and EGL Streams interop, where consumer's EGL Stream is on one GPU and producer's on other and both consumer-producer are different processes.
Demonstrates CUDA and EGL Streams interop between separate consumer and producer processes. By default, both processes use the same GPU. Use `-crossdev` to place the consumer on a discrete GPU and the producer on an integrated GPU.
The consumer adds its process ID to the Unix socket name and passes the path to the producer. Each process pair uses a separate socket, so multiple sample instances can run at the same time.
## Key Concepts

View File

@@ -89,6 +89,7 @@ typedef struct _TestArgs
{
unsigned int charCnt;
bool isProducer;
const char *socketPath;
} TestArgs;
extern int WIDTH, HEIGHT;

View File

@@ -93,12 +93,25 @@ int parseCmdLine(int argc, char *argv[], TestArgs *args)
else if (strcmp(argv[i], "-v") == 0) {
verbose = 1;
}
else if (strcmp(argv[i], "-socket") == 0) {
if (++i >= argc || argv[i][0] == '\0'
|| strlen(argv[i]) >= sizeof(sockaddr_un::sun_path)) {
printf("Invalid producer socket path\n");
return -1;
}
args->socketPath = argv[i];
}
else {
printf("Unknown option: %s\n", argv[i]);
return -1;
}
}
if (args->isProducer && args->socketPath == NULL) {
printf("Producer socket path is required\n");
return -1;
}
if (isCrossDevice) {
int deviceCount = 0;
@@ -192,7 +205,8 @@ void launchProducer(TestArgs *args)
char argsProducer[1024];
char str[256];
strcpy(argsProducer, "./EGLStream_CUDA_CrossGPU -proctype prod ");
snprintf(argsProducer, sizeof(argsProducer),
"./EGLStream_CUDA_CrossGPU -proctype prod -socket %s ", args->socketPath);
if (isCrossDevice) {
sprintf(str, "-crossdev ");
@@ -225,4 +239,5 @@ void printUsage(void)
printf(" -crossdev Run with producer on idgpu and consumer on dgpu\n");
printf(" -dgpu (same as -crossdev, deprecated)\n");
printf(" -v verbose output\n");
printf(" -socket path Producer socket path, set by the consumer\n");
}

View File

@@ -81,7 +81,7 @@ void DoneProd(int producerStatus, int connect_fd)
int WIDTH = 8192, HEIGHT = 8192;
int main(int argc, char **argv)
{
TestArgs args = {0, false};
TestArgs args = {0, false, NULL};
CUresult curesult = CUDA_SUCCESS;
unsigned int j = 0;
cudaError_t err = cudaSuccess;
@@ -90,11 +90,21 @@ int main(int argc, char **argv)
CUeglFrame cudaEgl1, cudaEgl2;
int consumerStatus = 0;
int send_fd = -1;
char socketPath[sizeof(sockaddr_un::sun_path)];
if (parseCmdLine(argc, argv, &args) < 0) {
printUsage();
curesult = CUDA_ERROR_UNKNOWN;
DoneCons(consumerStatus, send_fd);
return EXIT_FAILURE;
}
if (!args.isProducer) {
// Use the consumer PID to keep concurrent process pairs separate.
int written = snprintf(socketPath, sizeof(socketPath), "%s_%ld", SOCK_PATH, (long)getpid());
if (written < 0 || (size_t)written >= sizeof(socketPath)) {
printf("Socket path is too long\n");
return EXIT_FAILURE;
}
args.socketPath = socketPath;
}
printf("Width : %u, height: %u and iterations: %u\n", WIDTH, HEIGHT, NUMTRIALS);
@@ -137,9 +147,9 @@ int main(int argc, char **argv)
cuCtxPopCurrent(&cudaConsumer.context);
send_fd = UnixSocketConnect(SOCK_PATH);
send_fd = UnixSocketConnect(args.socketPath);
if (-1 == send_fd) {
printf("%s: Cuda Consumer cannot create socket %s\n", __func__, SOCK_PATH);
printf("%s: Cuda Consumer cannot create socket %s\n", __func__, args.socketPath);
consumerStatus = -1;
DoneCons(consumerStatus, send_fd);
}
@@ -242,9 +252,9 @@ int main(int argc, char **argv)
signal(SIGINT, sig_handler);
// Create connection to Consumer
connect_fd = UnixSocketCreate(SOCK_PATH);
connect_fd = UnixSocketCreate(args.socketPath);
if (-1 == connect_fd) {
printf("%s: Cuda Producer could not create socket: %s.\n", __func__, SOCK_PATH);
printf("%s: Cuda Producer could not create socket: %s.\n", __func__, args.socketPath);
producerStatus = -1;
DoneProd(producerStatus, connect_fd);
}