Program for two library methods with thread , Computer Networking


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_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
Categorization according to kind of instruction and data According to types of instruction and data subsequent types are identified under this classification: Scalar Pi

Q. Illustrate the Bus Backbone network? - Topology is a bus - Utilized in networks such as 10Base5 or 10Base2 - Normally utilized to connect different buildings or to con

What are the key benefits of layered network? Main advantages of layered network are given below: a) Complex systems can be split into understandable subsystems. b) Any f

Screened Host Architecture This architecture consists of two host machines: a Screening Router and a Screening Host. Screening Router is placed between a local network and the

Types of Redundancy Checks Parity Check Simple Parity Check Two Dimensional Parity Check / Longitudinal Redundancy Check (LRC) CRC (Cyclic Redundancy Check)

(a) Explain how a CDMA system works? (b) Explain howWelsh-Hadamard codes are generated. Explain why orthogonality between different spreading codes is important. (c) Consider

Transparency really means adumbrating the network and its servers from the users and even the application programmers.

Cisco is the defaul LMI type. There are three types of LMI standards:  ANSI - Annex D defined by ANSI standard T1.617  ITU-T (Q.933A) - Annex A defined by Q933A  Cisco

Question : a) Explain why pervasive computing can be termed as a "technology that disappears". b) List and briefly explain four main components of a MOTE used in Wireless

Q. How is computer networks used in teleconferencing? Teleconferencing: Teleconferencing allows conference to happen without the participants being in the same place. Applica