-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b30feba
commit a05bb76
Showing
5 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
8a9 | ||
> #include <causal.h> | ||
84,87d84 | ||
< fptype OutputX; | ||
< fptype xInput; | ||
< fptype xNPrimeofX; | ||
< fptype expValues; | ||
89,92d85 | ||
< fptype xK2_2, xK2_3; | ||
< fptype xK2_4, xK2_5; | ||
< fptype xLocal, xLocal_1; | ||
< fptype xLocal_2, xLocal_3; | ||
96,129c89,95 | ||
< InputX = -InputX; | ||
< sign = 1; | ||
< } else | ||
< sign = 0; | ||
< | ||
< xInput = InputX; | ||
< | ||
< // Compute NPrimeX term common to both four & six decimal accuracy calcs | ||
< expValues = exp(-0.5f * InputX * InputX); | ||
< xNPrimeofX = expValues; | ||
< xNPrimeofX = xNPrimeofX * inv_sqrt_2xPI; | ||
< | ||
< xK2 = 0.2316419 * xInput; | ||
< xK2 = 1.0 + xK2; | ||
< xK2 = 1.0 / xK2; | ||
< xK2_2 = xK2 * xK2; | ||
< xK2_3 = xK2_2 * xK2; | ||
< xK2_4 = xK2_3 * xK2; | ||
< xK2_5 = xK2_4 * xK2; | ||
< | ||
< xLocal_1 = xK2 * 0.319381530; | ||
< xLocal_2 = xK2_2 * (-0.356563782); | ||
< xLocal_3 = xK2_3 * 1.781477937; | ||
< xLocal_2 = xLocal_2 + xLocal_3; | ||
< xLocal_3 = xK2_4 * (-1.821255978); | ||
< xLocal_2 = xLocal_2 + xLocal_3; | ||
< xLocal_3 = xK2_5 * 1.330274429; | ||
< xLocal_2 = xLocal_2 + xLocal_3; | ||
< | ||
< xLocal_1 = xLocal_2 + xLocal_1; | ||
< xLocal = xLocal_1 * xNPrimeofX; | ||
< xLocal = 1.0 - xLocal; | ||
< | ||
< OutputX = xLocal; | ||
--- | ||
> InputX = -InputX; | ||
> sign = 1; | ||
> } else { | ||
> sign = 0; | ||
> } | ||
> | ||
> xK2 = 1.0 / (1.0 + 0.2316419 * InputX); | ||
132c98,100 | ||
< OutputX = 1.0 - OutputX; | ||
--- | ||
> return (0.319381530*xK2 - 0.356563782*xK2*xK2 + 1.781477937*xK2*xK2*xK2 - 1.821255978*xK2*xK2*xK2*xK2 + 1.330274429*xK2*xK2*xK2*xK2*xK2) * exp(-0.5f * InputX * InputX) * inv_sqrt_2xPI; | ||
> } else { | ||
> return 1.0 - (0.319381530*xK2 - 0.356563782*xK2*xK2 + 1.781477937*xK2*xK2*xK2 - 1.821255978*xK2*xK2*xK2*xK2 + 1.330274429*xK2*xK2*xK2*xK2*xK2) * exp(-0.5f * InputX * InputX) * inv_sqrt_2xPI; | ||
134,135d101 | ||
< | ||
< return OutputX; | ||
151,152d116 | ||
< fptype OptionPrice; | ||
< | ||
154,162d117 | ||
< fptype xStockPrice; | ||
< fptype xStrikePrice; | ||
< fptype xRiskFreeRate; | ||
< fptype xVolatility; | ||
< fptype xTime; | ||
< fptype xSqrtTime; | ||
< | ||
< fptype logValues; | ||
< fptype xLogTerm; | ||
165,178c120 | ||
< fptype xPowerTerm; | ||
< fptype xDen; | ||
< fptype d1; | ||
< fptype d2; | ||
< fptype FutureValueX; | ||
< fptype NofXd1; | ||
< fptype NofXd2; | ||
< fptype NegNofXd1; | ||
< fptype NegNofXd2; | ||
< | ||
< xStockPrice = sptprice; | ||
< xStrikePrice = strike; | ||
< xRiskFreeRate = rate; | ||
< xVolatility = volatility; | ||
--- | ||
> fptype xDen; | ||
180,181c122 | ||
< xTime = time; | ||
< xSqrtTime = sqrt(xTime); | ||
--- | ||
> xD1 = (rate + volatility * volatility * 0.5) * time + log( sptprice / strike ); | ||
183,195c124 | ||
< logValues = log( sptprice / strike ); | ||
< | ||
< xLogTerm = logValues; | ||
< | ||
< | ||
< xPowerTerm = xVolatility * xVolatility; | ||
< xPowerTerm = xPowerTerm * 0.5; | ||
< | ||
< xD1 = xRiskFreeRate + xPowerTerm; | ||
< xD1 = xD1 * xTime; | ||
< xD1 = xD1 + xLogTerm; | ||
< | ||
< xDen = xVolatility * xSqrtTime; | ||
--- | ||
> xDen = volatility * sqrt(time); | ||
198,205c127 | ||
< | ||
< d1 = xD1; | ||
< d2 = xD2; | ||
< | ||
< NofXd1 = CNDF( d1 ); | ||
< NofXd2 = CNDF( d2 ); | ||
< | ||
< FutureValueX = strike * ( exp( -(rate)*(time) ) ); | ||
--- | ||
> | ||
207c129 | ||
< OptionPrice = (sptprice * NofXd1) - (FutureValueX * NofXd2); | ||
--- | ||
> return (sptprice * CNDF( xD1 )) - (strike * ( exp( -(rate)*(time) ) ) * CNDF( xD2 )); | ||
209,211c131 | ||
< NegNofXd1 = (1.0 - NofXd1); | ||
< NegNofXd2 = (1.0 - NofXd2); | ||
< OptionPrice = (FutureValueX * NegNofXd2) - (sptprice * NegNofXd1); | ||
--- | ||
> return (strike * ( exp( -(rate)*(time) ) ) * (1.0 - CNDF( xD1 ))) - (sptprice * (1.0 - CNDF( xD2 ))); | ||
213,214d132 | ||
< | ||
< return OptionPrice; | ||
256a175 | ||
> CAUSAL_PROGRESS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
64,66c64,66 | ||
< unsigned char* sha1name = ((CacheKey*)k)->sha1name; | ||
< for (i = 0; i < SHA1_LEN; i++) { | ||
< hash += *(((unsigned char*)sha1name) + i); | ||
--- | ||
> /*uint32_t* sha1name = ((CacheKey*)k)->sha1name;*/ unsigned char* sha1name = ((CacheKey*)k)->sha1name; | ||
> for (i = 0; /* i*4 */ i < SHA1_LEN; i++) { | ||
> /*hash ^= sha1name[i];*/ hash += *(((unsigned char*)sha1name) + i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
6a7 | ||
> #include <causal.h> | ||
612a614,619 | ||
> /*float* dest = &cell.density[j]; | ||
> float expected = *dest; | ||
> float newval = expected + tc; | ||
> while(!__atomic_compare_exchange((uint32_t*)dest, (uint32_t*)&expected, (uint32_t*)&newval, true, __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) { | ||
> newval = expected + tc; | ||
> }*/ | ||
621a629,634 | ||
> /*float* dest = &neigh.density[iparNeigh]; | ||
> float expected = *dest; | ||
> float newval = expected + tc; | ||
> while(!__atomic_compare_exchange((uint32_t*)dest, (uint32_t*)&expected, (uint32_t*)&newval, true, __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) { | ||
> newval = expected + tc; | ||
> }*/ | ||
783c796 | ||
< | ||
--- | ||
> void wait_at_barrier() { pthread_barrier_wait(&barrier); CAUSAL_PROGRESS; } | ||
787c800 | ||
< pthread_barrier_wait(&barrier); | ||
--- | ||
> wait_at_barrier(); //pthread_barrier_wait(&barrier); | ||
789c802 | ||
< pthread_barrier_wait(&barrier); | ||
--- | ||
> wait_at_barrier(); //pthread_barrier_wait(&barrier); | ||
791c804 | ||
< pthread_barrier_wait(&barrier); | ||
--- | ||
> wait_at_barrier(); //pthread_barrier_wait(&barrier); | ||
793c806 | ||
< pthread_barrier_wait(&barrier); | ||
--- | ||
> wait_at_barrier(); //pthread_barrier_wait(&barrier); | ||
795c808 | ||
< pthread_barrier_wait(&barrier); | ||
--- | ||
> wait_at_barrier(); //pthread_barrier_wait(&barrier); | ||
797c810 | ||
< pthread_barrier_wait(&barrier); | ||
--- | ||
> wait_at_barrier(); //pthread_barrier_wait(&barrier); | ||
799c812 | ||
< pthread_barrier_wait(&barrier); | ||
--- | ||
> wait_at_barrier(); //pthread_barrier_wait(&barrier); | ||
801c814 | ||
< pthread_barrier_wait(&barrier); | ||
--- | ||
> wait_at_barrier(); //pthread_barrier_wait(&barrier); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
21c21 | ||
< #include "parsec_barrier.hpp" | ||
--- | ||
> //#include "parsec_barrier.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
*** /home/charlie/Projects/benchmarks/parsec2.1-unmodified/pkgs/apps/swaptions/src/HJM_SimPath_Forward_Blocking.cpp 2008-11-11 15:23:28.000000000 -0500 | ||
--- HJM_SimPath_Forward_Blocking.cpp 2015-03-23 12:37:56.687945058 -0400 | ||
*************** | ||
*** 62,69 **** | ||
|
||
|
||
for(int l=0;l<=iFactors-1;++l){ | ||
! for(int b=0; b<BLOCKSIZE; b++){ | ||
! for (int j=1;j<=iN-1;++j){ | ||
pdZ[l][BLOCKSIZE*j + b]= CumNormalInv(randZ[l][BLOCKSIZE*j + b]); /* 18% of the total executition time */ | ||
} | ||
} | ||
--- 62,69 ---- | ||
|
||
|
||
for(int l=0;l<=iFactors-1;++l){ | ||
! for (int j=1;j<=iN-1;++j){ | ||
! for(int b=0; b<BLOCKSIZE; b++){ | ||
pdZ[l][BLOCKSIZE*j + b]= CumNormalInv(randZ[l][BLOCKSIZE*j + b]); /* 18% of the total executition time */ | ||
} | ||
} | ||
*************** | ||
*** 99,122 **** | ||
// t=0 forward curve stored iN first row of ppdHJMPath | ||
// At time step 0: insert expected drift | ||
// rest reset to 0 | ||
! for(int b=0; b<BLOCKSIZE; b++){ | ||
for(j=0;j<=iN-1;j++){ | ||
ppdHJMPath[0][BLOCKSIZE*j + b] = pdForward[j]; | ||
|
||
for(i=1;i<=iN-1;++i) | ||
{ ppdHJMPath[i][BLOCKSIZE*j + b]=0; } //initializing HJMPath to zero | ||
} | ||
! } | ||
// ----------------------------------------------------- | ||
|
||
// ===================================================== | ||
// sequentially generating random numbers | ||
|
||
! | ||
! for(int b=0; b<BLOCKSIZE; b++){ | ||
! for(int s=0; s<1; s++){ | ||
! for (j=1;j<=iN-1;++j){ | ||
! for (l=0;l<=iFactors-1;++l){ | ||
//compute random number in exact same sequence | ||
randZ[l][BLOCKSIZE*j + b + s] = RanUnif(lRndSeed); /* 10% of the total executition time */ | ||
} | ||
--- 99,136 ---- | ||
// t=0 forward curve stored iN first row of ppdHJMPath | ||
// At time step 0: insert expected drift | ||
// rest reset to 0 | ||
! /*for(int b=0; b<BLOCKSIZE; b++){ | ||
for(j=0;j<=iN-1;j++){ | ||
ppdHJMPath[0][BLOCKSIZE*j + b] = pdForward[j]; | ||
|
||
for(i=1;i<=iN-1;++i) | ||
{ ppdHJMPath[i][BLOCKSIZE*j + b]=0; } //initializing HJMPath to zero | ||
} | ||
! }*/ | ||
! for(j=0;j<=iN-1;j++) { | ||
! for(int b=0; b<BLOCKSIZE; b++) { | ||
! ppdHJMPath[0][BLOCKSIZE*j + b] = pdForward[j]; | ||
! } | ||
! } | ||
! | ||
! for(i=1;i<=iN-1;++i) { | ||
! memset(ppdHJMPath[i], 0, BLOCKSIZE*iN*sizeof(FTYPE)); | ||
! //for(j=0;j<=iN-1;j++) { | ||
! //memset(&ppdHJMPath[i][BLOCKSIZE*j], BLOCKSIZE, sizeof(FTYPE)); | ||
! //for(int b=0; b<BLOCKSIZE; b++) { | ||
! // ppdHJMPath[i][BLOCKSIZE*j + b]=0; | ||
! //} | ||
! //} | ||
! } | ||
// ----------------------------------------------------- | ||
|
||
// ===================================================== | ||
// sequentially generating random numbers | ||
|
||
! for (l=0;l<=iFactors-1;++l){ | ||
! for (j=1;j<=iN-1;++j){ | ||
! for(int b=0; b<BLOCKSIZE; b++){ | ||
! for(int s=0; s<1; s++){ | ||
//compute random number in exact same sequence | ||
randZ[l][BLOCKSIZE*j + b + s] = RanUnif(lRndSeed); /* 10% of the total executition time */ | ||
} | ||
*************** | ||
*** 141,150 **** | ||
|
||
// ===================================================== | ||
// Generation of HJM Path1 | ||
! for(int b=0; b<BLOCKSIZE; b++){ // b is the blocks | ||
! for (j=1;j<=iN-1;++j) {// j is the timestep | ||
|
||
! for (l=0;l<=iN-(j+1);++l){ // l is the future steps | ||
dTotalShock = 0; | ||
|
||
for (i=0;i<=iFactors-1;++i){// i steps through the stochastic factors | ||
--- 155,165 ---- | ||
|
||
// ===================================================== | ||
// Generation of HJM Path1 | ||
! | ||
! for (j=1;j<=iN-1;++j) {// j is the timestep | ||
|
||
! for (l=0;l<=iN-(j+1);++l){ // l is the future steps | ||
! for(int b=0; b<BLOCKSIZE; b++){ // b is the blocks | ||
dTotalShock = 0; | ||
|
||
for (i=0;i<=iFactors-1;++i){// i steps through the stochastic factors |