@@ -16,48 +16,45 @@ public class MinerRunner : IMinerRunner
1616 [ Dependency ]
1717 public IFinalizer Finalizer { get ; set ; }
1818
19- [ Dependency ]
20- public MasterConfigurationModel MasterConfigurationModel { get ; set ; }
21-
2219 [ Dependency ]
2320 public RunConfigurationModel RunConfigurationModel { get ; set ; }
2421
25- public void Run ( )
22+ public void Run ( MasterConfigurationModel configuration )
2623 {
27- var solution = MasterConfigurationModel . SolutionProfiles . GetValue ( RunConfigurationModel . ActiveSolutionConfiguration ) ;
28- var workload = MasterConfigurationModel . WorkloadProfiles . GetValue ( RunConfigurationModel . ActiveWorkloadConfiguration ) ;
24+ var solution = configuration . SolutionProfiles . GetValue ( RunConfigurationModel . ActiveSolutionConfiguration ) ;
25+ var workload = configuration . WorkloadProfiles . GetValue ( RunConfigurationModel . ActiveWorkloadConfiguration ) ;
2926
3027 var i = 0 ;
3128 foreach ( var instances in solution )
3229 {
3330 i ++ ;
34- var outputPools = GetOutputPools ( instances . Pools ) ;
31+ var outputPools = GetOutputPools ( configuration . Pools , instances . Pools ) ;
3532
3633 if ( outputPools . Count == 0 )
3734 {
3835 Console . WriteLine ( @"Instance {0}.{1} does not contain any pool bindings." , RunConfigurationModel . ActiveSolutionConfiguration , i ) ;
3936 continue ;
4037 }
4138
42- var configArgument = GetConfigurationArgument ( outputPools ) ;
39+ var configArgument = GetConfigurationArgument ( configuration . PathsConfiguration . ConfigTemplate , outputPools ) ;
4340 var utilizedHardware = instances . Hardware . Select ( x => new UtilizedHardware
4441 {
45- Hardware = MasterConfigurationModel . Hardware . GetValue ( x ) ,
42+ Hardware = configuration . Hardware . GetValue ( x ) ,
4643 Profile = workload . GetValue ( x )
4744 } ) . ToList ( ) ;
4845
49- var cpuArgument = GetCpuArgument ( utilizedHardware . Where ( x => x . Hardware . Type == "cpu" ) . ToList ( ) ) ;
50- var amdArgument = GetAmdArgument ( utilizedHardware . Where ( x => x . Hardware . Type == "amd" ) . ToList ( ) ) ;
51- var nvidiaArgument = GetNvidiaArgument ( utilizedHardware . Where ( x => x . Hardware . Type == "nvidia" ) . ToList ( ) ) ;
46+ var cpuArgument = GetCpuArgument ( configuration . PathsConfiguration . CpuTemplate , configuration . CpuProfiles , utilizedHardware . Where ( x => x . Hardware . Type == "cpu" ) . ToList ( ) ) ;
47+ var amdArgument = GetAmdArgument ( configuration . PathsConfiguration . AmdTemplate , configuration . AmdProfiles , utilizedHardware . Where ( x => x . Hardware . Type == "amd" ) . ToList ( ) ) ;
48+ var nvidiaArgument = GetNvidiaArgument ( configuration . PathsConfiguration . NvidiaTemplate , configuration . NvidiaProfiles , utilizedHardware . Where ( x => x . Hardware . Type == "nvidia" ) . ToList ( ) ) ;
5249
5350 RunMiner ( $ "{ configArgument } { cpuArgument } { amdArgument } { nvidiaArgument } ") ;
5451 }
5552 }
5653
57- private List < PrioritizedPoolEntry > GetOutputPools ( IEnumerable < string > pools )
54+ private static List < PrioritizedPoolEntry > GetOutputPools ( IDictionary < string , PoolEntry > poolConfiguration , IEnumerable < string > pools )
5855 {
5956 return pools
60- . Select ( x => MasterConfigurationModel . Pools . GetValue ( x ) )
57+ . Select ( poolConfiguration . GetValue )
6158 . Reverse ( )
6259 . Select ( ( x , i ) => new PrioritizedPoolEntry
6360 {
@@ -84,29 +81,29 @@ private static void RunMiner(string arguments)
8481 Process . Start ( startInfo ) ;
8582 }
8683
87- private string GetConfigurationArgument ( IReadOnlyCollection < PrioritizedPoolEntry > pools )
84+ private string GetConfigurationArgument ( string configurationTemplatePath , IReadOnlyCollection < PrioritizedPoolEntry > pools )
8885 {
89- var configPath = CreateTemporaryConfiguration ( MasterConfigurationModel . PathsConfiguration . ConfigTemplate , "config" , "%POOLS%" , pools ) ;
86+ var configPath = CreateTemporaryConfiguration ( configurationTemplatePath , "config" , "%POOLS%" , pools ) ;
9087 ScheduleFileDelete ( configPath ) ;
9188
9289 return $ "--config \" { configPath } \" ";
9390 }
9491
95- private string GetCpuArgument ( ICollection < UtilizedHardware > entry )
92+ private string GetCpuArgument ( string cpuTemplatePath , IDictionary < string , IList < CpuThreadEntry > > cpuConfiguration , ICollection < UtilizedHardware > entry )
9693 {
9794 if ( entry . Count == 0 )
9895 {
9996 return "--noCPU" ;
10097 }
10198
102- var cpuProfile = entry . SelectMany ( x => MasterConfigurationModel . CpuProfiles . GetValue ( x . Profile ) ) . ToList ( ) ;
103- var path = CreateTemporaryConfiguration ( MasterConfigurationModel . PathsConfiguration . CpuTemplate , "cpu" , "%THREADS%" , cpuProfile ) ;
99+ var cpuProfile = entry . SelectMany ( x => cpuConfiguration . GetValue ( x . Profile ) ) . ToList ( ) ;
100+ var path = CreateTemporaryConfiguration ( cpuTemplatePath , "cpu" , "%THREADS%" , cpuProfile ) ;
104101 ScheduleFileDelete ( path ) ;
105102
106103 return $ "--cpu \" { path } \" ";
107104 }
108105
109- private string GetAmdArgument ( ICollection < UtilizedHardware > entry )
106+ private string GetAmdArgument ( string amdTemplatePath , IDictionary < string , IList < AmdThreadEntry > > amdConfiguration , ICollection < UtilizedHardware > entry )
110107 {
111108 if ( entry . Count == 0 )
112109 {
@@ -116,7 +113,7 @@ private string GetAmdArgument(ICollection<UtilizedHardware> entry)
116113 var amdProfile = entry
117114 . SelectMany (
118115 x =>
119- MasterConfigurationModel . AmdProfiles . GetValue ( x . Profile )
116+ amdConfiguration . GetValue ( x . Profile )
120117 . Select ( profile => new IndexedAmdThreadEntry
121118 {
122119 Index = x . Hardware . Index ,
@@ -127,13 +124,13 @@ private string GetAmdArgument(ICollection<UtilizedHardware> entry)
127124 } ) )
128125 . ToList ( ) ;
129126
130- var path = CreateTemporaryConfiguration ( MasterConfigurationModel . PathsConfiguration . AmdTemplate , "amd" , "%THREADS%" , amdProfile ) ;
127+ var path = CreateTemporaryConfiguration ( amdTemplatePath , "amd" , "%THREADS%" , amdProfile ) ;
131128 ScheduleFileDelete ( path ) ;
132129
133130 return $ "--amd \" { path } \" ";
134131 }
135132
136- private string GetNvidiaArgument ( ICollection < UtilizedHardware > entry )
133+ private string GetNvidiaArgument ( string nvidiaTemplatePath , IDictionary < string , IList < NvidiaThreadEntry > > nvidiaConfiguration , ICollection < UtilizedHardware > entry )
137134 {
138135 if ( entry . Count == 0 )
139136 {
@@ -143,7 +140,7 @@ private string GetNvidiaArgument(ICollection<UtilizedHardware> entry)
143140 var nvidiaProfile = entry
144141 . SelectMany (
145142 x =>
146- MasterConfigurationModel . NvidiaProfiles . GetValue ( x . Profile )
143+ nvidiaConfiguration . GetValue ( x . Profile )
147144 . Select ( profile => new IndexedNvidiaThreadEntry
148145 {
149146 Index = x . Hardware . Index ,
@@ -156,7 +153,7 @@ private string GetNvidiaArgument(ICollection<UtilizedHardware> entry)
156153 } ) )
157154 . ToList ( ) ;
158155
159- var path = CreateTemporaryConfiguration ( MasterConfigurationModel . PathsConfiguration . NvidiaTemplate , "nvidia" , "%THREADS%" , nvidiaProfile ) ;
156+ var path = CreateTemporaryConfiguration ( nvidiaTemplatePath , "nvidia" , "%THREADS%" , nvidiaProfile ) ;
160157 ScheduleFileDelete ( path ) ;
161158
162159 return $ "--nvidia \" { path } \" ";
0 commit comments