Skip to content

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

Merged
owulveryck merged 1 commit intogorgonia:masterfrom
chrmang:fix-concurrent-example
Feb 11, 2021
Merged

fix(concurrent example): process partial filled chunks too#472
owulveryck merged 1 commit intogorgonia:masterfrom
chrmang:fix-concurrent-example

Conversation

@chrmang
Copy link
Copy Markdown
Contributor

@chrmang chrmang commented Feb 10, 2021

No description provided.

}

func concurrentTraining(xV, yV Value, bs []batch, es int) {
threads := runtime.GOMAXPROCS(-1) // reserve one thread for the CPU locked thread
Copy link
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch !

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
Copy Markdown
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.

3 participants