579
社区成员
发帖
与我相关
我的任务
分享
// Test.h
#ifndef TEST_H
#define TEST_H
extern "C"
void __declspec (dllexport) Test(int n);
#endif
// Test.cu
#include <stdio.h>
#include "Test.h"
__global__
void Kernel(int *n)
{
*n *= 10;
}
void Test(int n)
{
int *n_d;
cudaMalloc((void**)&n_d, sizeof(int));
cudaMemcpy(n_d, &n, sizeof(int), cudaMemcpyHostToDevice);
Kernel<<<1, 1>>>(n_d);
cudaMemcpy(&n, n_d, sizeof(int), cudaMemcpyDeviceToHost);
cudaFree(n_d);
printf("%d\n", n);
}
#include "Test.h"
void main()
{
Test(20);
}