- Timestamp:
- 06/08/11 11:07:33 (13 years ago)
- Location:
- branches/MPI/HeuristicLab.ExtLibs/HeuristicLab.MPInet/MPIAlgorithmRunner/3.3
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MPI/HeuristicLab.ExtLibs/HeuristicLab.MPInet/MPIAlgorithmRunner/3.3/HeuristicLab.MPIAlgorithmRunner-3.3.csproj
r6354 r6388 103 103 </PropertyGroup> 104 104 <ItemGroup> 105 <Reference Include="Microsoft.Hpc.Scheduler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> 106 <HintPath>Microsoft.Hpc.Scheduler.dll</HintPath> 107 </Reference> 105 108 <Reference Include="MPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=29b4a045737654fe, processorArchitecture=MSIL"> 106 109 <HintPath>..\HeuristicLab.ExtLibs\HeuristicLab.MPInet\1.0.0\MPI.dll</HintPath> … … 108 111 <Reference Include="System" /> 109 112 <Reference Include="System.Core" /> 113 <Reference Include="System.ServiceModel" /> 110 114 <Reference Include="System.Xml.Linq" /> 111 115 <Reference Include="System.Data.DataSetExtensions" /> … … 115 119 </ItemGroup> 116 120 <ItemGroup> 121 <Compile Include="AlgorithmBroker.cs" /> 117 122 <Compile Include="HeuristicLabMPIAlgorithmRunnerPlugin.cs" /> 123 <Compile Include="IAlgorithmBroker.cs" /> 118 124 <Compile Include="Program.cs" /> 119 125 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/MPI/HeuristicLab.ExtLibs/HeuristicLab.MPInet/MPIAlgorithmRunner/3.3/HeuristicLabMPIAlgorithmRunnerPlugin.cs.frame
r6354 r6388 28 28 [Plugin("HeuristicLab.MPIAlgorithmRunner", "3.3.4.$WCREV$")] 29 29 [PluginFile("HeuristicLab.MPIAlgorithmRunner-3.3.exe", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.Collections", "3.3")] 30 31 [PluginDependency("HeuristicLab.Common", "3.3")] 31 32 [PluginDependency("HeuristicLab.Core", "3.3")] 32 [PluginDependency("HeuristicLab.Collections", "3.3")]33 33 [PluginDependency("HeuristicLab.MPInet", "1.0.0")] 34 [PluginDependency("HeuristicLab.Operators.MPISupport", "3.3")] 34 35 [PluginDependency("HeuristicLab.Optimization", "3.3")] 35 36 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
branches/MPI/HeuristicLab.ExtLibs/HeuristicLab.MPInet/MPIAlgorithmRunner/3.3/Program.cs
r6354 r6388 29 29 using HeuristicLab.Operators.MPISupport; 30 30 using HeuristicLab.Core; 31 using Microsoft.Hpc.Scheduler; 32 using System.ServiceModel; 33 using System.Net; 31 34 32 35 namespace HeuristicLab.MPIAlgorithmRunner { … … 34 37 EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); 35 38 39 private static void SetJobStatus(string address) { 40 Console.WriteLine("Started service... at " + address); 41 42 // Discover the job's context from the environment 43 String headNodeName = System.Environment.GetEnvironmentVariable("CCP_CLUSTER_NAME"); 44 int jobId = System.Convert.ToInt32(System.Environment.GetEnvironmentVariable("CCP_JOBID")); 45 46 // Connect to the head node and get the job 47 IScheduler scheduler = new Scheduler(); 48 scheduler.Connect(headNodeName); 49 ISchedulerJob job = scheduler.OpenJob(jobId); 50 51 job.SetCustomProperty("address", address); 52 53 job.Commit(); 54 } 55 56 private static string GetAddress(ServiceHost service) { 57 IPHostEntry IPHost = Dns.GetHostByName(Dns.GetHostName()); 58 string address = "net.tcp://" + IPHost.AddressList[0].ToString() + ":" + service.ChannelDispatchers[0].Listener.Uri.Port + "/AlgorithmBroker"; 59 60 return address; 61 } 62 36 63 static void Main(string[] args) { 37 if (args.Length != 3) { 38 Console.WriteLine("Args:" + args.Length); 64 using (new MPI.Environment(ref args)) { 65 int clients = MPI.Communicator.world.Group.Size; 66 int updateInterval = 5000; 39 67 40 throw new ArgumentException("You must provide 3 arguments - the algorithm file, the result file and the update interval (in ms)");41 }42 43 string fileName = args[0];44 string resultName = args[1];45 int updateInterval = int.Parse(args[2]);46 47 using (new MPI.Environment(ref args)) {48 68 MPI.Communicator communicator = MPI.Communicator.world.Clone() as MPI.Communicator; 49 69 50 70 if (communicator.Rank == 0) { 51 IAlgorithm alg = XmlParser.Deserialize<IAlgorithm>(fileName);52 MPITransportWrapper<IAlgorithm> transport = new MPITransportWrapper<IAlgorithm>(alg);71 ServiceHost service = AlgorithmBroker.StartService(communicator); 72 AlgorithmBroker broker = (service.SingletonInstance as AlgorithmBroker); 53 73 54 int clients = communicator.Size - 1; 55 Console.WriteLine("Sending alg to " + clients + " clients"); 56 for (int i = 0; i < clients; i++) { 57 int client = i + 1; 58 communicator.Send(transport, client, 0); 59 } 74 string address = GetAddress(service); 75 SetJobStatus(address); 60 76 61 77 ItemList<ResultCollection> results = new ItemList<ResultCollection>(); … … 87 103 88 104 Console.WriteLine("Update results"); 89 lock (resultName) { 90 XmlGenerator.Serialize(results, resultName); 91 } 105 broker.Results = results; 92 106 } 93 107 108 lock (broker.ExitWaitHandle) { 109 broker.Terminated = true; 110 } 111 112 broker.ExitWaitHandle.WaitOne(); 94 113 Console.WriteLine("Finished."); 114 service.Close(); 95 115 } else { 96 116 Program p = new Program();
Note: See TracChangeset
for help on using the changeset viewer.