Révision 10

Pi/C/Simple/Pi.c (revision 10)
15 15
#define CONG  (jcong=69069*jcong+1234567)
16 16
#define KISS  ((MWC^CONG)+SHR3)
17 17

  
18
#define CONGfp CONG * 2.328306435454494e-10f
18 19
#define MWCfp MWC * 2.328306435454494e-10f
19 20
#define KISSfp KISS * 2.328306435454494e-10f
20 21

  
Pi/C/Simple/Makefile (revision 10)
21 21
mrproper: 
22 22
	rm -rf $(EXECUTABLE)
23 23
	find . -name "*~" -exec rm {} \;
24
	find . -name "*.log" -exec rm {} \;
24 25

  
25 26
clean:
26 27
	find . -name "*~" -exec rm {} \;
Pi/C/OpenMP/Pi_OpenMP.c (revision 10)
21 21

  
22 22
#define ITERATIONS 1000000000
23 23

  
24
#define PROCESS 8
24
#define PROCESS 4
25 25

  
26 26
#ifdef LONG
27 27
#define LENGTH unsigned long
......
51 51

  
52 52
int main(int argc, char *argv[]) {
53 53

  
54
  unsigned int seed_w=10,seed_z=10;
54
  unsigned int seed_w=10,seed_z=10,process=PROCESS;
55 55
  LENGTH iterations=ITERATIONS;
56 56
  LENGTH inside[1024],insides=0;
57 57

  
58 58
  if (argc > 1) {
59 59
    iterations=(LENGTH)atol(argv[1]);
60
    process=atoi(argv[2]);
60 61
  }
61 62
  else {
62
    printf("\n\tPi : Estimate Pi with Monte Carlo exploration\n\n\t\t#1 : number of iterations (default 1 billion)\n\n");
63
    printf("\n\tPi : Estimate Pi with Monte Carlo exploration\n\n");
64
    printf("\t\t#1 : number of iterations (default 1 billion)\n");
65
    printf("\t\t#2 : number of process (default 4)\n\n");
63 66
  }
64 67

  
65 68
#pragma omp parallel for
66
  for (int i=0 ; i<PROCESS; i++) {
67
    inside[i]=MainLoopGlobal(iterations/PROCESS,seed_w,seed_z);
68
    printf("%lu\n",inside[i]);
69
  for (int i=0 ; i<process; i++) {
70
    inside[i]=MainLoopGlobal(iterations/process,seed_w,seed_z);
71
    printf("\tFound %lu for process %i\n",(unsigned long)inside[i],i);
69 72
  }
73
  printf("\n");
70 74

  
71
  for (int i=0 ; i<PROCESS; i++) {
75
  for (int i=0 ; i<process; i++) {
72 76
    insides+=inside[i];
73 77
  }
74 78
  
Pi/C/MPI/Pi_MPI.c (revision 10)
84 84
    }
85 85
    
86 86
    insides=MainLoopGlobal(part_iterations,seed_w,seed_z);
87
    printf("\tOn %i, find %lu inside\n",rank,(unsigned long)insides);
87 88
    
88 89
    // Join part of code
89 90
    for (i=1;i<numtasks;i++) {
......
95 96
    
96 97
    pi=4.*(float)insides/(float)((iterations/numtasks)*numtasks);
97 98
    
98
    printf("\tPi=%f with error %f and %lu iterations\n\n",pi,
99
    printf("\n\tPi=%f with error %f and %lu iterations\n\n",pi,
99 100
           fabs(pi-4*atan(1))/pi,(unsigned long)iterations);
100 101
  }
101 102
  else

Formats disponibles : Unified diff