Hi Mohammed,
since the CUDA C compiler nvcc uses MS Visual C++ for creating the
host code on
MS Windows and gcc for creating the host code on Linux, the Dislin
libraries for MS
Visual C++ and Linux can be used for linking with CUDA programs. The
following small
CUDA program calculates squares from floatingpoint numbers and plots
them with the
Dislin quick plot routine qplot.
--------
#include <stdio.h>
#include <cuda.h>
#include "dislin.h"
__global__ void square (float *xray, int n)
{ int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) xray[i] = xray[i] * xray[i];
}
#define N 101
int main (void)
{ float *xray, *yray, *p;
int i, blocksize = 48, nblocks, n;
n = N * sizeof (float);
xray = (float*) malloc (n);
yray = (float*) malloc (n);
for (i = 0; i < N; i++)
{ xray[i] = i;
yray[i] = i;
}
cudaMalloc ((void **) &p, n);
cudaMemcpy (p, yray, n, cudaMemcpyHostToDevice);
nblocks = N / blocksize;
if ((N % blocksize) != 0) nblocks++;
square <<< nblocks, blocksize >>> (p, N);
cudaMemcpy (yray, p, n, cudaMemcpyDeviceToHost);
cudaFree (p);
qplot (xray, yray, N);
free (xray);
free (yray);
return 0;
}
----------------
The program can be compiled and linked on Windows with
nvcc -Ic:\dislin
test.cu c:\dislin\disvc.lib user32.lib
gdi32.lib
Tested on Windows 7 (64-bit) with MS Visual Studio 2010 and a Nvidia
GLS 450 graphics card with 4 multiprocessors and 48 cores for each
multiprocessor.
Best regards,
Helmut