Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7835 Discussions

Linking glibc2.* with icc (Intel C Compiler)

mudassarm30
Beginner
345 Views

Hello people, I have spent the previous day but could not figure out the way yet to solve my problem. I want to use the function sched_getcpu(); to get the core ids where my MPI processes run. I have used the following code

#define _GNU_SOURCE
#include

int cpu = sched_getcpu();

but it seems that the kernal contains the glibc that does not contain this function (Or I do not know exactly how to link this library).

I also tried to use

#include 

int cpu = syscall(318);

but still i got the cpu = -1.

My linux is: Linux neolith1 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:22:04 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

glibc installed is: glibc-2.5-58.el5_6.3

"icc -v" shows me the following

Version 10.1 
ld /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtbegin.o --eh-frame-hdr -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out --rpath /software/intel/cce/10.1.017/lib -L/software/intel/cce/10.1.017/lib -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/ -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64 -limf -lsvml -lm -lipgo -lintlc -lgcc_s -lgcc -lintlc -lc -lgcc_s -lgcc -lirc_s -ldl -lc /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crtn.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
rm /tmp/iccbIhF9glibgcc

rm /tmp/iccTYPjcGgnudirs

rm /tmp/iccEishiugnudirs

I am linking like this (there are other libraries linked as well that worked fine)

icc -I/home/x_mudma/experiments/libs/gnugsl/include -c cannon.c -Nmpi -lrt -O0 -w
icc -L/home/x_mudma/experiments/libs/gnugsl/lib cannon.o -o output.o -lgsl -lgslcblas -lm -O0 -Nmpi

But on the above statements, it gives me

cannon.o: In function `main':
cannon.c:(.text+0xa6): undefined reference to `sched_getcpu'

Please help me to solve my problem

Thanks Mudassar

0 Kudos
2 Replies
TimP
Black Belt
345 Views
According to the doc (kernel.org/man-pages/....) you're looking for a function specific to glibc 2.6 and later, so it seems not yet available in glibc 2.5. Also, according to the doc, a more portable equivalent could be formed from getcpu().
0 Kudos
aazue
New Contributor I
345 Views
Hi
Maybe
test with header #include "/usr/include/bits/sched.h"
Regards
0 Kudos
Reply