Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(concurrent example): process partial filled chunks too #472

Merged
merged 1 commit into from
Feb 11, 2021
Merged

fix(concurrent example): process partial filled chunks too #472

merged 1 commit into from
Feb 11, 2021

Conversation

chrmang
Copy link
Contributor

@chrmang chrmang commented Feb 10, 2021

No description provided.

@@ -149,7 +149,7 @@ func prep() (x, y Value, bs []batch) {
}

func concurrentTraining(xV, yV Value, bs []batch, es int) {
threads := runtime.GOMAXPROCS(-1) // reserve one thread for the CPU locked thread
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment was misleading. -1 doesn't change the current setting of max cpus.
https://golang.org/pkg/runtime/#GOMAXPROCS says, this call will go away, when scheduler improves, so I switched to NumCPU()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch !

@@ -80,7 +80,7 @@ func (t *concurrentTrainer) train(x, y Value, costChan chan cost, wg *sync.WaitG
func trainEpoch(bs []batch, ts []*concurrentTrainer, threads int) {
// costs := make([]float64, 0, len(bs))
chunks := len(bs) / len(ts)
for chunk := 0; chunk < chunks; chunk++ {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a integer division. Due to the remainder we need a '<='.

@owulveryck owulveryck merged commit c8283ea into gorgonia:master Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants