Skip to content

scalan/scalanizer-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scalanizer-sample

This project contains source code that is used in Scala Days 2015 Amsterdam talk. See example implementation of matrix-vector multiplication written in functional style using Matr, Vec and Col abstract types.

Note that both Matr and Vec types are parameterized by the type of the elements T. In order to perform operations on elements some methods have implicit typeclass arguments Num or NumMonoid.

DenseMatr class implements abstract interface Matr keeping matrix data in a collection of type Col[Vec[T]]. This means that even though DenseMatr is a concrete implementation of Matr it is still abstracted from concrete implementations of both Col interface and Vec types. This allows to specialize abstract mvm code in many different ways.

Method LA.ddmvm shows how to use abstract mvm function with concrete data stored in the nested array of type Array[Array[Double]].

Note that LA.ddmvm method annotated with @HotSpot. This annotation is recognized by Scalanizer plugin. Scalanizer takes AST of LA.ddmvm method and produces its virtualized version. (See LinearAlgebraOpsImpl.scala file, which is generated by Scalanizer and saved in the repository for demonstration)

Method LA.ddmvm is called from LinearAlgebraTests.scala file.

In order to understand how Scalanizer works, run compilation and observe generated xxxImpl files which are saved in impl subdirectories. Look for

If -P:scalan:debug compiler option is specified Scalanizer will output additional files then show the content of the hotspot after it is replaces by Scalanizer. The files are stored in the directory specified in ScalanPluginConfig.home field.

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages