Initial commit
This commit is contained in:
23
hipmallocmanaged_hipmemset.cpp
Normal file
23
hipmallocmanaged_hipmemset.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
#include <hip/hip_runtime.h>
|
||||
|
||||
#define HIP(e) \
|
||||
if (hipError_t err = (e); err != hipSuccess) { \
|
||||
std::cerr << __FILE__ << ":" << __LINE__ << " " << err << "\n"; \
|
||||
exit(1); \
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
||||
size_t n = 1024 * 1024;
|
||||
double *p;
|
||||
|
||||
HIP(hipMallocManaged(&p, sizeof(double) * n, hipMemAttachGlobal));
|
||||
HIP(hipDeviceSynchronize());
|
||||
HIP(hipMemset(p, 17, sizeof(double)*n));
|
||||
HIP(hipDeviceSynchronize());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user