Ejemplo n.º 1
0
    def __init__(self,
                 precision=ML_Binary32,
                 accuracy=ML_Faithful,
                 libm_compliant=True,
                 debug_flag=False,
                 fuse_fma=True,
                 fast_path_extract=True,
                 processor=GenericProcessor(),
                 output_file="cosf.c",
                 function_name="cosf",
                 input_interval=Interval(0, 1),
                 result_precision=ML_Binary32,
                 table_size_log=8,
                 cos_output=True):
        # initializing I/O precision
        io_precisions = [result_precision, precision]

        # initializing base class
        ML_FunctionBasis.__init__(self,
                                  base_name="cos",
                                  function_name=function_name,
                                  output_file=output_file,
                                  io_precisions=io_precisions,
                                  abs_accuracy=None,
                                  libm_compliant=libm_compliant,
                                  processor=processor,
                                  fuse_fma=fuse_fma,
                                  fast_path_extract=fast_path_extract,
                                  debug_flag=debug_flag)
        self.precision = precision
        self.cos_output = cos_output
        self.accuracy = accuracy
        self.input_interval = input_interval
        self.table_size_log = table_size_log
Ejemplo n.º 2
0
    def __init__(self,
                 arg_template=DefaultArgTemplate,
                 precision=ML_Binary32,
                 abs_accuracy=S2**-24,
                 libm_compliant=True,
                 debug_flag=False,
                 fuse_fma=True,
                 fast_path_extract=True,
                 target=GenericProcessor(),
                 output_file="log2f.c",
                 function_name="log2f"):
        # extracting precision argument from command line
        precision = ArgDefault.select_value(
            [arg_template.precision, precision])
        io_precisions = [precision] * 2

        # initializing base class
        ML_FunctionBasis.__init__(self,
                                  base_name="log2",
                                  function_name=function_name,
                                  output_file=output_file,
                                  io_precisions=io_precisions,
                                  abs_accuracy=None,
                                  libm_compliant=libm_compliant,
                                  processor=target,
                                  fuse_fma=fuse_fma,
                                  fast_path_extract=fast_path_extract,
                                  debug_flag=debug_flag,
                                  arg_template=arg_template)

        self.precision = precision
Ejemplo n.º 3
0
    def __init__(self,
                 arg_template=DefaultArgTemplate,
                 precision=ML_Binary32,
                 accuracy=ML_Faithful,
                 libm_compliant=True,
                 debug_flag=False,
                 fuse_fma=True,
                 fast_path_extract=True,
                 target=GenericProcessor(),
                 output_file="my_empty.c",
                 function_name="my_empty",
                 language=C_Code,
                 vector_size=1):
        # initializing I/O precision
        precision = ArgDefault.select_value(
            [arg_template.precision, precision])
        io_precisions = [precision] * 2

        # initializing base class
        ML_FunctionBasis.__init__(self,
                                  base_name="empty",
                                  function_name=function_name,
                                  output_file=output_file,
                                  io_precisions=io_precisions,
                                  abs_accuracy=None,
                                  libm_compliant=libm_compliant,
                                  processor=target,
                                  fuse_fma=fuse_fma,
                                  fast_path_extract=fast_path_extract,
                                  debug_flag=debug_flag,
                                  language=language,
                                  vector_size=vector_size,
                                  arg_template=arg_template)

        self.precision = precision
Ejemplo n.º 4
0
  def __init__(self, 
             precision = ML_Binary32, 
             abs_accuracy = S2**-24, 
             libm_compliant = True, 
             debug_flag = False, 
             fuse_fma = True, 
             fast_path_extract = True,
             target = GenericProcessor(), 
             output_file = None, 
             function_name = None):

    io_precisions = [precision] * 2

    # initializing base class
    ML_FunctionBasis.__init__(self, 
      base_name = "acos",
      function_name = function_name,
      output_file = output_file,

      io_precisions = io_precisions,
      abs_accuracy = None,
      libm_compliant = libm_compliant,

      processor = target,
      fuse_fma = fuse_fma,
      fast_path_extract = fast_path_extract,

      debug_flag = debug_flag
    )

    self.precision = precision
Ejemplo n.º 5
0
    def __init__(self, 
                 base_name = "sincospi",
                 name=None,
                 output_file = None,
                 io_precision = ML_Binary32, 
                 libm_compliant = True, 
                 processor = GenericProcessor(), 
                 fuse_fma = True, 
                 fast_path_extract = True,
                 debug_flag = False
             ):
        # declaring CodeFunction and retrieving input variable
        ML_Function.__init__(self,
                             base_name = base_name,
                             name=name,
                             output_file = name,
                             io_precision = io_precision,
                             libm_compliant = libm_compliant,
                             processor=processor,
                             fuse_fma = fuse_fma,
                             fast_path_extract = fast_path_extract,
                             debug_flag = debug_flag)

        # main scheme
        Log.report(Log.Info, "Construction of the initial evaluation scheme")

        vx = self.implementation.add_input_variable("x", self.io_precision) 
        self.evalScheme = Statement(Return(vx))

        self.opt_engine.optimization_process(self.evalScheme, self.io_precision)
        self.generate_C()
Ejemplo n.º 6
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for MetaAtan,
             builtin from a default argument mapping overloaded with @p kw
     """
     default_args_rootn = {
         "output_file":
         "rootn.c",
         "function_name":
         "rootn",
         "input_precisions": [ML_Binary32, ML_Int32],
         "accuracy":
         ML_Faithful,
         "input_intervals": [
             sollya.Interval(-2.0**126, 2.0**126),
             sollya.Interval(-2**24, 2**24)
         ],
         "auto_test_range": [
             sollya.Interval(-2.0**126, 2.0**126),
             sollya.Interval(-2**24, 2**24)
         ],
         "target":
         GenericProcessor.get_target_instance(),
         "expand_div":
         False,
     }
     default_args_rootn.update(kw)
     return DefaultArgTemplate(**default_args_rootn)
Ejemplo n.º 7
0
 def get_default_args(**args):
     """ Generate a default argument structure set specifically for
         the Hyperbolic Cosine """
     default_div_args = {
         "precision":
         ML_Binary32,
         "accuracy":
         ML_CorrectlyRounded,
         "target":
         GenericProcessor.get_target_instance(),
         "output_file":
         "my_div.c",
         "function_name":
         "my_div",
         "input_intervals": [DefaultArgTemplate.input_intervals[0]] * 2,
         "auto_test_range":
         DefaultArgTemplate.auto_test_range * 2,
         "bench_test_range":
         DefaultArgTemplate.bench_test_range * 2,
         "language":
         C_Code,
         "num_iter":
         3,
         "passes": [
             "typing:basic_legalization",
             "beforecodegen:expand_multi_precision"
         ],
         "vector_size":
         1,
     }
     default_div_args.update(args)
     return DefaultArgTemplate(**default_div_args)
Ejemplo n.º 8
0
 def get_default_args(**kw):
   """ Return a structure containing the arguments for ML_Cosine,
       builtin from a default argument mapping overloaded with @p kw """
   default_args_cos = {
       "output_file": "my_cosf.c",
       "function_name": "my_cosf",
       "precision": ML_Binary32,
       "accuracy": ML_Faithful,
       "target": GenericProcessor()
Ejemplo n.º 9
0
 def __init__(self,
              precision=ML_Binary32,
              abs_accuracy=S2**-24,
              libm_compliant=True,
              debug_flag=False,
              fuse_fma=True,
              fast_path_extract=True,
              target=GenericProcessor(),
              output_file="empty.c",
              function_name="empty"):
     pass
Ejemplo n.º 10
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_HyperbolicSine,
             builtin from a default argument mapping overloaded with @p kw """
     default_args_sinh = {
             "output_file": "my_sinh.c",
             "function_name": "my_sinh",
             "precision": ML_Binary32,
             "accuracy": ML_Faithful,
             "target": GenericProcessor.get_target_instance()
     }
     default_args_sinh.update(kw)
     return DefaultArgTemplate(**default_args_sinh)
Ejemplo n.º 11
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_Exponential,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_exp = {
         "output_file": "ml_exp.c",
         "function_name": "ml_exp",
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor()
     }
     default_args_exp.update(kw)
     return DefaultArgTemplate(**default_args_exp)
Ejemplo n.º 12
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_GenericLog,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_log = {
         "output_file": "ml_genlog.c",
         "function_name": "ml_genlog",
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor(),
         "basis": exp(1),
     }
     default_args_log.update(kw)
     return DefaultArgTemplate(**default_args_log)
Ejemplo n.º 13
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for MetalibmSqrt,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_sqrt = {
         "output_file": "my_sqrtf.c",
         "function_name": "my_sqrtf",
         "num_iter": 3,
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor()
     }
     default_args_sqrt.update(kw)
     return DefaultArgTemplate(**default_args_sqrt)
Ejemplo n.º 14
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_ExternalBench
     builtin from a default argument mapping overloaded with @p kw """
     default_args_exp = {
         "output_file": "bench.c",
         "function_name": "external_bench_wrapper",
         "extra_src_files": [],
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor.get_target_instance()
     }
     default_args_exp.update(kw)
     return DefaultMultiAryArgTemplate(**default_args_exp)
Ejemplo n.º 15
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for MetaFMOD,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_exp = {
         "output_file": "ml_fmod.c",
         "function_name": "ml_fmod",
         "input_intervals": (Interval(-100, 100), Interval(-100, 100)),
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor.get_target_instance(),
     }
     default_args_exp.update(kw)
     return DefaultArgTemplate(**default_args_exp)
Ejemplo n.º 16
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_SoftMax,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_exp = {
         "output_file": "ml_softmax.c",
         "function_name": "ml_softmax",
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "use_libm_function": False,
         "target": GenericProcessor.get_target_instance()
     }
     default_args_exp.update(kw)
     return DefaultArrayFunctionArgTemplate(**default_args_exp)
Ejemplo n.º 17
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_ImplementPoly """
     default_args_log = {
         "output_file": "POLY.c",
         "function_name": "POLY",
         "precision": ML_Binary64,
         "target": GenericProcessor(),
         "function": None,
         "interval": None,
         "epsilon": None
     }
     default_args_log.update(kw)
     return DefaultArgTemplate(**default_args_log)
Ejemplo n.º 18
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_Log1p,
             builtin from a default argument mapping overloaded with @p kw """
     default_args_log1p = {
             "output_file": "my_log1p.c",
             "function_name": "my_log1pf",
             "precision": ML_Binary32,
             "accuracy": ML_Faithful,
             "target": GenericProcessor.get_target_instance(),
             "passes": [("start:instantiate_abstract_prec"), ("start:instantiate_prec"), ("start:basic_legalization"), ("start:expand_multi_precision")],
     }
     default_args_log1p.update(kw)
     return DefaultArgTemplate(**default_args_log1p)
Ejemplo n.º 19
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_SinCos,
     builtin from a default argument mapping overloaded with @p kw """
     default_args_sincos = {
         "output_file": "my_sincos.c",
         "function_name": "my_sincos",
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor(),
         "sin_output": False
     }
     default_args_sincos.update(kw)
     return DefaultArgTemplate(**default_args_sincos)
Ejemplo n.º 20
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for MetalibmSqrt,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_fast_exp2i = {
         "output_file": "fast_expi.c",
         "function_name": "fast_expi",
         "input_precisions": [ML_Int32],
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor.get_target_instance()
     }
     default_args_fast_exp2i.update(kw)
     return DefaultArgTemplate(**default_args_fast_exp2i)
Ejemplo n.º 21
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for FunctionExpression,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_log = {
         "output_file": "func_expr.c",
         "function_name": "func_expr",
         "function_expr_str": "exp(x)",
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "expand_div": False,
         "target": GenericProcessor.get_target_instance(),
     }
     default_args_log.update(kw)
     return DefaultArgTemplate(**default_args_log)
Ejemplo n.º 22
0
 def get_default_args(**args):
     """ Generate a default argument structure set specifically for
     the Hyperbolic Cosine """
     default_cosh_args = {
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor.get_target_instance(),
         "output_file": "my_cosh.c",
         "function_name": "my_cosh",
         "language": C_Code,
         "vector_size": 1
     }
     default_cosh_args.update(args)
     return DefaultArgTemplate(**default_cosh_args)
Ejemplo n.º 23
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_Exponential,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_mmk = {
         "output_file": "mm_kernel.c",
         "function_name": "mm_kernel",
         "test_index_range": [[16, 32], [16, 32], [16, 32]],
         "auto_test_range": [Interval(-1, 1), Interval(-1, 1)],
         "vectorize": False,
         "precision": ML_Binary32,
         "target": GenericProcessor.get_target_instance()
     }
     default_args_mmk.update(kw)
     return DefaultArgTemplate(**default_args_mmk)
Ejemplo n.º 24
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for current class,
     builtin from a default argument mapping overloaded with @p kw """
     default_args = {
         "output_file": "ut_fuse_fma.c",
         "function_name": "ut_fuse_fma",
         "target": GenericProcessor.get_target_instance(),
         "fast_path_extract": True,
         "fuse_fma": True,
         "libm_compliant": True,
         "precision": ML_Binary32,
     }
     default_args.update(kw)
     return DefaultArgTemplate(**default_args)
Ejemplo n.º 25
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for MetaAtan,
             builtin from a default argument mapping overloaded with @p kw
     """
     default_args_pow = {
         "output_file": "ml_pow.c",
         "function_name": "ml_pow",
         "input_precisions": [ML_Binary32, ML_Binary32],
         "accuracy": ML_Faithful,
         "input_intervals": [None, Interval(-2**24, 2**24)], # sollya.Interval(-2.0**126, 2.0**126), sollya.Interval(0, 2**31-1)],
         "auto_test_range": [None, Interval(-2**24, 2**24)], # sollya.Interval(-2.0**126, 2.0**126), sollya.Interval(0, 47)],
         "target": GenericProcessor.get_target_instance()
     }
     default_args_pow.update(kw)
     return DefaultArgTemplate(**default_args_pow)
Ejemplo n.º 26
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for current class,
         builtin from a default argument mapping overloaded with @p kw
     """
     default_args = {
             "output_file": "ut_mp_vectorization.c",
             "function_name": "ut_mp_vectorization",
             "precision": ML_DoubleDouble,
             "target": GenericProcessor.get_target_instance(),
             "fast_path_extract": True,
             "fuse_fma": True,
             "passes": ["start:basic_legalization", "start:expand_multi_precision"],
             "libm_compliant": True
     }
     default_args.update(kw)
     return DefaultArgTemplate(**default_args)
Ejemplo n.º 27
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for current class,
             builtin from a default argument mapping overloaded with @p kw """
     default_args = {
             "precision": ML_Int32,
             "target": GenericProcessor.get_target_instance(),
             "bench_test_number": 10,
             "execute_trigger": True,
             "embedded_bin": False,
             "function_name": "ml_ut_embedded_bin",
             "bench_test_range": DefaultMultiAryArgTemplate.bench_test_range * 2,
             "auto_test_range": DefaultMultiAryArgTemplate.auto_test_range * 2,
             "arity": 2
     }
     default_args.update(kw)
     return DefaultMultiAryArgTemplate(**default_args)
Ejemplo n.º 28
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for ML_VectorialFunction,
         builtin from a default argument mapping overloaded with @p kw """
     default_args_exp = {
         "output_file": "ml_vectorial_function.c",
         "function_name": "ml_vectorial_function",
         "function_ctor": ML_Exponential,
         "use_libm_function": False,
         "scalar_emulate": sollya.exp,
         "multi_elt_num": 1,
         "precision": ML_Binary32,
         "accuracy": ML_Faithful,
         "target": GenericProcessor.get_target_instance()
     }
     default_args_exp.update(kw)
     return DefaultArrayFunctionArgTemplate(**default_args_exp)
Ejemplo n.º 29
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for current class,
             builtin from a default argument mapping overloaded with @p kw """
     default_args = {
         "output_file": "ut_multi_precision.c",
         "function_name": "ut_multi_precision",
         "precision": ML_Binary32,
         "target": GenericProcessor(),
         "language": C_Code,
         "arity": 2,
         "input_precisions": [ML_Binary32, ML_Binary32],
         "fast_path_extract": True,
         "fuse_fma": False,
         "libm_compliant": True
     }
     default_args.update(kw)
     return DefaultArgTemplate(**default_args)
Ejemplo n.º 30
0
 def get_default_args(**kw):
     """ Return a structure containing the arguments for current class,
         builtin from a default argument mapping overloaded with @p kw """
     default_args = {
         "output_file": "ut_legalize_sqrt.c",
         "function_name": "ut_legalize_sqrt",
         "precision": ML_Binary32,
         "target": GenericProcessor(),
         "fast_path_extract": True,
         "fuse_fma": True,
         "debug": True,
         "libm_compliant": True,
         "test_range": Interval(S2**-8, S2**8),
         "accuracy": dar(S2**-7),
     }
     default_args.update(kw)
     return DefaultArgTemplate(**default_args)