Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of...

32
Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Transcript of Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of...

Page 1: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

Evolution of genome based Embryos in 2D

Anna Aichmayr, Markus Dauschan

14.02. 2011

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 2: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

Contents

1 Introduction to ThrustWhat is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

2 The ProgramGeneral IdeaImplementation in NetLogoImplementation in C++First Results

3 Outlook

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 3: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

What is Thrust?

Thrust is...

an open-source template library for developing CUDAapplications

modeled after the C++ STL

bringing a familiar abstraction layer to the realm of GPUcomputing

already available in version 1.3 (01-2011)

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 4: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

How does it work?

Since Thrust is a C++ template library there is nothing to ”build”.

Simply download the newest version and extract the contents ofthe zip file to a directory and installing Thrust to the CUDA

include directory.

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 5: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Advantages of Thrust

Programmer productivity- rapidly develop complex applications- leverage parallel primitives

Encourage generic programming - don’t reinvent the wheel

High performance with minimal programmer effort

Interoperability: integrates with CUDA C/C++ code

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 6: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Containers

1 t h r u s t : : h o s t v e c t o r <T>2 t h r u s t : : d e v i c e v e c t o r <T>

Advantages:

makes common operations concise and readable

hides cudaMalloc, cudaMemcpy and cudaFree

compatible with STL containers

eases integration (vector, list, map, ...)

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 7: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Use of Thrust Containers

1 // a l l o c a t e h o s t v e c t o r w i t h two e l e m e n t s2 t h r u s t : : h o s t v e c t o r <int> h v e c ( 2 ) ;3

4 // copy h o s t v e c t o r to d e v i c e5 t h r u s t : : d e v i c e v e c t o r <int> d v e c = h v e c ;6

7 // m a n i p u l a t e d e v i c e va lues from t he h o s t8 d v e c [ 0 ] = 1 3 ;9 d v e c [ 1 ] = 2 7 ;

10 s t d : : cout<< ”sum : ” << d v e c [0]+ d v e c [ 1 ] << s t d : : e n d l ;11 // v e c t o r memory a u t o m a t i c a l l y r e l e a s e d

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 8: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

STL and Thrust Containers

1 // l i s t c o n t a i n e r on h o s t2 s t d : : l i s t <int> h l i s t ;3 h l i s t . push back ( 1 3 ) ;4 h l i s t . push back ( 2 7 ) ;5

6 // copy l i s t to d e v i c e v e c t o r7 t h r u s t : : d e v i c e v e c t o r <int> d v e c ( h l i s t . s i z e ( ) ) ;8 t h r u s t : : copy ( h l i s t . b e g i n ( ) , h l i s t . end ( ) ,9 d v e c . b e g i n ( ) ) ;

10

11 // a l t e r n a t i v e method12 t h r u s t : : d e v i c e v e c t o r <int> d v e c ( h l i s t . b e g i n ( ) ,13 h l i s t . end ( ) ) ;

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 9: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Iterators

behave like pointers

sequences are defined by a pair of pointers

keep track of memory space

convertible to raw pointers

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 10: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Iterators

Example 1: sequences defined by a pair of pointers

1 // a l l o c a t e d e v i c e v e c t o r2 t h r u s t : : d e v i c e v e c t o r <int> d v e c ( 4 ) ;3

4 d v e c . b e g i n ( ) ;5 // r e t u r n s i t e r a t o r at f i r s t e l em ent o f d v e c6 d v e c . end ( ) ;7 // r e t u r n s i t e r a t o r one p a s t t he l a s t e l em en t o f d v e c8

9 // [ beg in , end ) p a i r d e f i n e s a s e q u e n c e o f 4 e l e m e n t s

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 11: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Iterators

Example 2: iterators act like pointers

1 // a l l o c a t e d e v i c e v e c t o r2 t h r u s t : : d e v i c e v e c t o r <int> d v e c ( 4 ) ;3

4 t h r u s t : : d e v i c e v e c t o r <int > : : i t e r a t o r b e g i n =5 d v e c . b e g i n ( ) ;6 t h r u s t : : d e v i c e v e c t o r <int > : : i t e r a t o r end = d v e c . end ( ) ;7

8 // compute s i z e o f s e q u e n c e [ beg in , end )9 i n t length = end − b e g i n ;

10

11 // d e f i n e a s e q u e n c e o f 3 e l e m e n t s12 end = d v e c . b e g i n ( ) + 3 ;

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 12: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Iterators

Example 3: use iterators like pointers

1 // a l l o c a t e d e v i c e v e c t o r2 t h r u s t : : d e v i c e v e c t o r <int> d v e c ( 4 ) ;3

4 t h r u s t : : d e v i c e v e c t o r <int > : : i t e r a t o r b e g i n=d v e c . b e g i n ( ) ;5

6 * b e g i n = 1 3 ; // same as d v e c [ 0 ] = 1 3 ;7

8 i n t temp = * b e g i n ; // same as temp = d v e c [ 0 ] ;9

10 b e g i n ++; // advance i t e r a t o r one p o s i t i o n11

12 * b e g i n = 2 5 ; // same as d v e c [ 1 ] = 2 5 ;

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 13: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Algorithms

Thrust provides many standard algorithms

Transformations

Reductions

Prefix Sums

Sorting

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 14: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Algorithms

The algorithms...

are generic:

general types and operators are supported (int, float, ...,user-defined structures)general operators: reduce with plus operator, scan withmaximum operator

have default arguments: e.g. reduce(begin, end)

are statically dispatched based on iterator type:memory space is known at compile time

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 15: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

What is Thrust?Advantages of ThrustContainersIteratorsAlgorithms

Algorithms

Some Examples:

1 t h r u s t : : so r t ( . . . )2 t h r u s t : : r e d u c e ( . . . )3 t h r u s t : : random ( . . . )4 t h r u s t : : count ( . . . )5 t h r u s t : : remove ( . . . )6 t h r u s t : : swap ( . . . )7 t h r u s t : : d i s t a n c e ( . . . )8 t h r u s t : : e q u a l ( . . . )9 t h r u s t : : m i n e l e m e n t ( . . . )

10 . . .

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 16: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

General Idea

Bio inspired embryology

deterministic and genome based

generate artificial neural networks (ANNs)

morphology based evolution

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 17: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

General Idea

in every timestep a cell does:

interpret its genome according to morphogen levels

emit proteins

production of morphogenschange sensitivitytrigger proliferation

diffuse morphogens

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 18: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

General Idea

the overhead controller:

induces a primary gradient

decides in which concrete direction to duplicate

pushes all cells

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 19: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

General Idea

Figure: process of virtual embryology

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 20: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

General Idea

Figure: overhead evolution process

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 21: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

First Steps using NetLogo

Pros:

easy to ”program”

immediate and appealing graphical output

easy large scale parameter sweeps

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 22: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

Second Steps using NetLogo

Cons:

too slow for sophisticated evolution runs

only uses 1 core

NO classes, hierarchy, inheritance...basically structure

hard to expand

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 23: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

First C++ version

very fast compared to the NetLogo version

badly implemented (globals, no encapsulation etc.)

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 24: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

First C++ version

Figure: first usable results

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 25: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

Current C++ version

Complete restart of the project

Cell class should also pose as an robot

duplication corresponds to docking

not yet featuring evolution

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 26: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

Using Thrust

Problems:

hardly any (and small) STL containers in use

the program consists of many classes

calculation of one individual:every process depends on the result of previous process

→ no obvious possibiliy to parallelize the calculation of oneindividual

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 27: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

Using Thrust

Our idea:

parallelize the calculation of all individuals of one generation on theGPU

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 28: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

KaBot

Figure: first prototype of the KaBot robot

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 29: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

Acting as a Robot Controller

the CellController class was already able to steer a robot

based on a genome and the flow of morphogens plusemittance of proteins

primitive collision avoidance and docking signals could beproduced

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 30: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

General IdeaImplementation in NetLogoImplementation in C++First Results

EmbryoGenesis on Robot

it was possible to cc the whole EmbryoGenesis and run it onone single robot

EmbryoGenesis was able to produce a genome based bodyshape scheme

next step: onboard Evolution

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 31: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

Outlook

finish the C++ version:implementation of evolution

parallelisation in CUDAfind an appropriate solution for our problem

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D

Page 32: Evolution of genome based Embryos in 2D...Introduction to Thrust The Program Outlook Evolution of genome based Embryos in 2D Anna Aichmayr, Markus Dauschan 14.02. 2011 Aichmayr, Dauschan

Introduction to ThrustThe Program

Outlook

Outlook

Thank you for your attention!

Any questions?

Aichmayr, Dauschan Evolution of Genome Based Embryos in 2D