Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hank Childs, University of Oregon Jan. 21st, 2013 CIS 610: Many-core visualization libraries.

Similar presentations


Presentation on theme: "Hank Childs, University of Oregon Jan. 21st, 2013 CIS 610: Many-core visualization libraries."— Presentation transcript:

1 Hank Childs, University of Oregon Jan. 21st, 2013 CIS 610: Many-core visualization libraries

2 Schedule for this class We have done 5 lectures in 2 weeks – We should have done 4 lectures over last two weeks We will do 3 lectures this week  We will be one full week ahead of schedule.  We will cancel two lectures over the coming weeks.

3 Schedule this week Tuesday lecture: today – Review of data parallel operations, general discussion of packages so far Thursday lecture: Ken Moreland (Thursday colloquium @ 12: Ken Moreland) Friday lecture: Ken Moreland – 8:30-10 (I can’t make this time) – 11-12:30 – 11:30-1:00

4 Upcoming schedule Tuesday, Jan 28 th – 10 minute presentation by each student on the project they want to pursue Non-binding – Discuss the problem, and some initial thoughts about how to do it in many-core libraries

5 Upcoming schedule Thursday, Jan 30 th – Group session debugging problems. – Important that you have started your project by then.

6 Upcoming schedule Weeks following – Series of 20 minute presentations, 3 per lecture – Two flavors of presentation: “Update on my project” “Overview of a paper I read”

7 How this class will be graded You will all submit a report at the end of the quarter. The report will include: – A summary of what you have done – It will focus on your project – You should also include Presentations made Porting of libraries Assistance to other students Bugs debugged (or reported) Etc…

8 How this class will be graded It is not curved – If you all decide to not to present papers, you will all be penalized I expect you all get very good grades – But it is important that you work hard and accomplish something in this class Play with the libraries, present papers in class, and really try to nail your “research project”

9 Lectures I expect you will all make about 3 presentations – 1 research update, 2 papers – 2 research updates, 1 paper Some lectures in the short term on CUDA, Thrust, data parallelism, etc, would probably be helpful.

10 EAVL EAVL E XTREME - SCALE A NALYSIS AND V ISUALIZATION L IBRARY Jeremy Meredith January, 2014

11 A Simple Data-Parallel Operation void CellToCellDivide(Field &a, Field &b, Field &b, Field &c) Field &c){ for_each(i) for_each(i) c[i] = a[i] / b[i]; c[i] = a[i] / b[i];} void CalculateDensity(...) { //... //... CellToCellDivide(mass, volume, density); CellToCellDivide(mass, volume, density);} Internal Library API Provides This Algorithm Developer Writes This

12 Functor + Iterator Approach void CalculateDensity(...) { //... //... CellToCellBinaryOp(mass, volume, density, Divide()); CellToCellBinaryOp(mass, volume, density, Divide());} template void CellToCellBinaryOp (Field &a, Field &b, Field &b, Field &c Field &c T &f) T &f){ for_each(i) for_each(i) f(a[i],b[i],c[i]); f(a[i],b[i],c[i]);} struct Divide { void operator()(float &a, void operator()(float &a, float &b, float &b, float &c) float &c) { c = a / b; c = a / b; }}; Internal Library API Provides This Algorithm Developer Writes This

13 Custom Functor void CalculateDensity(...) { //... //... CellToCellBinaryOp(mass, volume, density, MyFunctor()); CellToCellBinaryOp(mass, volume, density, MyFunctor());} template void CellToCellBinaryOp (Field &a, Field &b, Field &b, Field &c Field &c T &f) T &f){ for_each(i) for_each(i) f(a[i],b[i],c[i]); f(a[i],b[i],c[i]);} struct MyFunctor { void operator()(float &a, void operator()(float &a, float &b, float &b, float &c) float &c) { c = a + 2*log(b); c = a + 2*log(b); }}; Algorithm Developer Writes These Internal Library API Provides This

14 D ATA P ARALLELISM B ASICS

15 Map with 1 input, 1 output Simplest data-parallel operation. Each result item can be calculated from its corresponding input item alone. x 370140045310 01234567891011 61402800810620 struct f { float operator()(float x) { return x*2; } float operator()(float x) { return x*2; }}; result

16 Map with 2 inputs, 1 output With two input arrays, the functor takes two inputs. You can also have multiple outputs. x 370140045310 01234567891011 5 221239910431 struct f { float operator()(float a, float b) { return a+b; } float operator()(float a, float b) { return a+b; }}; result y 242183955121

17 Scatter with 1 input (and thus 1 output) Possibly inefficient, risks of race conditions and uninitialized results. (Can also scatter to larger array if desired.) Often used in a scatter_if –type construct. x 370140045310 01234567891011 0130 No functor result indices 4 241550421214

18 Gather with 1 input (and thus 1 output) Unlike scatter, no risk of uninitialized data or race condition. Plus, parallelization is over a shorter indices array, and caching helps more, so can be more efficient. x 370140045310 01234567891011 73031 No functor result indices 19693

19 Reduction with 1 input (and thus 1 output) Example: max-reduction. Sum is also common. Often a fat-tree-based implementation. x 370140045310 01234567891011 7 result struct f { float operator()(float a, float b) { return a>b ? a : b; } float operator()(float a, float b) { return a>b ? a : b; }};

20 Inclusive Prefix Sum (a.k.a. Scan) with 1 input/output Value at result[i] is sum of values x[0]..x[i]. Surprisingly efficient parallel implementation. Basis for many more complex algorithms. x 370140045310 01234567891011 310 1115 19242728 No functor. result +++++++++++

21 Exclusive Prefix Sum (a.k.a. Scan) with 1 input/output Initialize with zero, value is sum of only up to x[i-1]. May be more commonly used than inclusive scan. x 370140045310 01234567891011 010 1115 19242728 No functor. result 3 +++++++++++ 0

22 W RITING A LGORITHMS IN EAVL

23 E XAMPLE : T HRESHOLD

24 Threshold Keep cell if it meets some criteria, else discard Criteria: – Pressure > 2 – 10 < temperature < 20 Cells that meet criteria

25 How to implement threshold Iterate over cells If a cell meets the criteria, then place that cell in the output Output is an unstructured mesh

26 FieldName: “x” “y” “z” Component: 0 0 0 Explicit cells can be combined with structured coordinates. Explicit cells can be combined with structured coordinates. Example: Thresholding an RGrid (a) eavlCoordinates Name: “x” Association: LogicalDim0 Values[ni] eavlField#0 Name: “y” Association: LogicalDim1 Values[nj] eavlField#1 Name: “z” Association: LogicalDim2 Values[nk] eavlField#2 RegularStructure: 30 40 30 eavlStructuredCellSet FieldName: “x” “y” “z” Component: 0 0 0 eavlCoordinates Name: “x” Association: LogicalDim0 Values[ni] eavlField#0 Name: “y” Association: LogicalDim1 Values[nj] eavlField#1 Name: “z” Association: LogicalDim2 Values[nk] eavlField#2 Connectivity: (a bunch of cells) eavlExplicitCellSet

27 Cells: (…) Parent: ( ) A second Cell Set can be added which refers to the first one A second Cell Set can be added which refers to the first one Example: Thresholding an RGrid (b) RegularStructure: 30 40 30 eavlStructuredCellSeteavlSubset FieldName: “x” “y” “z” Component: 0 0 0 eavlCoordinates Name: “x” Association: LogicalDim0 Values[ni] eavlField#0 Name: “y” Association: LogicalDim1 Values[nj] eavlField#1 Name: “z” Association: LogicalDim2 Values[nk] eavlField#2 RegularStructure: 30 40 30 eavlStructuredCellSet Name: “x” Association: LogicalDim0 Values[ni] eavlField#0 Name: “y” Association: LogicalDim1 Values[nj] eavlField#1 Name: “z” Association: LogicalDim2 Values[nk] eavlField#2 FieldName: “x” “y” “z” Component: 0 0 0 eavlCoordinates

28 475263 3249 31 Starting Mesh We want to threshold a mesh based on its density values (shown here). 43475263 32384249 31374138 density 434752633238424931374138 01234567891011 If we threshold 35 < density < 45, we want this result: 43 3842 374138

29 Which Cells to Include? Evaluate a Map operation with this functor: struct InRange { float lo, hi; float lo, hi; InRange ( float l, float h ) : lo ( l ), hi ( h ) { } InRange ( float l, float h ) : lo ( l ), hi ( h ) { } int operator ()( float x ) { return x>lo && x lo && x<hi ; }} 1000 0110 0111 density 434752633238424931374138 01234567891011 100001100111 inrange InRange()

30 How Many Cells in Output? Evaluate a Reduce operation using the Add<> functor. We can use this to create output cell length arrays. 1000 0110 0111 01234567891011 100001100111 inrange 6 result plus

31 Where Do the Output Cells Go? InputindicesOutputindices 0123 4567 891011 01234567891011 012345output cell 0 12 345 input cell How do we create this mapping?

32 Create Input-to-Output Indexing? Exclusive Scan (exclusive prefix sum) gives us the output index positions. 0 12 345 01234567891011 100001100111 inrange 011111233345 startidx +++++++++++ 0

33 Scatter Input Arrays to Output? NO. We can do this, but scatters can be risky/inefficient. Assuming we have multiple arrays to process, we can do something better.... 01234567891011 output_ density 011111233345 0 56 91011 density 434752633238424931374138 Race condition unless we add a mask array! 433842374138

34 startidx Create Output-to-Input Indexing? We want to work in the shorter output-length arrays and use gathers. A specialized scatter in EAVL creates this reverse index. 01234567891011 05691011 revindex 011111233345 0 56 91011

35 density Gather Input Mesh Arrays to Output? We can now use simple gathers to pull input arrays (density, pressure) into the output mesh. 01234567891011 434752633238424931374138 05691011 revindex 433842374138 43 3842 374138 output_ density


Download ppt "Hank Childs, University of Oregon Jan. 21st, 2013 CIS 610: Many-core visualization libraries."

Similar presentations


Ads by Google