Getting started with OpenCL on the Parallella

Moderator: dar

Getting started with OpenCL on the Parallella

Postby smoothy » Tue Jul 05, 2016 6:31 pm

Hi,

I thought it would be nice to share some experience on getting started with OpenCL, COPRTHR and STDCL on the Parallella board.

After a few hair-ripping attempts to install coprthr 1.6.0, I followed this guide here:

http://www.browndeertechnology.com/docs/app_note_epiphany_parallella_build.pdf

I didn't install the optional packages m4-1.4.16, flex-2.5.35 and bison-2.5 since m4 and bison had some make errors in previous attempts even though I installed them in the correct order.

The packages libelf, libevent and libconfig are mandatory however before installing COPRTHR. Simply download these packages following the links in the guide,
unzip with tar -xzvf file.tar.gz
cd into the new folder
./configure
sudo make install

I went for the pre-build browndeer package which is pre-installed on the newest Linaro desktop version 14.04.
DO NOT run the uninstall script when you're in the /usr/local/ directory since this will remove the browndeer directory.
Then run sudo ./browndeer/scripts/install_coprthr_parallella.sh
For me, this went fast since the terminal says most files already existed, so I guess it was preinstalled.
Then I set the 2 paths for root and user as described in the guide, copied the test and examples directories into my Work folder existing in /home/linaro with

cp -R /usr/local/browndeer/examples ./Work
cp -R /usr/local/browndeer/test ./Work

Then go into test folder and execute the test as root.

cd Work/test
sudo su
make quicktest

Very important to note is that all the tests should finish with [pass], except for the test
test_stdcl_ndev_float4 stddev 1
which is expected to [fail], which shouldn't be a problem.

Now that COPRTHR seems to be set up and good to go, I want to start programming and testing.
I cd into /Work/examples/parallella/hello_opencl
and run the compile cmd as provided in the README.txt file:

gcc hello_opencl.c -o hello_opencl.x -I/usr/local/browndeer/include \ -L/usr/local/browndeer/lib -lcoprthr-e
/usr/bin/ld: cannot find -lcoprthr-e
collect2: error: ld returned 1 exit status

I successfully reinstalled COPRTHR using the latest stable version from source https://github.com/browndeer/coprthr
and still get the same error. Running the other browndeer examples won't work for me either.
Somehow the path does not seem to be set correctly and the linker doesn't seem find the file. Could anybody give me some support on how to fix this please?

Cheers
Last edited by smoothy on Tue Jul 12, 2016 1:33 pm, edited 2 times in total.
smoothy
 
Posts: 6
Joined: Sun Jul 03, 2016 4:13 pm

Re: Getting started with OpenCL on the Parallella

Postby smoothy » Wed Jul 06, 2016 2:27 pm

Has nobody ever encountered this problem beforer? It seems that my linker can't find the library statically, also the path looks wrong. I saw in one of the very first posts here that lcoprthr-e seems to be the platform implementation for the epiphany arcitecture. But I still couldn't find a way to fix this.

please help...
smoothy
 
Posts: 6
Joined: Sun Jul 03, 2016 4:13 pm

Re: Getting started with OpenCL on the Parallella

Postby smoothy » Mon Jul 11, 2016 11:52 pm

Ok then, I guess the compile cmd in the README.txt is simply out of date or something...
So I couldn't find a coprthr-e file anywhere, but compiling the hello_opencl example with ocl should do the trick:

gcc -o hello_opencl.x hello_opencl.c -I/usr/local/browndeer/include \-L/usr/local/browndeer/lib -locl
smoothy
 
Posts: 6
Joined: Sun Jul 03, 2016 4:13 pm

Re: Getting started with OpenCL on the Parallella

Postby Fabian » Fri Oct 28, 2016 2:29 pm

Hello smoothy,
even though your post is a little in the past I will write about my experience.

I did the same as you. I also followed the guide (http://www.browndeertechnology.com/docs/app_note_epiphany_parallella_build.pdf) and installed the first three Pre-requisites.The addition Pre-requisites were already installed. So I am using:
[*]m4 (GNU M4) 1.4.17 (instead of 1.4.1)
[*]flex 2.5.39 (instead of 2.5.3)
[*]bison (GNU Bison) 3.0.2 (instead of 2.5)
I assumed that this was not an issue.

Afterwards I installed the pre-compiled package and updated the .bashrc file for both root and user. The installation I have done being logged in as root. Did you do the installation as root?

Then I went on to section 3 Testing. I am little confused the with commands
Code: Select all
cd ./work/test
su
make quicktest

and their sentence:
Typical problems are (...) attempting to run the test as a user (incorrect) and not root(correct)

Because for me executing the command su as suggested, will switch to root on the parallella:
Code: Select all
fabian@parallella:/home/parallella/testOpenCL/test$ su
Password:
root@parallella:/home/parallella/testOpenCL/test#

So why is it incorrect to be root if they say su?

Furthermore for me the make quicktest only runs through when I am root. (If am not root it can't find: libstdcl.so.)
The last tests all pass. But some of the first tests fail (All stdcpu pass and all stdacc and stddev fail) This is part of the output:
Code: Select all
root@parallella:/home/parallella/testOpenCL/test# make quicktest
(...)
./test_stdcl_arg_int.x 65536 16 (stdcpu 0)                              [pass]
./test_stdcl_arg_int.x 65536 16 (stdacc 0)                            [failed]
./test_stdcl_arg_int4.x 65536 16 (stddev 0)                         ./scripts/run_quick_tests.sh: line 3:  4673 Segmentation fault      $1 --size $2 --blocksize $3 --di
  [failed]
./test_stdcl_arg_int4.x 65536 16 (stddev 1)                         ./scripts/run_quick_tests.sh: line 3:  4765 Segmentation fault      $1 --size $2 --blocksize $3 --di
  [failed]
./test_stdcl_arg_int4.x 65536 16 (stdcpu 0)                             [pass]
(...)
RUNNING TESTS ...
./test_arg_int.x 65536 16                                               [pass]
(...)
./test_special.x 65536 16                                               [pass]
... TESTS COMPLETE.


Nevertheless I continued and went to the examples. Compiling the hello world example did also not work for me using their command from the readme. Your command runs for me without an error message or warning:

smoothy wrote:gcc -o hello_opencl.x hello_opencl.c -I/usr/local/browndeer/include \-L/usr/local/browndeer/lib -locl


I can run ./hello_opencl.x and receive a lot of output lines ...
Code: Select all
(...)
c[1018] 1139956.500000
c[1019] 1142197.125000
c[1020] 1144440.000000
c[1021] 1146685.125000
c[1022] 1148932.500000
c[1023] 1151182.000000
clWaitForEvents returned 0
[7492] clmesg info: cmdsched.c(181): cmdqx1: shutdown


Which I guess is the correct output looking briefly at this rather complex hello world example.

Thanks very much for your command, that saved me some time :) !
Fabian
 
Posts: 10
Joined: Wed Aug 31, 2016 7:54 am

Re: Getting started with OpenCL on the Parallella

Postby jar » Fri Oct 28, 2016 5:26 pm

I think some of those quicktest codes are expected to fail. So carry on.

With that said, OpenCL isn't really the best model for Epiphany as I've said many times in other posts on the forum.
User avatar
jar
 
Posts: 295
Joined: Mon Dec 17, 2012 3:27 am

Re: Getting started with OpenCL on the Parallella

Postby Fabian » Wed Nov 02, 2016 7:26 am

jar wrote:With that said, OpenCL isn't really the best model for Epiphany as I've said many times in other posts on the forum.


What would you consider the best model? MPI? OpenMP? I picked OpenCL, because it seemed to discussed the most and widely used among others.

I looked at the COPRTHR-2 that you actively present. But my problem with that approach is that I am running a parallella 4.4.0 and don't want to reinstall parallella3 3.14.12.
Fabian
 
Posts: 10
Joined: Wed Aug 31, 2016 7:54 am

Re: Getting started with OpenCL on the Parallella

Postby jar » Wed Nov 02, 2016 1:34 pm

OpenMP works if your problem is trivially parallel (no inter-core synchronization). I saw there were some new examples published recently.

The eSDK is okay if you don't mind writing the primitives you may need, but it's non-standard and takes some effort to learn.

I'm working to get OpenSHMEM support with eSDK and COPRTHR-2 (which has a partial implementation of MPI) and the 2016.3 image, but there are a lot of moving pieces that I do not control. It might be one or two months. I know that doesn't help you now.
User avatar
jar
 
Posts: 295
Joined: Mon Dec 17, 2012 3:27 am

Re: Getting started with OpenCL on the Parallella

Postby Fabian » Wed Nov 02, 2016 5:00 pm

Thanks for your answer.

I have been working with the eSDK so far. I was just looking for smarter ways to implement on the epiphany. I might look at OpenMP as well.
Fabian
 
Posts: 10
Joined: Wed Aug 31, 2016 7:54 am


Return to OpenCL

Who is online

Users browsing this forum: Google [Bot] and 1 guest