Okay, Here is my (Project)code which is in 3 different files(nixHead.h, nixUtil.cu, nixMain.cu). I have removed many other functions and now only the remaining code is left which still gives the error.
Error:
Severity Code Description Project File Line Suppression State
Error (active) expected an expression Test412 c:\Users\ns76685w\Desktop\Test412\Test412\nixUtil.cu 33
Severity Code Description Project File Line Suppression State
Error C2059 syntax error: ‘<’ Test412 c:\users\ns76685w\desktop\test412\test412\nixutil.cu 33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nixHead.h is as follows:
#include<cuda_runtime.h>
#ifndef NIKHIL
#define NIKHIL
#define BLOCK_SIZE 4
#define N = 10
int numElementsRand = 10, numElementsMat = 100, numElementsBestCost = 100;
int sizeRand = numElementsMat * sizeof(int);
int sizeMat = numElementsMat * sizeof(int);
int sizeBestCost = numElementsBestCost * sizeof(int);
void HC(int *h_A, int *h_B, int *h_C, int *h_bestCost);
global void cutSizeKernel(int *p, int *adj, int *d_bestCost);
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nixUtil.cu is as follows:
#include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <math.h>
#include “device_launch_parameters.h”
#include “nixHead.h”
#include <time.h>
void HC(int *h_A, int *h_B, int *h_C, int *h_bestCost) {
//Load A, B, C in Device Memeory
// Malloc device global memory
int *d_A, *d_B, *d_C, *d_bestCost;
cudaMalloc((void **)&d_A, sizeRand);
cudaMalloc((void **)&d_B, sizeRand);
cudaMalloc((void **)&d_C, sizeMat);
cudaMalloc((void**)&d_bestCost, sizeBestCost);
// transfer data from host to device
cudaMemcpy(d_A, h_A, sizeRand, cudaMemcpyHostToDevice);
cudaMemcpy(d_B, h_B, sizeRand, cudaMemcpyHostToDevice);
cudaMemcpy(d_C, h_C, sizeMat, cudaMemcpyHostToDevice);
cutSizeKernel <<<1, 1 >> > (d_A, d_C, d_bestCost);
cudaDeviceSynchronize();
// Transfer output from device memory to Host
cudaMemcpy(h_bestCost, d_bestCost, sizeBestCost, cudaMemcpyDeviceToHost);
// free device global memory
cudaFree(d_A);
cudaFree(d_B);
cudaFree(d_C);
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nixMain.cu is as follows:
#include “nixHead.h”
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <math.h>
int main() {
//Malloc Host memory
int *h_A = (int *)malloc(sizeRand);
int *h_B = (int *)malloc(sizeRand);
int *h_C = (int *)malloc(sizeMat);
int *h_bestCost = (int *)malloc(sizeBestCost);
// Verify that allocations succeeded
if (h_A == NULL || h_B == NULL || h_C == NULL || h_bestCost == NULL)
{
fprintf(stderr, "Failed to allocate host vectors!\n");
exit(EXIT_FAILURE);
}
//Call the Function()
void HC(int *h_A, int *h_B, int *h_C, int *h_bestCost);
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++