Thursday, March 25, 2010

so user threads can take advnatage of multi cores?

(10:28:26) The topic for #cat-v is: A channel for all things cat -v: http://cat-v.org - Glenda Camp, fuck yea! http://iwp9.cat-v.org/glenda-camp-10/ - This Channel is 100% troll. :: Microtrolling live.
(10:28:31) gavino: I am me!
(10:29:01) gavino: so some freebsd guys were saying user threads are only good for certain algorithms and apps that use 1 cpu, not very good for 8 core boxes
(10:29:08) gavino: is that so?
(10:49:06) EthanG: there's a lot of anti-thread FUD about
(10:49:40) EthanG: ways of doing things become beliefs, beliefs resist change. I think that's all it is
(10:50:19) EthanG: learn too many techniques & you lose your flexibility
(10:53:09) __20h__: Learn too many techniques, sort them and get too flexible.
(10:53:53) EthanG: well in some ways yeah... I don't know what's wrong with so many that they have their ways of doing things & won't look at ohters
(10:53:55) EthanG: others
(10:54:34) __20h__: Maybe all developers should physicially work together with their users.
(10:54:36) __20h__: At least some.
(10:54:42) __20h__: That could increase usability.
(10:54:48) EthanG: yeah
(10:54:59) EthanG: eh... I have to go out, wish I didn't
(10:55:21) __20h__: EthanG, don't get hit by flying cats.
(10:55:53) EthanG: well... it's not raining cats & dogs right now. I hope it doesn't start up again
(11:14:30) bvalek2 left the room (quit: Quit: I've seen things you people wouldn't believe).
(11:15:05) gavino: so user threads can take advnatage of multi cores?
(11:18:06) maht1: yes
(11:19:45) maht1: const NCPU = 4 // number of CPU cores
(11:19:45) maht1: func (v Vector) DoAll(u Vector) {
(11:19:45) maht1: c := make(chan int, NCPU) // Buffering optional but sensible.
(11:19:45) maht1: for i := 0; i < NCPU; i++ {
(11:19:45) maht1: go v.DoSome(i*len(v)/NCPU, (i+1)*len(v)/NCPU, u, c)
(11:19:45) maht1: }
(11:19:45) maht1: // Drain the channel.
(11:19:46) maht1: for i := 0; i < NCPU; i++ {
(11:19:47) maht1: <-c // wait for one task to complete
(11:19:47) maht1: }
(11:19:48) maht1: // All done.
(11:19:48) maht1: }
(11:22:34) maht1: see http://golang.org/doc/effective_go.html scroll to parallelization

No comments: