How to compile multi-threading test programs using pthread

988 views
Skip to first unread message

li...@umich.edu

unread,
May 28, 2015, 5:39:32 PM5/28/15
to gem5-g...@googlegroups.com
Hi,

I want to write a test program with multiple threads and run that on gem5-gpu. I added "-pthread" in CFLAGS. The error is:

g++-4.8 -DOUTPUT -pthread -O3 -DGEM5_FUSION matMult.cu_o -L../../libcuda -lcuda \
-L/z/liush/NVIDIA_SDK/C/lib \
-lz -static -static-libgcc -o gem5_fusion_matMult -L/usr/lib64 -lcutil_x86_64 -lm5op_x86 -lm -lc  
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libpthread.a(lowlevellock.o): In function `__lll_lock_wait_private':
/build/buildd/eglibc-2.19/nptl/../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:78: multiple definition of `__lll_lock_wait_private'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libc.a(libc-lowlevellock.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libpthread.a(lowlevellock.o): In function `__lll_unlock_wake_private':
/build/buildd/eglibc-2.19/nptl/../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:328: multiple definition of `__lll_unlock_wake_private'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libc.a(libc-lowlevellock.o):(.text+0x30): first defined here
collect2: error: ld returned 1 exit status
make: *** [gem5_fusion_matMult] Error 1

I tried gcc 4.4 and it also failed. Has anyone tried doing something like this? Or is there a way to run multi-thread programs on gem5-gpu.

Thank you,
Sihang

"Stamatis Kavvadias (Σταμάτης Καββαδίας)"

unread,
May 29, 2015, 12:20:19 AM5/29/15
to gem5-g...@googlegroups.com
Hi Sihang,

    I have compiled a few pairs of the rodinia benchmaker (with several changes to benchmark parameter reading and a custom main. I used g++-4.6 (on Ubuntu 12.04). The link command (the only one that needs -lpthread) was something like (in this case for backprop and hotspot pair):

g++-4.6
-DGEM5_FUSION main.o facetrain.c_o imagenet.c_o backprop.c_o backprop_cuda.cu_o hotspot.cu_o \
    -I/spare/gem5-work/benchmarks/GPGPU-Benchmarks/rodinia/backprop \
    -I/spare/gem5-work/benchmarks/GPGPU-Benchmarks/rodinia/hotspot \
    -L../../libcuda -L
/spare/gem5-work/benchmarks/NVIDIA_GPU_Computing_SDK/C/lib \
   
-O3 -static -static-libgcc -L/usr/lib64 -lcutil_x86_64 -lm5op_x86 -lcuda -lz -lm -lc -lpthread \
    -o gem5_fusion_backprop_hotspot

I believe you need to put -lpthread after 
-static -static-libgcc.

I hope this helps,

Stamatis
-- 


Stamatis Kavvadias, PhD

Research Associate
TEI of Crete, Greece

li...@umich.edu

unread,
Jun 8, 2015, 11:45:25 PM6/8/15
to gem5-g...@googlegroups.com
I finally figured out that we need to use M5Thread lib instead of the existing pthread lib. 
In the makefile, add <the path to m5thread file libpthread.a or libpthread.o > after "-lz -static -static-libgcc".
Reply all
Reply to author
Forward
0 new messages