2

I've been following this tutorial to install openacc locally on my jetson tk1 and I'm finding the install script to be incorrect. I didn't see any errors when I compiled the openacc library, however when I attempt to compile I get an error that says

ubuntu@tegra-ubuntu:~/apps/acc/accull/yacf/examples/acc$ accull -v -o gpu.x  acc_test.c 
 **************************************** 
                 _    _ _      _          
                | |  | | |    | |         
   __ _  ___ ___| |  | | |    | |         
  / _` |/ __/ __| |  | | |    | |         
 | (_| | (_| (__| |__| | |____| |____     
  \__,_|\___\___|\____/|______|______|    
 **************************************** 
 Release 0.4alpha 

* Verbose output
* Output executable name gpu.x
* Processing acc_test.c to ./accull_k3Ty8/acc_test.c
* Building acc_test.c
* Running StS translation 
Traceback (most recent call last):
  File "/home/ubuntu/apps/acc/accull/yacf//bin/c2frangollo.py", line 64, in <module>
    from Backends.Frangollo.Mutators.Common import FrangolloMutatorError
  File "/home/ubuntu/apps/acc/accull/yacf/Backends/Frangollo/Mutators/Common.py", line 33, in <module>
    from Backends.C99.Visitors.LlcFilters import AccScopeReverse, AccScopeFilter
  File "/home/ubuntu/apps/acc/accull/yacf/Backends/C99/Visitors/LlcFilters.py", line 40, in <module>
    from Tools.Tree import NodeNotFound
  File "/home/ubuntu/apps/acc/accull/yacf/Tools/Tree.py", line 34, in <module>
    c_ast = getCurrentLanguageAst()
  File "/home/ubuntu/apps/acc/accull/yacf/Frontend/Shortcuts.py", line 40, in getCurrentLanguageAst
    myclass = __import__(config.FRONTEND_MODULE + '.' + str(name) + "." + str(name).lower() + '_ast', globals(), locals(), [str(name),])
  File "/home/ubuntu/apps/acc/accull/yacf/Frontend/C99/__init__.py", line 16, in <module>
    from .c99_parser import C99Parser
  File "/home/ubuntu/apps/acc/accull/yacf/Frontend/C99/c99_parser.py", line 15, in <module>
    import ply.yacc
ImportError: No module named ply.yacc
! Compilation of acc_test.c FAILED (no Project directory build )
/usr/local/cuda/bin/nvcc -Xcompiler -fopenmp -lrt -lcuda -lOpenCL -lrt -lcuda -arch=sm_20 *.o /home/ubuntu/apps/acc/accull/frangollo/src/libfrangollo.a -o gpu.x
nvlink fatal   : Could not open input file '*.o'
* Finished

http://scelementary.com/2015/04/30/openacc-on-jetson-tk1.html

#!/bin/bash

ACCULLROOT=/home/ubuntu/apps/acc

mkdir -p $ACCULLROOT/source
cd $ACCULLROOT/source

wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz
wget https://pypi.python.org/packages/source/S/Sphinx/Sphinx-1.3.1.tar.gz
wget http://lxml.de/files/lxml-3.4.2.tgz
wget http://www.dabeaz.com/ply/ply-3.4.tar.gz
wget https://pypi.python.org/packages/source/M/Mako/Mako-1.0.1.tar.gz

tar xvf Python-2.7.9.tar.xz
cd Python-2.7.9/
./configure --prefix=$ACCULLROOT
make -j2 
make install

list=(Sphinx-1.3.1.tar.gz lxml-3.4.2.tgz ply-3.4.tar.gz Mako-1.0.1.tar.gz)
for file in $list
do
  if [ "$file" == "*.tgz" ] 
    name=$(basename $file .tgz)
  then
    name=$(basename $file .tar.gz)
  fi

  tar zxvf $file
  cd $basename
  $ACCULLROOT/bin/python setup.py build
  $ACCULLROOT/bin/python setup.py install
  cd ..

done
1
  • You might have to run the script as root/sudo. You could also try to install ply manually. pip install ply Commented Jan 30, 2016 at 18:16

1 Answer 1

1

There are several problems:

  • You initialize an array called list but you attempt to iterate over its elements like this for file in $list which will only iterate over the first element, since $list is like ${list[0]}. Use for file in "${list[@]}" to iterate over the complete array.
  • Don't forget to double-quote your expansions to prevent Globbing and WordSplitting. For example name=$(basename $file .tar.gz) or tar zxvf $file will yield unwanted results in case the the value of the variable file contains white-spaces and is left without double-quotes ( i.e. $file instead of the correct form: "$file" )
  • I guess that you mistakenly used cd $basename instead of cd "$name" - or something else, if it doesnt make sense. Anyhow the variable name appears to be unused.
  • This line [ "$file" == "*.tgz" ] is probably wrong. It seems that the writer is attempting to match "$file" against a glob pattern. Well, in order to do that, two things must change: 1. Use [[ instead of [, since the command [ simply does not support glob matching. 2. The double-quotes around *.tgz should be removed - otherwise, "$file" will be matched against a literal *.tgz. So to summarize 1 and 2, the script should use [[ $file = *.tgz ]] instead of [ "$file" == "*.tgz" ]. I encourage you to read further about TestsAndConditionals and to see this great FAQ, which is a part of this Bash Guide - probably one of the best ( if not the only ) source to learn Bash from.
  • The script does not check whether cd exited successfully, and simply continues on. It can give unwanted results. cd || exit is prefered, but modify it to be descriptive to the user.
  • Regarding the variable ACCULLROOT : By convention, environment variables (PATH, EDITOR, SHELL, ...) and internal shell variables (BASH_VERSION, RANDOM, ...) are fully capitalized. All other variable names should be lowercase. Since variable names are case-sensitive, this convention avoids accidentally overriding environmental and internal variables.
Sign up to request clarification or add additional context in comments.

1 Comment

I didn't see this before and I've seen found an alternative to openacc but thank you for this detailed reply!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.