1
0
mirror of https://github.com/golang/go synced 2024-11-24 13:10:11 -07:00

effective_go: provide reference to runtime.NumCPU()

R=golang-dev, robert.hencke, r
CC=golang-dev
https://golang.org/cl/5538050
This commit is contained in:
Dmitriy Vyukov 2012-01-12 22:06:50 +04:00
parent cd54e44b50
commit a03c519a8c
4 changed files with 8 additions and 3 deletions

View File

@ -2623,8 +2623,10 @@ is if you want CPU parallelism you must tell the run-time
how many goroutines you want executing code simultaneously. There how many goroutines you want executing code simultaneously. There
are two related ways to do this. Either run your job with environment are two related ways to do this. Either run your job with environment
variable <code>GOMAXPROCS</code> set to the number of cores to use variable <code>GOMAXPROCS</code> set to the number of cores to use
(default 1); or import the <code>runtime</code> package and call or import the <code>runtime</code> package and call
<code>runtime.GOMAXPROCS(NCPU)</code>. <code>runtime.GOMAXPROCS(NCPU)</code>.
A helpful value might be <code>runtime.NumCPU()</code>, which reports the number
of logical CPUs on the local machine.
Again, this requirement is expected to be retired as the scheduling and run-time improve. Again, this requirement is expected to be retired as the scheduling and run-time improve.
</p> </p>

View File

@ -2560,8 +2560,10 @@ is if you want CPU parallelism you must tell the run-time
how many goroutines you want executing code simultaneously. There how many goroutines you want executing code simultaneously. There
are two related ways to do this. Either run your job with environment are two related ways to do this. Either run your job with environment
variable <code>GOMAXPROCS</code> set to the number of cores to use variable <code>GOMAXPROCS</code> set to the number of cores to use
(default 1); or import the <code>runtime</code> package and call or import the <code>runtime</code> package and call
<code>runtime.GOMAXPROCS(NCPU)</code>. <code>runtime.GOMAXPROCS(NCPU)</code>.
A helpful value might be <code>runtime.NumCPU()</code>, which reports the number
of logical CPUs on the local machine.
Again, this requirement is expected to be retired as the scheduling and run-time improve. Again, this requirement is expected to be retired as the scheduling and run-time improve.
</p> </p>

View File

@ -19,6 +19,7 @@ func UnlockOSThread()
// GOMAXPROCS sets the maximum number of CPUs that can be executing // GOMAXPROCS sets the maximum number of CPUs that can be executing
// simultaneously and returns the previous setting. If n < 1, it does not // simultaneously and returns the previous setting. If n < 1, it does not
// change the current setting. // change the current setting.
// The number of logical CPUs on the local machine can be queried with NumCPU.
// This call will go away when the scheduler improves. // This call will go away when the scheduler improves.
func GOMAXPROCS(n int) int func GOMAXPROCS(n int) int

View File

@ -68,7 +68,7 @@ func funcline_go(*Func, uintptr) (string, int)
// mid returns the current os thread (m) id. // mid returns the current os thread (m) id.
func mid() uint32 func mid() uint32
// NumCPU returns the number of CPUs on the local machine. // NumCPU returns the number of logical CPUs on the local machine.
func NumCPU() int func NumCPU() int
// Semacquire waits until *s > 0 and then atomically decrements it. // Semacquire waits until *s > 0 and then atomically decrements it.