-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from spacemeshos/130-opencl-integration
OpenCL initialization integration
- Loading branch information
Showing
27 changed files
with
765 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package initialization | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/spacemeshos/post/internal/postrs" | ||
) | ||
|
||
// Benchmark returns the hashes per second the selected compute provider achieves on the current machine. | ||
func Benchmark(p ComputeProvider) (int, error) { | ||
endPosition := uint64(1 << 14) | ||
if p.DeviceType == postrs.ClassCPU { | ||
endPosition = uint64(1 << 12) | ||
} | ||
|
||
start := time.Now() | ||
_, err := postrs.ScryptPositions( | ||
postrs.WithProviderID(p.ID), | ||
postrs.WithCommitment(make([]byte, 32)), | ||
postrs.WithStartAndEndPosition(1, endPosition), | ||
postrs.WithScryptN(8192), | ||
) | ||
elapsed := time.Since(start) | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
hashesPerSecond := float64(endPosition) / elapsed.Seconds() | ||
return int(hashesPerSecond), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package initialization | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBenchmark(t *testing.T) { | ||
providers, err := OpenCLProviders() | ||
require.NoError(t, err) | ||
|
||
for _, p := range providers { | ||
hashes, err := Benchmark(p) | ||
require.NoError(t, err) | ||
require.Greater(t, hashes, 0) | ||
} | ||
} |
Oops, something went wrong.