mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-01-09 20:07:49 +08:00
Merge branch 'shawnz_bug_fix' into 'master'
Bug 5502937 and 5502929: Fixing 2 sample issue on WSL See merge request cuda-samples/cuda-samples!131
This commit is contained in:
commit
5e9d44634b
@ -188,7 +188,7 @@ int ipcCreateSocket(ipcHandle *&handle, const char *name,
|
|||||||
char path_name[50];
|
char path_name[50];
|
||||||
|
|
||||||
// Create unique name for the socket with path if SOCK_FOLDER is set.
|
// 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);
|
unlink(path_name);
|
||||||
memset(&servaddr, 0, sizeof(servaddr));
|
memset(&servaddr, 0, sizeof(servaddr));
|
||||||
@ -230,7 +230,7 @@ int ipcOpenSocket(ipcHandle *&handle) {
|
|||||||
char temp[50];
|
char temp[50];
|
||||||
|
|
||||||
// Create unique name for the socket with path if SOCK_FOLDER is set.
|
// 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);
|
strcpy(cliaddr.sun_path, temp);
|
||||||
if (bind(sock, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
|
if (bind(sock, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
|
||||||
@ -367,7 +367,7 @@ int ipcSendShareableHandle(ipcHandle *handle,
|
|||||||
memset(&cliaddr, 0, sizeof(cliaddr));
|
memset(&cliaddr, 0, sizeof(cliaddr));
|
||||||
cliaddr.sun_family = AF_UNIX;
|
cliaddr.sun_family = AF_UNIX;
|
||||||
char temp[20];
|
char temp[20];
|
||||||
sprintf(temp, "%s%u", SOCK_FOLDER, process);
|
sprintf(temp, "%s/%u", getSocketFolder().c_str(), process);
|
||||||
strcpy(cliaddr.sun_path, temp);
|
strcpy(cliaddr.sun_path, temp);
|
||||||
len = sizeof(cliaddr);
|
len = sizeof(cliaddr);
|
||||||
|
|
||||||
|
|||||||
@ -52,14 +52,12 @@
|
|||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <filesystem>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// Define "/tmp" as socket creating folder for QNX
|
inline std::string getSocketFolder() {
|
||||||
#if defined(__QNX__)
|
return std::filesystem::temp_directory_path().string();
|
||||||
#define SOCK_FOLDER "/tmp/"
|
}
|
||||||
#else
|
|
||||||
#define SOCK_FOLDER ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct sharedMemoryInfo_st {
|
typedef struct sharedMemoryInfo_st {
|
||||||
void *addr;
|
void *addr;
|
||||||
|
|||||||
@ -297,6 +297,9 @@ int main(int argc, char **argv)
|
|||||||
exit(EXIT_WAIVED);
|
exit(EXIT_WAIVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int concurrentManagedAccess;
|
||||||
|
checkCudaErrors(cudaDeviceGetAttribute(&concurrentManagedAccess, cudaDevAttrConcurrentManagedAccess, dev_id));
|
||||||
|
|
||||||
if (device_prop.major < 6) {
|
if (device_prop.major < 6) {
|
||||||
printf("%s: requires a minimum CUDA compute 6.0 capability, waiving "
|
printf("%s: requires a minimum CUDA compute 6.0 capability, waiving "
|
||||||
"testing.\n",
|
"testing.\n",
|
||||||
@ -326,6 +329,12 @@ int main(int argc, char **argv)
|
|||||||
atom_arr[7] = atom_arr[9] = 0xff;
|
atom_arr[7] = atom_arr[9] = 0xff;
|
||||||
|
|
||||||
atomicKernel<<<numBlocks, numThreads>>>(atom_arr);
|
atomicKernel<<<numBlocks, numThreads>>>(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);
|
atomicKernel_CPU(atom_arr, numBlocks * numThreads);
|
||||||
|
|
||||||
checkCudaErrors(cudaDeviceSynchronize());
|
checkCudaErrors(cudaDeviceSynchronize());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user