style(C): fix warnings and use C++ includes
This commit is contained in:
parent
26003ed956
commit
18d1fdfa11
@ -1,6 +1,5 @@
|
|||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include "kernel.cu"
|
|
||||||
|
|
||||||
#define CUDA_ERRCHK(fn) { __gpucheck((fn), __FILE__, __LINE__); }
|
#define CUDA_ERRCHK(fn) { __gpucheck((fn), __FILE__, __LINE__); }
|
||||||
|
|
||||||
@ -23,13 +22,13 @@ void mulAll_kernel(int *out, int *in, int n, size_t size) {
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void mulAll(int *out, const int *input, int n, size_t size) {
|
void mulAll(int *out, const int *input, int n, size_t size) {
|
||||||
int *out_d, *in_d, i_d, size_d;
|
int *out_d, *in_d;
|
||||||
|
|
||||||
CUDA_ERRCHK(cudaMalloc((void **) &in_d, sizeof(int) * size));
|
CUDA_ERRCHK(cudaMalloc((void **) &in_d, sizeof(int) * size));
|
||||||
CUDA_ERRCHK(cudaMemcpy(in_d, input, sizeof(int) * size, cudaMemcpyHostToDevice));
|
CUDA_ERRCHK(cudaMemcpy(in_d, input, sizeof(int) * size, cudaMemcpyHostToDevice));
|
||||||
|
|
||||||
CUDA_ERRCHK(cudaMalloc((void **) &out_d, sizeof(int) * size));
|
CUDA_ERRCHK(cudaMalloc((void **) &out_d, sizeof(int) * size));
|
||||||
mulAll_kernel << < 32, 32 >> > (out_d, in_d, n, size);
|
mulAll_kernel <<< 32, 32 >>> (out_d, in_d, n, size);
|
||||||
CUDA_ERRCHK(cudaMemcpy(out, out_d, sizeof(int) * size, cudaMemcpyDeviceToHost));
|
CUDA_ERRCHK(cudaMemcpy(out, out_d, sizeof(int) * size, cudaMemcpyDeviceToHost));
|
||||||
|
|
||||||
CUDA_ERRCHK(cudaFree(in_d));
|
CUDA_ERRCHK(cudaFree(in_d));
|
||||||
|
Loading…
Reference in New Issue
Block a user