From 3e6d1858af55c68a51af46ced97d4f1d0b0a35f9 Mon Sep 17 00:00:00 2001 From: shawnz Date: Fri, 5 Sep 2025 11:55:32 +0800 Subject: [PATCH 1/2] Bug 5502929: Update systemWideAtomics to add device sync for WSL --- .../systemWideAtomics/systemWideAtomics.cu | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Samples/0_Introduction/systemWideAtomics/systemWideAtomics.cu b/Samples/0_Introduction/systemWideAtomics/systemWideAtomics.cu index 121ba207..4b7e46b1 100644 --- a/Samples/0_Introduction/systemWideAtomics/systemWideAtomics.cu +++ b/Samples/0_Introduction/systemWideAtomics/systemWideAtomics.cu @@ -297,6 +297,9 @@ int main(int argc, char **argv) exit(EXIT_WAIVED); } + int concurrentManagedAccess; + checkCudaErrors(cudaDeviceGetAttribute(&concurrentManagedAccess, cudaDevAttrConcurrentManagedAccess, dev_id)); + if (device_prop.major < 6) { printf("%s: requires a minimum CUDA compute 6.0 capability, waiving " "testing.\n", @@ -326,6 +329,12 @@ int main(int argc, char **argv) atom_arr[7] = atom_arr[9] = 0xff; atomicKernel<<>>(atom_arr); + + // Do device synchronize for devices that don't support concurrent managed access such as WSL. + if (!concurrentManagedAccess) { + checkCudaErrors(cudaDeviceSynchronize()); + } + atomicKernel_CPU(atom_arr, numBlocks * numThreads); checkCudaErrors(cudaDeviceSynchronize()); From b0a2f2049f45475c3a2a8db6d011bd1ff40ceb12 Mon Sep 17 00:00:00 2001 From: shawnz Date: Fri, 5 Sep 2025 11:55:44 +0800 Subject: [PATCH 2/2] Bug 5502937: Set TEMPDIR as socket create dir to avoid socket create permission isue on systems like WSL --- Common/helper_multiprocess.cpp | 6 +++--- Common/helper_multiprocess.h | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Common/helper_multiprocess.cpp b/Common/helper_multiprocess.cpp index c7769b50..ee1618aa 100644 --- a/Common/helper_multiprocess.cpp +++ b/Common/helper_multiprocess.cpp @@ -188,7 +188,7 @@ int ipcCreateSocket(ipcHandle *&handle, const char *name, char path_name[50]; // Create unique name for the socket with path if SOCK_FOLDER is set. - sprintf(path_name, "%s%u", SOCK_FOLDER, getpid()); + sprintf(path_name, "%s/%u", getSocketFolder().c_str(), getpid()); unlink(path_name); memset(&servaddr, 0, sizeof(servaddr)); @@ -230,7 +230,7 @@ int ipcOpenSocket(ipcHandle *&handle) { char temp[50]; // Create unique name for the socket with path if SOCK_FOLDER is set. - sprintf(temp, "%s%u", SOCK_FOLDER, getpid()); + sprintf(temp, "%s/%u", getSocketFolder().c_str(), getpid()); strcpy(cliaddr.sun_path, temp); if (bind(sock, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) { @@ -367,7 +367,7 @@ int ipcSendShareableHandle(ipcHandle *handle, memset(&cliaddr, 0, sizeof(cliaddr)); cliaddr.sun_family = AF_UNIX; char temp[20]; - sprintf(temp, "%s%u", SOCK_FOLDER, process); + sprintf(temp, "%s/%u", getSocketFolder().c_str(), process); strcpy(cliaddr.sun_path, temp); len = sizeof(cliaddr); diff --git a/Common/helper_multiprocess.h b/Common/helper_multiprocess.h index d0bdcc20..2c09b5e3 100644 --- a/Common/helper_multiprocess.h +++ b/Common/helper_multiprocess.h @@ -52,14 +52,12 @@ #include #include #endif +#include #include -// Define "/tmp" as socket creating folder for QNX -#if defined(__QNX__) -#define SOCK_FOLDER "/tmp/" -#else -#define SOCK_FOLDER "" -#endif +inline std::string getSocketFolder() { + return std::filesystem::temp_directory_path().string(); +} typedef struct sharedMemoryInfo_st { void *addr;