How many threads are possible on an AMD 8150?

General OpenMP discussion

How many threads are possible on an AMD 8150?

Postby Ernst0 » Tue Apr 17, 2012 5:20 pm

Pardon me as being new to multi-threaded programs but I am sure it won't last long :)

I didn't see an answer to a question I have about the number of threads I can use. I did Google and look but I fear this is a noob question.

I have the AMD 8150 8-core cpu and I will be wanting to search a dataset to match bit-patterns.
This will be a 16GB dataset and so I will guess the more threads working on it the better.

What I am wondering is should I request 8 threads for the 8 cores or would I do something else?
I'm not there yet and this is research on the how to.

Thanks. I am just learning.


Re: How many threads are possible on an AMD 8150?

Postby ruud » Tue Apr 17, 2012 11:49 pm

Hi Ernst,

Basically you can use any number of threads you like. The easiest is to set this using environment variable OMP_NUM_THREADS. You may need to set OMP_DYNAMIC to FALSE, since some run-time systems by default will not let you use more threads than the hardware supports.

Having said that, it is good practice to see find out where the optimum for an application is. You mention an 8 core system. As far as I know, an AMD core does not support additional threading, so 8 OpenMP threads are most likely your upper limit regarding performance.

But, and that is a big "but", unless you have carefully parallelized the application, you may not get much benefit from using 8 cores. This is because of Amdahl's law which shows that any non-parallel part in your code will dominant performance sooner than later.

So again, I would do some trial runs with 1,2,4,... threads and see what number gives you the most satisfactory performance.

A whole different discussion is that performance analysis tools can guide how to improve the parallel performance in case the program doesn't scale well.


PS Since you're new to parallel programming, you may find my very extensive technical white paper on the basics of parallel programming useful. You can find it on my blog (

Re: How many threads are possible on an AMD 8150?

Postby Ernst0 » Wed Apr 18, 2012 5:55 pm

Oh cool! That is great!

Alright then I'll look at the 8. My effort will be elementary because I am just learning.

If it is possible I hope to have threads call a function and process a dataset each. Meaning each thread calling the function will process it's own chunk of data.

Again I have not worked out the how to on it because it's my first project.

I have cut and saved your reply so i can reference that as I work later this months. It's my hobby!


Re: How many threads are possible on an AMD 8150?

Postby Ernst0 » Wed Apr 18, 2012 7:04 pm

Okay Rudd!

Oh man, just watching the first video I learned something.

It may be better to have 2 or 4 threads working on an array! I see.

Cool.. I tell ya, there are many things to read and watch. I get why you suggest the performance analysis with the 1,2,4 and see what happens!

Okay.. Now what the heck are the RedhatEL6.x tools for that!?? LOL

--- Adding on to rather than add more posts.

Another great point you made was about cpu getting up to speed on processing a data set!!!
Cool! The AMD 8150 has 8 MB of L3.

Just watching the first video for a second time.


Second video explains a lot! I was so unsure what was what now I have a better understanding of cores, cache and threads.
I am looking at a graphic of the 8150 and I see L3 and L2 @ 2MB each so that seems favourable to accessing "a dataset."

Lots to learn..

On to Video 3


So now it starts to get node-y lol.. Talking about groups of units working together over distance. '
I'll watch more but I don't know when I will be doing that :)

Good stuff tho.. I'll probably not comment more since I am probably seeing these things for the first time.

So far tho, the first three are really helpful to me. Clears up some of the glazing over while reading the "Using OpenMP" book because of unfamiliar terms and concepts.
I see that it helps to know the architecture I would be using and, I will accept that it is true that a 5 line program can make or break any architecture. Not that I know how but I believe you Rudd.

Okay casual viewing from here on out unless there is something I think can add to this "thread." lol


Re: How many threads are possible on an AMD 8150?

Postby ruud » Thu Apr 19, 2012 4:03 am

Hi Ernst,

I'm very glad to hear you find the white paper and videos useful!

It looks like you're making good progress getting started. I forgot to mention I have more tutorial material on line. It is easiest if you go to and select "Previous IWOMPs". I gave a tutorial at IWOMP 2011, so if you follow that link you'll find the slides by going to the IWOMP 2011 page, select Program and then Tutorial. Somewhere there you'll find the PDF files with my talks.

I also wanted to answer 2 of your questions.

There are various profiling tools available, also under Linux. For one, you can use our Performance Analyzer. It is part of our Oracle Solaris Studio compilers and tools product that you can get and use for free. Don't be confused by the name though. Several major Linux distributions are supported too. I don't want to turn this into some sort of a product promo so will give you the link only:

But if I were you, I would first focus on getting it right. Once you have the code working correctly it is time to use a profiling tool to find out where the time is spent and to see if you can improve it.

That brings me to your other question. Yes, you can very easily call functions in parallel in OpenMP. There are several ways to do this. For example, if you have a limited set of functions to call, you can use parallel sections. Like this:

Code: Select all
#pragma omp sections
   #pragma omp section
   { (void) funcA();}
   #pragma omp section
   {(void) funcB();}
} // End of sections

If there are many, you could use a parallel loop structure along the following lines:

Code: Select all
#pragma omp parallel for
for (int i=0; i<n; i++)
    (void) function_to_do_what_you_want(i,....);

Last, but certainly not least, you can use tasks. Whether this provides the easiest solution depends on the details of what you're trying to do, but based on your description I can imagine you can assign tasks to specific data sets to be processed. In the IWOMP 2011 tutorial you can find examples of tasking.

One more, but important, comment. In all cases, your function needs to be thread safe. That means if it modifies a shared variable for example you need to make sure this happens in the right way. Through a critical section for example, but also here it is hard to generalize. Just be careful modifying shared data in a function that is executed in parallel.

Good luck and keep your posts coming!


Re: How many threads are possible on an AMD 8150?

Postby Ernst0 » Thu Apr 19, 2012 11:34 pm

Thank you Rudd.

Your help means I have not bitten off more than I can chew but I will be chewing for a while.

I'll be sure to update and when I have the instance to ask more I will. I am considering design aspects for my new project and I should, so, that is a time-factor but, I digress.

Parallel coding is a big change. Perhaps a paradigm-shift in motion for many people.

Again thanks..

Re: How many threads are possible on an AMD 8150?

Postby ruud » Tue Apr 24, 2012 4:24 am

Hi Ernst,

You're right. Parallel programming is a challenge. We're so used to think in a serial way and I maintain my claim that "thinking parallel" is the hardest aspect of it.

I like OpenMP because it is simple in the sense that I can fairly easily test or implement an idea without having to worry about tons of low level details. Still, it is on me to find the parallelism and to make sure my parallel program is correct. That is true for any parallel programming model.

There is one advantage OpenMP has. It is possible for compilers to detect some errors and issue a warning. That is really nice and can save time, but they can't catch everything and sophisticated tools are needed. I definitely encourage you to use those. It takes time to get to know these tools, but it is time well spent.

Good luck and don't hesitate to ask this forum for help.


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 5 guests