clustermode_luke

PURPOSE ^

SYNOPSIS ^

function [dkecluster] = clustermode_luke(param,fun,dkepath,remnum)

DESCRIPTION ^

 This function provides an interface between LUKE and mdce_clustermode(param,fun)

 INPUTS : 
   - param : parameters for distributed computing
 -> see mdce_clustermode for a detailed list of parameters

   Notes : 
           o if param contains the field 'remnum', it is equivalent to specifying the fourth argument 
           o if param == '', the field clustermode is searched within the structure 'dkepath'

   Different modes can be used for distributed computing

           o (0)           : sequential
           o (1)           : job scheduler (Matlab MDCE required)             (+i enables GPU calculations)
           o (2)           : parfor parallel computing (Matlab MDCE required) (+i enables GPU calculations)
           o (-1, -2, ...) : use of remcomputing with profile #1, #2, ... in structure dkepath

   - fun : function name, used if (fun) is a field of param 
               (case when param contains distributed computing parameters for multiple functions)

   - dkepath : LUKE path structure including remote profiles, and possibly a field clustermode

   - remnum : remote profile index for use of mdce_remote (transfer entire calculation to remote host)

 OUTPUT :
   - dkecluster : structure containing MDCE properties

 by J. Decker (CEA-IRFM) <joan.decker@cea.fr> and Y. Peysson (CEA-IRFM) <yves.peysson@cea.fr>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [dkecluster] = clustermode_luke(param,fun,dkepath,remnum)
0002 %
0003 % This function provides an interface between LUKE and mdce_clustermode(param,fun)
0004 %
0005 % INPUTS :
0006 %   - param : parameters for distributed computing
0007 % -> see mdce_clustermode for a detailed list of parameters
0008 %
0009 %   Notes :
0010 %           o if param contains the field 'remnum', it is equivalent to specifying the fourth argument
0011 %           o if param == '', the field clustermode is searched within the structure 'dkepath'
0012 %
0013 %   Different modes can be used for distributed computing
0014 %
0015 %           o (0)           : sequential
0016 %           o (1)           : job scheduler (Matlab MDCE required)             (+i enables GPU calculations)
0017 %           o (2)           : parfor parallel computing (Matlab MDCE required) (+i enables GPU calculations)
0018 %           o (-1, -2, ...) : use of remcomputing with profile #1, #2, ... in structure dkepath
0019 %
0020 %   - fun : function name, used if (fun) is a field of param
0021 %               (case when param contains distributed computing parameters for multiple functions)
0022 %
0023 %   - dkepath : LUKE path structure including remote profiles, and possibly a field clustermode
0024 %
0025 %   - remnum : remote profile index for use of mdce_remote (transfer entire calculation to remote host)
0026 %
0027 % OUTPUT :
0028 %   - dkecluster : structure containing MDCE properties
0029 %
0030 % by J. Decker (CEA-IRFM) <joan.decker@cea.fr> and Y. Peysson (CEA-IRFM) <yves.peysson@cea.fr>
0031 %
0032 if nargin < 3,
0033     dkepath = load_structures_yp('dkepath','','');
0034 end
0035 if nargin < 2,
0036     fun = '';
0037 end
0038 if nargin < 1,
0039     param = 0;
0040 end
0041 if isempty(param),
0042     if isfield(dkepath,'clustermode')
0043         param = dkepath.clustermode;
0044     else
0045         param = 0;
0046     end
0047 end
0048 %
0049 % manage case where param.(fun) is defined
0050 %
0051 if ~isempty(fun)% when function-specific DC parameters are present
0052     %
0053     if isfield(param,fun),% DC parameters found for the specific function
0054         if isfield(param.(fun),'scheduler') && isfield(param.(fun).scheduler,'mode'),
0055             dkecluster.scheduler = param.(fun).scheduler;
0056         elseif isfield(param.(fun),'batch'),
0057             %not yet implemented
0058             disp('Warning : batch structure not yet implemented')
0059             dkecluster.scheduler.mode = 0;%dkecluster type not recognized, sequential mode enforced
0060         else
0061             disp('Warning : dkecluster type not recognized')
0062             dkecluster.scheduler.mode = 0;%dkecluster type not recognized, sequential mode enforced
0063         end        
0064     else
0065         dkecluster.scheduler.mode = 0;%function not referenced in param, sequential mode enforced
0066     end
0067 elseif ~isstruct(param),
0068     if isscalar(param),
0069         dkecluster.scheduler.mode = param;
0070     else
0071         dkecluster.scheduler.mode = 0;%param type not recognized, sequential mode enforced
0072     end
0073 else
0074     if isfield(param,'mode'),
0075         dkecluster.scheduler = param;
0076     else
0077         disp('Warning : dkecluster type not recognized')
0078         dkecluster.scheduler.mode = 0;%dkecluster type not recognized, sequential mode enforced
0079     end
0080 end
0081 %
0082 % link with dkepath : LUKE paths, local cluster, remote profiles
0083 %
0084 mode = dkecluster.scheduler.mode;
0085 %
0086 if isfield(dkepath,'remote'),
0087     remote = dkepath.remote;
0088 else
0089     remote = [];
0090 end
0091 %
0092 nrem = length(remote);
0093 %
0094 % distributed computing mode
0095 %
0096 if ~any(mode == -nrem:3),
0097     disp('Warning : invalid cluster mode')
0098     dkecluster.scheduler.mode = 0;%dkecluster type not recognized, sequential mode enforced
0099 elseif any(mode == -nrem:-1),
0100     %
0101     if ~isfield(remote(-mode),'env') || ~isfield(remote(-mode).env,'luke_root'),
0102         disp(['Warning : luke_root not specified in dkepath.remote(',num2str(-mode),'). Switching to sequential mode'])
0103         dkecluster.scheduler.mode = 0;%sequential mode enforced
0104     else
0105         dkecluster.scheduler.mode = remote(-mode);
0106         dkecluster.scheduler.remnum = -mode*i;
0107     end
0108 end
0109 %
0110 % possible use of mdce_remote
0111 %
0112 if nargin < 4,
0113     if isfield(dkecluster.scheduler,'remnum'),
0114         remnum = dkecluster.scheduler.remnum;
0115     else
0116         remnum = 0;
0117     end
0118 end
0119 if ~iscell(remnum),
0120     remnum = {remnum};
0121 end
0122 if remnum{1} > 0,
0123     for irem = 1:length(remnum),
0124         if any(remnum{irem} == 1:nrem),
0125             dkecluster.scheduler.remote{irem} = remote(remnum{irem});
0126             if irem == length(remnum) && mode >= 0,% in this case remote{irem} must have LUKE paths
0127                 if ~isfield(remote(remnum{irem}),'env') || ~isfield(remote(remnum{irem}).env,'luke_root'),
0128                     disp(['Warning : luke_root not specified in dkepath.remote(',remnum{irem},'). Switching to sequential mode'])
0129                     dkecluster.scheduler.mode = 0;%sequential mode enforced
0130                     dkecluster.scheduler.remote = [];                    
0131                 end
0132             end
0133         else
0134             disp('Warning : invalid mdce_remote mode')
0135             dkecluster.scheduler.remote = [];
0136             break
0137         end
0138     end
0139 end
0140 %
0141 [dkecluster] = mdce_clustermode(dkecluster.scheduler);
0142 %

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.