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
SSK Software Corporation has opened an office in Toledo, Ohio. The office will have a wireless Wi-Fi (WLAN), and a Corporate wired Ethernet LAN. Workstation requirements are as

Explain Network Services Network services are the thing that a network can do. The main networking services are File Services: This contains file transfer, storage, data m

FDDI Media Access Control Unlike CSMA/CD networks such like Ethernet token-passing networks are deterministic--you are able to calculate the maximum time that will pass before

iLab 2: Office Network Expansion Connect to the iLab here. Submit your assignment to the Dropbox located on the silver tab at the top of this page. (See "Due Da

Categories of traditional Ethernet a)  Baseband - digital signals using Manchester encoding b) 10Base2, 10-Base-T, 10Base5, 10Base-FL c)  First number signifies data rate

How Intranet is different from Internet? Generally an Intranet is different from an Internet in the following ways: i. Intranet is a network within the organisation whereas

Q. Define the Backbone Networks? Backbone Networks - Allows several LANs to be connected - Non of station is directly connected to the backbone - Stations are part

Describe networking. Networking refers to the inter connection among computers and peripherals for data communication. Networking can be done using wired cabling or by wireless


Base 64 Encoding The Simple Mail Transfer Protocol (SMTP) is a protocol used on the Internet for sending email. When you send an email, your mail client establishes an SMTP co