PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Segmentation fault in memcpy

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
BerkinO



Joined: 04 Jun 2010
Posts: 2

PostPosted: Fri Jun 04, 2010 1:12 pm    Post subject: Segmentation fault in memcpy Reply with quote

Hi,

I have a simple kmeans application. When I compile I get the following information.

Code:

[boz283@honest2 ~/kmeans-pgi]$ make seq
pgcc -ta=nvidia -Minfo -g   -c seq_kmeans.c
seq_kmeans:
    104, Memory set idiom, loop replaced by call to __c_mset4
    119, Generating copyin(clusters[0:numClusters-1][0:numCoords-1])
         Generating copyin(objects[numObjs][numCoords])
         Generating compute capability 1.3 kernel
    120, Loop carried scalar dependence for 'delta' at line 139
         Scalar last value needed after loop for 'delta' at line 166
         Accelerator restriction: scalar variable live-out from loop: delta
         Sequential loop scheduled on host
    128, Loop carried scalar dependence for 'min_dist' at line 132
         Scalar last value needed after loop for 'index' at line 139
         Scalar last value needed after loop for 'index' at line 142
         Accelerator restriction: scalar variable live-out from loop: index
         Sequential loop scheduled on host
    130, Loop is parallelizable
         Accelerator kernel generated
        130, #pragma acc for parallel, vector(256)
        131, Sum reduction generated for dist
    157, Invariant if transformation
    158, Invariant if transformation
pgcc -ta=nvidia -Minfo -g -o seq_main seq_main.o seq_kmeans.o file_io.o wtime.o


When I run the application I get segmentation fault. I used gdb to check where the error occurs. And somehow the host pointer for my host data gets to be 0x0, and then it causes the seqmentation fault. The gdb code is below

Code:

[boz283@abe1201 ~/kmeans-pgi]$ gdb ./seq_main
GNU gdb Red Hat Linux (6.3.0.0-1.132.EL4rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...Using host libthread_db library "/usr/local/lib64/tls/libthread_db.so.1".

(gdb) run  -i out20 -b -n 20 -o -d
Starting program: /u/ac/boz283/kmeans-pgi/seq_main -i out20 -b -n 20 -o -d
File out20 numObjs   = 1000000
File out20 numCoords = 20
[Thread debugging using libthread_db enabled]
[New Thread 46912502230752 (LWP 27777)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 46912502230752 (LWP 27777)]
0x00002aaaaaebbf30 in memcpy () from /usr/local/lib64/tls/libc.so.6
(gdb) where
#0  0x00002aaaaaebbf30 in memcpy () from /usr/local/lib64/tls/libc.so.6
#1  0x00002aaab09fc0fb in ?? () from /usr/lib64/libcuda.so
#2  0x00002aaab09d72d9 in ?? () from /usr/lib64/libcuda.so
#3  0x00002aaab09d762f in ?? () from /usr/lib64/libcuda.so
#4  0x00002aaab09c792f in ?? () from /usr/lib64/libcuda.so
#5  0x00002aaab0a5a2c5 in ?? () from /usr/lib64/libcuda.so
#6  0x0000000000407c70 in __pgi_cu_upload1_p (devptr=1115904, hostptr=0x0, devx=0,
    hostx=1000020, size=1, hoststride=1, elementsize=4, lineno=119,
    name=0x409fe9 "objects") at ../src/nvupload1.c:48
#7  0x0000000000407f33 in __pgi_cu_upload2_p (devptr=1115904, hostptr=0x0, devx=0,
    devy=0, hostx=20, hosty=1000000, size1=1, size2=1, devstride2=1, hoststride1=1,
    hoststride2=1, elementsize=4, lineno=119, name=0x409fe9 "objects")
    at ../src/nvupload2.c:51
#8  0x0000000000405b48 in __pgi_cu_uploadpx (devptr=1115904, hostptr=0x2aaaab081010,
    dims=2, desc=0x7fffffffcda0, elementsize=4, lineno=119, name=0x409fe9 "objects")
    at ../src/nvuploadp.c:79
#9  0x00000000004063bb in __pgi_cu_uploadp_p (devptr=1115904, hostptr=0x2aaaab081010,
    dims=2, desc=0x7fffffffcda0, elementsize=4, lineno=119, name=0x409fe9 "objects")
    at ../src/nvuploadp.c:213
#10 0x0000000000402036 in seq_kmeans (objects=0x2aaaab081010, numCoords=20,
    numObjs=1000000, numClusters=20, threshold=0.00100000005, membership=0x2aaab046f010)
    at ./seq_kmeans.c:117
#11 0x0000000000401abc in main (argc=8, argv=0x7fffffffd008) at ./seq_main.c:106
(gdb) quit


My input dataset is 1million records, with each record consisting of 20 dimensions of floats.

Thanks
Berkin
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6134
Location: The Portland Group Inc.

PostPosted: Fri Jun 04, 2010 4:15 pm    Post subject: Reply with quote

Hi Berkin,

Quote:
Generating copyin(objects[numObjs][numCoords])
This indicates that you're copying only one element of objects, "objects[numObjs][numCoords]", and it's most likely out-of-bounds.

What does your copyin clause for objects looks like? I'm thinking you want to use "copyin(objects[0:numObjs-1][0:numCoords-1])".

Hope this helps,
Mat
Back to top
View user's profile
BerkinO



Joined: 04 Jun 2010
Posts: 2

PostPosted: Thu Jun 10, 2010 8:26 am    Post subject: Reply with quote

Hi Mat,

I had missed the "0:" part in my copyin statement. (For another array the compiler seems to have added it automatically).

The code compiles and runs without segmentation fault. The code doesn't complete a single iteration which I would need to look into with more detail.

Thanks,
Berkin
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group