Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6394


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

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

Location:
branches/MPI
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/MPI/HeuristicLab.ExtLibs/HeuristicLab.MPInet/1.0.0/HeuristicLab.MPInet-1.0.0.csproj

    r6393 r6394  
    168168  </PropertyGroup>
    169169  <PropertyGroup>
    170     <PostBuildEvent>
    171     </PostBuildEvent>
     170    <PostBuildEvent>set ProjectName=$(ProjectName)
     171set Source=$(TargetPath)
     172set Configuration=$(ConfigurationName)
     173set Platform=$(PlatformName)
     174set SolutionDir=$(SolutionDir)
     175
     176if exist "$(SolutionDir)CustomPostBuild.cmd" call "$(SolutionDir)CustomPostBuild.cmd"</PostBuildEvent>
    172177  </PropertyGroup>
    173178</Project>
  • branches/MPI/HeuristicLab.MPIAlgorithmRunner/3.3/AlgorithmBroker.cs

    r6388 r6394  
    3232using HeuristicLab.Core;
    3333using System.Threading;
     34using System.Xml;
    3435                     
    3536namespace HeuristicLab.MPIAlgorithmRunner {
     
    5354      endpoint.Name = "AlgorithmBrokerEndpoint";
    5455      NetTcpBinding netTCPBinding = new NetTcpBinding(SecurityMode.None);
     56      netTCPBinding.MaxReceivedMessageSize = int.MaxValue;
     57      XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
     58      quotas.MaxArrayLength = int.MaxValue;
     59      netTCPBinding.ReaderQuotas = quotas;
    5560      endpoint.Binding = netTCPBinding;
    5661      int port = FindFreeTcpPort();
    5762      endpoint.Address = new EndpointAddress("net.tcp://localhost:" + port + "/AlgorithmBroker");
    5863      service.AddServiceEndpoint(endpoint);
     64      ServiceDebugBehavior debug = service.Description.Behaviors.Find<ServiceDebugBehavior>();
     65      debug.IncludeExceptionDetailInFaults = true;
    5966
    6067      return service;
     
    8592    public void TransmitAlgorithm(MPITransportWrapper<IAlgorithm> algorithm) {
    8693      Console.WriteLine("Transmitting Algorithm...");
    87       int clients = MPI.Communicator.world.Group.Size;
     94      int clients = MPI.Communicator.world.Group.Size - 1;
    8895
    8996      for(int i = 0; i < clients; i++) {
  • branches/MPI/HeuristicLab.MPIAlgorithmRunner/3.3/HeuristicLab.MPIAlgorithmRunner-3.3.csproj

    r6393 r6394  
    129129    <Reference Include="System" />
    130130    <Reference Include="System.Core" />
     131    <Reference Include="System.Runtime.Serialization" />
    131132    <Reference Include="System.ServiceModel" />
    132133    <Reference Include="System.Xml.Linq" />
     
    168169SubWCRev "%25ProjectDir%25\" "%25ProjectDir%25\HeuristicLabMPIAlgorithmRunnerPlugin.cs.frame" "%25ProjectDir%25\HeuristicLabMPIAlgorithmRunnerPlugin.cs"</PreBuildEvent>
    169170  </PropertyGroup>
     171  <PropertyGroup>
     172    <PostBuildEvent>set ProjectName=$(ProjectName)
     173set Source=$(TargetPath)
     174set Configuration=$(ConfigurationName)
     175set Platform=$(PlatformName)
     176set SolutionDir=$(SolutionDir)
     177
     178if exist "$(SolutionDir)CustomPostBuild.cmd" call "$(SolutionDir)CustomPostBuild.cmd"</PostBuildEvent>
     179  </PropertyGroup>
    170180  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    171181       Other similar extension points exist, see Microsoft.Common.targets.
  • branches/MPI/HeuristicLab.MPIAlgorithmRunner/3.3/Program.cs

    r6388 r6394  
    4141
    4242      // Discover the job's context from the environment
    43       String headNodeName = System.Environment.GetEnvironmentVariable("CCP_CLUSTER_NAME");
     43      String headNodeName = System.Environment.GetEnvironmentVariable("CCP_SCHEDULER");
    4444      int jobId = System.Convert.ToInt32(System.Environment.GetEnvironmentVariable("CCP_JOBID"));
     45
     46      Console.WriteLine(jobId + "@" + headNodeName);
    4547
    4648      // Connect to the head node and get the job
     
    6365    static void Main(string[] args) {
    6466      using (new MPI.Environment(ref args)) {
    65         int clients = MPI.Communicator.world.Group.Size;
     67        int clients = MPI.Communicator.world.Group.Size - 1;
     68        Console.WriteLine("Clients: " + clients);
     69
    6670        int updateInterval = 5000;
    6771
  • 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      }
  • branches/MPI/HeuristicLab.Operators.MPISupport/3.3/MPITransportWrapper.cs

    r6354 r6394  
    4949
    5050    protected MPITransportWrapper(SerializationInfo info, StreamingContext context) {
    51       MemoryStream stream = new MemoryStream(info.GetValue("Item", typeof(byte[])) as byte[]);
    52       if (stream != null)
    53         innerItem = XmlParser.Deserialize(stream) as T;
     51      byte[] buffer = info.GetValue("Item", typeof(byte[])) as byte[];
     52      if (buffer != null)
     53        innerItem = XmlParser.Deserialize(new MemoryStream(buffer)) as T;
    5454      else
    5555        innerItem = null;
Note: See TracChangeset for help on using the changeset viewer.