DISLIN with CUDA

49 views
Skip to first unread message

Mohammed Mostafa

unread,
May 14, 2012, 7:49:06 AM5/14/12
to dislin-users
I was wondering if dislin can be used with CUDA.
for example to display the solution of a CFD problem when solved on a
GPU using CUDA

"Armin Rauthe-Schöch"

unread,
May 14, 2012, 7:53:38 AM5/14/12
to dislin...@googlegroups.com
Hi,

there even seems to be a Fortran library for GNU Fortran 95:
http://www.nvidia.de/object/cuda_fortran_de.html
http://sourceforge.net/apps/trac/flagon/wiki

So it should be possible to use DISLIN and CUDA in a Fortran programme.

As long as you use a compiler supported by DISLIN, this should also work for other programming languages (C, Java, ...)
Cheers,
Armin

--
Dr. Armin Rauthe-Schöch
Max Planck Institute for Chemistry
Department of Atmospheric Chemistry
Hahn-Meitner-Weg 1
D-55128 Mainz / GERMANY
Tel. +49-6131-305-4123
Fax. +49-6131-305-4009
Email: armin.raut...@mpic.de

Helmut Michels

unread,
May 24, 2012, 3:52:27 PM5/24/12
to dislin-users
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
Reply all
Reply to author
Forward
0 new messages