Scilab is an open source, cross-platform numerical computational package and a high-level, numerically oriented programming language. It can be used for signal processing, statistical analysis, image enhancement, fluid dynamics simulations, numerical optimization, and modeling, simulation of explicit and implicit dynamical systems and (if the corresponding toolbox is installed) symbolic manipulations. Scilab is the most complete open source alternative to MATLAB.

In this tutorial we will use ProActive PAConnector API to write simple Scilab computations which execute on four different machines (a.k.a ProActive Nodes) at the same time.

1 Install and configure Scilab environment


  1. Install and configure Scilab software environment. The minimal version of Scilab is 5.3.3 and the maximal is Scilab 5.4.1. The current version of ProActive Scilab Connector is not compatible with Scilab 5.5. You can find an installer which matches your platform from [ here ].

  2. If you downloaded ProActive Scilab Connector from ATOMS, please remove it as it is not compatible with the scheduler version on the http://trydev.activeeon.com platform :

    --> atomsRemove('ProActiveConnector')
                                                    

    Make sure the module JIMS (Java Integration Mechanism in Scilab is installed from ATOMS, if not install it :

    --> atomsInstall('JIMS')
                                                    
  3. Please contact us on contact@activeeon.com to get the Scilab Proactive Connector model link
    Once retrieved, unzip it in a directory for example c:\users\your_name

  4. Go to the folder where Scilab is installed and edit the following file SCILAB/etc/scilab.quit
    Add the following lines before the line " // starts modules .quit " :

    // 
    if isdef("ProActiveConnectorlib") then
       PAterminate();
    end
    												

2 Connection to the Scheduler.


Connection to the Scheduler

  1. Open Scilab

  2. Type the following commands to load PAConnector and connect to the Scheduler.
    Replace c:\users\your_name\PAConnector with the path where the toolbox was unzipped Replace 'login' and 'pwd' by the login and password you received when subscribing to the tutorial.

--> cd c:\users\your_name\PAConnector

--> exec loader.sce


--> PAConnect('pamr://1');

 Connection to JVM successful

 Connection successful to pamr://1

 Please enter login/password

                                        

Enter the login and password received when subscribing to the tutorial in the popup window.

Enter a simple command to verify the scheduler state :

-->PAstate()
	 ID       NAME            OWNER      PRIORITY     STATUS       START AT                         DURATION
	 2858     Scilab 19       demo       Normal       Finished     14/04/14 17:11 (23h43mn ago)      6s 200ms
	 2857     Scilab 18       demo       Normal       Finished     14/04/14 17:11 (23h43mn ago)      5s 721ms
	 2856     Scilab 17       demo       Normal       Finished     14/04/14 17:10 (23h43mn ago)      3s 737ms
	 2855     Scilab 16       demo       Normal       Finished     14/04/14 17:10 (23h44mn ago)      3s 852ms
	 2854     Scilab 15       demo       Normal       Finished     14/04/14 17:10 (23h44mn ago)     12s 522ms
	 2851     Scilab 12       demo       Normal       Finished     14/04/14 17:10 (23h44mn ago)     14s 323ms
	 2850     Scilab 11       demo       Normal       Finished     14/04/14 17:09 (23h44mn ago)     19s  30ms
	 2849     Scilab 10       demo       Normal       Finished     14/04/14
 17:08 (23h45mn ago)     58s 807ms
	 2848     Scilab 9        demo       Normal       Finished     14/04/14 17:07 (23h47mn ago)      1m 33s 686ms
	 2847     Scilab 8        demo       Normal       Finished     14/04/14 17:05 (23h48mn ago)     53s 544ms
	 2846     Scilab 7        demo       Normal       Finished     14/04/14 17:04 (23h50mn ago)     50s 813ms
	 2844     Scilab 5        demo       Normal       Finished     14/04/14 17:03 (23h51mn ago)     31s 351ms
	 2843     Scilab 4        demo       Normal       Finished     14/04/14 17:02 (23h51mn ago)     11s 342ms
	 2842     Scilab 3        demo       Normal       Finished     14/04/14 17:02 (23h52mn ago)     17s  44ms
	 2841     Scilab 2        demo       Normal       Finished     14/04/14 17:02 (23h52mn ago)     11s  30ms
	 2840     Scilab 1        demo       Normal       Finished     14/04/14 17:01 (23h52mn ago)     12s 989ms
	 2838     Job             a

                                        

3 Hello World Job


Hello World function with one parameter :

In this first example, we'll execute remotely a simple Hello World function.

We define the function hellow which prints Hello followed by the function argument :

--> deff('[y]=hellow(x)','disp(''Hello '' + x);y=%t')
                                        
We submit this function to the Scheduler using the function PAsolve (note the quote around the function name). PASolve returns an object which we store in a variable job. If displayed, this object describes the status of the job.

-->job = PAsolve( 'hellow', 'World')

 Job submitted : 2874
 job  =

(1):
Awaited (J:2874)

-->job
 job  =

(1):
Awaited (J:2874)

                                        
We wait for the job completion by calling the function PAwaitFor. This function returns the numeric result of the job and prints the remote output.
--> val = PAwaitFor(job)
Job 2874: Task 0_0
[2014-04-15 15:26:023 pacagrid-azure][SCILAB] Hello World


 val  =


       val(1)
 T

We can see on the Scilab console the remote execution log, and we receive in the val variable the value True (%t)

Now let's run it on several machines by providing more parameters :

-->job = PAsolve( 'hellow', 'World1','World2','World3','World4','World5','World6')

 Job submitted : 2877
 job  =

(1):
Awaited (J:2877)
(2):
Awaited (J:2877)
(3):
Awaited (J:2877)
(4):
Awaited (J:2877)
(5):
Awaited (J:2877)
(6):
Awaited (J:2877)
                                        

If we consequently display the value of the variable job, it will be updated as soon as tasks are finished on the server side:

-->job
 job  =

Job 2877: Task 0_0
[2014-04-15 15:31:037 pacagrid-azure][SCILAB] Hello World1


Job 2877: Task 1_0
[2014-04-15 15:31:037 pacagrid-azure][SCILAB] Hello World2


Job 2877: Task 2_0
[2014-04-15 15:31:037 pacagrid-azure][SCILAB] Hello World3


Job 2877: Task 3_0
[2014-04-15 15:31:037 pacagrid-azure][SCILAB] Hello World4


(1):

  T
(2):

  T
(3):

  T
(4):

  T
(5):
Awaited (J:2877)
(6):
Awaited (J:2877)
                                        

Here we see that the tasks 1 to 4 have been updated and tasks 5,6 are still awaited. The outputs of tasks 1-4 are printed.
Let's now get the final results :

--> val = PAwaitFor(job)
Job 2877: Task 4_0
[2014-04-15 15:31:044 pacagrid-azure][SCILAB] Hello World5


Job 2877: Task 5_0
[2014-04-15 15:31:044 pacagrid-azure][SCILAB] Hello World6


 val  =


       val(1)

  T

       val(2)

  T

       val(3)

  T

       val(4)

  T

       val(5)

  T

       val(6)

  T
                                        

Only the log outputs of tasks 5,6 are printed in this last call are others have already been printed. The variable val contain all six results though.
If we want to see the log outputs of all tasks, we can use the function PAgetLogs :

-->PAgetLogs(job)
 ans  =


       ans(1)

 Job 2877: Task 0_0
[2014-04-15 15:31:037 pacagrid-azure][SCILAB] Hello World1


       ans(2)

 Job 2877: Task 1_0
[2014-04-15 15:31:037 pacagrid-azure][SCILAB] Hello World2


       ans(3)

 Job 2877: Task 2_0
[2014-04-15 15:31:037 pacagrid-azure][SCILAB] Hello World3


       ans(4)

 Job 2877: Task 3_0
[2014-04-15 15:31:037 pacagrid-azure][SCILAB] Hello World4


       ans(5)

 Job 2877: Task 4_0
[2014-04-15 15:31:044 pacagrid-azure][SCILAB] Hello World5


       ans(6)

 Job 2877: Task 5_0
[2014-04-15 15:31:044 pacagrid-azure][SCILAB] Hello World6


                                        

Hello World function with multiple-parameter :

The function hellow of the previous example had a single parameter, how can we specify multiple parameters function to PAsolve ?
We'll define a function hellow2 which takes two parameters :

-->deff('[z]=hellow2(x,y)','disp(x + '' '' + y);z=%t')

-->hellow2('Hello','World')

 Hello World
 ans  =

  T
                                        

In order to submit this function to PAsolve, we need to wrap the parameters inside a list :

-->job=PAsolve('hellow2',list('Hello','World'))

 Job submitted : 2878
 job  =

(1):
Awaited (J:2878)

-->job
 job  =

Job 2878: Task 0_0
[2014-04-15 15:50:022 pacagrid-azure][SCILAB] Hello World


(1):

  T
                                        

As you can see the list is interpreted by PAsolve as a multiple-parameter call.
If we want to launch execution on several machines, simply add other list parameters to the PAsolve calls :

-->job=PAsolve('hellow2',list('Hello1','World1'),list('Hello2','World2'),list('Hello3','World3'))

 Job submitted : 2879
 job  =

(1):
Awaited (J:2879)
(2):
Awaited (J:2879)
(3):
Awaited (J:2879)

-->job
 job  =

Job 2879: Task 0_0
[2014-04-15 15:56:059 pacagrid-azure][SCILAB] Hello1 World1


Job 2879: Task 1_0
[2014-04-15 15:56:059 pacagrid-azure][SCILAB] Hello2 World2


Job 2879: Task 2_0
[2014-04-15 15:56:059 pacagrid-azure][SCILAB] Hello3 World3


(1):

  T
(2):

  T
(3):

  T
                                        

4 Job with File Transfer


In this chapter, we will demonstrate how to submit simple jobs that use input and output files.

PATask object

We will introduce the PATask object, necessary to use file transfer.
We define for the example a function mycopy which copies a file into another. It uses its parameter to determine the file name :

--> deff('[y]=mycopy(x)','y=copyfile(''in''+string(x)+''.txt'',''out''+string(x)+''.txt'')')
                                        
Check the current directory of your Scilab session by using the command pwd():
--> pwd()
 H:\Users\demo\Downloads\PAConnector
                                        

Create a file in1.txt in this directory. You can put some text content in this file if you want.

We will then create a PATask object of size 1 which contains the definition of the task to submit, including input and output files :

--> t=PATask(1,1);
                                        

We set the function to be computed to 'mycopy'

--> t(1,1).Func = 'mycopy';
                                        

We add the parameter : 1. Parameters are wrapped inside a list in PATask to support both single and multiple parameter functions.

--> t(1,1).Params = list(1);
                                        

We add input and output files. They can be specified as strings, or list of strings for multiple files.

--> t(1,1).InputFiles = 'in1.txt';
--> t(1,1).OutputFiles = 'out1.txt';
                                        

We can now display the content of the task and verify that it corresponds to what we want :

--> t
 t  =

(1,1):
Func: mycopy
Params:

    1.
InputFiles: { [in1.txt (automatic)] }
OutputFiles: { [out1.txt (automatic)] }
Static: false
ThresholdProximity: 0
Compose: false


                                        

We are ready to submit the task t using PAsolve :

--> job = PAsolve(t)

 Job submitted : 2880
 job  =

(1):
Awaited (J:2880)

--> job
 job  =

Job 2880: Task 0_0


(1):

    1.
                                        

No remote execution log will be displayed as the mycopy function does not print anything. The result is simply the result of the command copyfile. If we list the content of the current directory, we can verify that the file out1.txt is now present :

-->listfiles(pwd())
 ans  =

!unloader.sce  !
!              !
!unit_tests    !
!              !
!script        !
!              !
!out1.txt      !         <-- output file
!              !
!macros        !
!              !
!loader.sce    !
!              !
!licence.txt   !
!              !
!lib           !
!              !
!jar           !
!              !
!in1.txt       !
!              !
!help          !
!              !
!etc           !
!              !
!config        !
!              !
!cleaner.sce   !
!              !
!builder.sce   !
!              !
!.PAScheduler  !

                                        

Source Files

In all the examples above, functions defined in-line were automatically transferred to the remote workers.
PAsolve indeed transfers the function variable used as its function argument. This is true both for inline functions or functions defined in a .sci file.
However, PAsolve does not transfer automatically the content of auxiliary functions used by the main function. So if the main function calls other user-defined function, it is neceassary to transfer their definition manually.
To illustrate this, we will define two function fun1 and fun2 in a sci file call myfunctions.sci located in the current directory :

myfunctions.sci :

function y=fun1(x)
    y = fun2(x) * fun2(x)
endfunction

function y=fun2(x)
    y = x*x
endfunction
                                        

We will construct a PATask of size 3 which uses the fun1 and fun2 functions :

-->t=PATask(1,3);
                                        

For all PATasks, we define the function to be fun1 (this syntax allow multiple assignment) :

-->t.Func='fun1';
                                        

We then have to set input parameters :

-->t(1,1).Params = list(1);
-->t(1,2).Params = list(2);
-->t(1,3).Params = list(3);
                                        

Finally we define the source file to be used. Like input files, if we needed several files, we could use a list of strings :

-->t.Sources='myfunctions.sci';
                                        

We can now display the content of the task :

-->t
 t  =

(1,1):
Func: fun1
Params:

    1.
InputFiles: { }
OutputFiles: { }
Static: false
ThresholdProximity: 0
Sources: myfunctions.sci
Compose: false

(1,2):
Func: fun1
Params:

    2.
InputFiles: { }
OutputFiles: { }
Static: false
ThresholdProximity: 0
Sources: myfunctions.sci
Compose: false

(1,3):
Func: fun1
Params:

    3.
InputFiles: { }
OutputFiles: { }
Static: false
ThresholdProximity: 0
Sources: myfunctions.sci
Compose: false
                                        

Before submitting it, it is necessary to load the fun1 and fun2 functions into the scilab memory :

-->exec myfunctions.sci

-->function y=fun1(x)
-->    y = fun2(x) * fun2(x)
-->endfunction


-->function y=fun2(x)
-->    y = x*x
-->endfunction


-->job = PAsolve(t)

 Job submitted : 2881
 job  =

(1):
Awaited (J:2881)
(2):
Awaited (J:2881)
(3):
Awaited (J:2881)

                                        

When printing the results, we see that the fun1 and fun2 functions were correctly used by the remote engines :

-->job
 job  =

Job 2881: Task 0_0


Job 2881: Task 1_0


Job 2881: Task 2_0


(1):

    1.
(2):

    16.
(3):

    81.
                                        

That's all for the tutorial ! You can have more detailed information on the PAconnector features by reading the module's help section.