Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/08/11 14:26:36 (14 years ago)
Author:
svonolfe
Message:

Added first working version of the MPI engine (#1542)

Location:
branches/MPI/HeuristicLab.MPIEngine/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/MPI/HeuristicLab.MPIEngine/3.3/HeuristicLab.MPIEngine-3.3.csproj

    r6393 r6394  
    128128      <HintPath>..\..\HeuristicLab.ExtLibs\HeuristicLab.MPInet\MPIAlgorithmRunner\3.3\Microsoft.Hpc.Scheduler.dll</HintPath>
    129129    </Reference>
     130    <Reference Include="Microsoft.Hpc.Scheduler.Properties, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
     131      <HintPath>..\..\Microsoft.Hpc.Scheduler.Properties.dll</HintPath>
     132    </Reference>
    130133    <Reference Include="System" />
    131134    <Reference Include="System.Core" />
     135    <Reference Include="System.Runtime.Serialization" />
    132136    <Reference Include="System.ServiceModel" />
    133137    <Reference Include="System.Xml.Linq" />
  • branches/MPI/HeuristicLab.MPIEngine/3.3/MPIEngine.cs

    r6388 r6394  
    3535using HeuristicLab.MPIAlgorithmRunner;
    3636using HeuristicLab.Operators.MPISupport;
     37using Microsoft.Hpc.Scheduler.Properties;
     38using System.Xml;
    3739
    3840namespace HeuristicLab.MPIEngine {
     
    7476    }
    7577
     78    protected override void OnPaused() {
     79      base.OnPaused();
     80
     81      Stop();
     82    }
     83
    7684    protected override void Run(System.Threading.CancellationToken cancellationToken) {
     85      string username = @"user";
     86      string password = @"password";
     87      string headNode = "blade00.hpc.fh-hagenberg.at";
     88      List<string> requestedNodes = new List<string>();
     89      requestedNodes.Add("BLADE00");
     90      string path = @"C:\public\MPISupport";
     91      int cpuPerNode = 8;
     92
    7793      if (ExecutionStack.Count == 1) {
    7894        ExecutionContext context = ExecutionStack.Pop() as ExecutionContext;
     
    8197
    8298        string exec = @"mpiexec";
    83         string args = @"-c 3 C:\public\MPISupport\HeuristicLab.MPIAlgorithmRunner-3.3.exe ";
     99        string args = @"-c " + cpuPerNode + " /genvlist CCP_JOBID " + path + @"\HeuristicLab.MPIAlgorithmRunner-3.3.exe";
    84100
    85101        IScheduler scheduler = new Scheduler();
    86         scheduler.Connect("blade00.hpc.fh-hagenberg.at");
     102        scheduler.Connect(headNode);
    87103
    88104        ISchedulerJob job = scheduler.CreateJob();
    89105        job.Name = "HeuristicLab.MPIEngine";
    90         job.RequestedNodes.Add("BLADE03");
     106        foreach (string requestedNode in requestedNodes)
     107          job.RequestedNodes.Add(requestedNode);
    91108        ISchedulerTask task = job.CreateTask();
    92109        task.Name = "HeuristicLab.MPIAlgorithmRunner";
     
    94111        task.StdOutFilePath = "stdout.txt";
    95112        task.StdErrFilePath = "stderr.txt";
     113        task.WorkDirectory = path;
    96114        task.MinimumNumberOfCores = task.MaximumNumberOfCores = 3;
    97115        job.AddTask(task);
    98116
    99         scheduler.SubmitJob(job, @"HPC\svonolfe", @"Vunkopf!3");
     117        scheduler.SubmitJob(job, username, "");
    100118
    101119        try {
     
    104122
    105123          while (address == null && timeout > 0) {
     124            cancellationToken.ThrowIfCancellationRequested();
     125
    106126            ISchedulerJob schedulerJob = scheduler.OpenJob(job.Id);
    107127            if (schedulerJob != null) {
    108               INameValueCollection properties = schedulerJob.GetCustomProperties();
    109               NameValue item = properties.FirstOrDefault(i => i.Name == "address");
    110               if (item != null) {
    111                 address = item.Value;
     128              NameValue property = schedulerJob.GetCustomProperties().FirstOrDefault(p => p.Name == "address");
     129
     130              if (property != null) {
     131                address = property.Value;
    112132              } else {
    113133                System.Threading.Thread.Sleep(1000);
    114134                timeout--;
    115135              }
    116             }
     136            }           
    117137          }
    118138
     
    122142
    123143          NetTcpBinding netTCPBinding = new NetTcpBinding(SecurityMode.None);
     144          XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
     145          quotas.MaxArrayLength = int.MaxValue;
     146          netTCPBinding.ReaderQuotas = quotas;
     147          netTCPBinding.MaxReceivedMessageSize = int.MaxValue;
    124148          ChannelFactory<IAlgorithmBroker> factory = new ChannelFactory<IAlgorithmBroker>(netTCPBinding, address);
    125149          IAlgorithmBroker proxy = factory.CreateChannel();
     
    128152
    129153          while (!proxy.IsAlgorithmTerminated()) {
     154            cancellationToken.ThrowIfCancellationRequested();
     155
    130156            ItemList<ResultCollection> results = proxy.GetResults().InnerItem;
    131157
     
    143169        }
    144170        catch (Exception e) {
    145           scheduler.CancelJob(job.Id, "Exception: " + e.Message);
     171          scheduler.CancelJob(job.Id, "Exception: " + e.GetType());
    146172          throw e;
     173        }
     174        finally {
     175           /*ISchedulerJob schedulerJob = scheduler.OpenJob(job.Id);
     176           if (schedulerJob != null &&
     177             (schedulerJob.State == JobState.Running || schedulerJob.State == JobState.Queued)) {
     178               scheduler.CancelJob(job.Id, "Cancelled");           
     179           } */
    147180        }
    148181      }
Note: See TracChangeset for help on using the changeset viewer.