@@ -16,48 +16,45 @@ public class MinerRunner : IMinerRunner
16
16
[ Dependency ]
17
17
public IFinalizer Finalizer { get ; set ; }
18
18
19
- [ Dependency ]
20
- public MasterConfigurationModel MasterConfigurationModel { get ; set ; }
21
-
22
19
[ Dependency ]
23
20
public RunConfigurationModel RunConfigurationModel { get ; set ; }
24
21
25
- public void Run ( )
22
+ public void Run ( MasterConfigurationModel configuration )
26
23
{
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 ) ;
29
26
30
27
var i = 0 ;
31
28
foreach ( var instances in solution )
32
29
{
33
30
i ++ ;
34
- var outputPools = GetOutputPools ( instances . Pools ) ;
31
+ var outputPools = GetOutputPools ( configuration . Pools , instances . Pools ) ;
35
32
36
33
if ( outputPools . Count == 0 )
37
34
{
38
35
Console . WriteLine ( @"Instance {0}.{1} does not contain any pool bindings." , RunConfigurationModel . ActiveSolutionConfiguration , i ) ;
39
36
continue ;
40
37
}
41
38
42
- var configArgument = GetConfigurationArgument ( outputPools ) ;
39
+ var configArgument = GetConfigurationArgument ( configuration . PathsConfiguration . ConfigTemplate , outputPools ) ;
43
40
var utilizedHardware = instances . Hardware . Select ( x => new UtilizedHardware
44
41
{
45
- Hardware = MasterConfigurationModel . Hardware . GetValue ( x ) ,
42
+ Hardware = configuration . Hardware . GetValue ( x ) ,
46
43
Profile = workload . GetValue ( x )
47
44
} ) . ToList ( ) ;
48
45
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 ( ) ) ;
52
49
53
50
RunMiner ( $ "{ configArgument } { cpuArgument } { amdArgument } { nvidiaArgument } ") ;
54
51
}
55
52
}
56
53
57
- private List < PrioritizedPoolEntry > GetOutputPools ( IEnumerable < string > pools )
54
+ private static List < PrioritizedPoolEntry > GetOutputPools ( IDictionary < string , PoolEntry > poolConfiguration , IEnumerable < string > pools )
58
55
{
59
56
return pools
60
- . Select ( x => MasterConfigurationModel . Pools . GetValue ( x ) )
57
+ . Select ( poolConfiguration . GetValue )
61
58
. Reverse ( )
62
59
. Select ( ( x , i ) => new PrioritizedPoolEntry
63
60
{
@@ -84,29 +81,29 @@ private static void RunMiner(string arguments)
84
81
Process . Start ( startInfo ) ;
85
82
}
86
83
87
- private string GetConfigurationArgument ( IReadOnlyCollection < PrioritizedPoolEntry > pools )
84
+ private string GetConfigurationArgument ( string configurationTemplatePath , IReadOnlyCollection < PrioritizedPoolEntry > pools )
88
85
{
89
- var configPath = CreateTemporaryConfiguration ( MasterConfigurationModel . PathsConfiguration . ConfigTemplate , "config" , "%POOLS%" , pools ) ;
86
+ var configPath = CreateTemporaryConfiguration ( configurationTemplatePath , "config" , "%POOLS%" , pools ) ;
90
87
ScheduleFileDelete ( configPath ) ;
91
88
92
89
return $ "--config \" { configPath } \" ";
93
90
}
94
91
95
- private string GetCpuArgument ( ICollection < UtilizedHardware > entry )
92
+ private string GetCpuArgument ( string cpuTemplatePath , IDictionary < string , IList < CpuThreadEntry > > cpuConfiguration , ICollection < UtilizedHardware > entry )
96
93
{
97
94
if ( entry . Count == 0 )
98
95
{
99
96
return "--noCPU" ;
100
97
}
101
98
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 ) ;
104
101
ScheduleFileDelete ( path ) ;
105
102
106
103
return $ "--cpu \" { path } \" ";
107
104
}
108
105
109
- private string GetAmdArgument ( ICollection < UtilizedHardware > entry )
106
+ private string GetAmdArgument ( string amdTemplatePath , IDictionary < string , IList < AmdThreadEntry > > amdConfiguration , ICollection < UtilizedHardware > entry )
110
107
{
111
108
if ( entry . Count == 0 )
112
109
{
@@ -116,7 +113,7 @@ private string GetAmdArgument(ICollection<UtilizedHardware> entry)
116
113
var amdProfile = entry
117
114
. SelectMany (
118
115
x =>
119
- MasterConfigurationModel . AmdProfiles . GetValue ( x . Profile )
116
+ amdConfiguration . GetValue ( x . Profile )
120
117
. Select ( profile => new IndexedAmdThreadEntry
121
118
{
122
119
Index = x . Hardware . Index ,
@@ -127,13 +124,13 @@ private string GetAmdArgument(ICollection<UtilizedHardware> entry)
127
124
} ) )
128
125
. ToList ( ) ;
129
126
130
- var path = CreateTemporaryConfiguration ( MasterConfigurationModel . PathsConfiguration . AmdTemplate , "amd" , "%THREADS%" , amdProfile ) ;
127
+ var path = CreateTemporaryConfiguration ( amdTemplatePath , "amd" , "%THREADS%" , amdProfile ) ;
131
128
ScheduleFileDelete ( path ) ;
132
129
133
130
return $ "--amd \" { path } \" ";
134
131
}
135
132
136
- private string GetNvidiaArgument ( ICollection < UtilizedHardware > entry )
133
+ private string GetNvidiaArgument ( string nvidiaTemplatePath , IDictionary < string , IList < NvidiaThreadEntry > > nvidiaConfiguration , ICollection < UtilizedHardware > entry )
137
134
{
138
135
if ( entry . Count == 0 )
139
136
{
@@ -143,7 +140,7 @@ private string GetNvidiaArgument(ICollection<UtilizedHardware> entry)
143
140
var nvidiaProfile = entry
144
141
. SelectMany (
145
142
x =>
146
- MasterConfigurationModel . NvidiaProfiles . GetValue ( x . Profile )
143
+ nvidiaConfiguration . GetValue ( x . Profile )
147
144
. Select ( profile => new IndexedNvidiaThreadEntry
148
145
{
149
146
Index = x . Hardware . Index ,
@@ -156,7 +153,7 @@ private string GetNvidiaArgument(ICollection<UtilizedHardware> entry)
156
153
} ) )
157
154
. ToList ( ) ;
158
155
159
- var path = CreateTemporaryConfiguration ( MasterConfigurationModel . PathsConfiguration . NvidiaTemplate , "nvidia" , "%THREADS%" , nvidiaProfile ) ;
156
+ var path = CreateTemporaryConfiguration ( nvidiaTemplatePath , "nvidia" , "%THREADS%" , nvidiaProfile ) ;
160
157
ScheduleFileDelete ( path ) ;
161
158
162
159
return $ "--nvidia \" { path } \" ";
0 commit comments