Compiling tensorflow: undefined reference to `clSetUserEventStatus#OPENCL_1.1' - tensorflow

PS: Question is at the end, the following is just background information that might help.
I'm trying to compile tensorflow, but getting this error:
bazel-out/host/bin/_solib_local/_U#local_Uconfig_Usycl_S_Ssycl_Csyclrt___Uexternal_Slocal_Uconfig_Usycl_Ssycl_Slib/libComputeCpp.so:
undefined reference to `clSetUserEventStatus#OPENCL_1.1'
By using "strace" tool, i've isolated the exact statement that's failing to be:
(
cd /home/rh/.cache/bazel/_bazel_rh/81919f16ea125cb9f08993f06569f022/execroot/tensorflow && \
exec env - PATH=/home/rh/.nvm/versions/node/v6.9.5/bin:/home/rh/perl5/bin:/home/rh/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/rh/bin:/usr/local/java/jdk1.8.0_74/bin:/home/rh/.local/bin:/home/rh/myscripts \
/usr/bin/clang++-3.6 \
-o \
bazel-out/host/bin/tensorflow/python/gen_functional_ops_py_wrappers_cc \
-Lbazel-out/host/bin/_solib_local/_U#local_Uconfig_Usycl_S_Ssycl_Csyclrt___Uexternal_Slocal_Uconfig_Usycl_Ssycl_Slib \
-Wl,-rpath,$ORIGIN/../../_solib_local/_U#local_Uconfig_Usycl_S_Ssycl_Csyclrt___Uexternal_Slocal_Uconfig_Usycl_Ssycl_Slib \
-pthread \
-Wl,-no-as-needed \
-B/usr/bin/ \
-Wl,-no-as-needed \
-Wl,--build-id=md5 \
-Wl,--hash-style=gnu \
-Wl,-S \
-Wl,#bazel-out/host/bin/tensorflow/python/gen_functional_ops_py_wrappers_cc-2.params \
-Wl,--no-undefined
)
strace also confirms that this command IS reading /usr/local/computecpp/lib/libComputeCpp.so, which contains the aforementioned clSetUserEventStatus symbol.
I verified that libComputeCpp.so contains clSetUserEventStatus by checking the output of the nm command:
nm /usr/local/computecpp/lib/libComputeCpp.so | grep clSetUserEventStatus
>> U clSetUserEventStatus##OPENCL_1.1
So here is my question: clang (and/or its linker) is reading the file that contains the symbol that it's complaining about... why is it "missing something" and complaining that it's undefined?
How can I get this compile to work?

Related

How to run 'run_squad.py' on google colab? It gives 'invalid syntax' error

I downloaded the file first using:
!curl -L -O https://github.com/huggingface/transformers/blob/master/examples/legacy/question-answering/run_squad.py
Then used following code:
!python run_squad.py \
--model_type bert \
--model_name_or_path bert-base-uncased \
--output_dir models/bert/ \
--data_dir data/squad \
--overwrite_output_dir \
--overwrite_cache \
--do_train \
--train_file /content/train.json \
--version_2_with_negative \
--do_lower_case \
--do_eval \
--predict_file /content/val.json \
--per_gpu_train_batch_size 2 \
--learning_rate 3e-5 \
--num_train_epochs 2.0 \
--max_seq_length 384 \
--doc_stride 128 \
--threads 10 \
--save_steps 5000
Also tried following:
!python run_squad.py \
--model_type bert \
--model_name_or_path bert-base-cased \
--do_train \
--do_eval \
--do_lower_case \
--train_file /content/train.json \
--predict_file /content/val.json \
--per_gpu_train_batch_size 12 \
--learning_rate 3e-5 \
--num_train_epochs 2.0 \
--max_seq_length 584 \
--doc_stride 128 \
--output_dir /content/
The error says in both the codes:
File "run_squad.py", line 7
^ SyntaxError: invalid syntax
What exactly is the issue? How can I run the .py file?
SOLVED: It was giving error because I was downloading the github link rather than the script in github. Once I copied and used 'Raw' link to download the script, the code ran.

LLVM ERROR: Cannot select: intrinsic %llvm.objc.clang.arc.use

I'm getting the next error with llc when trying to to link some IR files:
LLVM ERROR: Cannot select: intrinsic %llvm.objc.clang.arc.use
I discovered that if I disabled clang optimization (O0) during compilation the error doesn't pop up, but I don't want to do that
I attach a sample of how to reproduce it, just cd the 'issue' folder and run the 'issue.sh' to reproduce the error. You must have Xcode (12.x preferred) tu run it
https://drive.google.com/file/d/1j0TvMZI2A7QxRbv_Q7aydtlNYaiTPYBm/view?usp=sharing
This is what the issue.sh contains, that is a reduced version of my real implementation:
echo "clang..."
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c \
-target arm64-apple-ios12.0 \
-fobjc-arc -fmodules \
-S -Os -flto=thin \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.1.sdk \
-fembed-bitcode \
-c ${PWD}/GTMSessionFetcher.m \
-o ${PWD}/GTMSessionFetcher.ll
echo "llc..."
${PWD}/llc \
GTMSessionFetcher.ll \
-stats -filetype=obj \
-code-model=small \
-enable-machine-outliner=never \
--mtriple=arm64-apple-ios12.0 \
-o ${PWD}/GTMSessionFetcher.o
As I mentioned before, if you change -Os for -O0, the error disappears, but I do need the size optimization.
The objective-c file that I included is a file from a pod from a Google library
https://github.com/google/gtm-session-fetcher
I found a similar question, but it doesn't have any answer yet
LLVM Error Cannot select intrinsic %llvm.coro.begin
I thought it was bug, but it wasn't
As Akira pointed me in LLVM bug report I was able to fix it by adding an intermediate optimizer OPT step with -objc-arc-contract flag:
clang
...
<path to your LLVM tools>/OPT \
<Your IR file> \
-objc-arc-contract \
-o <Output file>
llc
...

How to convert configure options for use with cmake

I have a script for building a project that I need to upgrade from using configure to cmake. The original configure command is
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
--with-clang \
--prefix=$PREFIX \
--libdir=$PREFIX/lib${LIBDIRSUFFIX} \
--incdir=$PREFIX/include \
--mandir=$PREFIX/man/man1 \
--etcdir=$PREFIX/etc/root \
--docdir=/usr/doc/$PRGNAM-$VERSION \
--enable-roofit \
--enable-unuran \
--disable-builtin-freetype \
--disable-builtin-ftgl \
--disable-builtin-glew \
--disable-builtin-pcre \
--disable-builtin-zlib \
--disable-builtin-lzma \
$GSL_FLAGS \
$FFTW_FLAGS \
$QT_FLAGS \
--enable-shared \
--build=$ARCH-slackware-linux
I am not familiar enough with cmake to know how to do the equivalent. I would prefer a command line option but am open to modifying the CMakeLists.txt file as well.

How can fixed this problem related with GEM5 , benchmark Parsec

sudo scons FULL_SYSTEM=1 build/ALPHA/gem5.opt RUBY=true PROTOCOL=MOESI_CMP_directory
build/ALPHA/gem5.opt configs/example/fs.py --cpu-type=timing \ --script=run_scripts/blackscholes_4c_simsmall.rcS \ --num-cpus=4 --ruby --mesh-rows=2 --garnet=fixed --topology=Mesh \ --caches --l2cache --l2_size=512kB --num-dirs=4 --num-l2=4 \ --l1d_size=32kB --l1i_size=32kB --l1d_assoc=2 --l1i_assoc=2 \ --kernel=/home/fur/gem5/full_system_images_ALPHA/binaries/vmlinux_2.6.27-gcc_4.3.4 \ --disk-image=/home/fur/gem5/full_system_images_ALPHA/disks/linux-parsec-2-1-m5-withtest-inputs.img
it gave my error: 'fixed' invalid value !!!
please how can fixed that?
GEM5, Parsec benchmark, ruby network

yum stopped working with error No module named transactioninfo

Removed the following files by mistake and as a result yum stopped working.
Any idea what rpms exactly we need to re-install?
./abrt_exception_handler.pyo
./abrt_exception_handler.pyc
./abrt.pth
./abrt_exception_handler.py
./yum/sqlitesack.pyo
./yum/rpmsack.pyo
./yum/packages.pyo
./yum/misc.pyo
./yum/metalink.pyo
./yum/__init__.pyo
./yum/history.pyo
./yum/depsolve.pyo
./rpmUtils/miscutils.pyo
./yum/yumRepo.pyo
./yum/yumRepo.pyc
./yum/yumRepo.py
./yum/update_md.pyo
./yum/update_md.pyc
./yum/update_md.py
./yum/transactioninfo.pyo
./yum/transactioninfo.pyc
./yum/transactioninfo.py
./yum/sqlutils.pyo
./yum/sqlutils.pyc
./yum/sqlutils.py
Ok, found the solution. Since I don't know exactly which python modules belongs to which rpm, I did a re-install of most of the dependent rpms. Here it goes.
#!/bin/bash
for file in \
elfutils-0.152-1.el6.x86_64.rpm \
elfutils-libs-0.152-1.el6.x86_64.rpm \
expat-2.0.1-11.el6_2.x86_64.rpm \
gmp-4.3.1-7.el6_2.2.x86_64.rpm \
libxml2-2.7.6-8.el6_3.4.x86_64.rpm \
libxml2-python-2.7.6-8.el6_3.4.x86_64.rpm \
m2crypto-0.20.2-9.el6.x86_64.rpm \
python-2.6.6-36.el6.x86_64.rpm \
python-iniparse-0.3.1-2.1.el6.noarch.rpm \
python-urlgrabber-3.9.1-8.el6.noarch.rpm \
readline-6.0-4.el6.x86_64.rpm \
rpm-4.8.0-32.el6.x86_64.rpm \
rpm-libs-4.8.0-32.el6.x86_64.rpm \
rpm-python-4.8.0-32.el6.x86_64.rpm \
sqlite-3.6.20-1.el6.x86_64.rpm \
yum-3.2.29-40.el6.centos.noarch.rpm \
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
do wget http://mirror.centos.org/centos-6/6/os/x86_64/Packages/$file;
done
rpm -Uvh *.rpm --force