Program for two library methods with thread , Computer Networking

#include

void subdomain(float x[ ], int istart, int ipoints)

{

int i;

for (i = 0; i < ipoints; i++)

x[istart+i] = 123.456;

}

void sub(float x[ 10000], int npoints)

{

int t_num, num_t, ipoints, istart;

#pragma omp parallel default(shared) private(t_num , num_t, ipoints, istart)

{

t_num = omp_get_thread_num(); //thread number of current thread num_t = omp_get_num_threads(); //number of threads

ipoints = npoints / num_t; /* size of partition */

istart = t_num * ipoints; /* starting array index */

if (t_num == num_t-1) /* last thread may do more */

ipoints = npoints - istart;

subdomain(x, istart, ipoints);

}

}

int main()

{

float array[10000];

sub(array, 10000);

 return 0;

}

In this example we used two library methods : omp_get_num_threads() and

omp_get_thread_num().

omp_get_num_threads() returns number of threads that are currently being used in parallel directive.

omp_get_thread_num() returns thread number (an integer from 0 to omp_get_num_threads() - 1 where thread 0 is the master thread).

Posted Date: 3/4/2013 5:22:18 AM | Location : United States







Related Discussions:- Program for two library methods with thread , Assignment Help, Ask Question on Program for two library methods with thread , Get Answer, Expert's Help, Program for two library methods with thread Discussions

Write discussion on Program for two library methods with thread
Your posts are moderated
Related Questions
Wait protocol The wait protocol is used for resolving the conflicts, which arise due to number of multiprocessors demanding the same resource. There are two types of wait prot

• This device creates one big collision domain and one large broadcast domain.

Question Approximately what is the low frequency cut-off of the band-pass filter shown in the figure?

What is the importance of implementing a Fault Tolerance System? Are there limitations? A fault tolerance system makes sure continuous data availability. This is done by elimin


Q. Multimode for transmitting optical signals? - Multiple beams from light source travel through core at different paths - Multimode step-index fiber Density remains

Give me a wide idea about simple pendulum and its types with equation and tables as usual assignment?

Q. Explain about Virtual Circuit Switching? Virtual Circuit Switching - All packets belong to a message (or) session is preserved. - Single route is selected between s

The Data link layer performs the following: Responsible for physically passing data from single node to another. Translates messages from the upper layers into data frames and adds

Q. Define the Network Security? The Internet and Web technology presents enormous promise for e-commerce. Web now is used to handle important business assets that became the