Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Fine-Grained and Coarse-Grained actions - Help me understand

1. ## Fine-Grained and Coarse-Grained actions - Help me understand

Hi

I have a question around fine-grained and coarse-grained atomic actions.

Could someone please give me a very basic description on what each one is.

As far as I understand, coarse-grained is built up of multiple fine-grained actions in that it being something like a synchronized method.

But for fine-grained I am unsure on exactly what this means, i know it is an instruction which has either happened or hasn't in that it have either processed everything or nothing at all. An as far as my research goes it has led me to believe that the following is an example of a fine-grained atomic action:

int x = 0;

where as:

int x = y+3;

isnt due to the fact it must read and process data before doing a direct write to a memory location.

Am i on the right track?

2. ## Re: Fine-Grained and Coarse-Grained actions - Help me understand

Never heard those terms used to describe programming. Where did you get them from?

3. ## Re: Fine-Grained and Coarse-Grained actions - Help me understand

I've heard these terms used in parallel programming. In that context, the granularity refers to the amount you're able to split the original job up into.

For example, say you want to add up two vectors each with 1 million numbers. The coarsest possible grain size is to have everything in 1 job.

```// coursest grain size
for(int i = 0; i < 1000000; ++i)
{
result[i] = A[i] + B[i];
}```

The finest grain size would be to have each grain (or task) add up one element.
```// finest grain size

And it's possible to have various grain sizes between these (for example adding up 10 elements/task, 100 elements/task, etc. etc.).