View Full Version : Multicore CPU question for the IT types
ManDownUnder
17th October 2007, 16:44
I'm coding an app that is going to do some heavy maths. Nothing complex - just lots of it.. again and again and again and... you get the idea.
Now I have the option of getting a box with a multi-core CPU or a faster single core CPU for a given price.
Dumb arse questions...
1) Do I need to do anything in the code (VB6... yes yes ys... old...!) to take advantage of multicore
2) Assuming multicore advantages can be gleaned, what's the speed boost? Is it 2x (i.e. 2 cores both processing) or is there something more I need to know?
Ta.
jrandom
17th October 2007, 16:57
Your app will not take any advantage of multiple processors (whether a 'multi core' CPU or actual multiple CPUs) unless it is written to be multithreaded.
I'm guessing that it currently isn't. :)
Writing a math program to compute results in parallel and thereby take advantage of multiple CPUs, regardless of the simplicity of the computations involved, is a non-trivial job. If you're keen to learn how, say the word and I can give you an hour or two in front of a whiteboard that should start you down the right path.
It's good fun.
twinkle
17th October 2007, 16:58
1) I don't know about VB6, but I would expect you will have to start muliple threads to get any benefit multiple cpu's. Can you get hold of a multiple core machine to experiment on? Then you would know for sure.
2) the speed boost will not be 2x, there is an overhead cost to get multiple cpu's working together. Maybe 1.7x or thereabouts?
The Stranger
17th October 2007, 17:09
I'm coding an app that is going to do some heavy maths. Nothing complex - just lots of it.. again and again and again and... you get the idea.
Now I have the option of getting a box with a multi-core CPU or a faster single core CPU for a given price.
Dumb arse questions...
1) Do I need to do anything in the code (VB6... yes yes ys... old...!) to take advantage of multicore
2) Assuming multicore advantages can be gleaned, what's the speed boost? Is it 2x (i.e. 2 cores both processing) or is there something more I need to know?
Ta.
You will only run a single thread on a single core i.e. unless you pass the computational stuff out to another thread there would be no direct benefit to your app having a second CPU (or core).
What would your app be doing whilst the computational stuff is running? If the answer is waiting then again, why put it into a second thread, the original one would just wait anyway.
Unless you are familiar with multi threading they can add a lot of complexity, that said, like anything there are some tricks.
If however your calcs can be split and/or the application has other work it can continue with whilst the calcs are being run it may be worth the extra complexity.
Personally I would however tend toward the multi core CPU anyway. This allows the OS and it's services etc to use one core whilst you utilise the second. The OS will automatically take care of this for you.
Architecture would play a huge part in any speed gain that a straight answer would be impossible with the info you have given, however no way would get half.
Best results would be gained from experimenting and optimising the calc - you would be surprised at the tricks that can save time in a loop or repetitive calc.
Next best may be to research the math co-processor and choose the CPU with the quickest math processor.
jrandom
17th October 2007, 17:29
... choose the CPU with the quickest math processor.
... unless he's doing integer arithmetic.
One way or t'other, his problem is bound to be parallelisable via the 'parcel assignment' paradigm, with multiple threads each working on a segment of the input range. It's easy to see that applying that approach to a long computation on a dual-core computer will halve running time. It's worth implementing the program that way if possible.
Sanx
17th October 2007, 19:34
The ten commandments of VB6:
1) Any programs thou shalt write shalt be have one thread and only one thread.
2) ... 10) Don't matter.
If it's in VB6, you cannot take advantage of multiple threads. Therefore, the best option is a fast single-core CPU. Though as someone else pointed out, multi-core will give you guaranteed CPU time for the operating system to take advantage of.
pzkpfw
17th October 2007, 20:11
I hear the cool kids are using their GPU's to do some of their maths - the video people are even helping: http://arstechnica.com/news.ars/post/20070219-8878.html
VB6?
Download C# Express.
Now.
jrandom
17th October 2007, 20:26
The ten commandments of VB6:
1) Any programs thou shalt write shalt be have one thread and only one thread.
Today's refutation of Sanx's assertion is brought to you by the VB6 'AddressOf' operator and the Windows API 'CreateThread' function.
;)
Personally, I never use VB unless I absolutely have to. VB.NET addresses a lot of the shortcomings of VB6, though; perhaps MDU might like to upgrade his development environment and learn the new class hierarchy?
riffer
17th October 2007, 20:38
How did you find the transition from VB to VB.net Dan?
We're currently still using VB6 at work.
xwhatsit
17th October 2007, 20:46
As above, does VB6 even support threads? I wasn't aware it'd changed much since Microsoft BASIC 1.0 on the Apple II...
Learn C, or at least C++, then you can do some real work. You don't use vicegrips to tighten your cylinder head bolts, and neither should you use silly toys for coding anything non-trivial. If it's so CPU-bound, you'll probably want something low-level like C so you can perform some basic optimisation (and use a compiler that makes nice assembly), I would doubt the VB6 `compiler' is any good (or is it just a glorified interpreter like .NET/Java? Yes I know about JIT, but still...).
Yes you'll need to learn threading. Welcome to the world of locks and race conditions. It can be a brain-fuck, but that's why I went to university (not the University of Life, see other thread :lol:).
Get multicore anyway -- that's where consumer stuff is moving to anyway, so you'll be a little more future-proof. There's a lot of work going on right now to re-write stuff to take advantage of multiple cores.
ManDownUnder
17th October 2007, 20:50
Cheers you guys. Dan, Noel - FYI I'm a hack at programming so learning new hierarchies etc in .NET might be something to do in time, but fiurst I simply have a ton of numbers to download and anal-ize.
Looks like I'm gettin' me a high speed single threaded CPU. I could parallel process in the future - y'know - getting another box and sitting it next to the first one :niceone:
Thanks all.
Seriously though. Yes to .NET when I'm done doing this maybe... but that's a wee way away. This tool does the job, I know it well enough to do what I want so I'll stick with it rather than change mid project.
jrandom
17th October 2007, 20:54
How did you find the transition from VB to VB.net Dan?
We're currently still using VB6 at work.
I've never done a .NET project. Been through the required tinkering with the .NET class hierarchy, realised that Hejlsberg essentially just recreated the Borland VCL, etc, but never had cause to use the .NET framework in an actual commercial endeavour.
My last major software project (acoustic testing system) used a VB6 framework with the guts implemented in C++ and embodied in ActiveX controls, and I'm currently using non-.NET C++ to write COM classes extending a large commercial software product.
I did consider porting the aforementioned acoustic testing system to .NET, but cost/benefit never looked worthwhile. Although I'm afraid I must admit that by the time I left that company, development on the system had essentially plateaued, and I was on the verge of having to justify my salary with pseudo-commercial bullshit around the Big .NET Port (tm) being a crucial R&D investment. ;)
I've always strongly suspected that money gets burned that way more often than many CEOs and boards realise...
jrandom
17th October 2007, 20:57
As above, does VB6 even support threads?
Yes. Perhaps I was too oblique before. You can take the address of VB6 functions via 'AddressOf' and feed that into the Windows multithreading API to write threaded applications.
Basically it involves a lot of bullshit and verbiage in the code to make it do what you should have been using C++ for in the first place, but it's entirely possible and works just fine.
Street Gerbil
17th October 2007, 21:12
If you are doing heavy math, stay away from OOP. VB6 is about as unsuitable for math apps as say SQL or LISP.
The best language that gives you benefits of parallel CPUs is C (C++ is easier to code but the overhead is too big and the way I see it you need all the performance you can lay your hands on), but *IF* and only if you can change the algorithm to benefit from parallelism (usually some tricky math involved) and you have balls to deal with the troubleshooting. (I've spent some time debugging some code written in ParC back at school and it was a nightmare).
If calculations are really heavy the best approach is a distributed seti@home style application.
Just my NZ$0.02
jrandom
17th October 2007, 21:21
The best language that gives you benefits of parallel CPUs is C (C++ is easier to code but the overhead is too big...
How do you think using C++ would slow down a mathematical computation program?
Street Gerbil
17th October 2007, 21:29
How do you think using C++ would slow down a mathematical computation program?
Hmmmm.... Object construction/destruction? Dynamic binding?... OOP is nice to have but expensive in terms of CPU usage.
xwhatsit
17th October 2007, 21:38
C++ (at least in the old days) was basically pre-processed into C anyway. I don't think any more, at least with GCC.
But C is as close to the bones as you'll get these days without resorting to assembly, which few people use any more, and a VB6 programmer will likely lack the required skills to deal with that. C's quite easy to use, especially if you're brought up doing manual garbage collection.
Zapf
17th October 2007, 21:40
And someone will tell you that different CPU's perform differently with integer, floating point calculations. Also more Ghz's doesn't = better performance.
limbimtimwim
17th October 2007, 22:02
Cheers you guys. Dan, Noel - FYI I'm a hack at programming so learning new hierarchies etc in .NET might be something to do in time, but fiurst I simply have a ton of numbers to download and anal-ize.Go on, go nuts and write your code to use the vector unit on your CPU.
http://ds9a.nl/gcc-simd/example.html
Actually I have no clue of how well the VB optimizer is, and not much more about GCC's, so I'll leave this thread now.
xwhatsit
17th October 2007, 22:41
Go on, go nuts and write your code to use the vector unit on your CPU.
http://ds9a.nl/gcc-simd/example.html
Actually I have no clue of how well the VB optimizer is, and not much more about GCC's, so I'll leave this thread now.
The link you posted is about GCC, you silly man :lol: Interesting stuff in that link -- at uni we played with some vector floating point stuff in assembly (Alpha! Wo0o0o0), but not on x86 with C yet.
It's worth asking here while we're at it -- Mr Original Poster, do you want to do integer or float number crunching?
Gremlin
17th October 2007, 22:41
bloody geeks :Pokey:
unless you're an actual programmer... multi-threading don't happen overnight. It did my head in for days (I am not a programmer... but the boss beat me into coding a data processing app) until I gave up, and left it as a single thread. I needed to refer to the other thread, and the simple beginnings of how to do it left me contemplating a long jump off a short pier.
On the other hand... just how essential is this program? How much will it do, etc, ie, if you are going to use the computer for other stuff, and the program isn't that big, meh, I would just get multi-core...
limbimtimwim
18th October 2007, 05:11
The link you posted is about GCC, you silly man :lol: Interesting stuff in that link -- at uni we played with some vector floating point stuff in assembly (Alpha! Wo0o0o0), but not on x86 with C yet.I was meaning that I had no clue if the VB optimizer was clever enough to spot what you were up to and use it automatically in some magical way. It seems to me that (not unexpectedly!) one has to structure things in a certain way to take advantage of the vector unit in ones CPU.
It also lets one process several chunks of information at a time (4?) which may or may not help MDU. Without resorting to multi-threading.
Anyway, I shouldn't really talk, in this sort of thing I am an armchair expert, I've not done anything with it ever.
Street Gerbil
18th October 2007, 08:33
Just out of curiosity: what kind of data and what kind of crunching are we talking about?
ManDownUnder
18th October 2007, 09:29
Just out of curiosity: what kind of data and what kind of crunching are we talking about?
Currency price movement analysis and modelling... correlations and a shiteload of "what if" scenarios
avgas
18th October 2007, 09:36
Today's refutation of Sanx's assertion is brought to you by the VB6 'AddressOf' operator and the Windows API 'CreateThread'
Black magic i tell ya...
I'm paranoid of using API's these days after being blatantly shafted my microsoft after the whole serial api nonsense.
A little warning about API's changing would be nice in this day and age.
RantyDave
18th October 2007, 10:38
Any programs thou shalt write shalt be have one thread and only one thread.
This is not to say that you can't make use of a multicore box, however. If you can break the workload into discrete parcels there's no reason why you can't spawn another entire application to crunch the data. It's easy too - no pissing around with locks and stuff. Also, if the load can be split into independent lumps then going this way with a multicore box will give you a much bigger speedup than just trying to shove more cycles into a single core.
Seriously upping performance would almost certainly be a question of writing something in C++. I imagine you'd get something along the lines of 10x and more if you get to use SIMD into the deal.
Dave
RantyDave
18th October 2007, 10:39
Currency price movement analysis and modelling... correlations and a shiteload of "what if" scenarios
There are probably libraries around for that sort of thing - have you had a look?
Dave
Finn
18th October 2007, 11:16
It's good fun.
But does it help you get laid?
imdying
18th October 2007, 11:19
But does it help you get laid?Sure does... I've never met a software developer that didn't earn enough to pay for pussy :laugh:
jrandom
18th October 2007, 11:21
But does it help you get laid?
Indirectly, yes.
The sequence tends to go 'technology, efficiency, commercial leverage, wealth, get laid'.
After the initial ramp-up period in their early twenties, geeks usually seem to get better-quality pussy than meatheads.
But then you knew that already.
jrandom
18th October 2007, 11:22
Sure does... I've never met a software developer that didn't earn enough to pay for pussy :laugh:
:2thumbsup
limbimtimwim
18th October 2007, 11:25
But does it help you get laid?If you are a woman, yes, a lot.
The Stranger
18th October 2007, 11:44
This is not to say that you can't make use of a multicore box, however. If you can break the workload into discrete parcels there's no reason why you can't spawn another entire application to crunch the data. It's easy too - no pissing around with locks and stuff. Also, if the load can be split into independent lumps then going this way with a multicore box will give you a much bigger speedup than just trying to shove more cycles into a single core.
Fast and dirty, but safe and effective.
Zapf
18th October 2007, 14:57
Currency price movement analysis and modelling... correlations and a shiteload of "what if" scenarios
U work for a company doing this? or just for yourself? Is this for trading or longer term what if predictions?
Finn
18th October 2007, 15:02
The sequence tends to go 'technology, efficiency, commercial leverage, wealth, get laid'.
But in reality within the NZ IT industry, it goes something like... technology, budget blow out, failure, heads on the line, bullshit case study, change in management, get some more technology and so on... the only sex involved is the customer getting screwed up the arse. But of course this is really their own fault anyway. Ohhhh let's issue an RFP with a laundry list of shit we found on google and once heard at an IBM breakfast.
Notice anything new about your Vodafone bill? Me neither but it cost them $600 million.
ManDownUnder
18th October 2007, 15:20
U work for a company doing this? or just for yourself? Is this for trading or longer term what if predictions?
Just for me - exploring a possible alternative source of income. Trades in the short (2-10 days) to medium (1-3 week?) timeframe.
You got an interest?
jrandom
18th October 2007, 15:24
Notice anything new about your Vodafone bill? Me neither but it cost them $600 million.
Yes. That sort of brain-dead shit is why I now work for myself and a mate, writing software that people actually need and selling it directly to them via the magic of the internets (yes, vifferman, the internets).
It's working out pretty good so far...
Finn
18th October 2007, 15:26
Yes. That sort of brain-dead shit is why I now work for myself and a mate, writing software that people actually need and selling it directly to them via the magic of the internets (yes, vifferman, the internets).
It's working out pretty good so far...
Yes, I remember you discussing what you do. Very interesting.
ManDownUnder
20th October 2007, 10:06
But in reality within the NZ IT industry, it goes something like... technology, budget blow out, failure, heads on the line, bullshit case study, change in management, get some more technology and so on... the only sex involved is the customer getting screwed up the arse. But of course this is really their own fault anyway. Ohhhh let's issue an RFP with a laundry list of shit we found on google and once heard at an IBM breakfast.
LOL God that's funny - and so frighteningly accurate.
RFP - three little letters that put the shits up anyone involved in them - except the consultants. From the supplier side they're a bloody nightmare. 2 weeks work for a 1 in 50 chance of winning the business and when you're shortlisted there's still a better than even chance you only made it that far to justify the preferred supplier's price (a guy the CTO met at that IBM breakfast)
Boad of lollix all in all... but hey - welcome to IT.
xwhatsit
20th October 2007, 14:48
Yes. That sort of brain-dead shit is why I now work for myself and a mate, writing software that people actually need and selling it directly to them via the magic of the internets (yes, vifferman, the internets).
It's working out pretty good so far...
Link, la?
Large organisations worry me too. I need to do something after I graduate.
scracha
20th October 2007, 17:23
Link, la?
Large organisations worry me too. I need to do something after I graduate.
Well don't even consider working for a blue chip co developing software.
Street Gerbil
20th October 2007, 21:35
Well don't even consider working for a blue chip co developing software.
Why? What's wrong with that?
I do that for a living since nineties.
Have I missed something?
imdying
21st October 2007, 19:49
Why? What's wrong with that?
I do that for a living since nineties.
Have I missed something?I do it... it really sucks... onsite parking for my bike, nice office with all the toys I could ever want... sub 40 hours a week, time to surf the web, can come and go as a I please, generous salary, life, medical, surgical insurance... free extra training, all learning resources like books paid for... totally shit job, could never recommend it :lol:
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.