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

In HTML, a tag shows the browser what to do. When you write an HTML page, you enter tags for lot of  reasons -- to change the appearance of text, to show a graphic, or to make a co

QUESTION (a) Briefly describe three security requirements of an agent (b) List four threats that may be caused by malicious hosts to mobile agents (c) Describe the forwar

Q. Use of Infrared? - Frequencies among 300 GHz and 400 THz - Short-range communication - High frequencies can't penetrate walls - Necessitate line-of-sight propagati

QUESTION (a) Explain briefly what is meant Client-server Computing? (b) Distinguish among client process and server process (c) What are the four basic characteristics of

Name the layer responsible for putting 1s and 0s into a logical group? Ans) Frames are broken down into 1s and 0s and placed onto the physical medium by the Data Lin layer.


How to Configure the Ethernet Interfaces on the Host PCs Configure the Ethernet interfaces of PC1, PC2, PC3, PC4, PC5, and PC6 with the IP addresses and default gateways indica

What must be true for two Routers running IGRP to communicate their routes? Ans) Similar autonomous system number

802.11 FHSS Frequency-hopping spread spectrum in a 2.4 GHz band Carrier sends on one frequency for short duration then hops to another frequency for same duration, hops agai