Commit 4aa42a62 authored by Amir Yazdanbakhsh's avatar Amir Yazdanbakhsh
Browse files

remove unnecessary files


Former-commit-id: 3e1386850eff950a938a22d2cbb8fb4c93baa7ad [formerly 6df93f9cc5806fd9b851c6f14dfcdceed6142276]
Former-commit-id: 0c9e5cbd1269d3bb1cbf06ad882ba715df8d97f5
parent 54b6f119
obj/blackscholes.o: obj/blackscholes.o.parroto.c \
/usr/include/stdc-predef.h \
/home/yazdan/phd/projects/parrot.cpu/parrot.c/src/ParrotLib/parroto.h \
/usr/include/stdio.h /usr/include/features.h \
/usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
/usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h \
/usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/string.h \
/usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string3.h \
/usr/include/assert.h /usr/include/c++/4.8/iostream \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/os_defines.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/cpu_defines.h \
/usr/include/c++/4.8/ostream /usr/include/c++/4.8/ios \
/usr/include/c++/4.8/iosfwd /usr/include/c++/4.8/bits/stringfwd.h \
/usr/include/c++/4.8/bits/memoryfwd.h \
/usr/include/c++/4.8/bits/postypes.h /usr/include/c++/4.8/cwchar \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/wchar2.h \
/usr/include/c++/4.8/exception \
/usr/include/c++/4.8/bits/atomic_lockfree_defines.h \
/usr/include/c++/4.8/bits/exception_ptr.h \
/usr/include/c++/4.8/bits/exception_defines.h \
/usr/include/c++/4.8/bits/nested_exception.h \
/usr/include/c++/4.8/bits/char_traits.h \
/usr/include/c++/4.8/bits/stl_algobase.h \
/usr/include/c++/4.8/bits/functexcept.h \
/usr/include/c++/4.8/bits/cpp_type_traits.h \
/usr/include/c++/4.8/ext/type_traits.h \
/usr/include/c++/4.8/ext/numeric_traits.h \
/usr/include/c++/4.8/bits/stl_pair.h /usr/include/c++/4.8/bits/move.h \
/usr/include/c++/4.8/bits/concept_check.h \
/usr/include/c++/4.8/type_traits \
/usr/include/c++/4.8/bits/stl_iterator_base_types.h \
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h \
/usr/include/c++/4.8/debug/debug.h \
/usr/include/c++/4.8/bits/stl_iterator.h /usr/include/c++/4.8/cstdint \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/c++/4.8/bits/localefwd.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++locale.h \
/usr/include/c++/4.8/clocale /usr/include/locale.h \
/usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/4.8/cctype \
/usr/include/ctype.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
/usr/include/c++/4.8/bits/ios_base.h \
/usr/include/c++/4.8/ext/atomicity.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/gthr.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/gthr-default.h \
/usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/sched.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/bits/timex.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/x86_64-linux-gnu/bits/setjmp.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/atomic_word.h \
/usr/include/c++/4.8/bits/locale_classes.h /usr/include/c++/4.8/string \
/usr/include/c++/4.8/bits/allocator.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++allocator.h \
/usr/include/c++/4.8/ext/new_allocator.h /usr/include/c++/4.8/new \
/usr/include/c++/4.8/bits/ostream_insert.h \
/usr/include/c++/4.8/bits/cxxabi_forced.h \
/usr/include/c++/4.8/bits/stl_function.h \
/usr/include/c++/4.8/backward/binders.h \
/usr/include/c++/4.8/bits/range_access.h \
/usr/include/c++/4.8/bits/basic_string.h \
/usr/include/c++/4.8/initializer_list \
/usr/include/c++/4.8/ext/string_conversions.h \
/usr/include/c++/4.8/cstdlib /usr/include/stdlib.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/sys/types.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/select2.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
/usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/c++/4.8/cstdio \
/usr/include/c++/4.8/cerrno /usr/include/errno.h \
/usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/x86_64-linux-gnu/asm/errno.h \
/usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
/usr/include/c++/4.8/bits/functional_hash.h \
/usr/include/c++/4.8/bits/hash_bytes.h \
/usr/include/c++/4.8/bits/basic_string.tcc \
/usr/include/c++/4.8/bits/locale_classes.tcc \
/usr/include/c++/4.8/streambuf /usr/include/c++/4.8/bits/streambuf.tcc \
/usr/include/c++/4.8/bits/basic_ios.h \
/usr/include/c++/4.8/bits/locale_facets.h /usr/include/c++/4.8/cwctype \
/usr/include/wctype.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/ctype_base.h \
/usr/include/c++/4.8/bits/streambuf_iterator.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/ctype_inline.h \
/usr/include/c++/4.8/bits/locale_facets.tcc \
/usr/include/c++/4.8/bits/basic_ios.tcc \
/usr/include/c++/4.8/bits/ostream.tcc /usr/include/c++/4.8/istream \
/usr/include/c++/4.8/bits/istream.tcc /usr/include/math.h \
/usr/include/x86_64-linux-gnu/bits/huge_val.h \
/usr/include/x86_64-linux-gnu/bits/huge_valf.h \
/usr/include/x86_64-linux-gnu/bits/huge_vall.h \
/usr/include/x86_64-linux-gnu/bits/inf.h \
/usr/include/x86_64-linux-gnu/bits/nan.h \
/usr/include/x86_64-linux-gnu/bits/mathdef.h \
/usr/include/x86_64-linux-gnu/bits/mathcalls.h \
/usr/include/x86_64-linux-gnu/bits/mathinline.h \
/usr/include/c++/4.8/fstream /usr/include/c++/4.8/bits/codecvt.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/basic_file.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++io.h \
/usr/include/c++/4.8/bits/fstream.tcc /usr/include/c++/4.8/vector \
/usr/include/c++/4.8/bits/stl_construct.h \
/usr/include/c++/4.8/ext/alloc_traits.h \
/usr/include/c++/4.8/bits/alloc_traits.h \
/usr/include/c++/4.8/bits/ptr_traits.h \
/usr/include/c++/4.8/bits/stl_uninitialized.h \
/usr/include/c++/4.8/bits/stl_vector.h \
/usr/include/c++/4.8/bits/stl_bvector.h \
/usr/include/c++/4.8/bits/vector.tcc /usr/include/c++/4.8/iomanip \
/usr/include/c++/4.8/locale \
/usr/include/c++/4.8/bits/locale_facets_nonio.h \
/usr/include/c++/4.8/ctime \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/time_members.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/messages_members.h \
/usr/include/libintl.h /usr/include/c++/4.8/bits/locale_facets_nonio.tcc
#include "parroto.h"
extern ParrotObserver parroto;
// Copyright (c) 2007 Intel Corp.
// Black-Scholes
// Analytical method for calculating European Options
//
//
// Reference Source: Options, Futures, and Other Derivatives, 3rd Edition, Prentice
// Hall, John C. Hull,
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
//double max_otype, min_otype ;
//double max_sptprice, min_sptprice;
//double max_strike, min_strike;
//double max_rate, min_rate ;
//double max_volatility, min_volatility;
//double max_otime, min_otime ;
//double max_out_price, min_out_price;
#define DIVIDE 120.0
//Precision to use for calculations
#define fptype float
#define NUM_RUNS 1
typedef struct OptionData_ {
fptype s; // spot price
fptype strike; // strike price
fptype r; // risk-free interest rate
fptype divq; // dividend rate
fptype v; // volatility
fptype t; // time to maturity or option expiration in years
// (1yr = 1.0, 6mos = 0.5, 3mos = 0.25, ..., etc)
char OptionType; // Option type. "P"=PUT, "C"=CALL
fptype divs; // dividend vals (not used in this test)
fptype DGrefval; // DerivaGem Reference Value
} OptionData;
OptionData *data;
fptype *prices;
int numOptions;
int * otype;
fptype * sptprice;
fptype * strike;
fptype * rate;
fptype * volatility;
fptype * otime;
int numError = 0;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Cumulative Normal Distribution Function
// See Hull, Section 11.8, P.243-244
#define inv_sqrt_2xPI 0.39894228040143270286
fptype CNDF ( fptype InputX )
{
int sign;
fptype OutputX;
fptype xInput;
fptype xNPrimeofX;
fptype expValues;
fptype xK2;
fptype xK2_2, xK2_3;
fptype xK2_4, xK2_5;
fptype xLocal, xLocal_1;
fptype xLocal_2, xLocal_3;
// Check for negative value of InputX
if (InputX < 0.0) {
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;
//printf("# xLocal: %10.10f\n", xLocal);
xLocal = 1.0 - xLocal;
OutputX = xLocal;
//printf("# Output: %10.10f\n", OutputX);
if (sign) {
OutputX = 1.0 - OutputX;
}
return OutputX;
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
fptype BlkSchlsEqEuroNoDiv( fptype sptprice,
fptype strike, fptype rate, fptype volatility,
fptype time, int otype, float timet, fptype* N1, fptype* N2)
{
fptype OptionPrice;
// local private working variables for the calculation
//fptype xStockPrice;
//fptype xStrikePrice;
fptype xRiskFreeRate;
fptype xVolatility;
fptype xTime;
fptype xSqrtTime;
fptype logValues;
fptype xLogTerm;
fptype xD1;
fptype xD2;
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;
xTime = time;
xSqrtTime = sqrt(xTime);
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;
xD1 = xD1 / xDen;
xD2 = xD1 - xDen;
d1 = xD1;
d2 = xD2;
NofXd1 = CNDF( d1 );
if(NofXd1 > 1.0)
std::cerr << "Greater than one!" << std::endl ;
//printf("# d1: %10.10f\n", NofXd1);
NofXd2 = CNDF( d2 );
if(NofXd2 > 1.0)
std::cerr << "Greater than one!" << std::endl ;
//printf("# d2: %10.10f\n", NofXd2);
*N1 = NofXd1 ;
*N2 = NofXd2 ;
FutureValueX = strike * ( exp( -(rate)*(time) ) );
if (otype == 0) {
OptionPrice = (sptprice * NofXd1) - (FutureValueX * NofXd2);
} else {
NegNofXd1 = (1.0 - NofXd1);
NegNofXd2 = (1.0 - NofXd2);
OptionPrice = (FutureValueX * NegNofXd2) - (sptprice * NegNofXd1);
}
return OptionPrice;
}
double normalize(double in, double min, double max, double min_new, double max_new)
{
return (((in - min) / (max - min)) * (max_new - min_new)) + min_new ;
}
int bs_thread(void *tid_ptr) {
int i, j;
int tid = *(int *)tid_ptr;
int start = tid * (numOptions);
int end = start + (numOptions);
fptype price_orig;
for (j=0; j<NUM_RUNS; j++) {
for (i=start; i<end; i++) {
/* Calling main function to calculate option value based on
* Black & Scholes's equation.
*/
fptype price;
fptype N1, N2;
double dataIn[6];
double dataOut[1];
dataIn[0] = sptprice[i];
dataIn[1] = strike[i];
dataIn[2] = rate[i];
dataIn[3] = volatility[i];
dataIn[4] = otime[i];
dataIn[5] = otype[i];
#pragma parrot(input, "blackscholes", [6]dataIn)
parroto.write("blackscholes", 0, dataIn, 6, 0, 0);
price_orig = BlkSchlsEqEuroNoDiv( sptprice[i], strike[i],
rate[i], volatility[i], otime[i],
otype[i], 0, &N1, &N2);
dataOut[0] = price_orig;
parroto.write("blackscholes", 1, dataOut, 1, 0.1, 0.9);
#pragma parrot(output, "blackscholes", [1]<0.1; 0.9>dataOut)
price_orig = dataOut[0];
prices[i] = price_orig;
}
}
return 0;
}
int main (int argc, char **argv)
{
FILE *file;
int i;
int loopnum;
fptype * buffer;
int * buffer2;
int rv;
fflush(NULL);
char *inputFile = argv[1];
char *outputFile = argv[2];
//Read input data from file
file = fopen(inputFile, "r");
if(file == NULL) {
printf("ERROR: Unable to open file `%s'.\n", inputFile);
exit(1);
}
rv = fscanf(file, "%i", &numOptions);
if(rv != 1) {
printf("ERROR: Unable to read from file `%s'.\n", inputFile);
fclose(file);
exit(1);
}
// alloc spaces for the option data
data = (OptionData*)malloc(numOptions*sizeof(OptionData));
prices = (fptype*)malloc(numOptions*sizeof(fptype));
for ( loopnum = 0; loopnum < numOptions; ++ loopnum )
{
rv = fscanf(file, "%f %f %f %f %f %f %c %f %f", &data[loopnum].s, &data[loopnum].strike, &data[loopnum].r, &data[loopnum].divq, &data[loopnum].v, &data[loopnum].t, &data[loopnum].OptionType, &data[loopnum].divs, &data[loopnum].DGrefval);
if(rv != 9) {
printf("ERROR: Unable to read from file `%s'.\n", inputFile);
fclose(file);
exit(1);
}
}
rv = fclose(file);
if(rv != 0) {
printf("ERROR: Unable to close file `%s'.\n", inputFile);
exit(1);
}
#define PAD 256
#define LINESIZE 64
buffer = (fptype *) malloc(5 * numOptions * sizeof(fptype) + PAD);
sptprice = (fptype *) (((unsigned long long)buffer + PAD) & ~(LINESIZE - 1));
strike = sptprice + numOptions;
rate = strike + numOptions;
volatility = rate + numOptions;
otime = volatility + numOptions;
buffer2 = (int *) malloc(numOptions * sizeof(fptype) + PAD);
otype = (int *) (((unsigned long long)buffer2 + PAD) & ~(LINESIZE - 1));
for (i=0; i<numOptions; i++) {
otype[i] = (data[i].OptionType == 'P') ? 1 : 0;
sptprice[i] = data[i].s / DIVIDE;
strike[i] = data[i].strike / DIVIDE;
rate[i] = data[i].r;
volatility[i] = data[i].v;
otime[i] = data[i].t;
}
//serial version
int tid=0;
bs_thread(&tid);
//Write prices to output file
file = fopen(outputFile, "w");
if(file == NULL) {
printf("ERROR: Unable to open file `%s'.\n", outputFile);
exit(1);
}
//rv = fprintf(file, "%i\n", numOptions);
if(rv < 0) {
printf("ERROR: Unable to write to file `%s'.\n", outputFile);
fclose(file);
exit(1);
}
for(i=0; i<numOptions; i++) {
rv = fprintf(file, "%.18f\n", prices[i]);
if(rv < 0) {
printf("ERROR: Unable to write to file `%s'.\n", outputFile);
fclose(file);
exit(1);
}
}
rv = fclose(file);
if(rv != 0) {
printf("ERROR: Unable to close file `%s'.\n", outputFile);
exit(1);
}
free(data);
free(prices);
return 0;
}
obj/blackscholes_nn.o: src.nn/blackscholes_nn.c \
/usr/include/stdc-predef.h /usr/local/include/fann.h \
/usr/local/include/floatfann.h /usr/local/include/fann.h \
/usr/include/x86_64-linux-gnu/sys/time.h /usr/include/features.h \
/usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/select2.h \
/usr/local/include/fann_error.h /usr/include/stdio.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h /usr/include/libio.h \
/usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h \
/usr/include/x86_64-linux-gnu/bits/stdio2.h \
/usr/local/include/fann_activation.h /usr/local/include/fann_data.h \
/usr/local/include/fann_internal.h /usr/include/math.h \
/usr/include/x86_64-linux-gnu/bits/huge_val.h \
/usr/include/x86_64-linux-gnu/bits/huge_valf.h \
/usr/include/x86_64-linux-gnu/bits/huge_vall.h \
/usr/include/x86_64-linux-gnu/bits/inf.h \
/usr/include/x86_64-linux-gnu/bits/nan.h \
/usr/include/x86_64-linux-gnu/bits/mathdef.h \
/usr/include/x86_64-linux-gnu/bits/mathcalls.h \
/usr/include/x86_64-linux-gnu/bits/mathinline.h /usr/include/stdlib.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/xlocale.h \
/usr/include/x86_64-linux-gnu/sys/types.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
/usr/include/x86_64-linux-gnu/bits/stdlib.h \
/usr/local/include/fann_train.h /usr/local/include/fann_cascade.h \
/usr/local/include/fann_io.h \
/home/yazdan/phd/projects/parrot.cpu/parrot.c/src/ParrotLib/parroto.h \
/usr/include/string.h /usr/include/x86_64-linux-gnu/bits/string3.h \
/usr/include/assert.h /usr/include/c++/4.8/iostream \