L Fu - Dao: a novel programming language for bioinformatics
1. Motivation Example Features Concurrent Programming JIT ClangDao Future
Dao: a novel programming language for
bioinformatics
Limin Fu
UC San Diego
BOSC 2012
July 14, 2012
2. Motivation Example Features Concurrent Programming JIT ClangDao Future
Why a new language for bioinformatics?
A simple fact:
Programming languages commonly used in bioinformatics are
designed before:
multi-core machines started to become common;
some important programming paradigms are widely accepted.
Once a language has got a lot of backward compatibility to maintain,
it becomes very hard to add new features or support new
programming paradigms without introducing inconsistency!
3. Motivation Example Features Concurrent Programming JIT ClangDao Future
Dao programming language (http://daovm.net)
Key Features
Optional typing with type inference and static type checking;
Native support for concurrent programming;
LLVM-based Just-In-Time (JIT) compiling;
Simple C interfaces for easy embedding and extending;
Clang-based tool for automatic wrapping of C/C++ libraries;
4. Motivation Example Features Concurrent Programming JIT ClangDao Future
A simple example
Use thread task to compute the sum of squares:
# Start a thread task and return a future value:
fut = mt.start( $now )::{
sum2 = 0
for( i = 1 : 1000 ) sum2 += i * i
return sum2
}
5. Motivation Example Features Concurrent Programming JIT ClangDao Future
A simple example
Use thread task to compute the sum of squares:
# Start a thread task and return a future value:
fut = mt.start( $now )::{
sum2 = 0
for( i = 1 : 1000 ) sum2 += i * i
return sum2
}
Due to type inference, variable fut will be a future value with type,
future<int>
It is optional to write the type explicitly as the following,
fut : future<int> = mt.start( $now )::{ ...
6. Motivation Example Features Concurrent Programming JIT ClangDao Future
A simple example
Use thread task to compute the sum of squares:
# Start a thread task and return a future value:
fut = mt.start( $now )::{
sum2 = 0
for( i = 1 : 1000 ) sum2 += i * i
return sum2
}
mt built-in module for multi-threading;
mt.start()::{} a code section method to start a thread task;
The thread task will be executed in a different thread.
7. Motivation Example Features Concurrent Programming JIT ClangDao Future
A simple example
Use thread task to compute the sum of squares:
# Start a thread task and return a future value:
fut = mt.start( $now )::{
sum2 = 0
for( i = 1 : 1000 ) sum2 += i * i
return sum2
}
An enum symbol to request immediate start of the thread task.
(More or less a combination of C++ enum and Ruby symbol.)
8. Motivation Example Features Concurrent Programming JIT ClangDao Future
Concurrent programming: parallelized code section methods
Parallelized code section methods
The multi-threading module mt provides a number of parallelized
code section methods:
mt.iterate(): iterate on array, list, map, or a number of iteration;
mt.map(): map items of array, list or map to produce new array or list;
mt.apply(): apply new values to the items of array, list or map;
mt.find(): find the first item that satisfy a condition;
Example,
ls = {1,2,3,4,5,6}
# Parallel iteration:
mt.iterate( times => 10 )::{ [index] io.writeln( index ) }
mt.iterate( ls, threads => 2 )::{ [item] io.writeln( item ) }
# Parallel mapping and value application:
ls2 = mt.map( ls, 2 )::{ [it] it*it } # ls2 = {1,4,9,16,25,36}
mt.apply( ls, 2 )::{ [it] it*it } # ls = {1,4,9,16,25,36}
9. Motivation Example Features Concurrent Programming JIT ClangDao Future
Concurrent programming: asynchronous classes
Asynchronous classes
Asynchronous classes produce asynchronous instances;
Calling a method will automatically create a thread task;
Thread tasks on the same instance are queued for execution.
Example,
class @Clustering {
routine Run(){ DoKmeansClustering() }
}
cls = Clustering()
job = cls.Run()
while( 1 ){
DoSomethingElse();
if( job.wait( 0.1 ) ) break; # wait for 0.1 second
}
10. Motivation Example Features Concurrent Programming JIT ClangDao Future
LLVM-based Just-In-Time (JIT) compiler
Based on the Low Level Virtual Machine (LLVM);
Emphasis on numeric computation;
Compiles a subset of Dao virtual machine instructions;
11. Motivation Example Features Concurrent Programming JIT ClangDao Future
LLVM-based Just-In-Time (JIT) compiler
Based on the Low Level Virtual Machine (LLVM);
Emphasis on numeric computation;
Compiles a subset of Dao virtual machine instructions;
JIT Performance Test (time in seconds)
Program Argument Dao Dao+JIT Speedup Python C (-O2)
fannkuch 11 100.5 22.8 4.4X 339.3 4.8
mandelbrot 4000 40.0 5.1 7.8X 158.8 3.8
nbody 10000000 63.5 19.2 3.4X 333.4 2.4
spectral-norm 5000 98.0 7.6 12.8X 985.5 7.7
binary-trees 16 64.4 64.4 1.0X 22.3 5.5
Note: benchmark programs are taken from Computer Language Benchmarks Game
http://shootout.alioth.debian.org
12. Motivation Example Features Concurrent Programming JIT ClangDao Future
ClangDao: bringing C/C++ libraries to your finger tips
Based on Clang (C Language Family Frontend for LLVM);
Generate bindings directly from C/C++ header files;
Support C/C++ functions, C structs, C callbacks, C++ classes
and inheritance, C++ virtual functions, C++ templates (to some
extent) etc.;
13. Motivation Example Features Concurrent Programming JIT ClangDao Future
ClangDao: bringing C/C++ libraries to your finger tips
List of bindings generated by ClangDao
Scientific: DaoGSL GNU Science Library (GSL)
DaoBamTools BamTools
DaoGenomeTools GenomeTools
DaoSVM LibSVM (Support Vector Machine)
Visualization: DaoVTK Visualization Toolkit
DaoMathGL MathGL
2D Graphics: DaoGraphicsMagick GraphicsMagick
3D Graphics: DaoOpenGL OpenGL
DaoHorde3D Horde3D Engine
DaoIrrlicht Irrlicht 3D Engine
Multimedia: DaoSDL Simple DirectMedia Layer (SDL)
DaoSFML Simple and Fast Multimedia Library
GUI: DaoFLTK Fast Light Toolkit (FLTK)
Miscellaneous: DaoXML libxml2
DaoBullet Bullet Physics Engine
DaoGameKit GameKit Game Engine
DaoGamePlay GamePlay Game Engine
14. Motivation Example Features Concurrent Programming JIT ClangDao Future
Future development
The development of Dao in the context of bioinformatics
BioDao : future<Dao::Bioinformatics> = mt.start::{
DevelopDaoPackages( field => Bioinformatics )
}
It should lead to an open source project named BioDao;
This project will provide a large number of modules and
packages for bioinformatics;
It may start from screening candidate C/C++ bioinformatics
libraries for automatic or semi-automatic binding;
Suggestions for such libraries are highly welcome.
15. Motivation Example Features Concurrent Programming JIT ClangDao Future
Thank you!
Links and Contacts
http://daovm.net
https://github.com/daokoder
daokoder@gmail.com
l2fu@ucsd.edu