This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Scala spin-off for the LLVM

10 replies
loxal
Joined: 2010-04-13,
User offline. Last seen 1 year 26 weeks ago.
I've read about creating a spin-off of Scala for the .NET environment... 
Is it feasible to create a spin-off for the LLVM (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would enable Scala apps to run natively on Google's Chromium OS (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html) which doesn't allow any "native code" apps in the classic sense. Also you'll have not to rely on a client-side JVM as LLVM will be built-in in Google's browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
Cheers -Alex
David Flemström
Joined: 2009-08-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala spin-off for the LLVM
A LLVM backend would also have other clear advantages, such as being able to produce much, much faster code that is optimized for a specific platform, or being able to use OpenCL in an efficient manner (there are plans for LLVM OpenCL backends). It would definitely be worth it to invest time in an effort like this.
Please have a look at the VMKit (http://vmkit.llvm.org/ ) project; might facilitate a LLVM port of the scala nsc.
(cross-posting to 'scala-debate'; not sure where this thread belongs)

On Sun, Apr 18, 2010 at 9:36 PM, Alexander Orlov <alexander [dot] orlov [at] loxal [dot] net> wrote:
I've read about creating a spin-off of Scala for the .NET environment... 
Is it feasible to create a spin-off for the LLVM (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would enable Scala apps to run natively on Google's Chromium OS (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html) which doesn't allow any "native code" apps in the classic sense. Also you'll have not to rely on a client-side JVM as LLVM will be built-in in Google's browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
Cheers -Alex

David Flemström
Joined: 2009-08-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala spin-off for the LLVM
A LLVM backend would also have other clear advantages, such as being able to produce much, much faster code that is optimized for a specific platform, or being able to use OpenCL in an efficient manner (there are plans for LLVM OpenCL backends). It would definitely be worth it to invest time in an effort like this.
Please have a look at the VMKit (http://vmkit.llvm.org/ ) project; might facilitate a LLVM port of the scala nsc.
(cross-posting to 'scala-debate'; not sure where this thread belongs)

On Sun, Apr 18, 2010 at 9:36 PM, Alexander Orlov <alexander [dot] orlov [at] loxal [dot] net> wrote:
I've read about creating a spin-off of Scala for the .NET environment... 
Is it feasible to create a spin-off for the LLVM (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would enable Scala apps to run natively on Google's Chromium OS (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html) which doesn't allow any "native code" apps in the classic sense. Also you'll have not to rely on a client-side JVM as LLVM will be built-in in Google's browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
Cheers -Alex

loxal
Joined: 2010-04-13,
User offline. Last seen 1 year 26 weeks ago.
Re: Scala spin-off for the LLVM
On Sun, Apr 18, 2010 at 9:45 PM, David Flemström <david [dot] flemstrom [at] gmail [dot] com> wrote:
Please have a look at the VMKit (http://vmkit.llvm.org/ ) project; might facilitate a LLVM port of the scala nsc.

So, basically it's already possible to execute Scala apps within the LLVM context. However a native LLVM compiler for scala would reduce the complexity and the number of additional abstraction layers. Nice to know about the feasibility of this option; cf. http://www.scala-lang.org/node/140 
-Alex
calathus
Joined: 2010-03-22,
User offline. Last seen 2 years 28 weeks ago.
Re: Re: Scala spin-off for the LLVM

Can you provide more information for LLVM OpenCL backends?

Is it only for chrome?
there is a open source project:
http://code.google.com/p/nativelibs4java/wiki/OpenCL

I'm interested in using openCL in Scala with higher level than OpenCL
API provide.
Do you have any idea for this?

On Sun, Apr 18, 2010 at 12:45 PM, David Flemström
wrote:
> A LLVM backend would also have other clear advantages, such as being able to
> produce much, much faster code that is optimized for a specific platform, or
> being able to use OpenCL in an efficient manner (there are plans for LLVM
> OpenCL backends). It would definitely be worth it to invest time in an
> effort like this.
> Please have a look at the VMKit (http://vmkit.llvm.org/ ) project; might
> facilitate a LLVM port of the scala nsc.
> (cross-posting to 'scala-debate'; not sure where this thread belongs)
>
> On Sun, Apr 18, 2010 at 9:36 PM, Alexander Orlov
> wrote:
>>
>> I've read about creating a spin-off of Scala for the .NET environment...
>> Is it feasible to create a spin-off for the LLVM
>> (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would
>> enable Scala apps to run natively on Google's Chromium OS
>> (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html)
>> which doesn't allow any "native code" apps in the classic sense. Also you'll
>> have not to rely on a client-side JVM as LLVM will be built-in in Google's
>> browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
>> Cheers
>> -Alex
>

calathus
Joined: 2010-03-22,
User offline. Last seen 2 years 28 weeks ago.
Re: Re: Scala spin-off for the LLVM

Can you provide more information for LLVM OpenCL backends?

Is it only for chrome?
there is a open source project:
http://code.google.com/p/nativelibs4java/wiki/OpenCL

I'm interested in using openCL in Scala with higher level than OpenCL
API provide.
Do you have any idea for this?

On Sun, Apr 18, 2010 at 12:45 PM, David Flemström
wrote:
> A LLVM backend would also have other clear advantages, such as being able to
> produce much, much faster code that is optimized for a specific platform, or
> being able to use OpenCL in an efficient manner (there are plans for LLVM
> OpenCL backends). It would definitely be worth it to invest time in an
> effort like this.
> Please have a look at the VMKit (http://vmkit.llvm.org/ ) project; might
> facilitate a LLVM port of the scala nsc.
> (cross-posting to 'scala-debate'; not sure where this thread belongs)
>
> On Sun, Apr 18, 2010 at 9:36 PM, Alexander Orlov
> wrote:
>>
>> I've read about creating a spin-off of Scala for the .NET environment...
>> Is it feasible to create a spin-off for the LLVM
>> (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would
>> enable Scala apps to run natively on Google's Chromium OS
>> (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html)
>> which doesn't allow any "native code" apps in the classic sense. Also you'll
>> have not to rely on a client-side JVM as LLVM will be built-in in Google's
>> browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
>> Cheers
>> -Alex
>

David Hall 4
Joined: 2009-08-21,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Scala spin-off for the LLVM

On Sun, Apr 18, 2010 at 12:45 PM, David Flemström
wrote:
> A LLVM backend would also have other clear advantages, such as being able to
> produce much, much faster code that is optimized for a specific platform, or
> being able to use OpenCL in an efficient manner (there are plans for LLVM
> OpenCL backends). It would definitely be worth it to invest time in an
> effort like this.

While I certainly would like to see an LLVM port of Scala, it's worth
pointing out that OpenCL bindings already exist from the JVM. They're
certainly not going to be as high-performing as you could get, but I
imagine it's better than nothing:

http://code.google.com/p/nativelibs4java/wiki/OpenCL

> Please have a look at the VMKit (http://vmkit.llvm.org/ ) project; might
> facilitate a LLVM port of the scala nsc.
> (cross-posting to 'scala-debate'; not sure where this thread belongs)
>
> On Sun, Apr 18, 2010 at 9:36 PM, Alexander Orlov
> wrote:
>>
>> I've read about creating a spin-off of Scala for the .NET environment...
>> Is it feasible to create a spin-off for the LLVM
>> (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would
>> enable Scala apps to run natively on Google's Chromium OS
>> (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html)
>> which doesn't allow any "native code" apps in the classic sense. Also you'll
>> have not to rely on a client-side JVM as LLVM will be built-in in Google's
>> browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
>> Cheers
>> -Alex
>

David Hall 4
Joined: 2009-08-21,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Scala spin-off for the LLVM

On Sun, Apr 18, 2010 at 12:45 PM, David Flemström
wrote:
> A LLVM backend would also have other clear advantages, such as being able to
> produce much, much faster code that is optimized for a specific platform, or
> being able to use OpenCL in an efficient manner (there are plans for LLVM
> OpenCL backends). It would definitely be worth it to invest time in an
> effort like this.

While I certainly would like to see an LLVM port of Scala, it's worth
pointing out that OpenCL bindings already exist from the JVM. They're
certainly not going to be as high-performing as you could get, but I
imagine it's better than nothing:

http://code.google.com/p/nativelibs4java/wiki/OpenCL

> Please have a look at the VMKit (http://vmkit.llvm.org/ ) project; might
> facilitate a LLVM port of the scala nsc.
> (cross-posting to 'scala-debate'; not sure where this thread belongs)
>
> On Sun, Apr 18, 2010 at 9:36 PM, Alexander Orlov
> wrote:
>>
>> I've read about creating a spin-off of Scala for the .NET environment...
>> Is it feasible to create a spin-off for the LLVM
>> (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would
>> enable Scala apps to run natively on Google's Chromium OS
>> (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html)
>> which doesn't allow any "native code" apps in the classic sense. Also you'll
>> have not to rely on a client-side JVM as LLVM will be built-in in Google's
>> browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
>> Cheers
>> -Alex
>

Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala spin-off for the LLVM

As long as a Scala program is compiled against libraries that LLVM supports there should be no problem in having a backend generate LLVM executables from the lowest-level internal representation (ICode) used by the Scala compiler (which gets fed to platform-specific backends, currently GenJVM and GenMSIL). Otherwise, additional program transformations are needed, to rephrase library calls unsupported in LLVM (thus avoiding one level of indirection when calling to library wrappers at runtime).   The nodes in ICode ASTs are instances of case classes, and the type system in effect is akin to that of the JVM (classes and interfaces, generic types have been erased into raw types, there's more but backends like GenJVM need only that).   Besides the starting point on writing compiler plugins [1], the write-ups at The Scala Compiler Corner(s) [2], [3] should also prove useful.   Miguel     [1] http://www.scala-lang.org/node/140   [2] http://www.sts.tu-harburg.de/people/mi.garcia/ScalaCompilerCorner   [3] http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded    
"Alexander Orlov" <alexander [dot] orlov [at] loxal [dot] net> wrote in message g2za3a342b71004181236yd88e4397z4f9bc6e778d66847 [at] mail [dot] gmail [dot] com" rel="nofollow">news:g2za3a342b71004181236yd88e4397z4f9bc6e778d66847 [at] mail [dot] gmail [dot] com...I've read about creating a spin-off of Scala for the .NET environment... 
Is it feasible to create a spin-off for the LLVM (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would enable Scala apps to run natively on Google's Chromium OS (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html) which doesn't allow any "native code" apps in the classic sense. Also you'll have not to rely on a client-side JVM as LLVM will be built-in in Google's browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
Cheers -Alex
Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala spin-off for the LLVM

Perhaps one more option. I'm not familiar with the way "LLVM libraries" or "OpenCL bindings for Java" can be consumed by the Scala compiler, but if all else fails, there's always the option of creating stubs (as done by IKVM, to provide a facade for .NET libraries in the form of a jar file). A backend for LLVM would then rephrase the call sites to such stubs, making them into the real thing.   http://www.ikvm.net/userguide/ikvmstub.html  
Miguel      
"Miguel Garcia" <miguel [dot] garcia [at] tuhh [dot] de> wrote in message 1 [at] dough [dot] gmane [dot] org" rel="nofollow">news:hqgvja$q8s$1 [at] dough [dot] gmane [dot] org...
As long as a Scala program is compiled against libraries that LLVM supports there should be no problem in having a backend generate LLVM executables from the lowest-level internal representation (ICode) used by the Scala compiler (which gets fed to platform-specific backends, currently GenJVM and GenMSIL). Otherwise, additional program transformations are needed, to rephrase library calls unsupported in LLVM (thus avoiding one level of indirection when calling to library wrappers at runtime).   The nodes in ICode ASTs are instances of case classes, and the type system in effect is akin to that of the JVM (classes and interfaces, generic types have been erased into raw types, there's more but backends like GenJVM need only that).   Besides the starting point on writing compiler plugins [1], the write-ups at The Scala Compiler Corner(s) [2], [3] should also prove useful.   Miguel     [1] http://www.scala-lang.org/node/140   [2] http://www.sts.tu-harburg.de/people/mi.garcia/ScalaCompilerCorner   [3] http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded    
"Alexander Orlov" <alexander [dot] orlov [at] loxal [dot] net> wrote in message g2za3a342b71004181236yd88e4397z4f9bc6e778d66847 [at] mail [dot] gmail [dot] com" rel="nofollow">news:g2za3a342b71004181236yd88e4397z4f9bc6e778d66847 [at] mail [dot] gmail [dot] com...I've read about creating a spin-off of Scala for the .NET environment... 
Is it feasible to create a spin-off for the LLVM (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would enable Scala apps to run natively on Google's Chromium OS (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html) which doesn't allow any "native code" apps in the classic sense. Also you'll have not to rely on a client-side JVM as LLVM will be built-in in Google's browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
Cheers -Alex
Sylvain HENRY
Joined: 2009-05-28,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Scala spin-off for the LLVM

Le 19/04/2010 03:44, calathus a écrit :
> Can you provide more information for LLVM OpenCL backends?
>
> Is it only for chrome?
> there is a open source project:
> http://code.google.com/p/nativelibs4java/wiki/OpenCL
>
> I'm interested in using openCL in Scala with higher level than OpenCL
> API provide.
> Do you have any idea for this?
>
I'm currently working on this as it may become a part of my PhD thesis
[0]. I tried to use the binding from nativelibs4java project but it
requires too many dependencies (JNAerator, etc.) for my liking,
especially regarding a library as simple as OpenCL.
You can find my project here: http://github.com/hsyl20/Auratune

The binding part with SNA (JNA) is mostly done (image object management
excepted) but could (and will) still be enhanced. I've started working
on kernel generation from higher concepts but it is still alpha and
experimental (see TestLanguage test).

This project is still really alpha and I would not have speak about it
if this topic hadn't been raised. ;-)

Cheers
Sylvain

[0] It's not yet sure that I will work on OpenCL with Scala in part of
my PhD because people with HPC background don't consider using anything
more abstract than C/OpenMP/MPI... Anyway I'll do it on my free time if
necessary.
>
> On Sun, Apr 18, 2010 at 12:45 PM, David Flemström
> wrote:
>
>> A LLVM backend would also have other clear advantages, such as being able to
>> produce much, much faster code that is optimized for a specific platform, or
>> being able to use OpenCL in an efficient manner (there are plans for LLVM
>> OpenCL backends). It would definitely be worth it to invest time in an
>> effort like this.
>> Please have a look at the VMKit (http://vmkit.llvm.org/ ) project; might
>> facilitate a LLVM port of the scala nsc.
>> (cross-posting to 'scala-debate'; not sure where this thread belongs)
>>
>> On Sun, Apr 18, 2010 at 9:36 PM, Alexander Orlov
>> wrote:
>>
>>> I've read about creating a spin-off of Scala for the .NET environment...
>>> Is it feasible to create a spin-off for the LLVM
>>> (http://en.wikipedia.org/wiki/LLVM)? Compiling Scala to LLVM's bitcode would
>>> enable Scala apps to run natively on Google's Chromium OS
>>> (cf. http://blog.chromium.org/2010/03/native-client-and-web-portability.html)
>>> which doesn't allow any "native code" apps in the classic sense. Also you'll
>>> have not to rely on a client-side JVM as LLVM will be built-in in Google's
>>> browser independent NaCl plugin (cf. http://nativeclient.googlecode.com/).
>>> Cheers
>>> -Alex
>>>
>>
>
>
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland