Fix bug where too many simulations were being run
This commit is contained in:
BIN
build/opt-pricer
BIN
build/opt-pricer
Binary file not shown.
@@ -101,6 +101,7 @@ void gbm(struct Option *opt)
|
|||||||
pthread_t *threads;
|
pthread_t *threads;
|
||||||
struct Option *options;
|
struct Option *options;
|
||||||
options = malloc(sizeof(struct Option) * NUM_THREADS);
|
options = malloc(sizeof(struct Option) * NUM_THREADS);
|
||||||
|
opt->sims = opt->sims / NUM_THREADS;
|
||||||
for(i=0; i<NUM_THREADS; i++) {
|
for(i=0; i<NUM_THREADS; i++) {
|
||||||
options[i] = *opt;
|
options[i] = *opt;
|
||||||
options[i].expiry_date = opt->expiry_date;
|
options[i].expiry_date = opt->expiry_date;
|
||||||
@@ -108,7 +109,6 @@ void gbm(struct Option *opt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
threads = malloc(sizeof(pthread_t) * NUM_THREADS);
|
threads = malloc(sizeof(pthread_t) * NUM_THREADS);
|
||||||
opt->sims = opt->sims / NUM_THREADS;
|
|
||||||
|
|
||||||
for(i=0; i<NUM_THREADS; i++) {
|
for(i=0; i<NUM_THREADS; i++) {
|
||||||
if (pthread_create(&threads[i], NULL, run_simulations, &options[i])) {
|
if (pthread_create(&threads[i], NULL, run_simulations, &options[i])) {
|
||||||
@@ -116,11 +116,12 @@ void gbm(struct Option *opt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opt->sims = 0;
|
||||||
|
|
||||||
for(i=0; i<NUM_THREADS; i++) {
|
for(i=0; i<NUM_THREADS; i++) {
|
||||||
void *res;
|
void *res;
|
||||||
struct Option *result;
|
struct Option *result;
|
||||||
pthread_join(threads[i], &res);
|
pthread_join(threads[i], &res);
|
||||||
printf("got here opt assignment too!\n");
|
|
||||||
result = (struct Option*) res;
|
result = (struct Option*) res;
|
||||||
opt->fv += result->fv / NUM_THREADS;
|
opt->fv += result->fv / NUM_THREADS;
|
||||||
opt->delta += result->delta / NUM_THREADS;
|
opt->delta += result->delta / NUM_THREADS;
|
||||||
@@ -130,4 +131,5 @@ void gbm(struct Option *opt)
|
|||||||
opt->rho += result->rho / NUM_THREADS;
|
opt->rho += result->rho / NUM_THREADS;
|
||||||
opt->sims += result->sims;
|
opt->sims += result->sims;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user