gmac problem with dependencies

23 views
Skip to first unread message

LaZaRo

unread,
Feb 17, 2011, 3:16:11 AM2/17/11
to ADSM Users
Hello how are you?,

I am an employee of a department of the University of Córdoba (Spain).
I found your library and appeared to me through the web gpgpu.org, and
I found very interesting, but I have a problem. I followed the steps
gmac manual for installation, but when I compile your example, the
name gmac.cu, using the command: nvcc -o gmac.cu gmac, I get the
following error:

/ tmp/tmpxft_00000952_00000000-13_gmac.o: In function `main ':
tmpxft_00000952_00000000-1_gmac.cudafe1.cpp: (. text +0 x1d):
undefined reference to `gmacMalloc '
tmpxft_00000952_00000000-1_gmac.cudafe1.cpp: (. text +0 x4b):
undefined reference to `gmacMalloc '
tmpxft_00000952_00000000-1_gmac.cudafe1.cpp: (. XD2 text +0):
undefined reference to `gmacMalloc '
tmpxft_00000952_00000000-1_gmac.cudafe1.cpp: (. text +0 x16e):
undefined reference to `gmacThreadSynchronize '
tmpxft_00000952_00000000-1_gmac.cudafe1.cpp: (. text +0 x21c):
undefined reference to `gmacFree '
tmpxft_00000952_00000000-1_gmac.cudafe1.cpp: (. text +0 x245):
undefined reference to `gmacFree '
tmpxft_00000952_00000000-1_gmac.cudafe1.cpp: (. text +0 x26e):
undefined reference to `gmacFree '

It also gives me the error compiling with CUDA Makefiles. This work on
an Ubuntu 10.10 of 64-bit processor i7. Do you know who gives this
error?.

Thank you very much.

Javi

unread,
Feb 17, 2011, 11:57:13 AM2/17/11
to adsm-...@googlegroups.com, LaZaRo
Hi Lazaro,

I see two problems in your mail:

1) You have to specify the binary name next to the -o flag to the compiler:
> nvcc -o gmac gmac.cu

2) You have to use gcc/g++ to link the program, since nvcc links the
program with the cuda run-time library:
> nvcc -c gmac.cu -o gmac.o
> g++ -o gmac gmac.o -L<path_to_gmac> -lgmac

Javi

--
Javi

LaZaRo

unread,
Feb 18, 2011, 11:47:45 AM2/18/11
to ADSM Users
Hi Javier, I have performed the steps you told me and compiles without
problems. Now I get the following runtime error:

Condition 'ret == CUDA_SUCCESS' failed
in function popContext [/home/antonio/adsm/libgmac/src/api/cuda/
Accelerator-impl.h:236]Abortado

Greetings and thanks again

Isaac Gelado

unread,
Feb 18, 2011, 12:00:12 PM2/18/11
to adsm-...@googlegroups.com, LaZaRo
Dear Lazaro,
could you send us the source code you are compiling. That error
message is quite unusual, so we will have to debug the application to
know the where the error is coming from. It would be great if you
could also fill an Issue in the Google code site, so you can track
what actions we are doing so solve this error.

Cheers,
Isaac

--
Isaac Gelado

 'As gold which he cannot spend will make no man rich
    so knowledge which he cannot apply will make no man wise'

LaZaRo

unread,
Feb 18, 2011, 12:41:59 PM2/18/11
to ADSM Users
Hi Isaac. I send you my code without any problem. Is the sample code
you propose in the repository. I copy here for you to see if they want
other users. The code would be:

#include <gmac/cuda.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

#define VECTOR_SIZE 1024
#define BLOCK_SIZE 256

__global__ void vecAdd(float *c, const float *a, const float *b,
size_t size)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if(i >= size) return;

c[i] = a[i] + b[i];
}

int main(int argc, char * argv[])
{
float *a, *b, *c;

/* 1- Allocate the input vectors */
assert(gmacMalloc((void **)&a, VECTOR_SIZE * sizeof(float)) ==
gmacSuccess);
assert(gmacMalloc((void **)&b, VECTOR_SIZE * sizeof(float)) ==
gmacSuccess);

/* 2- Initialize the input vectors */
for (int i = 0; i < VECTOR_SIZE; i++) {
a[i] = 1.0f * rand();
b[i] = 1.0f * rand();
}

/* 3- Allocate the output vector */
assert(gmacMalloc((void **)&c, VECTOR_SIZE * sizeof(float)) ==
gmacSuccess);

/* 4- Invoke the kernel */
dim3 block(BLOCK_SIZE);
dim3 grid(VECTOR_SIZE / BLOCK_SIZE);
if(VECTOR_SIZE % BLOCK_SIZE) grid.x++;

vecAdd<<<grid, block>>>(c, a, b, VECTOR_SIZE);

/* 5- Wait for kernel completion */
assert(gmacThreadSynchronize() == gmacSuccess);

/* Check the result */
for(int i = 0; i < VECTOR_SIZE; i++) {
assert(c[i] = a[i] + b[i]);
}

/* 6- Free shared structures */
assert(gmacFree(a) == gmacSuccess);
assert(gmacFree(b) == gmacSuccess);
assert(gmacFree(c) == gmacSuccess);

return 0;
}

Well not if it's something to consider, but CUDA capability of my
graphics card is 1.1. I can test the code in my work I have a C2050
card (Fermi)

Isaac Gelado

unread,
Feb 19, 2011, 1:32:10 PM2/19/11
to adsm-...@googlegroups.com, LaZaRo
Hi Lazaro,
finally I was able to find the error. It seems like the project wiki
is out of date. In the current GMAC version, pointers cannot be used
as kernel parameters anymore due to changes NVIDIA introduced starting
with CUDA 3.1. You need to use a wrapper function that will translate
from a host pointer to a valid device pointer, as follows:

-    vecAdd<<<grid, block>>>(c, a, b, VECTOR_SIZE);
+    vecAdd<<<grid, block>>>(gmacPtr(c), gmacPtr(a), gmacPtr(b), VECTOR_SIZE);

We expect to remove this limitation when CUDA 4.0 becomes public :-).

Cheers,
Isaac

LaZaRo

unread,
Feb 20, 2011, 4:24:05 AM2/20/11
to ADSM Users
Hi Isaac,

I've tried the changes you told me and it works perfectly. Your
library is going to be very helpful, because I work with Multi-GPU
and the exchange of information between cards, lost a lot of speed.

Well thanks again and be attentive to your wiki to see new versions
of
your project and on the other hand if you need something, because here
I am.

Greetings!
Antonio José Lázaro.
Reply all
Reply to author
Forward
0 new messages