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
Determine the working of LAN within a corporate network It should be very clear right from the beginning that a firewall is not simply for protecting a corporate network from u

Describe Circuit switching, Packet switching and Virtual Circuit Packet switching. Explain their suitability for different applications such as telephone and internet. Packet S

What are short, long and medium-term scheduling? Long term scheduler verifies which programs are admitted to the system for processing. It controls the degree of multiprogrammi

configure a router . get the default gateway

TP Monitor does mainly two things extremely well. They are Process management and Transaction management? They were originally introduced to run classes of applications that co

There are many types of servers:- a) File servers b) Database servers c) Transaction servers d)  Groupware servers e) Object servers Web servers.

Network Consultant, My name is Jason Long. I am the CEO of IL Corporation. IL is an investment firm that performs financial services to many organizations. We currently have a

The distance over which data moves within a computer may differ from a few thousandths of an inch, as is the case within a one IC chip, to as much as lot of feet along the backplan

Explain the physical and logical paths in a computer communication network also

QUESTION (a) Define what you understand by the following terms in Network Flows: i) UnDirected Path ii) Directed Path iii) Directed Cycle. iv) Tree In each of th