mirror of
https://github.com/samuelncui/acp.git
synced 2026-09-03 22:57:23 +00:00
keep source preparation parallel for linear targets
This commit is contained in:
@@ -64,10 +64,6 @@ func (o *option) check() error {
|
||||
|
||||
o.fromDevice.check()
|
||||
o.toDevice.check()
|
||||
if o.fromDevice.linear || o.toDevice.linear {
|
||||
o.fromDevice.threads = 1
|
||||
o.toDevice.threads = 1
|
||||
}
|
||||
if o.logger == nil {
|
||||
o.logger = logrus.StandardLogger()
|
||||
}
|
||||
|
||||
+47
@@ -51,3 +51,50 @@ func TestComparePath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinearDeviceOnlySerializesItsOwnStage(t *testing.T) {
|
||||
// Cover each directional linear constraint independently.
|
||||
tests := []struct {
|
||||
name string
|
||||
options []Option
|
||||
wantFromThreads int
|
||||
wantToThreads int
|
||||
}{
|
||||
{
|
||||
name: "linear target",
|
||||
options: []Option{
|
||||
SetToDevice(LinearDevice(true)),
|
||||
},
|
||||
wantFromThreads: 8,
|
||||
wantToThreads: 1,
|
||||
},
|
||||
{
|
||||
name: "linear source",
|
||||
options: []Option{
|
||||
SetFromDevice(LinearDevice(true)),
|
||||
},
|
||||
wantFromThreads: 1,
|
||||
wantToThreads: 8,
|
||||
},
|
||||
}
|
||||
|
||||
// Keep the unconstrained side parallel while serializing only the linear stage.
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
option := newOption()
|
||||
for _, apply := range test.options {
|
||||
option = apply(option)
|
||||
}
|
||||
|
||||
if err := option.check(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if option.fromDevice.threads != test.wantFromThreads {
|
||||
t.Fatalf("source threads = %d, want %d", option.fromDevice.threads, test.wantFromThreads)
|
||||
}
|
||||
if option.toDevice.threads != test.wantToThreads {
|
||||
t.Fatalf("target threads = %d, want %d", option.toDevice.threads, test.wantToThreads)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user