How to access/use the E16/64 from the R prompt - Part 1

Moderator: censix

How to access/use the E16/64 from the R prompt - Part 1

Postby censix » Wed Jun 12, 2013 8:13 pm

The purpose of this post is to show how to install the "ROpenCL" R package so that we can then quickly put together a simple *parallel* vector addition example that will run on the E16/64. The first part of this process is a bit more involved, but don't get stressed. We only will have to do it once. The general idea is to show how we can, very easily, run standard OpenCL programs on the E16/64 without having to go thought the compile/link/run process every time. Instead we'll let R take care of that.

We assume that you have followed the steps for installing R successfully. We also assume that you have installed the parallella eSDK and the COPRTHR library.

Before we start, make sure you have the following environment variables set. (Replace "/home/censix/compile" with whaetever is appropriate for your system and home directory)

Code: Select all
export PATH="/home/censix/compile/R-2.15.1/bin:$PATH"
export PATH="/usr/local/browndeer/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/browndeer/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/opt/adapteva/esdk/tools/host/armv7l/lib:$LD_LIBRARY_PATH"


Now start R and install the "Rcpp" package

Code: Select all
R
R>  install.packages("Rcpp")


Once that is done, quit R and download the sources for the "ROpenCL" package from the openanalytics site (they are not available in the standard R package repository yet) and extract them to your home directory. We'll have to tweak them a bit.

Code: Select all
wget http://repos.openanalytics.eu/src/contrib/ROpenCL_0.1-1.tar.gz
tar zxf ROpenCL_0.1-1.tar.gz


Download and apply the patch "parallella-ROpenCL_0.1-1.patch". (The patch will make sure that, when we install the ROpenCL package it will be linked against the OpenCL headers provided by COPRTHR)

Code: Select all
wget http://censix.com/parallella/parallella-ROpenCL_0.1-1.patch
patch -p0 <parallella-ROpenCL_0.1-1.patch


Now we can install the modified package code. The quick way to do this is to put yourself in the home directory and issue the following command, which will take the contents of the "ROpenCL" directory we just modified and use them to build and install a new R package automatically.

Code: Select all
R CMD INSTALL ROpenCL


You will see the R build process, and toward the end you will get this message that looks very much like an error, but is not, according to the creators of the COPRTHR library.

** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
[17289] clmesg CRITICAL: libocl.c(849): Linux mmap does not support MAP_NOSYNC, demand a work-around
_libocl_clproc_state 0xb6f44000

* DONE (ROpenCL)


Now we are ready to check if the E16/64 is really alive and can be seen by from R. For that, the forums says that you will need to be root. So be it ... root

Code: Select all
sudo su
export LD_LIBRARY_PATH="/usr/local/browndeer/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/opt/adapteva/esdk/tools/host/armv7l/lib:$LD_LIBRARY_PATH"
R
R> require(ROpenCL)


What you should see is this:

Loading required package: ROpenCL
Loading required package: Rcpp
[17316] clmesg CRITICAL: libocl.c(849): Linux mmap does not support MAP_NOSYNC, demand a work-around
_libocl_clproc_state 0xb6fa6000


Again, the "clmesg CRITICAL.." is NOT an error, just some annoying output that will hopefully disappear in future releases of COPRTHR.

Good, so now we can do the final test. Try to get the E16/64 deviceId from the R prompt.

Code: Select all
> p <- getPlatformIDs()
coprthr-1.6.0 (Freewill)
> d <- getDeviceIDs(p[[1]])
> d
[[1]]
<pointer: 0x224548>

[[2]]
<pointer: 0x5bdea0>


That is the output we want! Time to take a break and continue with part 2 of this post ...
censix
 
Posts: 49
Joined: Sun Dec 16, 2012 7:54 pm
Location: europe

Re: How to access/use the E16/64 from the R prompt - Part 1

Postby censix » Thu Jun 12, 2014 6:45 pm

Important:

Please note that the Epiphany always shows up as the second device in the list! The first evice d[[1]] is always the ARM host.
The Epiphany is d[[2]].
censix
 
Posts: 49
Joined: Sun Dec 16, 2012 7:54 pm
Location: europe

Re: How to access/use the E16/64 from the R prompt - Part 1

Postby Tohru » Fri Jan 02, 2015 1:52 pm

Thank you for your nice introduction of ROpenCL. I have tried to install it, but 'parallella-ROpenCL_0.1-1.patch' is not fit for ROpenCL 0.1-2. I hope the patch will be revised.
Tohru
 
Posts: 1
Joined: Thu Jan 01, 2015 9:59 am

Re: How to access/use the E16/64 from the R prompt - Part 1

Postby NelsCarlson » Fri Aug 07, 2015 2:22 pm

I'm getting an extra prompt when I try to apply the patch.

After I type:
Code: Select all
$ patch -p0 <parallella-ROpenCL_0.1-1.patch


I'm prompted with:
Code: Select all
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -ruNp ROpenCL//src/createContext.cpp ROpenCL1//src/createContext.cpp
|--- ROpenCL//src/createContext.cpp      2012-03-01 18:33:41.000000000 +0000
|+++ ROpenCL1//src/createContext.cpp     2013-06-11 17:25:51.614739313 +0000
--------------------------
File to patch:


I've tried typing the paths to several directories and files that seem appropriate, but nothing has worked.

I get this error:
Code: Select all
File /home/parallella/R-3.0.3 is not a regular file -- refusing to patch
1 out of 1 hunk ignored -- saving rejects to file /home/parallella/R-3.0.3.rej


Any help would be appreciated I would love to get R working on my parallella
NelsCarlson
 
Posts: 2
Joined: Fri Aug 07, 2015 2:12 pm

Re: How to access/use the E16/64 from the R prompt - Part 1

Postby piotr5 » Sat Aug 08, 2015 12:05 pm

not sure how much you know about patch.
basically you first type "cd pathname" where pathname is the location of whatever sourcecode. then do "patch -p1 <patchname" where patchname is the name of whatever patch-file you use, probably "../parallella-ROpenCL_0.1-1.patch" in your case. never tried "man patch"?
piotr5
 
Posts: 230
Joined: Sun Dec 23, 2012 2:48 pm

Re: How to access/use the E16/64 from the R prompt - Part 1

Postby NelsCarlson » Mon Aug 10, 2015 2:11 pm

I believe the problem is that some of the links are dead and as a result I've downloaded ROpenCL1-0.1 from a different link: https://github.com/aaronpuchert/ROpenCL ... 1-1.tar.gz The build no longer happens automatically, all I'm asking is in the standard setup what file is being patched? You reference a directory in which the source code is stored, what source code are you referring to? If its the patch, I know that, the problem is that I'm not entirely sure where to apply the patch.

Looking at the patch it appears to look for this directory
Code: Select all
ROpenCL//src/createContext.cpp


This does not exist on my parallella.
NelsCarlson
 
Posts: 2
Joined: Fri Aug 07, 2015 2:12 pm

Re: How to access/use the E16/64 from the R prompt - Part 1

Postby piotr5 » Tue Aug 11, 2015 1:15 pm

why not use http://repos.openanalytics.eu/src/contrib/ROpenCL_0.1-2.tar.gz? as mentioned above, you'd need to alter the files manually to reflect the changes intended by the patch...
piotr5
 
Posts: 230
Joined: Sun Dec 23, 2012 2:48 pm

Re: How to access/use the E16/64 from the R prompt - Part 1

Postby davewr2015 » Sun Aug 30, 2015 1:05 am

Has anyone tested this with R3.03?

The latest README implies that it will work -- however -- as noted the patch files are out of date.

Any thoughts? Is there a new (working) procedure?
davewr2015
 
Posts: 7
Joined: Sat Aug 29, 2015 8:57 pm


Return to R

Who is online

Users browsing this forum: No registered users and 2 guests

cron