1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng...

68
1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana University Bloomington IN 47404 Xiaohong Qiu Research Computing UITS, Indiana University Bloomington IN George Chrysanthakopoulos, Henrik Frystyk Nielsen Microsoft Research, Redmond WA [email protected], http://www.infomall.org

Transcript of 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng...

Page 1: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

11

Multicore SalsaParallel Programming 2.0

Peking UniversityOctober 31 2007

Geoffrey Fox, Huapeng Yuan, Seung-Hee BaeCommunity Grids Laboratory, Indiana University Bloomington IN 47404

Xiaohong QiuResearch Computing UITS, Indiana University Bloomington IN

George Chrysanthakopoulos, Henrik Frystyk Nielsen

Microsoft Research, Redmond WA

[email protected], http://www.infomall.org

Page 2: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

22

Abstract of Multicore SalsaParallel Programming 2.0

Multicore or manycore systems are probably not architecturally that different from parallel machines with which we are familiar. However in next 5-8 years the basic commodity (PC) chips will have 64-256 cores and currently there is little understanding of how to use them. It is clearly essential (at least for major US technology companies) that we effectively use such cores on broadly deployed machines.

This constraint makes multicore chips an exciting and different problem.We describe general issues in context of the SALSA project at http://www.infomall.org/multicore. This is using Service Aggregated Linked Sequential Activities where we are looking at a suite of parallel datamining applications as one important broadly useful capability for future multicore-based systems that will offer users navigation and advice based on the ever increasing data from sensors and the Internet. A key idea is using services not libraries as the basic building block so that we can offer productive user interfaces (Parallel Programming 2.0) by adapting workflow and mashups for composing parallel services. We still imagine that services will be constructed by experts using extensions of current threading and MPI models. Automatic compilers do not seem practical in the key 5-8 year time frame although PGAS((Partitioned Global Address Space) could be valuable. We present results on 8 cores (two quadcore chips) using the Microsoft CCR/DSS runtime that combines MPI, threading and service capabilities.

Page 3: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Too much Computing? Historically both grids and parallel computing have tried to increase

computing capabilities by• Optimizing performance of codes at cost of re-usability• Exploiting all possible CPU’s such as Graphics co-processors and

“idle cycles” (across administrative domains)• Linking central computers together such as NSF/DoE/DoD

supercomputer networks without clear user requirements Next Crisis in technology area will be the opposite problem –

commodity chips will be 32-128way parallel in 5 years time and we currently have no idea how to use them – especially on clients• Only 2 releases of standard software (e.g. Office) in this time span

so need solutions that can be implemented in next 3-5 years Note that even cell phones will be multicore There is “Too much data” as well as “Too much computing” and

maybe processing the data deluge will “solve” the “Too much computing” problem• Quite plausible on servers where we naturally will have lots of data• Less clear on clients but short of other ideas• Intel RMS analysis: Gaming and Generalized decision support

(data mining) are two ways of using these cycles

Page 4: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Intel’s Projection

Page 5: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Tomorrow

What is …? What if …?Is it …?

Recognition Mining Synthesis

Create a model instance

RMS: Recognition Mining SynthesisRMS: Recognition Mining Synthesis

Model-basedmultimodalrecognition

Find a modelinstance

Model

Real-time analytics ondynamic, unstructured,

multimodal datasets

Photo-realism andphysics-based

animation

TodayModel-less Real-time streaming and

transactions on static – structured datasets

Very limited realism

Page 6: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

What is a tumor? Is there a tumor here? What if the tumor progresses?

It is all about dealing efficiently with complex multimodal datasetsIt is all about dealing efficiently with complex multimodal datasets

Recognition Mining Synthesis

Images courtesy: http://splweb.bwh.harvard.edu:8000/pages/images_movies.html

Page 7: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Intel’s Application Stack

Page 8: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Too much Data to the Rescue? Multicore servers have clear “universal parallelism” as many

users can access and use machines simultaneously Maybe also need application parallelism (e.g. datamining) as

needed on client machines Over next years, we will be submerged of course in data

deluge• Scientific observations for e-Science• Local (video, environmental) sensors• Data fetched from Internet defining users interests

Maybe data-mining of this “too much data” will use up the “too much computing” both for science and commodity PC’s• PC will use this data(-mining) to be intelligent user

assistant?• Must have highly parallel algorithms

Page 9: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Broad Parallelism Issues and Data-mining Algorithms

Looking at Intel list of algorithms (and all previous experience), we find there are two styles of “micro” parallelism• Dynamic search as in integer programming, Hidden Markov Methods

(and computer chess); irregular synchronization with dynamic threads

• “MPI Style” i.e. several threads running typically in SPMD (Single Program Multiple Data); collective synchronization of all threads together

Most Intel RMS are “MPI Style” and very close to scientific algorithms even if applications are not science

Note MPI historically runs with processes not threads but likely that threads will be implementation of choice for commodity applications

Most “commodity experience” is for few way concurrency to support Windows/Linux O/S in “dynamic thread” paradigm

Little experience in MPI style synchronization with threads

Page 10: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

“Space-Time” Picture• Data-parallel applications map spatial structure

of problem on parallel structure of both CPU’s and memory

• However “left over” parallelism has to map into time on computer

• Data-parallel languages support this

Application Time

Application Spacet0

t1

t2

t3

t4

Computer Time

4-wayParallelComputer(CPU’s)

T0

T1

T2

T3

T4

“Internal” (to data chunk) application spatial dependence (n degrees of freedom) maps into time on the computer

Page 11: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Data Parallel Time Dependence• A simple form of data parallel applications are synchronous with all elements

of the application space being evolved with essentially the same instructions• Such applications are suitable for SIMD computers and run well on vector

supercomputers (and GPUs but these are more general than just synchronous)

• However synchronous applications also run fine on MIMD machines• SIMD CM-2 evolved to MIMD CM-5 with same data parallel language

CMFortran• The iterative solutions to Laplace’s equation are synchronous as are many full

matrix algorithms

Synchronization on MIMD machines is accomplished by messaging

It is automatic on SIMD machines!

Application Time

Application Spacet0

t1

t2

t3

t4

Synchronous

Identical evolution algorithms

Page 12: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Local Messaging for Synchronization• MPI_SENDRECV is typical primitive• Processors do a send followed by a receive or a receive followed by a send• In two stages (needed to avoid race conditions), one has a complete left shift• Often follow by equivalent right shift, do get a complete exchange• This logic guarantees correctly updated data is sent to processors that have their data at same

simulation time

……

…8 Processors

Application and Processor Time

Application Space

ComputePhase

CommunicationPhase

ComputePhase

CommunicationPhase

ComputePhase

CommunicationPhase

CommunicationPhase

Page 13: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Loosely Synchronous Applications• This is most common large scale science and engineering and

one has the traditional data parallelism but now each data point has in general a different update– Comes from heterogeneity in problems that would be synchronous if

homogeneous• Time steps typically uniform but sometimes need to support variable time steps across

application space – however ensure small time steps are t = (t1-t0)/Integer so subspaces with finer time steps do synchronize with full domain

• The time synchronization via messaging is still valid

• However one no longer load balances (ensure each processor does equal work in each time step) by putting equal number of points in each processor

• Load balancing although NP complete is in practice surprisingly easy

Application Time

Application Spacet0

t1

t2

t3

t4

Distinct evolution algorithms for each data point in each processor

Page 14: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Dynamic (search/Thread) Applications

Application Time

Application Space

Application Space

Application Time

• Here there is no natural universal ‘time’ in the application as there is in science algorithms where an iteration number or Mother Nature’s time gives global synchronization

• Loose (zero) coupling or special features of application needed for successful parallelization

• In computer chess, the minimax scores at parent nodes provide multiple dynamic synchronization points

Page 15: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Some links See http://www.connotea.org/user/crmc for references --

select tag oldies for venerable links; tags like MPI Applications Compiler have obvious significance

http://www.infomall.org/salsa for recent work including publications

My tutorialhttp://grids.ucs.indiana.edu/ptliupages/presentations/PC2007/index.html If you have forgotten about parallel computing (or never learnt)

Page 16: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Multicore SALSA at CGL Service Aggregated Linked Sequential Activities Aims to link parallel and distributed (Grid) computing by

developing parallel applications as services and not as programs or libraries• Improve traditionally poor parallel programming

development environments Can use messaging to link parallel and Grid services but

performance – functionality tradeoffs different• Parallelism needs few µs latency for message latency and

thread spawning• Network overheads in Grid 10-100’s µs

Use low latency where performance needed; use high latency where productivity needed

Developing set of services (library) of multicore parallel data mining algorithms

Page 17: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Parallel Programming Model If multicore technology is to succeed, mere mortals must be able to build

effective parallel programs There are interesting new developments – especially the new Darpa

HPCS Languages X10, Chapel and Fortress However if mortals are to program the 64-256 core chips expected in 5-7

years, then we must use today’s technology and we must make it easy• This rules out radical new approaches such as new languages

Remember that the important applications are not scientific computing but most of the algorithms needed are similar to those explored in scientific parallel computing

We can divide problem into two parts:• Micro-parallelism: High Performance scalable (in number of cores)

parallel kernels or libraries • Macro-parallelism: Composition of kernels into complete

applications We currently assume that the kernels of the scalable parallel

algorithms/applications/libraries will be built by experts with a Broader group of programmers (mere mortals) composing library

members into complete applications.

Page 18: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Scalable Parallel Components There are no agreed high-level programming environments for

building library members that are broadly applicable. However lower level approaches where experts define

parallelism explicitly are available and have clear performance models.

These include MPI for messaging or just locks within a single shared memory.

There are several patterns to support here including the collective synchronization of MPI, dynamic irregular thread parallelism needed in search algorithms, and more specialized cases like discrete event simulation.

We use Microsoft CCR http://msdn.microsoft.com/robotics/ as it supports both MPI and dynamic threading style of parallelism

Page 19: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Good and Bad about MPI MPI (or equivalent locks on shared memory machine)

has a bad reputation as the “machine-code” approach to parallel computing• User must break problem into parts

• User must program each part

• User must generate synchronization/messaging between parts However these defects imply a very clear performance

model as user needs to make explicit both application and machine structure

Thus if you can do this, one expects reliable understandable results that port well between different architectures

Page 20: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Other Parallel Programming Models OpenMP annotation or Automatic Parallelism of existing

software is practical way to use those pesky cores with existing code• As parallelism is typically not expressed precisely, one needs luck to get

good performance• Remember writing in Fortran, C, C#, Java … throws away information

about parallelism HPCS Languages should be able to properly express parallelism

but we do not know how efficient and reliable compilers will be• High Performance Fortran failed as language expressed a subset of

parallelism and compilers did not give predictable performance PGAS (Partitioned Global Address Space) like UPC, Co-array

Fortran, Titanium, HPJava• One decomposes application into parts and writes the code for each

component but use some form of global index • Compiler generates synchronization and messaging• PGAS approach should work but has never been widely used – presumably

because compilers not mature

Page 21: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Summary of micro-parallelism On new applications, use MPI/locks with explicit

user decomposition A subset of applications can use “data parallel”

compilers which follow in HPF footsteps• Graphics Chips and Cell processor motivate such

special compilers but not clear how many applications can be done this way

OpenMP and/or Compiler-based Automatic Parallelism for existing codes in conventional languages

Page 22: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Composition of Parallel Components The composition (macro-parallelism) step has many excellent solutions

as this does not have the same drastic synchronization and correctness constraints as one has for scalable kernels• Unlike micro-parallelism step which has no very good solutions

Task parallelism in languages such as C++, C#, Java and Fortran90; General scripting languages like PHP Perl Python Domain specific environments like Matlab and Mathematica Functional Languages like MapReduce, F# HeNCE, AVS and Khoros from the past and CCA from DoE Web Service/Grid Workflow like Taverna, Kepler, InforSense KDE,

Pipeline Pilot (from SciTegic) and the LEAD environment built at Indiana University.

Web solutions like Mash-ups and DSS Many scientific applications use MPI for the coarse grain composition

as well as fine grain parallelism but this doesn’t seem elegant The new languages from Darpa’s HPCS program support task

parallelism (composition of parallel components) decoupling composition and scalable parallelism will remain popular and must be supported.

Page 23: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

2323

Mashups v Workflow? Mashup Tools are reviewed at

http://blogs.zdnet.com/Hinchcliffe/?p=63 Workflow Tools are reviewed by Gannon and Fox

http://grids.ucs.indiana.edu/ptliupages/publications/Workflow-overview.pdf Both include scripting

in PHP, Python, sh etc. as both implement distributed programming at level of services

Mashups use all types of service interfaces and perhaps do not have the potential robustness (security) of Grid service approach

Mashups typically “pure” HTTP (REST)

Page 24: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Grid Workflow Data Assimilation in Earth Science Grid services triggered by abnormal events and controlled by workflow process real

time data from radar and high resolution simulations for tornado forecasts

Typical graphical interface to service composition

Taverna another well known Grid/Web Service workflow tool

Recent Web 2.0 visual Mashup tools include Yahoo Pipes and Microsoft Popfly

Page 25: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

“Service Aggregation” in SALSA Kernels and Composition must be supported both inside

chips (the multicore problem) and between machines in clusters (the traditional parallel computing problem) or Grids.

The scalable parallelism (kernel) problem is typically only interesting on true parallel computers as the algorithms require low communication latency.

However composition is similar in both parallel and distributed scenarios and it seems useful to allow the use of Grid and Web composition tools for the parallel problem. • This should allow parallel computing to exploit large

investment in service programming environments Thus in SALSA we express parallel kernels not as traditional

libraries but as (some variant of) services so they can be used by non expert programmers

For parallelism expressed in CCR, DSS represents the natural service (composition) model.

Page 26: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Parallel Programming 2.0 Web 2.0 Mashups will (by definition the largest market)

drive composition tools for Grid, web and parallel programming

Parallel Programming 2.0 will build on Mashup tools like Yahoo Pipes and Microsoft Popfly

Yahoo Pipes

Page 27: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Inter-Service Communication Note that we are not assuming a uniform implementation of

service composition even if user sees same interface for multicore and a Grid• Good service composition inside a multicore chip can require

highly optimized communication mechanisms between the services that minimize memory bandwidth use.

• Between systems interoperability could motivate very different mechanisms to integrate services.

• Need both MPI/CCR level and Service/DSS level communication optimization

Note bandwidth and latency requirements reduce as one increases the grain size of services • Suggests the smaller services inside closely coupled cores and

machines will have stringent communication requirements.

Page 28: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Inside the SALSA Services We generalize the well known CSP (Communicating Sequential

Processes) of Hoare to describe the low level approaches to fine grain parallelism as “Linked Sequential Activities” in SALSA.

We use term “activities” in SALSA to allow one to build services from either threads, processes (usual MPI choice) or even just other services.

We choose term “linkage” in SALSA to denote the different ways of synchronizing the parallel activities that may involve shared memory rather than some form of messaging or communication.

There are several engineering and research issues for SALSA• There is the critical communication optimization problem area for

communication inside chips, clusters and Grids. • We need to discuss what we mean by services• The requirements of multi-language support

Further it seems useful to re-examine MPI and define a simpler model that naturally supports threads or processes and the full set of communication patterns needed in SALSA (including dynamic threads).• Should start a new standards effort in OGF perhaps?

Page 29: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

CICC Chemical Informatics and Cyberinfrastructure Collaboratory Web Service Infrastructure

Portal ServicesRSS FeedsUser ProfilesCollaboration as in Sakai

Core Grid ServicesService RegistryJob Submission and Management

Local ClustersIU Big Red, TeraGrid, Open Science Grid

Varuna.netQuantum Chemistry

Statistics Services Database Services

Core functionality Computation functionality 3D structures byFingerprints Regression CIDSimilarity Classification SMARTSDescriptors Clustering 3D Similarity2D diagrams Sampling distributionsFile format conversion

Docking scores/poses byApplications Applications CID

Docking Predictive models SMARTSFiltering Feature selection Protein

2D plots Docking scoresToxicity predictions

Anti-cancer activity predictionsCID, SMARTS

Cheminformatics Services

DruglikenessArbitrary R code (PkCell)

Mutagenecity predictionsPubChem related data by

Pharmacokinetic parametersOSCAR Document AnalysisInChI Generation/SearchComputational Chemistry (Gamess, Jaguar etc.)

Need to make all this parallel

Page 30: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Deterministic Annealing for Data Mining We are looking at deterministic annealing algorithms because

although heuristic• They have clear scalable parallelism (e.g. use parallel BLAS)• They avoid (some) local minima and regularize ill defined

problems in an intuitively clear fashion• They are fast (no Monte Carlo)• I understand them and Google Scholar likes them

Developed first by Durbin as Elastic Net for TSP Extended by Rose (my student then; now at UCSB)) and Gurewitz

(visitor to C3P) at Caltech for signal processing and applied later to many optimization and supervised and unsupervised learning methods.

See K. Rose, "Deterministic Annealing for Clustering, Compression, Classification, Regression, and Related Optimization Problems," Proceedings of the IEEE, vol. 80, pp. 2210-2239, November 1998

Page 31: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

High Level Theory Deterministic Annealing can be looked at from a Physics,

Statistics and/or Information theoretic point of view Consider a function (e.g. a likelihood) L({y}) that we

want to operate on (e.g. maximize)

Set L ({y},T) = L({y}) exp(- ({y} - {y})2 /T ) d{y}• Incorporating entropy term ensuring that one looks for most

likely states at temperature T• If {y} is a distance, replacing L by L corresponds to smearing

or smoothing it over resolution T Minimize Free Energy F = -Ln L ({y},T) rather than

energy E = -Ln L ({y}) • Use mean field approximation to avoid Monte Carlo

(simulated annealing)

Page 32: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Deterministic Annealing for Clustering I

Illustrating similarity between clustering and Gaussian mixtures Deterministic annealing for mixtures replaces by

and anneals down to mixture size

))2/(),(exp()(

with centers)(K MixtureGaussian Simple Compare

))(lnEnergy Free

)(),(

)/),(exp()(

where)(/)/),(exp()Pr(

CentersCluster and Points

1

2

1

2

1

K

k kkiki

N

i i

kiki

K

k kii

ikiki

ki

yxEPxZ

xZTF

yxyxE

TyxExZ

xZTyxECx

yKxN

22 k Tk 22

Page 33: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Deterministic Annealing for Clustering II

This is an extended K-means algorithm Start with a single cluster giving as solution y1 as centroid For some annealing schedule for T, iterate above algorithm testing

correlation matrix in xi about each cluster center to see if “elongated” Split cluster if elongation “long enough”; splitting is a phase

transition in physics view You do not need to assume number of clusters but rather a final

resolution T or equivalent At T=0, uninteresting solution is N clusters; one at each point xi

N

i ki

N

i kiinew

k

old

kiold

kiki

Cx

Cxxy

yxZTyxECx

1

1

)Pr(

)Pr( Calculate

),(/)/),(exp()Pr(with

Page 34: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Minimum evolving as temperature decreases Movement at fixed temperature going to local

minima if not initialized “correctly

Solve Linear Equations for each temperature

Nonlinearity removed by approximating with solution at previous higher temperature

DeterministicAnnealing

F({y}, T)

Configuration {y}

Page 35: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Clustering Data Cheminformatics was tested successfully with small datasets and

compared to commercial tools Cluster on properties of chemicals from high throughput

screening results to chemical properties (structure, molecular weight etc.)

Applying to PubChem (and commercial databases) that have 6-20 million compounds• Comparing traditional fingerprint (binary properties) with real-valued

properties GIS uses publicly available Census data; in particular the 2000

Census aggregated in 200,000 Census Blocks covering Indiana• 100MB of data

Initial clustering done on simple attributes given in this data• Total population and number of Asian, Hispanic and Renters

Working with POLIS Center at Indianapolis on clustering of SAVI (Social Assets and Vulnerabilities Indicators) attributes at http://www.savi.org) for community and decision makers• Economy, Loans, Crime, Religion etc.

Page 36: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Where are we? We have deterministically annealed clustering running well on 8-

core (2-processor quad core) Intel systems using C# and Microsoft Robotics Studio CCR/DSS

Could also run on multicore-based parallel machines but didn’t do this (is there a large Windows quad core cluster on TeraGrid?)• This would also be efficient on large problems

Applied to Geographical Information Systems (GIS) and census data• Could be an interesting application on future broadly deployed PC’s• Visualize nicely on Google Maps (and presumably Microsoft Virtual Earth)

Applied to several Cheminformatics problems and have parallel efficiency but visualization harder as in 150-1024 (or more) dimensions

Will develop a family of such parallel annealing data-mining tools where basic approach known for• Clustering• Gaussian Mixtures (Expectation Maximization)• and possibly Hidden Markov Methods

Page 37: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

37

Microsoft CCR• Supports exchange of messages between threads using named

ports• FromHandler: Spawn threads without reading ports• Receive: Each handler reads one item from a single port• MultipleItemReceive: Each handler reads a prescribed number of

items of a given type from a given port. Note items in a port can be general structures but all must have same type.

• MultiplePortReceive: Each handler reads a one item of a given type from multiple ports.

• JoinedReceive: Each handler reads one item from each of two ports. The items can be of different type.

• Choice: Execute a choice of two or more port-handler pairings• Interleave: Consists of a set of arbiters (port -- handler pairs) of 3

types that are Concurrent, Exclusive or Teardown (called at end for clean up). Concurrent arbiters are run concurrently but exclusive handlers are

• http://msdn.microsoft.com/robotics/

Page 38: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Preliminary Results• Parallel Deterministic Annealing Clustering in

C# with speed-up of 7 on Intel 2 quadcore systems

• Analysis of performance of Java, C, C# in MPI and dynamic threading with XP, Vista, Windows Server, Fedora, Redhat on Intel/AMD systems

• Study of cache effects coming with MPI thread-based parallelism

• Study of execution time fluctuations in Windows (limiting speed-up to 7 not 8!)

Page 39: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Machines UsedAMD4: HPxw9300 workstation, 2 AMD Opteron CPUs Processor 275 at 2.19GHz, 4 coresL2 Cache 4x1MB (summing both chips), Memory 4GB, XP Pro 64bit , Windows Server, Red HatC# Benchmark Computational unit: 1.388 µs

Intel4: Dell Precision PWS670, 2 Intel Xeon Paxville CPUs at 2.80GHz, 4 coresL2 Cache 4x2MB, Memory 4GB, XP Pro 64bitC# Benchmark Computational unit: 1.475 µs

Intel8a: Dell Precision PWS690, 2 Intel Xeon CPUs E5320 at 1.86GHz, 8 coresL2 Cache 4x4M, Memory 8GB, XP Pro 64bit C# Benchmark Computational unit: 1.696 µs

Intel8b: Dell Precision PWS690, 2 Intel Xeon CPUs E5355 at 2.66GHz, 8 coresL2 Cache 4x4M, Memory 4GB, Vista Ultimate 64bit, Fedora 7C# Benchmark Computational unit: 1.188 µs

Intel8c: Dell Precision PWS690, 2 Intel Xeon CPUs E5345 at 2.33GHz, 8 coresL2 Cache 4x4M, Memory 8GB, Red Hat 5.0, Fedora 7

Page 40: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Clustering algorithm annealing by decreasing distance scale and gradually finds more clusters as resolution improvedHere we see 10 clusters increasing to 30 as algorithm progresses

Page 41: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Renters

Total

Asian

Hispanic

Renters

IUB

Purdue

10 Clusters

Total

Asian

Hispanic

Renters

30 Clusters

Page 42: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

In detail, different groups have different cluster centers

Page 43: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

DSS Section

• We view system as a collection of services – in this case– One to supply data– One to run parallel clustering– One to visualize results – in this by spawning

a Google maps browser– Note we are clustering Indiana census data

• DSS is convenient as built on CCR

Page 44: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

4444

0

50

100

150

200

250

300

350

1 10 100 1000 10000

Round trips

Av

era

ge

ru

n t

ime

(m

icro

se

co

nd

s)

Timing of HP Opteron Multicore as a function of number of simultaneous two-way service messages processed (November 2006 DSS Release)

Measurements of Axis 2 shows about 500 microseconds – DSS is 10 times better

DSS Service Measurements

Page 45: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.
Page 46: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.
Page 47: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.
Page 48: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Clustering Problem

Page 49: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Deterministic Annealing • See K. Rose, "Deterministic Annealing for Clustering,

Compression, Classification, Regression, and Related Optimization Problems," Proceedings of the IEEE, vol. 80, pp. 2210-2239, November 1998

• Parallelization is similar to ordinary K-Means as we are calculating global sums which are decomposed into local averages and then summed over components calculated in each processor

• Many similar data mining algorithms (such as annealing for E-M expectation maximization) which have high parallel efficiency and avoid local minima

• For more details see – http://grids.ucs.indiana.edu/ptliupages/presentations/

Grid2007PosterSept19-07.ppt and– http://grids.ucs.indiana.edu/ptliupages/presentations/

PC2007/PC07BYOPA.ppt

Page 50: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Parallel MulticoreDeterministic Annealing Clustering

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0 0.5 1 1.5 2 2.5 3 3.5 4

Parallel Overheadon 8 Threads Intel 8b

Speedup = 8/(1+Overhead)

10000/(Grain Size n = points per core)

Overhead = Constant1 + Constant2/n

Constant1 = 0.05 to 0.1 (Client Windows) due to threadruntime fluctuations

10 Clusters

20 Clusters

Page 51: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Parallel Multicore Deterministic Annealing Clustering

0.000

0.050

0.100

0.150

0.200

0.250

0 5 10 15 20 25 30 35

#cluster

over

head

“Constant1”

Increasing number of clusters decreases communication/memory bandwidth overheads

Parallel Overhead for large (2M points) Indiana Census clustering on 8 Threads Intel 8bThis fluctuating overhead due to 5-10% runtime fluctuations between threads

Page 52: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Parallel Multicore Deterministic Annealing Clustering

“Constant1”

Increasing number of clusters decreases communication/memory bandwidth overheads

Parallel Overhead for subset of PubChem clustering on 8 Threads (Intel 8b)

The fluctuating overhead is reduced to 2% (under investigation!)40,000 points with 1052 binary properties (Census is 2 real valued properties)

Page 53: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

250

300

350

400

450

500

550

600

650

700

0 10 20 30 40 50 60 70 80 90

Number of processors

Ru

nti

me

(sec

on

ds)

Minsize 1 Minsize 100 Minsize 1000

MPI Parallel Divkmeans clustering of PubChem

AVIDD Linux cluster, 5,273,852 structures (Pubchem compound collection, Nov 2005)

min_size ncpus wall_mins walltime1 20 676 11:16:061 40 444 7:24:241 60 379 6:18:411 80 353 5:53:00

100 20 462 7:41:58100 40 356 5:56:01100 40 356 5:55:47100 60 339 5:38:44100 80 337 5:36:53

1000 20 513 8:32:391000 40 376 6:16:251000 60 346 5:46:221000 80 346 5:45:40

Page 54: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Scaled Speed up Tests• The full clustering algorithm involves different values of the

number of clusters NC as computation progresses• The amount of computation per data point is proportional to NC

and so overhead due to memory bandwidth (cache misses) declines as NC increases

• We did a set of tests on the clustering kernel with fixed NC

• Further we adopted the scaled speed-up approach looking at the performance as a function of number of parallel threads with constant number of data points assigned to each thread– This contrasts with fixed problem size scenario where the number of

data points per thread is inversely proportional to number of threads• We plot Run time for same workload per thread divided by

number of data points multiplied by number of clusters multiped by time at smallest data set (10,000 data points per thread)

• Expect this normalized run time to be independent of number of threads if not for parallel and memory bandwidth overheads– It will decrease as NC increases as number of computations per points

fetched from memory increases proportional to NC

Page 55: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Intel 8-core C# with 80 Clusters: Vista Run Time Fluctuations for Clustering Kernel

• 2 Quadcore Processors

• This is average of standard deviation of run time of the 8 threads between messaging synchronization points

Number of Threads

Standard Deviation/Run Time

Page 56: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Intel 8 core with 80 Clusters: Redhat Run Time Fluctuations for Clustering Kernel

• This is average of standard deviation of run time of the 8 threads between messaging synchronization points

Number of Threads

Standard Deviation/Run Time

Page 57: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Basic Performance of CCR

Page 58: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

MPI Exchange Latency in µs (20-30 µs computation between messaging)

Machine OS Runtime Grains Parallelism MPI Exchange Latency

Intel8c:gf12

(8 core 2.33 Ghz)

(in 2 chips)

Redhat MPJE (Java) Process 8 181

MPICH2 (C) Process 8 40.0

MPICH2: Fast Process 8 39.3

Nemesis Process 8 4.21

Intel8c:gf20

(8 core 2.33 Ghz)

Fedora MPJE Process 8 157

mpiJava Process 8 111

MPICH2 Process 8 64.2

Intel8b

(8 core 2.66 Ghz)

Vista MPJE Process 8 170

Fedora MPJE Process 8 142

Fedora mpiJava Process 8 100

Vista CCR (C#) Thread 8 20.2

AMD4

(4 core 2.19 Ghz)

XP MPJE Process 4 185

Redhat MPJE Process 4 152

mpiJava Process 4 99.4

MPICH2 Process 4 39.3

XP CCR Thread 4 16.3

Intel4 (4 core 2.8 Ghz) XP CCR Thread 4 25.8

SALSA Performance

The macroscopic inter-service DSS Overhead is about 35µs

DSS is composed from CCR threads that have4µs overhead for spawning threads in dynamic search applications20µs overhead for MPI Exchange

Page 59: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

CCR Overhead for a computation of 23.76 µs between messaging

Rendezvous

Intel8b: 8 Core Number of Parallel Computations

(μs) 1 2 3 4 7 8

Spawned

Pipeline 1.58 2.44 3 2.94 4.5 5.06

Shift 2.42 3.2 3.38 5.26 5.14

Two Shifts 4.94 5.9 6.84 14.32 19.44

MPI

Pipeline 2.48 3.96 4.52 5.78 6.82 7.18

Shift 4.46 6.42 5.86 10.86 11.74

Exchange As Two Shifts

7.4 11.64 14.16 31.86 35.62

Exchange 6.94 11.22 13.3 18.78 20.16

Page 60: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Overhead (latency) of AMD4 PC with 4 execution threads on MPI style Rendezvous Messaging for Shift and Exchange implemented either as two shifts or as custom CCR pattern

0

5

10

15

20

25

30

0 2 4 6 8 10

AMD Exch

AMD Exch as 2 Shifts

AMD Shift

Stages (millions)

Time Microseconds

Page 61: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Overhead (latency) of Intel8b PC with 8 execution threads on MPI style Rendezvous Messaging for Shift and Exchange implemented either as two shifts or as custom CCR pattern

0

10

20

30

40

50

60

70

0 2 4 6 8 10

Intel Exch

Intel Exch as 2 Shifts

Intel Shift

Stages (millions)

Time Microseconds

Page 62: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Basic Performance of MPI for C and Java

Page 63: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

MPI Exchange Latency in µs (20-30 µs computation between messaging)

Machine OS Runtime Grains Parallelism MPI Exchange Latency

Intel8c:gf12

(8 core 2.33 Ghz)

(in 2 chips)

Redhat MPJE (Java) Process 8 181

MPICH2 (C) Process 8 40.0

MPICH2: Fast Process 8 39.3

Nemesis Process 8 4.21

Intel8c:gf20

(8 core 2.33 Ghz)

Fedora MPJE Process 8 157

mpiJava Process 8 111

MPICH2 Process 8 64.2

Intel8b

(8 core 2.66 Ghz)

Vista MPJE Process 8 170

Fedora MPJE Process 8 142

Fedora mpiJava Process 8 100

Vista CCR (C#) Thread 8 20.2

AMD4

(4 core 2.19 Ghz)

XP MPJE Process 4 185

Redhat MPJE Process 4 152

mpiJava Process 4 99.4

MPICH2 Process 4 39.3

XP CCR Thread 4 16.3

Intel4 (4 core 2.8 Ghz) XP CCR Thread 4 25.8

Page 64: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Cache Line Interference

Page 65: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Cache Line Interference• Early implementations of our clustering algorithm

showed large fluctuations due to the cache line interference effect discussed here and on next slide in a simple case

• We have one thread on each core each calculating a sum of same complexity storing result in a common array A with different cores using different array locations

• Thread i stores sum in A(i) is separation 1 – no variable access interference but cache line interference

• Thread i stores sum in A(X*i) is separation X

• Serious degradation if X < 8 (64 bytes) with Windows– Note A is a double (8 bytes)– Less interference effect with Linux – especially Red Hat

Page 66: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Time µs versus Thread Array Separation (unit is 8 bytes)

1 4 8 1024 Machine

OS

Run Time Mean Std/

Mean Mean Std/

Mean Mean Std/

Mean Mean Std/

Mean Intel8b Vista C# CCR 8.03 .029 3.04 .059 0.884 .0051 0.884 .0069 Intel8b Vista C# Locks 13.0 .0095 3.08 .0028 0.883 .0043 0.883 .0036 Intel8b Vista C 13.4 .0047 1.69 .0026 0.66 .029 0.659 .0057 Intel8b Fedora C 1.50 .01 0.69 .21 0.307 .0045 0.307 .016 Intel8a XP CCR C# 10.6 .033 4.16 .041 1.27 .051 1.43 .049 Intel8a XP Locks C# 16.6 .016 4.31 .0067 1.27 .066 1.27 .054 Intel8a XP C 16.9 .0016 2.27 .0042 0.946 .056 0.946 .058 Intel8c Red Hat C 0.441 .0035 0.423 .0031 0.423 .0030 0.423 .032 AMD4 WinSrvr C# CCR 8.58 .0080 2.62 .081 0.839 .0031 0.838 .0031 AMD4 WinSrvr C# Locks 8.72 .0036 2.42 0.01 0.836 .0016 0.836 .0013 AMD4 WinSrvr C 5.65 .020 2.69 .0060 1.05 .0013 1.05 .0014 AMD4 XP C# CCR 8.05 0.010 2.84 0.077 0.84 0.040 0.840 0.022 AMD4 XP C# Locks 8.21 0.006 2.57 0.016 0.84 0.007 0.84 0.007 AMD4 XP C 6.10 0.026 2.95 0.017 1.05 0.019 1.05 0.017

Cache Line Interference

• Note measurements at a separation X of 8 (and values between 8 and 1024 not shown) are essentially identical

• Measurements at 7 (not shown) are higher than that at 8 (except for Red Hat which shows essentially no enhancement at X<8)

• If effects due to co-location of thread variables in a 64 byte cache line, the array must be aligned with cache boundaries

– In early implementations we found poor X=8 performance expected in words of A split across cache lines

Page 67: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Inter-Service Communication Note that we are not assuming a uniform implementation of

service composition even if user sees same interface for multicore and a Grid• Good service composition inside a multicore chip can require

highly optimized communication mechanisms between the services that minimize memory bandwidth use.

• Between systems interoperability could motivate very different mechanisms to integrate services.

• Need both MPI/CCR level and Service/DSS level communication optimization

Note bandwidth and latency requirements reduce as one increases the grain size of services • Suggests the smaller services inside closely coupled cores and

machines will have stringent communication requirements.

Page 68: 1 Multicore Salsa Parallel Programming 2.0 Peking University October 31 2007 Geoffrey Fox, Huapeng Yuan, Seung-Hee Bae Community Grids Laboratory, Indiana.

Inside the SALSA Services We generalize the well known CSP (Communicating Sequential

Processes) of Hoare to describe the low level approaches to fine grain parallelism as “Linked Sequential Activities” in SALSA.

We use term “activities” in SALSA to allow one to build services from either threads, processes (usual MPI choice) or even just other services.

We choose term “linkage” in SALSA to denote the different ways of synchronizing the parallel activities that may involve shared memory rather than some form of messaging or communication.

There are several engineering and research issues for SALSA• There is the critical communication optimization problem area for

communication inside chips, clusters and Grids. • We need to discuss what we mean by services• The requirements of multi-language support

Further it seems useful to re-examine MPI and define a simpler model that naturally supports threads or processes and the full set of communication patterns needed in SALSA (including dynamic threads).• Should start a new standards effort in OGF perhaps?