Updating Samples for 12.3 and updating props files

This commit is contained in:
Rob Nertney
2023-10-23 18:44:49 +00:00
parent c46754b877
commit b5c84e6996
584 changed files with 2725 additions and 1167 deletions

View File

@@ -40,7 +40,7 @@ retrieve a device pointer first, which can be done using cuModuleGetGlobal().
size_t size_xxx; // size of xxx
result = cuModuleGetGlobal(&devp_xxx, &size_xxx, hModule, "xxx");
Whether or not the pointer points to managed memory may be queried
Whether of not the pointer points to a managed memory may be queried
by calling cuPointerGetAttribute() with the pointer attribute
CU_POINTER_ATTRIBUTE_IS_MANAGED.

View File

@@ -34,12 +34,6 @@
#include <string.h>
#include <sys/stat.h>
#define ERROR_IF(expr) \
if (expr) { \
fprintf(stderr, "Failed check at %s:%d\n", __FILE__, __LINE__); \
exit(EXIT_FAILURE); \
}
// If 'err' is non-zero, emit an error message and exit.
#define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__)
static void __checkCudaErrors(CUresult err, const char *filename, int line) {
@@ -227,7 +221,7 @@ static CUresult buildKernel(CUcontext *phContext, CUdevice *phDevice,
return CUDA_SUCCESS;
}
int main(void) {
int main(int argc, char **argv) {
const unsigned int nThreads = 1;
const unsigned int nBlocks = 1;
@@ -251,7 +245,7 @@ int main(void) {
int attrVal;
checkCudaErrors(cuDeviceGetAttribute(
&attrVal, CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING, hDevice));
ERROR_IF(attrVal != 1);
assert(attrVal == 1);
}
// Get the address of the variable xxx, yyy in the managed memory.
@@ -266,10 +260,23 @@ int main(void) {
checkCudaErrors(cuPointerGetAttribute(
&attrVal, CU_POINTER_ATTRIBUTE_IS_MANAGED, devp_xxx));
ERROR_IF(attrVal != 1);
assert(attrVal == 1);
checkCudaErrors(cuPointerGetAttribute(
&attrVal, CU_POINTER_ATTRIBUTE_IS_MANAGED, devp_yyy));
ERROR_IF(attrVal != 1);
assert(attrVal == 1);
}
// The "physical" memory location of the memory that the devp_yyy addresses is
// the device memory type.
{
unsigned int attrVal;
checkCudaErrors(cuPointerGetAttribute(
&attrVal, CU_POINTER_ATTRIBUTE_MEMORY_TYPE, devp_xxx));
assert(attrVal == CU_MEMORYTYPE_DEVICE);
checkCudaErrors(cuPointerGetAttribute(
&attrVal, CU_POINTER_ATTRIBUTE_MEMORY_TYPE, devp_yyy));
assert(attrVal == CU_MEMORYTYPE_DEVICE);
}
// Since CUdeviceptr is opaque, it is safe to use cuPointerGetAttribute to get
@@ -289,8 +296,8 @@ int main(void) {
printf("The initial value of xxx initialized by the device = %d\n", *p_xxx);
printf("The initial value of yyy initialized by the device = %d\n", *p_yyy);
ERROR_IF(*p_xxx != 10);
ERROR_IF(*p_yyy != 100);
assert(*p_xxx == 10);
assert(*p_yyy == 100);
// The host adds 1 and 11 to xxx and yyy.
*p_xxx += 1;