Java standalone version MPI application Java standalone version Valeria Ardizzone Tutorial su integrazione applicazioni sui Science Gateway, Roma, 23-27.01.2012
GRID opportunities Grid allows users to access resources not available locally Pro: users have a bigger storage and computational power Con: configuration and run-time errors are difficult to identify gLite provides several tools to manage parallel applications on Grid An application can be separated in several jobs for trivial parallel problems or requires a single parallel job Nome Cognome Occasione, Luogo, gg.mm.anno
MPI overview Execution of parallel jobs is an essential issue for modern informatics and applications. Most used library for parallel jobs support is MPI (Message Passing Interface) At the state of the art, parallel jobs can run inside single Computing Elements (CE) only; several projects are involved into studies concerning the possibility of executing parallel jobs on Worker Nodes (WNs) belonging to different Ces. The source code must have been compiled with mpicc libraries Nome Cognome Occasione, Luogo, gg.mm.anno
MPI on Grid MPI differs from a normal application MPI applications require contemporary access to distribute resources through a special software library. The Grid software has to control the resources access in relation with the MPI requirements Different implementation of MPI library are available Applications can use only one library Actually, the MPI is bounded inside a CE Nome Cognome Occasione, Luogo, gg.mm.anno
MPI-Start Specifies a unique interface to the upper layer to run a MPI job Allow the support of new MPI implementations without modifications in the Grid middleware Support of “simple” file distribution Provide some support for the user to help manage his data Grid Middleware MPI-START MPI Resources 6 6
MPI-Start mpi-start is a recommended solution to hide the implementation details for jobs submission. The design of mpi-start was focused in making the MPI job submission as transparent as possible from the cluster details! Using the mpi-start system requires the user to define a wrapper script that set the environment variables and a set of hooks. It was developed inside the Int.EU.Grid project 7 7
MPI-Start design goals Portable The program must be able to run under any supported operating system Modular and extensible architecture Plugin/Component architecture Relocatable Must be independent of absolute path, to adapt to different site configurations Remote “injection” of mpi-start along with the job “Remote” debugging features It was developed inside the Int.EU.Grid project 8
MPI JAVA STANDALONE CODE Nome Cognome Occasione, Luogo, gg.mm.anno
Introduction While developing a Grid Application the user needs to identify: 1. The Grid services to specify 2. The input and ouput files 3. The executable The three steps above can be easily identified, then written and tested with a small set of GridEngine API calls. This set of instructions can be used then inside the portlet concentrating the user to deal with the interface while developing the portlet Nome Cognome Occasione, Luogo, gg.mm.anno
Required files to submit on Grid An init script and a wrapper in order to submit an MPI application to the Grid: mpi-start-wrapper.sh mpi-hooks.sh Another file needed is the one representing the application to execute on Grid: cpi.c Nome Cognome Occasione, Luogo, gg.mm.anno
Required JAVA files to submit on Grid jobmanager.java: application that manages executed jobs via the GridEngine mi_mpi_standalone.java: standalone jobSubmission code in Multi Infrastructure mode Nome Cognome Occasione, Luogo, gg.mm.anno
mi_mpi-standalone.java (1) Main code just instanciate the submission object and calls the submitJob methid. public static void main(String[] Args) { mi_mpi_standalone mihs = new mi_mpi_standalone(); mihs.prepareAndSubmitJob(); System.out.println("Done!"); } Infrastructure information class stores: class Info_Infrastructure { String nameInfrastructure; String acronymInfrastructure; String bdiiHost; String wmsHosts; String pxServerHost; String pxServerPort; String pxServerSecure; String pxRobotId; String pxRobotVO; String pxRobotRole; String pxRobotRenewalFlag; It was developed inside the Int.EU.Grid project 13
mi_mpi-standalone.java (2) App_Input is a class where collect all job sumbission values: class App_Input { // Filename for application input file String inputFileName; // Text for application input file String inputFileText; // User' given job identifier String jobIdentifier; // Content of an uploaded file String inputSandbox_inputFile; // Some user level information String username; String timestamp; It was developed inside the Int.EU.Grid project The init values will be read from portlet.xml class App_Init { Class used to store the values of portlet preferences: class App_Preferences { 14
mi_mpi-standalone.java (3) Prepare and Submit: public void prepareAndSubmitJob() { // Simulate the application init parameters appInit.sciGwyUserTrackingDB_Database="userstracking"; appInit.sciGwyUserTrackingDB_Username="tracking_user”; appInit.sciGwyUserTrackingDB_Password="usertracking"; // Simulate application preferences appPreferences.logLevel="info"; appPreferences.setNumInfrastructures("1"); appPreferences.paneInfrastucture=1; Info_Infrastructure[] infoInfra = new Info_Infrastructure[1]; infoInfra[0]=new Info_Infrastructure(); infoInfra[0].nameInfrastructure="EUMEDGRID-Support infrastructure"; … appPreferences.infoInfra = infoInfra; appPreferences.pxUserProxy=""; appPreferences.sciGwyAppId="9"; appPreferences.jobRequirements="Member(\"MPI-START\", other.GlueHostApplicationSoftwareRunTimeEnvironment);"+ "Member(\"MPICH\”, other.GlueHostApplicationSoftwareRunTimeEnvironment)”; It was developed inside the Int.EU.Grid project 15
mi_mpi-standalone.java (4) Prepare and Submit: … // Application input object App_Input appInput=new App_Input(); appInput.inputFileName="input_file.txt"; //Filename for appl input file appInput.inputFileText="Text input file"; // Text for appl input file appInput.jobIdentifier="Standalone mpi-job id"; // User' given job identifier // This variable contains the content of an uploaded file appInput.inputSandbox_inputFile="application_input_file.txt"; appInput.username="test"; SimpleDateFormat dateFormat = new SimpleDateFormat(tsFormat); String timestamp = dateFormat.format(Calendar.getInstance().getTime()); appInput.timestamp=timestamp; // Submit job submitJob(appInput); } It was developed inside the Int.EU.Grid project 16
mi_mpi-standalone.java (5) SUBMITJOB method: void submitJob(App_Input appInput) { int numInfras=appPreferences.getNumInfrastructures(); if(numInfras >0) { MultiInfrastructureJobSubmission miJobSubmission = new MultiInfrastructureJobSubmission("jdbc:mysql://localhost/” +appInit.sciGwyUserTrackingDB_Database, appInit.sciGwyUserTrackingDB_Username, appInit.sciGwyUserTrackingDB_Password); InfrastructureInfo infrastructures[] = new InfrastructureInfo[numInfras]; for(int i=0; i<numInfras; i++) { int j=i+1; String wmsHostList[]=null; if( null != appPreferences.infoInfra[i].wmsHosts && !appPreferences.infoInfra[i].wmsHosts.equals("")) { wmsHostList = appPreferences.infoInfra[i].wmsHosts.split(";"); log.info(LS+"wmsHostList"); for(int k=0; k<wmsHostList.length; k++) log.info(LS+wmsHostList[k]); } infrastructures[i] = new InfrastructureInfo( appPreferences.infoInfra[i].acronymInfrastructure, appPreferences.infoInfra[i].bdiiHost, wmsHostList, appPreferences.infoInfra[i].pxServerHost, appPreferences.infoInfra[i].pxServerPort, appPreferences.infoInfra[i].pxRobotId, appPreferences.infoInfra[i].pxRobotRole, appPreferences.infoInfra[i].pxRobotVO); miJobSubmission.addInfrastructure(infrastructures[i]); _log.info(LS+appPreferences.dumpInfrastructure(j));} It was developed inside the Int.EU.Grid project 17
mi_mpi-standalone.java (6) Sumbit method job details: … String executable="/bin/sh"; //Application executable String cpunumber="4"; //cpunumber (default) String arguments ="mpi-start-wrapper.sh cpi mpich2"; String outputPath="/tmp/"; // Output Path String outputFile="mpi-Output.txt"; //application standard output String errorFile ="mpi-Error.txt"; // application standard error String inputSandbox= appServerPath+"/WEB-INF/job/cpi.c”+","+appServerPath+"/WEB-INF/job/mpi-hooks.sh”+","+appServerPath+"/WEB-INF/job/mpi-start-wrapper.sh”+","+appInput.inputSandbox_inputFile; String outputSandbox=""; It was developed inside the Int.EU.Grid project 18
mi_mpi-standalone.java (7) Submit method job Requirements: … String jdlRequirements[] = appPreferences.jobRequirements.split(";"); int numRequirements=0; for(int i=0; i<jdlRequirements.length; i++) { if(!jdlRequirements[i].equals("")) { jdlRequirements[numRequirements] = "JDLRequirements=( "+jdlRequirements[i]+")"; numRequirements++; } _log.info("Requirement[”+"]='"+jdlRequirements[i]+"'"); } // for each jobRequirement It was developed inside the Int.EU.Grid project 19
mi_mpi-standalone.java (8) Submit method miJobSubmission object: miJobSubmission.setExecutable(executable); miJobSubmission.setTotalCPUCount(cpunumber); miJobSubmission.setArguments(arguments); miJobSubmission.setOutputPath(outputPath); if(outputSandbox.compareTo("")!=0) { miJobSubmission.setOutputFiles(outputSandbox) } miJobSubmission.setJobOutput(outputFile); miJobSubmission.setJobError(errorFile); If( null != inputSandbox && inputSandbox.length() > 0) miJobSubmission.setInputFiles(inputSandbox); if(numRequirements > 0) miJobSubmission.setJDLRequirements(jdlRequirements); // Submit Job miJobSubmission.submitJobAsync(username, hostUTDB, applicationId, appInput.jobIdentifier); It was developed inside the Int.EU.Grid project 20
Final step At the end launch the command for the submission. Manage job execution sent by the GridEngine API calls For the java code responsible for monitoring the status of the job and getting the output you can refer to the https://gilda.ct.infn.it/wikimain/-/wiki/Main/GridEngineStandaloneCode This java file is exactly the same used for the normal job. Nome Cognome Occasione, Luogo, gg.mm.anno
Grid Option in mpi-portlet.java References Gilda Training Material: http://gilda.ct.infn.it/wikimain Science Gateway developer page: http://gilda.ct.infn.it/wikimain/- /wiki/Main/Science%20Gateway%20Developer%20Pag es MPI Standalone wiki:http://gilda.ct.infn.it/wikimain/- /wiki/Main/GridEngineMPIStandaloneCode How to run GridEngine Standalone Code: https://gilda.ct.infn.it/wikimain/- /wiki/Main/GridEngineStandaloneCode It was developed inside the Int.EU.Grid project 25