© Fraunhofer SCAI
Horst Schwichtenberg, Steffen Claus Win HPC User, Karlsruhe, 31.03.2011
MS HPC Integration von Excel und eigenen Anwendungen mit WCF
© Fraunhofer SCAI
SPEC MPI2007 (32 cores) SPECmpiM_base2007
Windows Linux % 7.44 7.42 0.2%
000 002 004 006 008 010 012 014
104.milc
107.leslie3d
113.GemsFDTD
115.fds4
121.pop2
122.tachyon
126.lamps
127.wrf2
128.GAPgeofem
129.tera_tf
130.socorro
132.zeusmp2
137.lu
Ratio - better →
Windows
Linux
© Fraunhofer SCAI
SPEC MPI2007 (64 cores)
,00 5,00 10,00 15,00 20,00 25,00
104.milc
107.leslie3d
113.GemsFDTD
115.fds4
121.pop2
122.tachyon
126.lamps
127.wrf2
128.GAPgeofem
129.tera_tf
130.socorro
132.zeusmp2
137.lu
Ratio - better →
Windows
Linux
SPECmpiM_base2007 Windows Linux %
14.26 14.24 0.2%
© Fraunhofer SCAI
SPEC MPI2007 (128 cores) SPECmpiM_base2007
Windows Linux % 25.81 24.94 3.37
000 005 010 015 020 025 030 035 040 045 050
104.milc
107.leslie3d
113.GemsFDTD
115.fds4
121.pop2
122.tachyon
126.lamps
127.wrf2
128.GAPgeofem
129.tera_tf
130.socorro
132.zeusmp2
137.lu
Ratio - better →
Windows (peak)
Linux
© Fraunhofer SCAI
Agenda
n 1.) Parallel Excel: Utilizing HPC resources
n How to use? When to use?
n Live demo
n 2.) WCF as interface to HPC resources
n Example: Industrial optimization
n Live demo
n Conclusion
© Fraunhofer SCAI
Parallel Excel – Best practices
§ Existing UDFs/XLL?
§ C/C++ programming skills, small changes required
§ Existing workbook?
§ Excel VBA (macro) development, apply macro framework
§ None of both?
§ Write own HPC services (WCF) in any .Net CLR supported language
§ Use Excel as front end
CLR: Common Language Runtime
© Fraunhofer SCAI
Parallel Excel – User defined function (UDF)
§ UDFs are function extensions to Excel, (Visual studio C, C# built XLL libraries)
§ UDFs programms use an Excel API (e.g. xlAutoOpen, Excel12, …)
§ Notify Excel of so-called „cluster safe“ functions by changing the function signature (add „&“ to the end of the string)
§ XLL is deployed to cluster; XLLs are loaded by a XLLContainerService (WCF service contained in HPC Server 2008 R2 installation)
§ „cluster safe“ XLLs can still be used locally (on/off switch in Excel options)
Remark: Threadsafe = $
© Fraunhofer SCAI
Public Network Private Network
Failover Head node
1. User creates session
3. Provide WCF Broker node as
EPR
5. Requests 4. Client connects to Broker and submits
requests
7. Responses return to client
Excel Client
6. Responses
UDF: Excel Client – Cluster Interaction
Head node
2 a). Session Manager assigns WCF Broker node
for client job
WCF Broker Compute nodes
2 b). Start service instances
UDF
XLLContainer
HpcServiceHost
© Fraunhofer SCAI
UDF: Live demonstration – Longstaff Schwartz
American-Asian Options with Monte Carlo
© Fraunhofer SCAI
UDF: Requirements, Considerations and Restrictions
§ Requirements:
§ WCF broker node on cluster; UDF XLL deployed to cluster; Excel 2010 on client; HPC Pack 2008 R2 client utilities on client; Developer: Visual Studio and Excel 2010 XLL SDK
§ Considerations:
§ Overhead through communication between local node, WCF broker node, compute nodes, XLLContainer service etc. à Applicability depends on ratio of runtime and overhead
§ Restrictions:
§ UDF must contain independent calculations, must not depend on input of other cells; no calls to access the spreadsheet; no pop-ups; no shared memory or static variables; XLL is loaded and started governed by the XLLContainerService
© Fraunhofer SCAI
Parallel Excel - Workbook § VBA code; apply Visual basic macros
§ HPC_Initialize: clear spreadsheet, and init stuff
§ HPC_Partition: return value is used as input for HPC_Execute; collects parameters for a single calculation step
§ HPC_Execute: one calculation step; can be executed on the cluster; return value is used as input for HPC_Merge
§ HPC_Merge: processes result of single calculation step; update of spreadsheet, writing of logfile etc.
§ HPC_Finalize: called after HPC_Partition has returned null
§ HPC_Error: …
§ HPCexcel client class reference (part of MS HPC client utilities)
§ Iterative calculation of (Partition à Execute à Merge …)
§ Requires Excel on compute nodes
© Fraunhofer SCAI
Workbook: Calculation steps
Partition Execute Merge Initialize Finalize
Error
client node client
© Fraunhofer SCAI
Public Network Private Network
Failover Head node
1. User creates session
3. Provide WCF Broker node as
EPR
5. Requests 4. Client connects to Broker and submits
requests
7. Responses return to client
Excel Client
6. Responses
Workbook: Excel Client – Cluster Interaction
Head node
2 a). Session Manager assigns WCF Broker node
for client job
WCF Broker Compute nodes
2 b). Start service instances
HpcServiceHost
ExcelService
© Fraunhofer SCAI
Workbook: Live demonstration – Convertible Pricing
© Fraunhofer SCAI
Workbook: Requirements, Considerations and Restrictions
§ Requirements:
§ WCF broker node on cluster; Excel 2010 installed on all compute nodes; Workbook deployed to shared directory; Excel 2010 on client, HPC Pack 2008 R2 client utilities on client.
§ Considerations:
§ Useful, if callbacks and lookups to the spreadsheets are needed (table lookup, multiple cells as input)
§ If calculations change over time; easier update than UDFs (require recompilation)
§ Restrictions:
§ Iterative, independent calculations
© Fraunhofer SCAI
UDF vs. Workbook
Cluster-safe UDF § Pro
§ Easy to „cluster enable“ existing UDFs
§ Easy to enable and disable
§ Well-suited for single, atomic calculations
§ No Excel on node
§ Contra § No callbacks to Excel sheet, no
pop-up dialogs
§ Changes to function require recompilation
Workbook § Pro
§ Pop-up dialogs possible
§ Flexible VBA development
§ Can use resources such as DBs, files, other workbooks
§ Excel on node
§ Contra § Manual problem partitioning
§ …
© Fraunhofer SCAI
Windows Communication Foundation (WCF)
§ Microsoft API for SOA applications
§ Part of the .Net Framework
§ Supports most common SOA technologies:
§ WS-*, WSDL, SOAP
§ Security, Transactions, Bindings (HTTPS, NetTCP, etc.),…
§ Why did we choose WCF for our industrial application (see later)?
§ WCF can be easily integrated into existing code
§ does not restrict the developer to use a specific language (if WSDL and XSD descriptions of the interface are available)
§ Concerning reachability (firewall issues) this is the easiest solution
© Fraunhofer SCAI
Parallel Excel – Excel as front end for custom WCF services First: Create a Service from your Application (eg. Numerical program e.g. Monte Carlo) Second: Create in Excel a Clint Application (Workbook to show results) Service:
§ Service Contract:
[ServiceContract] public interface IExampleService { [OperationContract] int ExampleCalculate( … ); }
1. Step: create a .net service (needs .net 3.5) by an .NET interface as starting point 2. Make it a WCF service contract anotate the interface itself with [ServiceContract] + any method
Namespace ServiceLibrary { {public interface IExampleService {string Echo(string msg)}}
© Fraunhofer SCAI
Parallel Excel – Excel as front end for custom WCF services § SvcUtil:
§ Service Usage (create a session and obtain service endpoint):
SvcUtil.exe ExampleService.dll à creates wsdl und xsd of the service SvcUtil.exe *.wsdl *.xsd /async /language:C# /out:ExampleServiceProxy.cs
public void Calculate(…) { SessionStartInfo info = new SessionStartInfo(“headnode“,“ExampleService“); … using (Session session = Session.CreateSession(info)) { ExampleServiceClient proxy = new ExampleServiceClient(binding, session.epr);
proxy.BeginExampleCalculate(…, ExampleServiceCallback, asyncState); } } private void ExampleServiceCallback(IAsyncResult result) { state = result.AsyncState; //to identify return value values = proxy.EndCalculate(result); //the real result }
© Fraunhofer SCAI
Parallel Excel – Excel as front end for custom WCF services
§ Config file (copied to HpcSercviceRegistration folder on headnode):
§ Cluster deployment:
<configuration>
…
<service assembly="C:\Services\ExampleService.dll“ contract=„ExampleService.IExampleService“ type=„ExampleService.ExampleService" />
… </configuration>
clusrun /exclude:headnode robocopy „<your_local_service_dir>" "C:\Services" /MIR > NUL clusrun /exclude:headnode robocopy „<your_local_service_reg_dir>" "%CCP_HOME%\ServiceRegistration" /MIR > NUL
© Fraunhofer SCAI
Industrial application
§ Solves optimization problem: „Placing pieces on fabrics/leather“
§ Optimization contrained by: size of fabrics, shape of pieces, quality of leather, etc.
§ Benefit of automatic optimization: minimize waste, faster results (compared to humans)
© Fraunhofer SCAI
Automatic placing of patterns on leather hides
§ Map a set of tiles (of car seats, sofas etc.) onto a leather hide
§ quality of leather varies (e.g. holes)
§ à additional quality constraints
© Fraunhofer SCAI
The idea: use remote HPC resources for solver
§ So far: User of application runs the software localyà problem solver runs locally on the users machine
§ Idea: Extract optimization algorithm and run it on HPC cluster
§ Why bother?
§ MPI-version of the algorithm exists à exploitation of cluster resources, faster results with even better efficiency
§ Advantages for software vendor: more sophisticated accounting models (pay per computation etc.),
§ Advantages for the software developer: straightforward and direct update of the optimization code
© Fraunhofer SCAI
Company LAN
Interaction between Application and HPC Cluster
SCAI Private Network
Compute nodes Head node Service
Provider
Client
Authentication
3. Jobs are submitted to
HPC scheduler
4. Jobs
1. web service DLL computes
remote
6. Results
5. Results and Accounting
2. Authentication and Authorization
Accounting
Internet
Products
© Fraunhofer SCAI
Conclusion
§ Excel: UDF and workbook
§ easy to use HPC resource without special knowledge
§ Excel as interface for own applications
§ nice and easy to use frontend for HPC application – wrap your application as service
§ WCF as integration
§ access your HPC application or integrate it in your environment
Thank you !
© Fraunhofer SCAI
Thank you!