In [ ]:
from titanfp import bench

data = bench.sweep_single(bench.cores['sqrt'],
                          bench.iter_1arg(range(-14, 16), range(1, 11), 1), 
                          64, 
                          bench.ctx128)


FPCore (x)
  name: None
   pre: None
  spec: None
  (sqrt x)
running with 64 total bits
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-4-3ac42300d0dc> in <module>()
      4                           bench.iter_1arg(range(-14, 16), range(1, 11), 1),
      5                           64,
----> 6                           bench.ctx128)

~/anaconda3/lib/python3.6/site-packages/titanfp/bench.py in sweep_single(core, cases, nbits, ctx)
    145     print('{:s}\nrunning with {:d} total bits'.format(str(core), nbits), flush=True)
    146 
--> 147     records = sweep(core, cases, nbits, ctx)
    148 
    149     if progress_update > 0:

~/anaconda3/lib/python3.6/site-packages/titanfp/bench.py in sweep(core, cases, nbits, ctx)
    135             continue
    136 
--> 137         records.append(bench_core(core, hi_args, lo_args, ctx))
    138         if progress_update > 0 and len(records) % progress_update == 0:
    139             print('.', end='', flush=True)

~/anaconda3/lib/python3.6/site-packages/titanfp/bench.py in bench_core(core, hi_args, lo_args, ctx)
     97 
     98 def bench_core(core, hi_args, lo_args, ctx):
---> 99     hi_result = ieee754.interpret(core, hi_args, ctx=ctx)
    100     lo_result = ieee754.interpret(core, lo_args, ctx=ctx)
    101     sunk = optimistic.interpret(core, lo_args, ctx)

~/anaconda3/lib/python3.6/site-packages/titanfp/arithmetic/ieee754.py in interpret(core, args, ctx)
    244         ctx.let([(name, argval)])
    245 
--> 246     return evaluate(core.e, ctx)
    247 
    248 

~/anaconda3/lib/python3.6/site-packages/titanfp/arithmetic/ieee754.py in evaluate(e, ctx)
    342 
    343         elif isinstance(e, ast.Sqrt):
--> 344             return sqrt(*children, ctx)
    345 
    346         elif isinstance(e, ast.Add):

~/anaconda3/lib/python3.6/site-packages/titanfp/arithmetic/ieee754.py in sqrt(x, ctx)
    194     prec = max(2, ctx.p + 1)
    195     result = compute_with_backend(OP.sqrt, x, prec=prec)
--> 196     return round_to_ieee_ctx(result, ctx)
    197 
    198 def floor(x, ctx):

~/anaconda3/lib/python3.6/site-packages/titanfp/arithmetic/ieee754.py in round_to_ieee_ctx(x, ctx)
     42 
     43     if ctx.rm == RM.RNE:
---> 44         if x_emag >= ctx.fbound:
     45             return sinking.Sink(negative=x.negative, c=0, exp=0, inf=True, rc=-1)
     46     else:

~/anaconda3/lib/python3.6/site-packages/titanfp/titanic/sinking.py in __ge__(self, x)
   1101 
   1102     def __ge__(self, x):
-> 1103         order, sharp = self.compareto(x)
   1104         return 0 <= order
   1105 

~/anaconda3/lib/python3.6/site-packages/titanfp/titanic/sinking.py in compareto(self, x, strict)
   1032 
   1033         # integer comparison
-> 1034         if not (lower_ord <= upper_ord and xlower_ord <= xupper_ord):
   1035             # TODO: assertion
   1036             print(lower_ord, upper_ord, xlower_ord, xupper_ord)

KeyboardInterrupt: 

In [12]:
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import matplotlib.transforms as mtransforms

import matplotlib
matplotlib.rcParams.update({'font.size': 16})


fig, ax = plt.subplots()

fig.set_size_inches(8, 5.5)

ax.set_ylim(0, 20)
ax.set_xlabel('sinking-point reported precision (bits)')
ax.set_ylabel('actual precision (bits)')

ax.scatter(xs, ys, s=100, color=greyscale)
#plt.ylim((0, 16))
#plt.xlim((0, 16))

xlim = ax.get_xlim()
line = mlines.Line2D(xlim, xlim, color='red')
#transform=ax.transAxes
#line.set_transform(transform)
ax.add_line(line)

plt.show()

# Write this as a cdf:

# one line for each number of ground truth bits bits
# plot % of reported bits

# x axis is y axis - x axis
# y axis is % points that are less than x axis
# separate line for each x axis position



In [10]:
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()

fig.set_size_inches(8, 5.5)

ax.set_xlabel('excess precision (bits)')
ax.set_ylabel('fraction of results')

for x_name, (cdf_xs, cdf_ys) in cdf_xys.items():
    ax.plot(cdf_xs, cdf_ys)
    
    
x_min, x_max = ax.get_xlim()
ref_x = np.linspace(x_min, x_max, 1000)
ref_y_one = [1 - (3/2) * (2**-x) for x in ref_x]
ref_y_zero = [1 - (1/2) * (2**-x) for x in ref_x]
ref_y_cancel = [1 - (0.3) * (2**-x) for x in ref_x]

line_one = mlines.Line2D(ref_x, ref_y_one, color='black', linestyle='--', linewidth=1)
line_zero = mlines.Line2D(ref_x, ref_y_zero, color='black', linestyle='--', linewidth=1)
line_cancel = mlines.Line2D(ref_x, ref_y_cancel, color='black', linestyle='-.', linewidth=1)
ax.add_line(line_one)
ax.add_line(line_zero)
ax.add_line(line_cancel)


Out[10]:
<matplotlib.lines.Line2D at 0x7f552810c198>

In [7]:
from titanfp import bench

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
fig.set_size_inches(8, 5.5)


for e in range(5):
    pts = []
    for i in range(10000):
        a_hi, a_lo = bench.gen_input(0, 24, 11)
        b_hi, b_lo = bench.gen_input(e, 24, 11)
        dif, logdif, sdif, logsdif = bench.bitsim(a_hi, b_hi)
        pts.append(logdif)
    
    xs = sorted(pts)
    ys = []

    count = 0
    for x in xs:
        count += 1
        ys.append(count / len(pts))

    ax.plot(xs, ys)