Beispiel #1
0
        sub_computation2, ext_function2 = self.externalize_call(
            sub_computation2, [vx, sub_computation])

        result = Return(sub_computation2)

        # dummy scheme to make functionnal code generation
        scheme = Statement(result)
        self.implementation.set_scheme(scheme)

        return [ext_function, ext_function2, self.implementation]


if __name__ == "__main__":
    # auto-test
    arg_template = ML_ArgTemplate(
        default_function_name="new_ut_call_externalization",
        default_output_file="new_ut_call_externalization.c")
    arg_template.sys_arg_extraction()

    ml_ut_call_externalization = ML_UT_CallExternaliation(
        arg_template.precision,
        libm_compliant=arg_template.libm_compliant,
        debug_flag=arg_template.debug_flag,
        target=arg_template.target,
        fuse_fma=arg_template.fuse_fma,
        fast_path_extract=arg_template.fast_path,
        function_name=arg_template.function_name,
        output_file=arg_template.output_file)

    ml_ut_call_externalization.gen_implementation(display_after_gen=False,
                                                  display_after_opt=False)
Beispiel #2
0
    #  log_inv_hi: Variable("log_inv_hi", precision = self.precision, interval = table_high_interval),
    #  log_inv_lo: Variable("log_inv_lo", precision = self.precision, interval = table_low_interval),
    #}
    # computing gappa error
    #poly_eval_error = self.get_eval_error(result, eval_error_map)



    # main scheme
    print "MDL scheme"
    scheme = Statement(Return(vx))
    return scheme



if __name__ == "__main__":
  # auto-test
  arg_template = ML_ArgTemplate(default_function_name = "new_acos", default_output_file = "new_acos.c" )
  arg_template.sys_arg_extraction()


  ml_acos          = ML_Acos(arg_template.precision, 
                                libm_compliant            = arg_template.libm_compliant, 
                                debug_flag                = arg_template.debug_flag, 
                                target                    = arg_template.target, 
                                fuse_fma                  = arg_template.fuse_fma, 
                                fast_path_extract         = arg_template.fast_path,
                                function_name             = arg_template.function_name,
                                output_file               = arg_template.output_file)
  ml_acos.gen_implementation()
Beispiel #3
0
            computation_precision,  # ML_Custom_FixedPoint_Format(5, 26, signed = True)
            tag="sin_P_cos_u_P_C2_u2_sin")

        scheme = Addition(
            sin_P_cos_u_P_C2_u2_sin,
            S2_u3_cos,
            precision=
            computation_precision  # ML_Custom_FixedPoint_Format(5, 26, signed = True)
        )

        return scheme


if __name__ == "__main__":
    # auto-test
    arg_template = ML_ArgTemplate(default_function_name="new_fastsincos",
                                  default_output_file="new_fastsincos.c")
    # argument extraction
    cos_output = arg_template.test_flag_option(
        "--sin",
        False,
        True,
        parse_arg=arg_template.parse_arg,
        help_str="select cos output")
    enable_subexpr_sharing = arg_template.test_flag_option(
        "--enable-subexpr-sharing",
        True,
        False,
        parse_arg=arg_template.parse_arg,
        help_str="force subexpression sharing")
    table_size_log = arg_template.extract_option_value(
        "--table-size-log",
Beispiel #4
0
                            declare_cst=False,
                            disable_debug=not debug_flag,
                            libm_compliant=libm_compliant)
        self.result = func_implementation.get_definition(cg,
                                                         C_Code,
                                                         static_cst=True)
        self.result.add_header("support_lib/ml_special_values.h")
        self.result.add_header("math.h")
        self.result.add_header("stdio.h")
        self.result.add_header("inttypes.h")
        #print self.result.get(cg)
        output_stream = open("%s.c" % func_implementation.get_name(), "w")
        output_stream.write(self.result.get(cg))
        output_stream.close()


if __name__ == "__main__":
    # auto-test
    arg_template = ML_ArgTemplate(default_function_name="log_fixed",
                                  default_output_file="log_fixed.c")
    arg_template.sys_arg_extraction()

    ml_log = ML_Logarithm(precision=arg_template.precision,
                          libm_compliant=arg_template.libm_compliant,
                          debug_flag=arg_template.debug_flag,
                          target=arg_template.target,
                          fuse_fma=arg_template.fuse_fma,
                          fast_path_extract=arg_template.fast_path,
                          function_name=arg_template.function_name,
                          output_file=arg_template.output_file)
Beispiel #5
0
                                                         k=k,
                                                         n=100)
        C32 = Constant(32, precision=int_precision)
        red_int_f = Conversion(Select(
            red_int < Constant(0, precision=int_precision), red_int + C32,
            red_int),
                               precision=self.precision)

        scheme = Statement(red_stat, Return(red_vx + red_int_f))

        return scheme


if __name__ == "__main__":
    # auto-test
    arg_template = ML_ArgTemplate(default_function_name="new_ut_payne_hanek",
                                  default_output_file="new_ut_payne_hanek.c")
    arg_template.sys_arg_extraction()

    ml_ut_payne_hanek = ML_UT_PayneHanek(
        arg_template.precision,
        libm_compliant=arg_template.libm_compliant,
        debug_flag=arg_template.debug_flag,
        target=arg_template.target,
        fuse_fma=arg_template.fuse_fma,
        fast_path_extract=arg_template.fast_path,
        function_name=arg_template.function_name,
        output_file=arg_template.output_file)

    ml_ut_payne_hanek.gen_implementation(display_after_gen=False,
                                         display_after_opt=False)
Beispiel #6
0
        # which is a dict indexed by the goals' tag
        gappa_result = execute_gappa_script_extract(
            gappa_code.get(self.gappa_engine))

        print "eval error: ", gappa_result["goal"], gappa_result["new_goal"]

        # dummy scheme to make functionnal code generation
        scheme = Statement(Return(vx))

        return scheme


if __name__ == "__main__":
    # auto-test
    arg_template = ML_ArgTemplate(
        default_function_name="new_ut_loop_operation",
        default_output_file="new_ut_loop_operation.c")
    arg_template.sys_arg_extraction()

    ml_ut_gappa_code = ML_UT_GappaCode(
        arg_template.precision,
        libm_compliant=arg_template.libm_compliant,
        debug_flag=arg_template.debug_flag,
        target=arg_template.target,
        fuse_fma=arg_template.fuse_fma,
        fast_path_extract=arg_template.fast_path,
        function_name=arg_template.function_name,
        output_file=arg_template.output_file)

    ml_ut_gappa_code.gen_implementation(display_after_gen=False,
                                        display_after_opt=False)
Beispiel #7
0
                           specifier=Comparison.GreaterOrEqual,
                           likely=True)

        exp0 = vx
        exp1 = vx + vx * vx + Constant(1, precision=self.precision)
        exp2 = vx * vx * vx
        scheme = Statement(
            ConditionBlock(cond0, Return(exp0),
                           ConditionBlock(cond1, Return(exp1), Return(exp2))))

        return scheme


if __name__ == "__main__":
    # auto-test
    arg_template = ML_ArgTemplate(default_function_name="new_ut_opencl_code",
                                  default_output_file="new_ut_opencl_code.c")
    arg_template.sys_arg_extraction()

    ml_ut_opencl_code = ML_UT_OpenCLCode(
        arg_template.precision,
        libm_compliant=arg_template.libm_compliant,
        debug_flag=arg_template.debug_flag,
        target=arg_template.target,
        fuse_fma=arg_template.fuse_fma,
        fast_path_extract=arg_template.fast_path,
        function_name=arg_template.function_name,
        output_file=arg_template.output_file,
        vector_size=arg_template.vector_size,
        language=arg_template.language)

    ml_ut_opencl_code.gen_implementation(
Beispiel #8
0
                             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()


if __name__ == "__main__":
    # auto-test
    arg_template = ML_ArgTemplate(default_function_name = "sincospi", default_output_file = "sincospi.c" )
    arg_template.sys_arg_extraction()
    ml_sincospi     = ML_SinCospi(base_name                 = arg_template.function_name,
                                  io_precision              = arg_template.precision, 
                                  libm_compliant            = arg_template.libm_compliant, 
                                  debug_flag                = arg_template.debug_flag, 
                                  processor                 = arg_template.target,  # TODO rename target into processor 
                                  fuse_fma                  = arg_template.fuse_fma, 
                                  fast_path_extract         = arg_template.fast_path,
                                  output_file               = arg_template.output_file
    )
Beispiel #9
0
        lar_result = SwitchBlock(lar_modk, lar_switch_map)

        # main scheme
        #Log.report(Log.Info, "\033[33;1m MDL scheme \033[0m")
        # scheme = Statement(ConditionBlock(cond, lar_result, result))

        Log.report(Log.Info, "Construction of the initial MDL scheme")
        scheme = Statement(pre_red_vx_d, red_vx_lo_sub,
                           ConditionBlock(cond, lar_result, result))

        return scheme


if __name__ == "__main__":
    # auto-test
    arg_template = ML_ArgTemplate(default_function_name="new_cos",
                                  default_output_file="new_cos.c")
    # argument extraction
    parse_arg_index_list = arg_template.sys_arg_extraction()
    arg_template.check_args(parse_arg_index_list)

    ml_cos = ML_Cosine(arg_template.precision,
                       libm_compliant=arg_template.libm_compliant,
                       debug_flag=arg_template.debug_flag,
                       target=arg_template.target,
                       fuse_fma=arg_template.fuse_fma,
                       fast_path_extract=arg_template.fast_path,
                       function_name=arg_template.function_name,
                       accuracy=arg_template.accuracy,
                       output_file=arg_template.output_file)
    ml_cos.gen_implementation()