-
-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
654 additions
and
229 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package gorgonia | ||
|
||
import "runtime" | ||
|
||
const ( | ||
// defaultBlockSize indicates the default size to chunk an array. | ||
defaultBlockSize = 64 | ||
|
||
// minParallelBlocks indicates how many blocks an array must be split up into | ||
// before we decide to parallelize | ||
minParallelBlocks = 4 | ||
) | ||
|
||
// workersChan creates a channel that is limited by the number of processor cores. | ||
// To signal that a processor core is being used: | ||
// ch <- struct{}{} | ||
// When done: | ||
// <- ch | ||
func workersChan() chan struct{} { return make(chan struct{}, runtime.GOMAXPROCS(0)) } | ||
|
||
// calcBlocks calculuates the best number of blocks given a blocksize | ||
func calcBlocks(dim, blocksize int) int { return (dim + blocksize - 1) / blocksize } |
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
Oops, something went wrong.