School of Computing Faculty of Engineering Meshing with Grids: Toward Functional Abstractions for Grid-based Visualization Rita Borgo & David Duke Visualization.

Slides:



Advertisements
Similar presentations
The Problem Decomposition of programs in terms of classes and in terms of crosscutting concerns are both useful, but languages based on source files allow.
Advertisements

Fine-grained Visualization Pipelines and Lazy Functional Languages D.J. Duke 1, M. Wallace 2, R. Borgo 1, & C. Runciman 2 1 Visualization and Virtual Reality.
Duagi Bulent UNIVERSITY POLITEHNICA of BUCHAREST DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY POLITEHNICA of BUCHAREST DEPARTMENT OF COMPUTER SCIENCE.
For(int i = 1; i
Introduction to Compilation of Functional Languages Wanhe Zhang Computing and Software Department McMaster University 16 th, March, 2004.
Company Address Website Faculty Advisor if known
Evaluating XML-Extended OLAP Queries Based on a Physical Algebra Xuepeng Yin and Torben B. Pedersen Department of Computer Science Aalborg University.
ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne
CLASS 9 ADVANCE RENDERING RAY TRACING RADIOSITY LIGHT FIELD CS770/870.
Chapter 5: Advanced Use Case Modeling [Arlow and Neustadt, 2005] CS 426/CPE 426 Senior Projects University of Nevada, Reno Department of Computer Science.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Haskell Fall 2005 Marco Valtorta
Introduction to Computer Engineering by Richard E. Haskell 8086 Tutor Monitor Module M14.3 Section 9.3 Appendix B.
BPC: Art and Computation – Spring 2007 Overview of Spring Semester Tools and Technologies Glenn Bresnahan
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
An Introduction to Software Visualization Dr. Jonathan I. Maletic Software DevelopMent Laboratory Department of Computer Science Kent State University.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Functional Programming Notes for CSCE 190 Based on Sebesta,
Challenge the future Delft University of Technology Interactive Environments Minor Introduction.
School of something FACULTY OF OTHER School of Computing FACULTY OF ENGINEERING PROJECT VISTA: Integrating Heterogeneous Utility Data A very brief overview.
A Study of MPLS Department of Computing Science & Engineering DE MONTFORT UNIVERSITY, LEICESTER, U.K. By PARMINDER SINGH KANG
An Augmented Virtual Reality Interface for Assistive Monitoring of Smart Spaces Shichao Ou, Deepak R. Karuppiah, Andrew H. Fagg, Edward Riseman Department.
DAAD project “Joint Course on OOP using Java” Design Patterns in the course ‘OOP in Java’ - first experiences Ana Madevska Bogdanova Institute of informatics.
INFSO-SSA International Collaboration to Extend and Advance Grid Education ICEAGE Forum Meeting at EGEE Conference, Geneva Malcolm Atkinson & David.
These materials are prepared only for the students enrolled in the course Distributed Software Development (DSD) at the Department of Computer.
Rule-based Database Visualization Yingcai Xiao. Introduction Framework and System Design Implementation Case Study Summary and Future Work.
Using Memory Diagrams When Teaching a Java-Based CS1 Mark A. Holliday David R. Luginbuhl Dept of Mathematics and Computer Science Western Carolina University.
A Collaborative-Interaction Model of Software Project Development An Extension to Agile Based Methodologies Rehan Akbar#1, Mohd Fadzil Hassan#2 Department.
Building (stage 2) for Dept. of Computer Science & Computer Unit  Total Cost Estimate :291 Million  Physical Progress: 80%  Financial Progress:60% University.
Adaptive Real-Time Rendering of Planetary Terrains WSCG 2010 Raphaël Lerbour Jean-Eudes Marvie Pascal Gautron THOMSON R&D, Rennes, France.
Measures of Academic Progress™ (MAP). What is MAP?  MAP - Measures of Academic Progress  Achievement tests (Math, Reading, Language, Science)  Delivered.
1 3/2/05CS250 Introduction to Computer Science II Composition and friend Functions.
DAME: A Distributed Diagnostics Environment for Maintenance Duncan Russell University of Leeds.
EDUCAUSE 2005 Annual Conference October 19, 2005.
Object Oriented Programming (OOP) Design Lecture 1 : Course Overview Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang.
Powers and roots. Square each number a) 7 b) 12 c) 20 d) 9 e) 40 a) 49 b) 144 c) 400 d) 81 e) 1600.
Werner Benger 1 and Georg Ritter 3 and Simon Su 4 and Dimitris E. Nikitopoulos 2 and Eamonn Walker 2 and Sumanta Acharya 2 and Somnath Roy 2 and Farid.
Real-time Simulation and Visualization using Pre-calculated Fluid Simulator States Marek Gayer, Pavel Slavík and František Hrdlička Computer Graphics Group.
HIERARCHICAL TREES OF UNSTEADY SIMULATION DATASETS Marek Gayer and Pavel Slavík C omputer G raphics G roup Department of Computer Science and Engineering.
Glen Dobson, Lancaster University Service Grids Workshop NeSC Edinburgh 23/7/04 Endpoint Services Glen Dobson Lancaster University,
Chapter 7 Day 3 Book Section 7.5 Get 2 grids for the 2 shift problems!
1 Introduction to Classes. 2 Terms and Concepts A class is... –The most important building block of any object- oriented system. –A description of a set.
Interactive educational system for coal combustion modeling in Power Plant boilers Marek Gayer, Pavel Slavík and František Hrdlička Computer.
Facial Motion Cloning Using Global Shape Deformation Marco Fratarcangeli and Marco Schaerf University of Rome “La Sapienza”
Section P7 Equations. Solving Rational Equations.
Haskell Introduction CSCE 314 Spring CSCE 314 – Programming Studio Historical Background 1930s: Alonzo Church develops the lambda calculus, a simple.
Computational Science and Purdue: Ananth Grama Director, Computational Science and Engineering Professor of Computer Science. Anita Park.
Application for Morphological Image Processing Dan Campbell 12/13/06 University of Wisconsin – Madison Departments of Computer Engineering and Computer.
Engineering Design Process: Overview Created by The North Carolina School of Science and Math.The North Carolina School of Science and Math Copyright 2012.
서울대한양대 ( 안 산 ) 충남대 1년1년 컴퓨터기초 (C) 컴퓨터프로그래밍 (C, Java) 컴퓨터프로그래밍 (C) 2. 봄 프로그래밍 원리 (Scheme, ML) Structure & Interpretation of Computer Programs 프로그래밍 방법론.
What is a Functional Language?
TK2023 Object-Oriented Software Engineering
Sliding Puzzle Project
Java 4/4/2017 Recursion.
Road Map Introduction to object oriented programming. Classes
Hire Toyota Innova in Delhi for Outstation Tour
Workshop II UU Crowd Simulation Framework
Chapter 5: Advanced Use Case Modeling
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Physics-based simulation for visual computing applications
Cs212: DataStructures Computer Science Department Lab 3 : Recursion.
National University of Laos
ARRAY DIVISION Identity matrix Islamic University of Gaza
PROGRAMMING IN HASKELL
8° International Conference on :
Manheim Central High School
Physically Based Modeling -Overview-
Solving Radical Equations
LABORATORY OF PROCESS ENGINEERING
GGF10 Workflow Workshop Summary
Equations Involving Absolute Value
Presentation transcript:

School of Computing Faculty of Engineering Meshing with Grids: Toward Functional Abstractions for Grid-based Visualization Rita Borgo & David Duke Visualization & Virtual Reality Group School of Computing University of Leeds, UK Colin Runciman & Malcolm Wallace Department of Computer Science University of York, UK

Overview Why functional programming (still) matters Project: a lazy polytypic grid Marching cubes Streaming Making it generic Performance Looking back, looking forwards

Why Functional Programming Still Matters Academic arguments J. Hughes, Why Functional Programming Matters Problem decomposition program composition Absence of side-effects Higher-order functions Laziness Practical arguments: Natural progression: OO service-orientation Tower of Babel Novel solutions come from working against the OO grain!

Introduction to FP and Haskell Functional building blocks square :: Int -> Int square x = x*x map :: (a -> b) -> [a] -> [b] map _ [] = [] map f (a:as) = (f a):(map f as) (.) :: (b -> c) -> (a -> b) -> (a -> c) (f. g) x = f(g(x)) sqList ls = map square ls sqsqList ls = map sqList (map sqList ls) = (map sqList. map sqList) ls = map (sqList. sqList) ls fibs = [0,1] ++ [ a+b | (a,b) <- zip fibs (tail fibs) ] Further information: see Note: loop fusion law encoded as a rule in GHC compiler

Why FP matters (to grid-enabled vis) pipeline architecture widespread in visualization supports distribution and streaming However Streaming is ad-hoc and coarse grained Algorithms depend on mesh type Data traversed multiple times readerozone levelsisosurfacenormals isosurfacereadertemperature displaygeo-reference ? Note: analogy of pipeline composition and function composition: f. g

A Lazy Polytypic Grid Grid enabling: distribution of the run-time system and on-demand streaming of arbitrary data. Through fusion laws, multiple traversals on a single resource are folded into one pass. 2 readerozone levelsisosurfacenormals isosurfac e reade r temperatu re geo-referencedisplay Algorithms: written once, based on generic pattern of data types, then instantiated for any type. 1 3 Specialization: adapt programs to utilize resources available – data or computational.

Isosurfaces Widely-used technique for both 2D and 3D scalar data Two general approaches: Contour tracking: follow a feature through the dataset Marching: traverse dataset, processing each cell as encountered in-core versus out-of-core variations 2D examples: skull cross-section; isoline for t=5

Marching Squares Input: a dataset, and a threshold value to be contoured Output: line segments representing contour's path within dataset Algorithm: For each cell, compare field value at point with threshold Sixteen possible cases: index into case-table to find edges Interpolate along edges to find intersection points Note ambiguity in cases 5 and 10!

Marching Cubes... and beyond 3D surface generalizes 2D case: Isolines become surfaces composed of triangles 16-case lookup table becomes 256-case table (15 cases if we use symmetry) Tetrahedral cells also common Other cell types possible common pattern of processing need appropriate case-table

Implementation 1: Functional Arrays Basic types type XYZ = (Int,Int,Int) type Num a => Dataset a = Array XYZ a type Cell a = (a,a,a,a,a,a,a,a) Top-level traversal isoA :: (Ord a, Intgeral a) => a -> Dataset a -> [Triangle] isoA th sampleArr = concat. zipWith1 (mcubeA th lookup) addrs where addrs = [ (i,j,k) | k <- [1..ksz-1], j <- [1..jsz-1], i <- [1..isz-1]] lookup arr (x,y,z) = (arr!(x,y,z), arr!(x+1,y,z),.., arr!(x+1,y+1,z+1)) Worker function mcubeA :: (Ord a, Intgeral a) => a -> (XYZ -> Cell a) -> XYZ -> [Triangle] mcubeA th lookup xyz = group3. map (interp th cell xyz). mctable!. toByte. map8 (>th) $ cell where cell = lookup xyz

Problems Entire dataset must be resident in memory Vertex shared by n cells threshold comparison repeated n times > 1 triangle in a cell => edge interpolation repeated within cell Edge shared by m cells interpolation repeated m times

Thinking differently - streaming mkStream :: XYZ -> [a] -> [Cell a] mkStream (isz,jsz,ksz) origin = zip8 origin (drop 1 origin) (drop (line+1) origin) (drop line origin) (drop plane origin) (drop (plane+1) origin) (drop (planeline+1) origin) (drop planeline origin) where line = isz plane = isz * jsz planeline = plane + line line plane 8-tuple...

Discontinuities Two solutions: Rewrite mkStream, considering dataset boundaries; or Strip phantom cells from output of mkStream disContinuities :: XYZ -> [b] -> [b] disContinuities (isz,jsz,ksz) = step (0,0,0) where step (i,j,k) (x:xs) | i==(isz-1) = step (0,j+1,k) xs | j==(jsz-1) = step (0,0,k+1) (drop (isz-1) xs) | k==(ksz-1) = [] | otherwise = x : step (i+1,j,k) xs cellStream = disContinuities size. stream

Implementations 2 & 3: Streams Version 2: replace array lookup with stream access isoS th samples = concat. zipWith2 (mcubeS th) addrs cells where cells = stream size samples mcubeS :: a -> XYZ -> Cell a -> [Triangle] mcubeS th xyz cell = group3. map (interp th cell xyz). mctable!. toByte. map8 (>th) $ cell Version 3: share vertex comparison by creating a stream of case-indices isoT th samples = concat. zipWith3 (mcubeS th) addrs cells indices where indices = map toByte. stream. map (>th) mcubeT :: a -> XYZ -> Cell a -> Byte -> [Triangle] mcubeT th xyz cell index = group3. map (interp th cell xyz). mctable! $ index Further improvements explored in IEEE Visualization paper

From generic cells... Functions already polymorphic.. generic over one or more type variables constraints may limit instantiation isoA :: (Ord a, Intgeral a, Fractional b) => a -> Dataset a -> [Triangle b]... and abstracting from Cell type is (nearly) straightforward mcubeRec :: (Num a, Floating b) => a -> XYZ -> CellR a -> [Triangle b] mcubeRec th xyz cell = group3. map (interp th cell xyz ). mcTable!. toByte8. map8 (>th) $ cell mcubeTet :: (Num a, Floating b) => a -> CellT a -> CellT b -> [Triangle b] mcubeTet th g cell verts = group3. map (interp th cell verts). mtTable!. toByte4. map4 (>th) $ cell Can capture general pattern within a type-class class Cell T where patch :: (Num a, Floating b) => a -> T a -> T b -> [Triangle b]

... to generic meshes Dealing with different mesh-type organizations is harder... Regular meshes: implicit geometry and topology Irregular meshes: implicit geometry Unstructured meshes: geometry and topology explicit Polytypic functions are independent of data organization Haskell data constructions isomorphic to sum-of-products type Foundation on categorical model of data type structure Examples data List a = Nil | Cons a (List a) --> List = 1 + (a x List) data Tree a = Leaf a | Node (Tree a) a (Tree a) --> Tree = a + (Tree x a x Tree)

Polytypism in practice From Generic Haskell: Practice & Theory, Hinze & Jeuring, 2001 define generic function by induction over type structure generic version can then be instantiated for any SoP type mapG {|t::kind|} :: Map {|kind|} t t mapG {|Char|} c = c mapG {|Int|} i = i mapG {|Unit|} Unit = Unit mapG {|:+:|} mapa mapb (InL a) = InL (mapa a) mapG {|:+:|} mapa mapb (InR b) = InR (mapb b) mapG {|:*:|} mapa mapb a :*: b = mapa a :*: mapb b data Tree a = Leaf a | Node (Tree a) a (Tree a) mapList = mapG {| List |} -- standard Haskell map mapTree = mapG {| Tree |} -- apply function to each node in the tree Research question: can we actually apply this idea to mesh traversal? surface t = concat. mapG {| Mesh |} (\c -> patch t c)

Sample Results

Performance Performance difference decreases with surface size D.J. Duke, M. Wallace, R. Borgo, and C. Runciman, Fine-grained visualization pipelines and lazy functional languages, to appear in Proc. IEEE Vis06

Conclusions and Future Work What we've achieved: re-constructed fundamental visualization algorithms Implemented fine-grained streaming demonstrated that FP can be (surprisingly) efficient What we're doing now: generalizing from specific types of mesh exploring capabilities of generic programming Where we are going next: grid-enabled Haskell pipelines some prior work: GRID-GUM, Michaelson, Trinder, Al Zain build into York Haskell Compiler (bytecode) RTS want simple, lightweight grid tools!

Finally... Thanks to EPSRC Fundamental Computing for e-Science Programme Further information: hackage.haskell.org/trac/PolyFunViz/ Any Questions?