Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Jul 2014 11:08:00 +0200
From:      Eduardo Morras <emorrasg@yahoo.es>
To:        Shane Ambler <FreeBSD@ShaneWare.Biz>
Cc:        sfourman@gmail.com, freebsd-questions@freebsd.org
Subject:   Re: OpenCL under FreeBSD-10?
Message-ID:  <20140706110800.d93a5993ddb05af2e8253844@yahoo.es>
In-Reply-To: <53B7901F.3020909@ShaneWare.Biz>
References:  <1404438060.76015.15.camel@btw.pki2.com> <20140705004936.86a175a89bd607eddb879eed@yahoo.es> <CAOFF%2BZ3Sg78Oj=SgB0ncbBHC54X2U3rcK%2BQXWaZ%2BSvFY6WcEFw@mail.gmail.com> <53B7901F.3020909@ShaneWare.Biz>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 05 Jul 2014 15:11:51 +0930
Shane Ambler <FreeBSD@ShaneWare.Biz> wrote:

> On 05/07/2014 08:31, Sam Fourman Jr. wrote:
> > I am also interested in this..
> > 
> > 
> > On Fri, Jul 4, 2014 at 5:49 PM, Eduardo Morras <emorrasg@yahoo.es>
> > wrote:
> > 
> >> On Thu, 03 Jul 2014 18:41:00 -0700
> >> Dennis Glatting <freebsd@pki2.com> wrote:
> >>
> >>> Is there a working version of OpenCL somewhere for FreeBSD10?
> >>> freeocl is broken, badly.
> >>
> >> Googling a bit shows llvm libclc project that outputs PTX (Nvidia)
> >> code. Clang+llvm is part of the system, don't know if this piece
> >> of llvm project has been ported too.
> >>
> >> http://llvm.org
> >>
> >> http://libclc.llvm.org/
> 
> According to http://llvm.org/docs/doxygen/html/Triple_8h_source.html
> llvm supports spir and spir64 for "standard portable IR for OpenCL"
> 
> Unfortunately we don't appear to have this enabled on freebsd.
> From a ports installed llvm - `llc33 --version`
> (base installed llc is a shorter list of only supported host cpu's)
> 
> LLVM (http://llvm.org/):
>   LLVM version 3.3
>   Optimized build.
>   Built Mar 21 2014 (05:38:50).
>   Default target: amd64-portbld-freebsd9.2
>   Host CPU: corei7-avx
> 
>   Registered Targets:

>     nvptx    - NVIDIA PTX 32-bit
>     nvptx64  - NVIDIA PTX 64-bit

Then the target for nvidia assembler is enabled. My output for llc33 and llc34 --version shows the same results. This permit us to convert from llvm IR to nvidia PTX.

Digging a bit more I found this page: 
http://steckdenis.be/post-2011-05-02-using-clang-to-compile-opencl-kernels.html

Following it's examples show me:
camibar% clang -v
FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
Target: x86_64-unknown-freebsd9.2
Thread model: posix
%mkdir opencl
%cd opencl

create file test.cl
/* Header to make Clang compatible with OpenCL */
#define __global __attribute__((address_space(1)))
int get_global_id(int index);

/* Test kernel */
__kernel void test(__global float *in, __global float *out)
{
    int index = get_global_id(0);
    out[index] = 3.14159f * in[index] + in[index];
}

%clang -S -emit-llvm -o test.ll -x cl test.cl
%ls
test.cl test.ll
%more test.ll
; ModuleID = 'test.cl'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-freebsd9.2"

; Function Attrs: nounwind uwtable
define void @test(float addrspace(1)* nocapture %in, float addrspace(1)* nocapture %out) #0 {
entry:
  %call = tail call i32 @get_global_id(i32 0) #3
  %idxprom = sext i32 %call to i64
  %arrayidx = getelementptr inbounds float addrspace(1)* %in, i64 %idxprom
  %0 = load float addrspace(1)* %arrayidx, align 4, !tbaa !1
...

So, clang3.3 in FreeBSD can compile opencl code to llvm assm (llvm IR). 

Will dig more when I'll have more time. 

Feel free to expand this mail thread.


---   ---
Eduardo Morras <emorrasg@yahoo.es>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140706110800.d93a5993ddb05af2e8253844>