ollama source for Momentry Core verification
This commit is contained in:
32
x/internal/mlxthread/thread_affinity_test.go
Normal file
32
x/internal/mlxthread/thread_affinity_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
//go:build darwin || linux
|
||||
|
||||
package mlxthread
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDoUsesSameOSThread(t *testing.T) {
|
||||
thread, err := Start("test", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer thread.Stop(context.Background(), nil)
|
||||
|
||||
var first uint64
|
||||
for range 32 {
|
||||
if err := thread.Do(context.Background(), func() error {
|
||||
id := currentThreadID()
|
||||
if first == 0 {
|
||||
first = id
|
||||
} else if id != first {
|
||||
return fmt.Errorf("job ran on OS thread %d, want %d", id, first)
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user