Fedora Linux Support Community & Resources Center
Prev Previous Post   Next Post Next
  #1  
Old 10th May 2012, 05:20 AM
aitm04 Offline
Registered User
 
Join Date: May 2012
Location: belgaum
Posts: 2
linuxchrome
Parallel programming

Thanks for the suggestion....Here is the code which is giving segmentation fault error(core dump)

Source Code

#include<stdio.h>
#include<omp.h>
int main()
{
int A[1000000],B[1000000],C[1000000];
int I;
double start,end,seq,par;
for(I=1;I<=1000000;I++)
{
A[I]=I;
B[I]=I;
}
start=omp_get_wtime();
for(I=1;I<=1000000;I++)
C[I]=A[I]+B[I];
end=omp_get_wtime();
seq=(end-start);
start=omp_get_wtime();
#pragma omp parallel for
for(I=1;I<=1000000;I++)
C[I]=A[I]+B[I];
end=omp_get_wtime();
par=(end-start);
printf("sequential time execution is=%lf",seq);
printf("parallel time execution is=%lf",par);
printf("\n the elements of array A are:\n");
for(I=1;I<=20;I++)
printf("%5d",A[I]);
printf("_ _ _ _ _ _ 1000000\n");
printf("\n the elements of array B are:\n");
for(I=1;I<=20;I++)
printf("%5d",B[I]);
printf("_ _ _ _ _ _ 1000000\n");
printf("\n the elements of array C are:\n");
for(I=1;I<=20;I++)
printf("%5d",C[I]);
printf("\n time taken for sequential execution=%lf secs",seq);
printf("\n time taken for parallel execution=%lf secs",par);
} 1,1 Top
Reply With Quote
 

Tags
parallel, programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parallel programming aitm04 Using Fedora 3 10th May 2012 02:26 PM
Parallel Processing? Ernst0 Programming & Packaging 3 5th February 2012 02:52 PM
linux programming vs. windows programming unlovedwarrior Programming & Packaging 11 22nd October 2006 09:14 PM
Parallel port programming in c/c++ JPEM Programming & Packaging 0 10th October 2005 11:53 AM


Current GMT-time: 07:05 (Tuesday, 21-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Volklingen - Dieburg Photos - Santander