Skip to content
Snippets Groups Projects
Commit 3c55b5aa authored by Nachiket Kapre's avatar Nachiket Kapre
Browse files

updating bench folder

parent e3f70c5d
No related branches found
No related tags found
No related merge requests found
// This is a one-step binomial option model, i.e. NUM_STEPS = 1
// Reference: https://software.intel.com/en-us/articles/binomial-options-pricing-model-code-for-intel-xeon-phi-coprocessor
#include<math.h>
binomial_option(double StockPrice, // Stock price of today
double binomial_option(double StockPrice, // Stock price of today
double OptionStrike,
double TimePeriod, // time period
double vol, // volatility
double risk, // risk free
double *CallResult
double risk // risk free
)
{
/* Note: for intermediate variables, please define them starting with a capital letter 'T' followed by a digit number */
......@@ -17,5 +16,5 @@ binomial_option(double StockPrice, // Stock price of today
double T3 = (exp(T2) - 1/exp(T1)) / (exp(T1) - 1/exp(T1)); // variable pu
double T4 = 1 - T3; // variable pd
double T5 = StockPrice * exp(T1) - OptionStrike; // variable d1
*CallResult = ( T3 * T5 - T4 * T5 ) / exp(T2);
return ( T3 * T5 - T4 * T5 ) / exp(T2);
}
iir8(double a0,
double iir8(double a0,
double a1,
double a2,
double a3,
......@@ -20,17 +23,12 @@ iir8(double a0,
double x4,
double x5,
double x6,
double x7,
double y0,
double y1,
double y2,
double y3,
double y4,
double y5,
double y6,
double y7
double x7
)
{
double y0,y1,y2,y3,y4,y5,y6;
y0 = a0*x0;
y1 = a1*x1 + y0 - b0*y0;
y2 = a2*x2 + y1 - b1*y1;
......@@ -38,5 +36,6 @@ iir8(double a0,
y4 = a4*x4 + y3 - b3*y3;
y5 = a5*x5 + y4 - b4*y4;
y6 = a6*x6 + y5 - b5*y5;
y7 = a7*x7 + y6 - b6*y6;
return (a7*x7 + y6 - b6*y6);
}
\ No newline at end of file
......@@ -16,6 +16,7 @@
# <http://www.gnu.org/licenses/>.
import gcc
import os
def sorted_dict_repr(d):
return '{' + ', '.join(['%r: %r' % (k, d[k])
......@@ -526,20 +527,27 @@ class CfgPrettyPrinter(DotPrettyPrinter):
# Walk the DFG taking care to remove LHS appearing in RHS of GCC's
# Tree structure
accumstr="";
for itr in range(0,i):
if itr in exit_variables:
accumstr += "+ 1 x" + str(itr) + " ";
else:
accumstr += "+ 0 x" + str(itr) + " ";
for key, values in blockdfg.iteritems():
if(key in values):
values.remove(key);
newkey=key.replace("*", "")
if(newkey in values):
values.remove(newkey);
for val in values:
accumstr+="+1 " + variable_names[key] +" -1 " + variable_names[val] + " "
# minimize objective function
if accumstr:
print "min: "+accumstr+";";
accumstr="";
# all slots > 0
for itr in range(0,i):
print "+1 x" + str(itr) + " >= 0;";
print "+1 x" + str(itr) + " >= 0;";
if itr in exit_variables:
accumstr += "+ 1 x" + str(itr) + " ";
if accumstr:#The latency constraint for MINREG
print accumstr + " = " + str(int(float(os.environ['obj_fun_val_q1']))) + ";"
# extract dependencies
for key, values in blockdfg.iteritems():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment