chore(repo): initialize reproducible research workspace
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
__global__ void increment(int* value) {
|
||||
*value += 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int host_value = 41;
|
||||
int* device_value = nullptr;
|
||||
|
||||
if (cudaMalloc(&device_value, sizeof(int)) != cudaSuccess) {
|
||||
return 1;
|
||||
}
|
||||
if (cudaMemcpy(device_value, &host_value, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess) {
|
||||
cudaFree(device_value);
|
||||
return 2;
|
||||
}
|
||||
|
||||
increment<<<1, 1>>>(device_value);
|
||||
if (cudaDeviceSynchronize() != cudaSuccess) {
|
||||
cudaFree(device_value);
|
||||
return 3;
|
||||
}
|
||||
if (cudaMemcpy(&host_value, device_value, sizeof(int), cudaMemcpyDeviceToHost) != cudaSuccess) {
|
||||
cudaFree(device_value);
|
||||
return 4;
|
||||
}
|
||||
|
||||
cudaFree(device_value);
|
||||
std::printf("cuda_smoke_result=%d\n", host_value);
|
||||
return host_value == 42 ? 0 : 5;
|
||||
}
|
||||
Reference in New Issue
Block a user