PandA-2024.02
main.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <unistd.h>
5 #include <stdint.h>
6 
7 #define RUN 32
8 
9 #include "black_scholes.h"
10 #include "fixedptc.h"
11 
13 {
14  int n = 100;
15  fixedpt s0 = 13107200; // fixedpt_rconst(200.0);
16  fixedpt mu = 16384; // fixedpt_rconst(0.25);
17  fixedpt sigma = 4391; //fixedpt_rconst(0.067);
18  fixedpt t1 = 131072; // fixedpt_rconst(2.0);
19  return asset_path_fixed_simplified(s0, mu, sigma, t1, n, &seed);
20 }
21 
23 {
24  int run = RUN;
25  fixedpt sum = 0;
26  const fixedpt seeds[RUN] = {
27  35645,
28  20955,
29  3231,
30  55398,
31  11191,
32  7730,
33  41421,
34  52573,
35  46468,
36  4465,
37  20791,
38  64790,
39  59818,
40  42394,
41  12807,
42  36702,
43  28255,
44  17195,
45  64055,
46  15204,
47  12488,
48  45439,
49  10215,
50  52185,
51  12464,
52  30711,
53  11892,
54  54818,
55  28299,
56  29363,
57  22002,
58  49795,
59  };
60 #pragma omp parallel for reduction(+:sum)
61  for (int i = 0; i < run; i++) {
62  fixedpt u = asset_path_test(seeds[i]);
63  sum += (u >> FIXEDPT_BITS - FIXEDPT_WBITS);
64  }
65  return sum;
66 }
67 
68 int main ( void )
69 {
70 
71  int ret = 0;
73  printf("sum = %d\n", sum); // the golden result will be the SUM of the prices
74  if (sum == 10752) {
75  printf("RESULT: PASS\n");
76  } else {
77  printf("RESULT: FAIL\n");
78  ret = 1;
79  }
80 
81  return ret;
82 }
83 
#define FIXEDPT_BITS
Definition: fixedptc.h:75
#define RUN
Definition: main.c:7
int sum
Definition: dotproduct.h:3
fixedpt black_scholes()
Definition: main.c:22
fixedpt asset_path_fixed_simplified(fixedpt s0, fixedpt mu, fixedpt sigma, fixedpt t1, int n, int *seed)
Definition: black_scholes.c:5
fixedpt asset_path_test(int seed)
Definition: main.c:12
void main()
Definition: main.c:670
int32_t fixedpt
Definition: fixedptc.h:79
int seeds[NUMPHOTONS]
Definition: tiny_fixed.h:1
#define FIXEDPT_WBITS
Definition: fixedptc.h:95

Generated on Mon Feb 12 2024 13:02:48 for PandA-2024.02 by doxygen 1.8.13