Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Jones__Brian
New Contributor I
123 Views

Two C programs in intel-cmt-cat utility (RDT) give compiler errors

I downloaded the intel-cmt-cat utility for Intel Resource Director Technology (RDT) from https://github.com/intel/intel-cmt-cat. For my project, I compile all 19 of the C programs in the /lib folder to object files only, then link them into my final project.

I cannot use the utility as a stand-alone executable because I am writing software for distribution to end users, and cache control is implemented as a call to an entry point in another program in my project. For that purpose, I altered the allocation_app_l3cat.c example so that the main program is renamed L3_main, and call that from my own program. Therefore, I'm not using the makefile because my use case is just to link in the object files.

Two of the 19 files distributed in the /lib folder -- allocation.c and cpuinfo.c -- give compiler errors (using Clang-8).

For allocation.c, the compiler string is:

sudo clang-8 -fPIC -c -o allocation.o allocation.c

and Clang generates these warnings:

allocation.c:1636:33: warning: expression result unused [-Wunused-value

ret = (m_cpu, mba_ids,

allocation.c:1636:49: warning: expression result unused [-Wunused-value

ret = (m_cpu, mba_ids,

allocation.c:1636:29: warning: incompatible pointer to integer conversi

assigning to 'int' from 'unsigned int *' [-Wint-conversion]

ret = (m_cpu, mba_ids,

For cpuinfo.c, the compiler string is:

sudo clang-8 -fPIC -c -o cpuinfo.o cpuinfo.c

and Clang generates these warnings:

cpuinfo.c:117:16: warning: implicit declaration of function 'sched_setaffinity'

is invalid in C99 [-Wimplicit-function-declaration]

return sched_setaffinity(0, sizeof(*p_set), p_set);

cpuinfo.c:138:9: warning: implicit declaration of function 'CPU_ZERO' is invalid

in C99 [-Wimplicit-function-declaration]

CPU_ZERO(&cpuset);

cpuinfo.c:139:9: warning: implicit declaration of function 'CPU_SET' is invalid

in C99 [-Wimplicit-function-declaration]

CPU_SET(id, &cpuset);

cpuinfo.c:157:9: warning: implicit declaration of function 'CPU_ZERO' is invalid

in C99 [-Wimplicit-function-declaration]

CPU_ZERO(p_set);

cpuinfo.c:159:16: warning: implicit declaration of function 'sched_getaffinity'

is invalid in C99 [-Wimplicit-function-declaration]

return sched_getaffinity(0, sizeof(*p_set), p_set);

5 warnings generated.

_________

These warnings generate runtime errors -- e.g "undefined symbol: CPU_ZERO" -- and I don't know how to resolve them. For example, cpu_zero is defined in sched.h, which is an include file for cpuinfo.c, but I still get the warnings.

I am looking forward to using RDT, so I hope someone with experience in the intel-cmt-cat urility programs can help with this.

Thanks very much.

 

 

0 Kudos
1 Reply
Jones__Brian
New Contributor I
123 Views

Here's how I solved this problem:

(1) in cpuinfo.c, add #define _GNU_SOURCE at the top of the includes. 

(2) in the linker string, add "/usr/lib/x86_64-linux-gnu/libc.so" to static link to libc.so (I use ld for linking). 

(3) the warnings in allocation.c do not produce run-time errors, apparently because the error is that the "expression result unused." 

 

Reply