From f86d73ceb320796a320498f15c48c6306a1f3eae Mon Sep 17 00:00:00 2001 From: KimNayoung <skdud1201@ajou.ac.kr> Date: Sat, 5 Feb 2022 02:07:12 +0900 Subject: [PATCH] project --- extra/fx_head.h | 79 ++++++++++++++++ extra/fx_s17_14.c | 104 +++++++++++++++++++++ extra/fx_s17_14.h | 37 ++++++++ extra/practice.c | 48 ++++++++++ extra/result.txt | 156 ++++++++++++++++++++++++++++++++ extra/test | Bin 0 -> 13752 bytes extra/test.c | 36 ++++++++ fx_s17_14/Makefile | 17 ++++ fx_s17_14/fx_head.h | 79 ++++++++++++++++ fx_s17_14/fx_s17_14.c | 104 +++++++++++++++++++++ fx_s17_14/fx_s17_14.h | 37 ++++++++ fx_s17_14/project_main.c | 77 ++++++++++++++++ overflow/fx_head.h | 79 ++++++++++++++++ overflow/fx_s17_14.c | 104 +++++++++++++++++++++ overflow/fx_s17_14.h | 37 ++++++++ overflow/testcodemul.c | 22 +++++ precisiontest/fx_head.h | 79 ++++++++++++++++ precisiontest/fx_s17_14.c | 104 +++++++++++++++++++++ precisiontest/fx_s17_14.h | 37 ++++++++ precisiontest/testcodediv.c | 21 +++++ precisiontest/testcodemul.c | 21 +++++ speedtest/fx_head.h | 79 ++++++++++++++++ speedtest/fx_s17_14.c | 104 +++++++++++++++++++++ speedtest/fx_s17_14.h | 37 ++++++++ speedtest/testcodediv.c | 22 +++++ speedtest/testcodediv.txt | 162 +++++++++++++++++++++++++++++++++ speedtest/testcodemul.c | 22 +++++ speedtest/testcodemul.txt | 162 +++++++++++++++++++++++++++++++++ speedtest/testdiv_32.txt | 175 ++++++++++++++++++++++++++++++++++++ speedtest/testdiv_64.txt | 162 +++++++++++++++++++++++++++++++++ speedtest/testmul_32.txt | 162 +++++++++++++++++++++++++++++++++ speedtest/testmul_64.txt | 162 +++++++++++++++++++++++++++++++++ 32 files changed, 2527 insertions(+) create mode 100644 extra/fx_head.h create mode 100644 extra/fx_s17_14.c create mode 100644 extra/fx_s17_14.h create mode 100644 extra/practice.c create mode 100644 extra/result.txt create mode 100755 extra/test create mode 100644 extra/test.c create mode 100644 fx_s17_14/Makefile create mode 100644 fx_s17_14/fx_head.h create mode 100644 fx_s17_14/fx_s17_14.c create mode 100644 fx_s17_14/fx_s17_14.h create mode 100644 fx_s17_14/project_main.c create mode 100644 overflow/fx_head.h create mode 100644 overflow/fx_s17_14.c create mode 100644 overflow/fx_s17_14.h create mode 100644 overflow/testcodemul.c create mode 100644 precisiontest/fx_head.h create mode 100644 precisiontest/fx_s17_14.c create mode 100644 precisiontest/fx_s17_14.h create mode 100644 precisiontest/testcodediv.c create mode 100644 precisiontest/testcodemul.c create mode 100644 speedtest/fx_head.h create mode 100644 speedtest/fx_s17_14.c create mode 100644 speedtest/fx_s17_14.h create mode 100644 speedtest/testcodediv.c create mode 100644 speedtest/testcodediv.txt create mode 100644 speedtest/testcodemul.c create mode 100644 speedtest/testcodemul.txt create mode 100644 speedtest/testdiv_32.txt create mode 100644 speedtest/testdiv_64.txt create mode 100644 speedtest/testmul_32.txt create mode 100644 speedtest/testmul_64.txt diff --git a/extra/fx_head.h b/extra/fx_head.h new file mode 100644 index 0000000..6d9bd26 --- /dev/null +++ b/extra/fx_head.h @@ -0,0 +1,79 @@ +#pragma once + +// Fixed with signed long long +#define FX_S28_35 ((1<<16) | (28<<8) | (35)) +#define FX_S29_34 ((1<<16) | (29<<8) | (34)) +#define FX_S30_33 ((1<<16) | (30<<8) | (33)) +#define FX_S31_32 ((1<<16) | (31<<8) | (32)) +#define FX_S32_31 ((1<<16) | (32<<8) | (31)) +#define FX_S33_30 ((1<<16) | (33<<8) | (30)) +#define FX_S34_29 ((1<<16) | (34<<8) | (29)) +#define FX_S35_28 ((1<<16) | (35<<8) | (28)) +// Fixed with unsigned long long +#define FX_U29_35 ((0<<16) | (29<<8) | (35)) +#define FX_U30_34 ((0<<16) | (30<<8) | (34)) +#define FX_U31_33 ((0<<16) | (31<<8) | (33)) +#define FX_U32_32 ((0<<16) | (32<<8) | (32)) +#define FX_U33_31 ((0<<16) | (33<<8) | (31)) +#define FX_U34_30 ((0<<16) | (34<<8) | (30)) +#define FX_U35_29 ((0<<16) | (35<<8) | (29)) +#define FX_U36_28 ((0<<16) | (36<<8) | (28)) +// Fixed with signed int +#define FX_S12_19 ((1<<16) | (12<<8) | (19)) +#define FX_S13_18 ((1<<16) | (13<<8) | (18)) +#define FX_S14_17 ((1<<16) | (14<<8) | (17)) +#define FX_S15_16 ((1<<16) | (15<<8) | (16)) +#define FX_S16_15 ((1<<16) | (16<<8) | (15)) +#define FX_S17_14 ((1<<16) | (17<<8) | (14)) +#define FX_S18_13 ((1<<16) | (18<<8) | (13)) +#define FX_S19_12 ((1<<16) | (19<<8) | (12)) +// Fixed with unsigned int +#define FX_S13_19 ((0<<16) | (13<<8) | (19)) +#define FX_S14_18 ((0<<16) | (14<<8) | (18)) +#define FX_S15_17 ((0<<16) | (15<<8) | (17)) +#define FX_S16_16 ((0<<16) | (16<<8) | (16)) +#define FX_S17_15 ((0<<16) | (17<<8) | (15)) +#define FX_S18_14 ((0<<16) | (18<<8) | (14)) +#define FX_S19_13 ((0<<16) | (19<<8) | (13)) +#define FX_S20_12 ((0<<16) | (20<<8) | (12)) +// Fixed with signed short +#define FX_S04_11 ((1<<16) | (4<<8) | (11)) +#define FX_S05_10 ((1<<16) | (5<<8) | (10)) +#define FX_S06_09 ((1<<16) | (6<<8) | (9)) +#define FX_S07_08 ((1<<16) | (7<<8) | (8)) +#define FX_S08_07 ((1<<16) | (8<<8) | (7)) +#define FX_S09_06 ((1<<16) | (9<<8) | (6)) +#define FX_S10_05 ((1<<16) | (10<<8) | (5)) +#define FX_S11_04 ((1<<16) | (11<<8) | (4)) +// Fixed with unsigned short +#define FX_S05_11 ((0<<16) | (5<<8) | (11)) +#define FX_S06_10 ((0<<16) | (6<<8) | (10)) +#define FX_S07_09 ((0<<16) | (7<<8) | (9)) +#define FX_S08_08 ((0<<16) | (8<<8) | (8)) +#define FX_S09_07 ((0<<16) | (9<<8) | (7)) +#define FX_S10_06 ((0<<16) | (10<<8) | (6)) +#define FX_S11_05 ((0<<16) | (11<<8) | (5)) +#define FX_S12_04 ((0<<16) | (12<<8) | (4)) +// Fixed with signed char +#define FX_S00_07 ((1<<16) | (0<<8) | (7)) +#define FX_S01_06 ((1<<16) | (1<<8) | (6)) +#define FX_S02_05 ((1<<16) | (2<<8) | (5)) +#define FX_S03_04 ((1<<16) | (3<<8) | (4)) +#define FX_S04_03 ((1<<16) | (4<<8) | (3)) +#define FX_S05_02 ((1<<16) | (5<<8) | (2)) +#define FX_S06_01 ((1<<16) | (6<<8) | (1)) +// #define FX_S07_00 ((1<<16) | (7<<8) | (0)) // It is same as unsigned char +// Fixed with unsigned char +#define FX_S00_08 ((0<<16) | (0<<8) | (8)) +#define FX_S01_07 ((0<<16) | (1<<8) | (7)) +#define FX_S02_06 ((0<<16) | (2<<8) | (6)) +#define FX_S03_05 ((0<<16) | (3<<8) | (5)) +#define FX_S04_04 ((0<<16) | (4<<8) | (4)) +#define FX_S05_03 ((0<<16) | (5<<8) | (3)) +#define FX_S06_02 ((0<<16) | (6<<8) | (2)) +#define FX_S07_01 ((0<<16) | (7<<8) | (1)) +// Operation Preference +#define FX_OP_FLOAT 1 +#define FX_OP_PRECISION 2 +#define FX_OP_FAIR 3 +#define FX_OP_PERFORMANCE 4 diff --git a/extra/fx_s17_14.c b/extra/fx_s17_14.c new file mode 100644 index 0000000..88bf98c --- /dev/null +++ b/extra/fx_s17_14.c @@ -0,0 +1,104 @@ +#include "fx_head.h" +#include "fx_s17_14.h" + +#define fxADD(a,b) ((a)+(b)) +#define fxSUB(a,b) ((a)-(b)) +#define FX_Q_NUM_H (FX_Q_NUM/2) +#define FX_Q_NUM_HA (FX_Q_NUM_H-FX_Q_NUM_H/2) +#define FX_Q_NUM_HB (FX_Q_NUM_H/2) +/* +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); +*/ + +// float function +fixed fxAdd_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) + toDouble(b)); +} + +fixed fxSub_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) - toDouble(b)); +} + +fixed fxMul_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) * toDouble(b)); +} + +fixed fxDiv_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) / toDouble(b)); +} + +// precision function +fixed fxAdd_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) + toFloat(b)); +} + +fixed fxSub_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) - toFloat(b)); +} + +fixed fxMul_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la * lb) >> FX_Q_NUM; +} + +fixed fxDiv_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la << FX_Q_NUM) / lb; +} + +// fair function +fixed fxAdd_fair(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_fair(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la >> FX_Q_NUM_HA) * (lb >> FX_Q_NUM_HB)) >> FX_Q_NUM_H; +} + +fixed fxDiv_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / lb) << FX_Q_NUM_H; +} + +// performance function +fixed fxAdd_performance(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_performance(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la>>FX_Q_NUM_H)*(lb>>FX_Q_NUM_H); +} + +fixed fxDiv_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / (lb >> FX_Q_NUM_H)); +} diff --git a/extra/fx_s17_14.h b/extra/fx_s17_14.h new file mode 100644 index 0000000..c7900f1 --- /dev/null +++ b/extra/fx_s17_14.h @@ -0,0 +1,37 @@ +#include "fx_head.h" +#include <math.h> + +#define FX_POINT FX_S17_14 + +#define FX_Q_NUM (FX_POINT & 0xFF) // 14 + +// If you want calculate with high precision set 64 +#define FX_SYSTEM_INTEGER 64 // 32 or 64 +#define FX_SYSTEM_FLOAT 64 // 32 or 64 + +#define FX_DATA_TYPE signed int + + +typedef int fx_s17_14; +typedef fx_s17_14 fixed; + +#define fromDouble(d) ((fixed)((d)*DOUBLE_Q_VALUE)) +#define toDouble(d) ((double)(d)*DOUBLE_1_Q_VALUE) +#define fromFloat(d) ((fixed)((d)*FLOAT_Q_VALUE)) +#define toFloat(d) ((float)(d)*FLOAT_1_Q_VALUE) + +// CONSTANTS +#define FLOAT_Q_VALUE (float)(1<<FX_Q_NUM) +#define DOUBLE_Q_VALUE (double)(1<<FX_Q_NUM) +#define FLOAT_1_Q_VALUE (float)(1.0f/FLOAT_Q_VALUE) +#define DOUBLE_1_Q_VALUE (double)(1.0f/DOUBLE_Q_VALUE) +#define FX_PI fromDOUBLE(M_PI) + +// One of FX_OP_FLOAT, FX_OP_PRECISION, FX_OP_FAIR, FX_OP_PERFORMANCE +#define FX_OP_PREFERENCE FX_OP_FLOAT + +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); + diff --git a/extra/practice.c b/extra/practice.c new file mode 100644 index 0000000..dbfec7b --- /dev/null +++ b/extra/practice.c @@ -0,0 +1,48 @@ +#include <stdio.h> +// #### #### #### #### . #### #### #### #### +// S 15 . 16 +#define FX_Q_NUM 16 +#define FX_2_MINUS_16 1.52587890625e-05F +#define FX_2_PLUS_16 (1<<16) +#define FX_S_15_16 11516 +#define FX_SYSTEM FX_S_15_16 + +typedef int fixed32; + +fixed32 fromFloat(float fa) +{ + return (fixed32) (fa * FX_2_PLUS_16); +} + +float toFloat(fixed32 xa) +{ + return ((float) (xa)) * FX_2_MINUS_16; +} + +fixed32 fxAdd(fixed32 a, fixed32 b) +{ + return fromFloat(toFloat(a)+toFloat(b)); +} + + +fixed32 fxAdd2(fixed32 a, fixed32 b) +{ + return a+b; +} + +int main() +{ + int i = 0; + int ia, ib, ic, ic2; + float fa; + // fscanf(stdin, "%d %d", &ia, &ib); + for (i = 0; i < 5000000; i++){ + ic = fxAdd(i, i); + ic2 = fxAdd2(i, i); + fprintf(stdout, "%f + %f : %f, %f diff = %d \n", toFloat(i), toFloat(i), toFloat(ic), toFloat(ic2), ic-ic2); + } + + // fprintf(stdout, "%d + %d : %d \n", ia, ib, ic); + // fprintf(stdout, "%f + %f : %f \n", toFloat(ia), toFloat(ib), toFloat(ic)); + // fprintf(stdout, "%d + %d : %d \n", ia, ib, ic); +} diff --git a/extra/result.txt b/extra/result.txt new file mode 100644 index 0000000..e1ba5ce --- /dev/null +++ b/extra/result.txt @@ -0,0 +1,156 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + no time accumulated + + % cumulative self self total + time seconds seconds calls Ts/call Ts/call name + 0.00 0.00 0.00 1 0.00 0.00 fxAdd_float + 0.00 0.00 0.00 1 0.00 0.00 fxDiv_float + 0.00 0.00 0.00 1 0.00 0.00 fxMul_float + 0.00 0.00 0.00 1 0.00 0.00 fxSub_float + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) no time propagated + +index % time self children called name + 0.00 0.00 1/1 main [22] +[1] 0.0 0.00 0.00 1 fxAdd_float [1] +----------------------------------------------- + 0.00 0.00 1/1 main [22] +[2] 0.0 0.00 0.00 1 fxDiv_float [2] +----------------------------------------------- + 0.00 0.00 1/1 main [22] +[3] 0.0 0.00 0.00 1 fxMul_float [3] +----------------------------------------------- + 0.00 0.00 1/1 main [22] +[4] 0.0 0.00 0.00 1 fxSub_float [4] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `<spontaneous>' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [1] fxAdd_float [3] fxMul_float + [2] fxDiv_float [4] fxSub_float diff --git a/extra/test b/extra/test new file mode 100755 index 0000000000000000000000000000000000000000..352edc9e64a61b84fcdcdef71dc95976b37c682e GIT binary patch literal 13752 zcmb<-^>JfjWMqH=W(GS35bpy!M8p9?F;wV584L^z4h$9yoD2>OvJ5f|YzzzxEMPH+ zJWM@|{sA(Kfq?-=b3l|aFhliOFhK;+X&Hzx1B`|m19lrLR1O<eAq^3Q(F_a<U;&VR zkXsvM!CZz0S%^4{o&a^n1}F{F2jYVCO@Qi~0M!ShKY$EoU|@jJF#mzV1cXCC1~4!% zpwli8XE4BMkXn#Xz|)cx5IaH~#A9GUr>{VS8DKO>El4QvX-Nvmogg+bSOBUh2x=d$ zaA|<LA4WsH%b=f=nPg_7pOd1SlbKgqp<7{LrfX)RSDdeB1Wpei^FeCe{X)Suf#Mr# z6j)w_fdQNbK=RA~F3wEY_h{z2Tb}DAH~)EgR>Z{yq?V6?0UX~De<?6DFbXh$#P}H) z7&K*jWYR+uLDqoHM<;eMz+w<pMxTL!K?qd{%;Ux(UWh|n6Nh*;4skae;=wq?vv7#_ z;t;pTA$|=<I7BlrFerh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%%-k*n!JHf`MK>Edy#*<*-*9T2gAoqcc zfc5)fG;ACTBnQGEyFfGyccSTsjSs+R@LUH>F=$=`%7!+p7$E&iNc@7NVB-id8s=Y+ z90<esFnTVU{jl~Xj9v#Dcm!!ivLDK2Sd6A0HZB39IbjN+G`jy+LiNMq4>o=Qqd{Zx zP_1AJ=58<tG~a@zAJ;w!n0j>k_oL~DjfcQ!53~V4bo);-Fo5?Wz?8wpUt#+w(AC5E zFdDRA7_{CQrXMyw+X3BY0#gTbKa3BfA42msOh0TK2DVQHwjTwSK4JP`>1PJi|1kZq z@tOvCh>hs!52hbRze3Xw@1H?4KFl77Y0$w}7zeap2AZc}_QU!q0#N->3a$g)ysuFE z4d5yu448h<{tSo+ganl#AQmzWOM4)37<PbK`~vDxP(1_MGXmwp%TG}HhPfT47es47 gE%rf6a4>s8YCss&O~IzW1hkeER5pSXAz^g=0B7bF$^ZZW literal 0 HcmV?d00001 diff --git a/extra/test.c b/extra/test.c new file mode 100644 index 0000000..a1ca9ca --- /dev/null +++ b/extra/test.c @@ -0,0 +1,36 @@ +#include "fx_s17_14.h" +#include <stdio.h> + +int main() +{ + double a,b; + + fscanf(stdin, "%lf %lf", &a, &b); + + fprintf(stdout, "\n"); + + fprintf(stdout, "fxAdd_float : a + b = %.15lf \n", toDouble(fxAdd_float(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxSub_float : a - b = %.15lf \n", toDouble(fxSub_float(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxMul_float : a * b = %.15lf \n", toDouble(fxMul_float(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxDiv_float : a / b = %.15lf \n", toDouble(fxDiv_float(fromDouble(a), fromDouble(b)))); + + fprintf(stdout, "------------------------------------------- \n"); + fprintf(stdout, "fxAdd_precision : a + b = %.15lf \n", toFloat(fxAdd_precision(fromFloat(a), fromFloat(b)))); + fprintf(stdout, "fxSub_precision : a - b = %.15lf \n", toFloat(fxSub_precision(fromFloat(a), fromFloat(b)))); + fprintf(stdout, "fxMul_precision : a * b = %.15lf \n", toDouble(fxMul_precision(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxDiv_precision : a / b = %.15lf \n", toDouble(fxDiv_precision(fromDouble(a), fromDouble(b)))); + + fprintf(stdout, "------------------------------------------- \n"); + fprintf(stdout, "fxAdd_fair : a + b = %.15lf \n", toDouble(fxAdd_fair(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxSub_fair : a - b = %.15lf \n", toDouble(fxSub_fair(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxMul_fair : a * b = %.15lf \n", toDouble(fxMul_fair(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxDiv_fair : a / b = %.15lf \n", toDouble(fxDiv_fair(fromDouble(a), fromDouble(b)))); + + fprintf(stdout, "------------------------------------------- \n"); + fprintf(stdout, "fxAdd_performance : a + b = %.15lf \n", toDouble(fxAdd_performance(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxSub_performance : a - b = %.15lf \n", toDouble(fxSub_performance(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxMul_performance : a * b = %.15lf \n", toDouble(fxMul_performance(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxDiv_performance : a / b = %.15lf \n", toDouble(fxDiv_performance(fromDouble(a), fromDouble(b)))); + + return 0; +} diff --git a/fx_s17_14/Makefile b/fx_s17_14/Makefile new file mode 100644 index 0000000..b763ad4 --- /dev/null +++ b/fx_s17_14/Makefile @@ -0,0 +1,17 @@ +CC = gcc +CFLAGS = -c -o +OBJS = project_main.o fx_s17_14.o +HEAD = fx_s17_14.h +FILE = fx_s17_14.c + +fx_s17_14.out: $(OBJS) + $(CC) $(OBJS) -o $@ + +project_main.o: project_main.c $(FILE) $(HEAD) + $(CC) project_main.c $(FILE) $(CFLAGS) $@ + +fx_s17_14.o: project_main.o $(FILE) $(HEAD) + $(CC) project_main.o $(FILE) $(CFLAGS) $@ + +clean: + rm $(OBJS) fx_s17_14.out diff --git a/fx_s17_14/fx_head.h b/fx_s17_14/fx_head.h new file mode 100644 index 0000000..6d9bd26 --- /dev/null +++ b/fx_s17_14/fx_head.h @@ -0,0 +1,79 @@ +#pragma once + +// Fixed with signed long long +#define FX_S28_35 ((1<<16) | (28<<8) | (35)) +#define FX_S29_34 ((1<<16) | (29<<8) | (34)) +#define FX_S30_33 ((1<<16) | (30<<8) | (33)) +#define FX_S31_32 ((1<<16) | (31<<8) | (32)) +#define FX_S32_31 ((1<<16) | (32<<8) | (31)) +#define FX_S33_30 ((1<<16) | (33<<8) | (30)) +#define FX_S34_29 ((1<<16) | (34<<8) | (29)) +#define FX_S35_28 ((1<<16) | (35<<8) | (28)) +// Fixed with unsigned long long +#define FX_U29_35 ((0<<16) | (29<<8) | (35)) +#define FX_U30_34 ((0<<16) | (30<<8) | (34)) +#define FX_U31_33 ((0<<16) | (31<<8) | (33)) +#define FX_U32_32 ((0<<16) | (32<<8) | (32)) +#define FX_U33_31 ((0<<16) | (33<<8) | (31)) +#define FX_U34_30 ((0<<16) | (34<<8) | (30)) +#define FX_U35_29 ((0<<16) | (35<<8) | (29)) +#define FX_U36_28 ((0<<16) | (36<<8) | (28)) +// Fixed with signed int +#define FX_S12_19 ((1<<16) | (12<<8) | (19)) +#define FX_S13_18 ((1<<16) | (13<<8) | (18)) +#define FX_S14_17 ((1<<16) | (14<<8) | (17)) +#define FX_S15_16 ((1<<16) | (15<<8) | (16)) +#define FX_S16_15 ((1<<16) | (16<<8) | (15)) +#define FX_S17_14 ((1<<16) | (17<<8) | (14)) +#define FX_S18_13 ((1<<16) | (18<<8) | (13)) +#define FX_S19_12 ((1<<16) | (19<<8) | (12)) +// Fixed with unsigned int +#define FX_S13_19 ((0<<16) | (13<<8) | (19)) +#define FX_S14_18 ((0<<16) | (14<<8) | (18)) +#define FX_S15_17 ((0<<16) | (15<<8) | (17)) +#define FX_S16_16 ((0<<16) | (16<<8) | (16)) +#define FX_S17_15 ((0<<16) | (17<<8) | (15)) +#define FX_S18_14 ((0<<16) | (18<<8) | (14)) +#define FX_S19_13 ((0<<16) | (19<<8) | (13)) +#define FX_S20_12 ((0<<16) | (20<<8) | (12)) +// Fixed with signed short +#define FX_S04_11 ((1<<16) | (4<<8) | (11)) +#define FX_S05_10 ((1<<16) | (5<<8) | (10)) +#define FX_S06_09 ((1<<16) | (6<<8) | (9)) +#define FX_S07_08 ((1<<16) | (7<<8) | (8)) +#define FX_S08_07 ((1<<16) | (8<<8) | (7)) +#define FX_S09_06 ((1<<16) | (9<<8) | (6)) +#define FX_S10_05 ((1<<16) | (10<<8) | (5)) +#define FX_S11_04 ((1<<16) | (11<<8) | (4)) +// Fixed with unsigned short +#define FX_S05_11 ((0<<16) | (5<<8) | (11)) +#define FX_S06_10 ((0<<16) | (6<<8) | (10)) +#define FX_S07_09 ((0<<16) | (7<<8) | (9)) +#define FX_S08_08 ((0<<16) | (8<<8) | (8)) +#define FX_S09_07 ((0<<16) | (9<<8) | (7)) +#define FX_S10_06 ((0<<16) | (10<<8) | (6)) +#define FX_S11_05 ((0<<16) | (11<<8) | (5)) +#define FX_S12_04 ((0<<16) | (12<<8) | (4)) +// Fixed with signed char +#define FX_S00_07 ((1<<16) | (0<<8) | (7)) +#define FX_S01_06 ((1<<16) | (1<<8) | (6)) +#define FX_S02_05 ((1<<16) | (2<<8) | (5)) +#define FX_S03_04 ((1<<16) | (3<<8) | (4)) +#define FX_S04_03 ((1<<16) | (4<<8) | (3)) +#define FX_S05_02 ((1<<16) | (5<<8) | (2)) +#define FX_S06_01 ((1<<16) | (6<<8) | (1)) +// #define FX_S07_00 ((1<<16) | (7<<8) | (0)) // It is same as unsigned char +// Fixed with unsigned char +#define FX_S00_08 ((0<<16) | (0<<8) | (8)) +#define FX_S01_07 ((0<<16) | (1<<8) | (7)) +#define FX_S02_06 ((0<<16) | (2<<8) | (6)) +#define FX_S03_05 ((0<<16) | (3<<8) | (5)) +#define FX_S04_04 ((0<<16) | (4<<8) | (4)) +#define FX_S05_03 ((0<<16) | (5<<8) | (3)) +#define FX_S06_02 ((0<<16) | (6<<8) | (2)) +#define FX_S07_01 ((0<<16) | (7<<8) | (1)) +// Operation Preference +#define FX_OP_FLOAT 1 +#define FX_OP_PRECISION 2 +#define FX_OP_FAIR 3 +#define FX_OP_PERFORMANCE 4 diff --git a/fx_s17_14/fx_s17_14.c b/fx_s17_14/fx_s17_14.c new file mode 100644 index 0000000..88bf98c --- /dev/null +++ b/fx_s17_14/fx_s17_14.c @@ -0,0 +1,104 @@ +#include "fx_head.h" +#include "fx_s17_14.h" + +#define fxADD(a,b) ((a)+(b)) +#define fxSUB(a,b) ((a)-(b)) +#define FX_Q_NUM_H (FX_Q_NUM/2) +#define FX_Q_NUM_HA (FX_Q_NUM_H-FX_Q_NUM_H/2) +#define FX_Q_NUM_HB (FX_Q_NUM_H/2) +/* +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); +*/ + +// float function +fixed fxAdd_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) + toDouble(b)); +} + +fixed fxSub_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) - toDouble(b)); +} + +fixed fxMul_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) * toDouble(b)); +} + +fixed fxDiv_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) / toDouble(b)); +} + +// precision function +fixed fxAdd_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) + toFloat(b)); +} + +fixed fxSub_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) - toFloat(b)); +} + +fixed fxMul_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la * lb) >> FX_Q_NUM; +} + +fixed fxDiv_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la << FX_Q_NUM) / lb; +} + +// fair function +fixed fxAdd_fair(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_fair(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la >> FX_Q_NUM_HA) * (lb >> FX_Q_NUM_HB)) >> FX_Q_NUM_H; +} + +fixed fxDiv_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / lb) << FX_Q_NUM_H; +} + +// performance function +fixed fxAdd_performance(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_performance(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la>>FX_Q_NUM_H)*(lb>>FX_Q_NUM_H); +} + +fixed fxDiv_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / (lb >> FX_Q_NUM_H)); +} diff --git a/fx_s17_14/fx_s17_14.h b/fx_s17_14/fx_s17_14.h new file mode 100644 index 0000000..c7900f1 --- /dev/null +++ b/fx_s17_14/fx_s17_14.h @@ -0,0 +1,37 @@ +#include "fx_head.h" +#include <math.h> + +#define FX_POINT FX_S17_14 + +#define FX_Q_NUM (FX_POINT & 0xFF) // 14 + +// If you want calculate with high precision set 64 +#define FX_SYSTEM_INTEGER 64 // 32 or 64 +#define FX_SYSTEM_FLOAT 64 // 32 or 64 + +#define FX_DATA_TYPE signed int + + +typedef int fx_s17_14; +typedef fx_s17_14 fixed; + +#define fromDouble(d) ((fixed)((d)*DOUBLE_Q_VALUE)) +#define toDouble(d) ((double)(d)*DOUBLE_1_Q_VALUE) +#define fromFloat(d) ((fixed)((d)*FLOAT_Q_VALUE)) +#define toFloat(d) ((float)(d)*FLOAT_1_Q_VALUE) + +// CONSTANTS +#define FLOAT_Q_VALUE (float)(1<<FX_Q_NUM) +#define DOUBLE_Q_VALUE (double)(1<<FX_Q_NUM) +#define FLOAT_1_Q_VALUE (float)(1.0f/FLOAT_Q_VALUE) +#define DOUBLE_1_Q_VALUE (double)(1.0f/DOUBLE_Q_VALUE) +#define FX_PI fromDOUBLE(M_PI) + +// One of FX_OP_FLOAT, FX_OP_PRECISION, FX_OP_FAIR, FX_OP_PERFORMANCE +#define FX_OP_PREFERENCE FX_OP_FLOAT + +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); + diff --git a/fx_s17_14/project_main.c b/fx_s17_14/project_main.c new file mode 100644 index 0000000..1593d67 --- /dev/null +++ b/fx_s17_14/project_main.c @@ -0,0 +1,77 @@ +#include "fx_s17_14.h" +#include <stdio.h> + +/* +int main() +{ + + printf("%f : %d\n",1.0, fromDouble(1.0)); + printf("%f : %f\n",1.3*0.3, toFloat(fxMul_float(fromDouble(1.3),fromDouble(0.3)))) ; + +} +*/ + +int main() +{ + double a,b; + int num; + + fprintf(stdout, "FX_OP_FLOAT : 1 \n"); + fprintf(stdout, "FX_OP_PRECISION : 2 \n"); + fprintf(stdout, "FX_OP_FAIR : 3 \n"); + fprintf(stdout, "FX_OP_PERFORMANCE : 4 \n"); + fprintf(stdout, "QUIT : The others \n\n"); + + fprintf(stdout, "Choose calculate way you want : "); + fscanf(stdin, "%d", &num); + + if(num!=1 && num!=2 && num!=3 && num!=4) + { + fprintf(stdout, "Thank you! \n"); + return 0; + } + + fprintf(stdout, "Input the First Number : "); + fscanf(stdin, "%lf", &a); + + fprintf(stdout, "Input the Second Number : "); + fscanf(stdin, "%lf", &b); + + fprintf(stdout, "\n"); + + switch (num) + { + case 1: + fprintf(stdout, "fxAdd_float : a + b = %.15lf \n", toDouble(fxAdd_float(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxSub_float : a - b = %.15lf \n", toDouble(fxSub_float(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxMul_float : a * b = %.15lf \n", toDouble(fxMul_float(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxDiv_float : a / b = %.15lf \n", toDouble(fxDiv_float(fromDouble(a), fromDouble(b)))); + break; + + case 2: + fprintf(stdout, "fxAdd_precision : a + b = %.15lf \n", toFloat(fxAdd_precision(fromFloat(a), fromFloat(b)))); + fprintf(stdout, "fxSub_precision : a - b = %.15lf \n", toFloat(fxSub_precision(fromFloat(a), fromFloat(b)))); + fprintf(stdout, "fxMul_precision : a * b = %.15lf \n", toFloat(fxMul_precision(fromFloat(a), fromFloat(b)))); + fprintf(stdout, "fxDiv_precision : a / b = %.15lf \n", toFloat(fxDiv_precision(fromFloat(a), fromFloat(b)))); + break; + + case 3: + fprintf(stdout, "fxAdd_fair : a + b = %.15lf \n", toFloat(fxAdd_fair(fromFloat(a), fromFloat(b)))); + fprintf(stdout, "fxSub_fair : a - b = %.15lf \n", toFloat(fxSub_fair(fromFloat(a), fromFloat(b)))); + fprintf(stdout, "fxMul_fair : a * b = %.15lf \n", toFloat(fxMul_fair(fromFloat(a), fromFloat(b)))); + fprintf(stdout, "fxDiv_fair : a / b = %.15lf \n", toFloat(fxDiv_fair(fromFloat(a), fromFloat(b)))); + break; + + case 4: + fprintf(stdout, "fxAdd_performance : a + b = %.15lf \n", toDouble(fxAdd_performance(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxSub_performance : a - b = %.15lf \n", toDouble(fxSub_performance(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxMul_performance : a * b = %.15lf \n", toDouble(fxMul_performance(fromDouble(a), fromDouble(b)))); + fprintf(stdout, "fxDiv_performance : a / b = %.15lf \n", toDouble(fxDiv_performance(fromDouble(a), fromDouble(b)))); + break; + + default: + break; + } + + return 0; +} diff --git a/overflow/fx_head.h b/overflow/fx_head.h new file mode 100644 index 0000000..6d9bd26 --- /dev/null +++ b/overflow/fx_head.h @@ -0,0 +1,79 @@ +#pragma once + +// Fixed with signed long long +#define FX_S28_35 ((1<<16) | (28<<8) | (35)) +#define FX_S29_34 ((1<<16) | (29<<8) | (34)) +#define FX_S30_33 ((1<<16) | (30<<8) | (33)) +#define FX_S31_32 ((1<<16) | (31<<8) | (32)) +#define FX_S32_31 ((1<<16) | (32<<8) | (31)) +#define FX_S33_30 ((1<<16) | (33<<8) | (30)) +#define FX_S34_29 ((1<<16) | (34<<8) | (29)) +#define FX_S35_28 ((1<<16) | (35<<8) | (28)) +// Fixed with unsigned long long +#define FX_U29_35 ((0<<16) | (29<<8) | (35)) +#define FX_U30_34 ((0<<16) | (30<<8) | (34)) +#define FX_U31_33 ((0<<16) | (31<<8) | (33)) +#define FX_U32_32 ((0<<16) | (32<<8) | (32)) +#define FX_U33_31 ((0<<16) | (33<<8) | (31)) +#define FX_U34_30 ((0<<16) | (34<<8) | (30)) +#define FX_U35_29 ((0<<16) | (35<<8) | (29)) +#define FX_U36_28 ((0<<16) | (36<<8) | (28)) +// Fixed with signed int +#define FX_S12_19 ((1<<16) | (12<<8) | (19)) +#define FX_S13_18 ((1<<16) | (13<<8) | (18)) +#define FX_S14_17 ((1<<16) | (14<<8) | (17)) +#define FX_S15_16 ((1<<16) | (15<<8) | (16)) +#define FX_S16_15 ((1<<16) | (16<<8) | (15)) +#define FX_S17_14 ((1<<16) | (17<<8) | (14)) +#define FX_S18_13 ((1<<16) | (18<<8) | (13)) +#define FX_S19_12 ((1<<16) | (19<<8) | (12)) +// Fixed with unsigned int +#define FX_S13_19 ((0<<16) | (13<<8) | (19)) +#define FX_S14_18 ((0<<16) | (14<<8) | (18)) +#define FX_S15_17 ((0<<16) | (15<<8) | (17)) +#define FX_S16_16 ((0<<16) | (16<<8) | (16)) +#define FX_S17_15 ((0<<16) | (17<<8) | (15)) +#define FX_S18_14 ((0<<16) | (18<<8) | (14)) +#define FX_S19_13 ((0<<16) | (19<<8) | (13)) +#define FX_S20_12 ((0<<16) | (20<<8) | (12)) +// Fixed with signed short +#define FX_S04_11 ((1<<16) | (4<<8) | (11)) +#define FX_S05_10 ((1<<16) | (5<<8) | (10)) +#define FX_S06_09 ((1<<16) | (6<<8) | (9)) +#define FX_S07_08 ((1<<16) | (7<<8) | (8)) +#define FX_S08_07 ((1<<16) | (8<<8) | (7)) +#define FX_S09_06 ((1<<16) | (9<<8) | (6)) +#define FX_S10_05 ((1<<16) | (10<<8) | (5)) +#define FX_S11_04 ((1<<16) | (11<<8) | (4)) +// Fixed with unsigned short +#define FX_S05_11 ((0<<16) | (5<<8) | (11)) +#define FX_S06_10 ((0<<16) | (6<<8) | (10)) +#define FX_S07_09 ((0<<16) | (7<<8) | (9)) +#define FX_S08_08 ((0<<16) | (8<<8) | (8)) +#define FX_S09_07 ((0<<16) | (9<<8) | (7)) +#define FX_S10_06 ((0<<16) | (10<<8) | (6)) +#define FX_S11_05 ((0<<16) | (11<<8) | (5)) +#define FX_S12_04 ((0<<16) | (12<<8) | (4)) +// Fixed with signed char +#define FX_S00_07 ((1<<16) | (0<<8) | (7)) +#define FX_S01_06 ((1<<16) | (1<<8) | (6)) +#define FX_S02_05 ((1<<16) | (2<<8) | (5)) +#define FX_S03_04 ((1<<16) | (3<<8) | (4)) +#define FX_S04_03 ((1<<16) | (4<<8) | (3)) +#define FX_S05_02 ((1<<16) | (5<<8) | (2)) +#define FX_S06_01 ((1<<16) | (6<<8) | (1)) +// #define FX_S07_00 ((1<<16) | (7<<8) | (0)) // It is same as unsigned char +// Fixed with unsigned char +#define FX_S00_08 ((0<<16) | (0<<8) | (8)) +#define FX_S01_07 ((0<<16) | (1<<8) | (7)) +#define FX_S02_06 ((0<<16) | (2<<8) | (6)) +#define FX_S03_05 ((0<<16) | (3<<8) | (5)) +#define FX_S04_04 ((0<<16) | (4<<8) | (4)) +#define FX_S05_03 ((0<<16) | (5<<8) | (3)) +#define FX_S06_02 ((0<<16) | (6<<8) | (2)) +#define FX_S07_01 ((0<<16) | (7<<8) | (1)) +// Operation Preference +#define FX_OP_FLOAT 1 +#define FX_OP_PRECISION 2 +#define FX_OP_FAIR 3 +#define FX_OP_PERFORMANCE 4 diff --git a/overflow/fx_s17_14.c b/overflow/fx_s17_14.c new file mode 100644 index 0000000..88bf98c --- /dev/null +++ b/overflow/fx_s17_14.c @@ -0,0 +1,104 @@ +#include "fx_head.h" +#include "fx_s17_14.h" + +#define fxADD(a,b) ((a)+(b)) +#define fxSUB(a,b) ((a)-(b)) +#define FX_Q_NUM_H (FX_Q_NUM/2) +#define FX_Q_NUM_HA (FX_Q_NUM_H-FX_Q_NUM_H/2) +#define FX_Q_NUM_HB (FX_Q_NUM_H/2) +/* +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); +*/ + +// float function +fixed fxAdd_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) + toDouble(b)); +} + +fixed fxSub_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) - toDouble(b)); +} + +fixed fxMul_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) * toDouble(b)); +} + +fixed fxDiv_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) / toDouble(b)); +} + +// precision function +fixed fxAdd_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) + toFloat(b)); +} + +fixed fxSub_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) - toFloat(b)); +} + +fixed fxMul_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la * lb) >> FX_Q_NUM; +} + +fixed fxDiv_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la << FX_Q_NUM) / lb; +} + +// fair function +fixed fxAdd_fair(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_fair(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la >> FX_Q_NUM_HA) * (lb >> FX_Q_NUM_HB)) >> FX_Q_NUM_H; +} + +fixed fxDiv_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / lb) << FX_Q_NUM_H; +} + +// performance function +fixed fxAdd_performance(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_performance(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la>>FX_Q_NUM_H)*(lb>>FX_Q_NUM_H); +} + +fixed fxDiv_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / (lb >> FX_Q_NUM_H)); +} diff --git a/overflow/fx_s17_14.h b/overflow/fx_s17_14.h new file mode 100644 index 0000000..c7900f1 --- /dev/null +++ b/overflow/fx_s17_14.h @@ -0,0 +1,37 @@ +#include "fx_head.h" +#include <math.h> + +#define FX_POINT FX_S17_14 + +#define FX_Q_NUM (FX_POINT & 0xFF) // 14 + +// If you want calculate with high precision set 64 +#define FX_SYSTEM_INTEGER 64 // 32 or 64 +#define FX_SYSTEM_FLOAT 64 // 32 or 64 + +#define FX_DATA_TYPE signed int + + +typedef int fx_s17_14; +typedef fx_s17_14 fixed; + +#define fromDouble(d) ((fixed)((d)*DOUBLE_Q_VALUE)) +#define toDouble(d) ((double)(d)*DOUBLE_1_Q_VALUE) +#define fromFloat(d) ((fixed)((d)*FLOAT_Q_VALUE)) +#define toFloat(d) ((float)(d)*FLOAT_1_Q_VALUE) + +// CONSTANTS +#define FLOAT_Q_VALUE (float)(1<<FX_Q_NUM) +#define DOUBLE_Q_VALUE (double)(1<<FX_Q_NUM) +#define FLOAT_1_Q_VALUE (float)(1.0f/FLOAT_Q_VALUE) +#define DOUBLE_1_Q_VALUE (double)(1.0f/DOUBLE_Q_VALUE) +#define FX_PI fromDOUBLE(M_PI) + +// One of FX_OP_FLOAT, FX_OP_PRECISION, FX_OP_FAIR, FX_OP_PERFORMANCE +#define FX_OP_PREFERENCE FX_OP_FLOAT + +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); + diff --git a/overflow/testcodemul.c b/overflow/testcodemul.c new file mode 100644 index 0000000..0bfcfa2 --- /dev/null +++ b/overflow/testcodemul.c @@ -0,0 +1,22 @@ +#include "fx_s17_14.h" +#include <stdio.h> + +int main() +{ + double i; + int mul1, mul2, mul3, mul4; + for ( i = 362; i < 363; i+=0.001) + { + mul1 = fxMul_float(fromDouble(i), fromDouble(i)); + mul2 = fxMul_precision(fromDouble(i), fromDouble(i)); + mul3 = fxMul_fair(fromDouble(i), fromDouble(i)); + mul4 = fxMul_performance(fromDouble(i), fromDouble(i)); + + fprintf(stdout, "%f * %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(mul1)); + fprintf(stdout, "%f * %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(mul2)); + fprintf(stdout, "%f * %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(mul3)); + fprintf(stdout, "%f * %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(mul4)); + fprintf(stdout, "=============================== \n"); + } + return 0; +} diff --git a/precisiontest/fx_head.h b/precisiontest/fx_head.h new file mode 100644 index 0000000..6d9bd26 --- /dev/null +++ b/precisiontest/fx_head.h @@ -0,0 +1,79 @@ +#pragma once + +// Fixed with signed long long +#define FX_S28_35 ((1<<16) | (28<<8) | (35)) +#define FX_S29_34 ((1<<16) | (29<<8) | (34)) +#define FX_S30_33 ((1<<16) | (30<<8) | (33)) +#define FX_S31_32 ((1<<16) | (31<<8) | (32)) +#define FX_S32_31 ((1<<16) | (32<<8) | (31)) +#define FX_S33_30 ((1<<16) | (33<<8) | (30)) +#define FX_S34_29 ((1<<16) | (34<<8) | (29)) +#define FX_S35_28 ((1<<16) | (35<<8) | (28)) +// Fixed with unsigned long long +#define FX_U29_35 ((0<<16) | (29<<8) | (35)) +#define FX_U30_34 ((0<<16) | (30<<8) | (34)) +#define FX_U31_33 ((0<<16) | (31<<8) | (33)) +#define FX_U32_32 ((0<<16) | (32<<8) | (32)) +#define FX_U33_31 ((0<<16) | (33<<8) | (31)) +#define FX_U34_30 ((0<<16) | (34<<8) | (30)) +#define FX_U35_29 ((0<<16) | (35<<8) | (29)) +#define FX_U36_28 ((0<<16) | (36<<8) | (28)) +// Fixed with signed int +#define FX_S12_19 ((1<<16) | (12<<8) | (19)) +#define FX_S13_18 ((1<<16) | (13<<8) | (18)) +#define FX_S14_17 ((1<<16) | (14<<8) | (17)) +#define FX_S15_16 ((1<<16) | (15<<8) | (16)) +#define FX_S16_15 ((1<<16) | (16<<8) | (15)) +#define FX_S17_14 ((1<<16) | (17<<8) | (14)) +#define FX_S18_13 ((1<<16) | (18<<8) | (13)) +#define FX_S19_12 ((1<<16) | (19<<8) | (12)) +// Fixed with unsigned int +#define FX_S13_19 ((0<<16) | (13<<8) | (19)) +#define FX_S14_18 ((0<<16) | (14<<8) | (18)) +#define FX_S15_17 ((0<<16) | (15<<8) | (17)) +#define FX_S16_16 ((0<<16) | (16<<8) | (16)) +#define FX_S17_15 ((0<<16) | (17<<8) | (15)) +#define FX_S18_14 ((0<<16) | (18<<8) | (14)) +#define FX_S19_13 ((0<<16) | (19<<8) | (13)) +#define FX_S20_12 ((0<<16) | (20<<8) | (12)) +// Fixed with signed short +#define FX_S04_11 ((1<<16) | (4<<8) | (11)) +#define FX_S05_10 ((1<<16) | (5<<8) | (10)) +#define FX_S06_09 ((1<<16) | (6<<8) | (9)) +#define FX_S07_08 ((1<<16) | (7<<8) | (8)) +#define FX_S08_07 ((1<<16) | (8<<8) | (7)) +#define FX_S09_06 ((1<<16) | (9<<8) | (6)) +#define FX_S10_05 ((1<<16) | (10<<8) | (5)) +#define FX_S11_04 ((1<<16) | (11<<8) | (4)) +// Fixed with unsigned short +#define FX_S05_11 ((0<<16) | (5<<8) | (11)) +#define FX_S06_10 ((0<<16) | (6<<8) | (10)) +#define FX_S07_09 ((0<<16) | (7<<8) | (9)) +#define FX_S08_08 ((0<<16) | (8<<8) | (8)) +#define FX_S09_07 ((0<<16) | (9<<8) | (7)) +#define FX_S10_06 ((0<<16) | (10<<8) | (6)) +#define FX_S11_05 ((0<<16) | (11<<8) | (5)) +#define FX_S12_04 ((0<<16) | (12<<8) | (4)) +// Fixed with signed char +#define FX_S00_07 ((1<<16) | (0<<8) | (7)) +#define FX_S01_06 ((1<<16) | (1<<8) | (6)) +#define FX_S02_05 ((1<<16) | (2<<8) | (5)) +#define FX_S03_04 ((1<<16) | (3<<8) | (4)) +#define FX_S04_03 ((1<<16) | (4<<8) | (3)) +#define FX_S05_02 ((1<<16) | (5<<8) | (2)) +#define FX_S06_01 ((1<<16) | (6<<8) | (1)) +// #define FX_S07_00 ((1<<16) | (7<<8) | (0)) // It is same as unsigned char +// Fixed with unsigned char +#define FX_S00_08 ((0<<16) | (0<<8) | (8)) +#define FX_S01_07 ((0<<16) | (1<<8) | (7)) +#define FX_S02_06 ((0<<16) | (2<<8) | (6)) +#define FX_S03_05 ((0<<16) | (3<<8) | (5)) +#define FX_S04_04 ((0<<16) | (4<<8) | (4)) +#define FX_S05_03 ((0<<16) | (5<<8) | (3)) +#define FX_S06_02 ((0<<16) | (6<<8) | (2)) +#define FX_S07_01 ((0<<16) | (7<<8) | (1)) +// Operation Preference +#define FX_OP_FLOAT 1 +#define FX_OP_PRECISION 2 +#define FX_OP_FAIR 3 +#define FX_OP_PERFORMANCE 4 diff --git a/precisiontest/fx_s17_14.c b/precisiontest/fx_s17_14.c new file mode 100644 index 0000000..88bf98c --- /dev/null +++ b/precisiontest/fx_s17_14.c @@ -0,0 +1,104 @@ +#include "fx_head.h" +#include "fx_s17_14.h" + +#define fxADD(a,b) ((a)+(b)) +#define fxSUB(a,b) ((a)-(b)) +#define FX_Q_NUM_H (FX_Q_NUM/2) +#define FX_Q_NUM_HA (FX_Q_NUM_H-FX_Q_NUM_H/2) +#define FX_Q_NUM_HB (FX_Q_NUM_H/2) +/* +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); +*/ + +// float function +fixed fxAdd_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) + toDouble(b)); +} + +fixed fxSub_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) - toDouble(b)); +} + +fixed fxMul_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) * toDouble(b)); +} + +fixed fxDiv_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) / toDouble(b)); +} + +// precision function +fixed fxAdd_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) + toFloat(b)); +} + +fixed fxSub_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) - toFloat(b)); +} + +fixed fxMul_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la * lb) >> FX_Q_NUM; +} + +fixed fxDiv_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la << FX_Q_NUM) / lb; +} + +// fair function +fixed fxAdd_fair(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_fair(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la >> FX_Q_NUM_HA) * (lb >> FX_Q_NUM_HB)) >> FX_Q_NUM_H; +} + +fixed fxDiv_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / lb) << FX_Q_NUM_H; +} + +// performance function +fixed fxAdd_performance(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_performance(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la>>FX_Q_NUM_H)*(lb>>FX_Q_NUM_H); +} + +fixed fxDiv_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / (lb >> FX_Q_NUM_H)); +} diff --git a/precisiontest/fx_s17_14.h b/precisiontest/fx_s17_14.h new file mode 100644 index 0000000..c7900f1 --- /dev/null +++ b/precisiontest/fx_s17_14.h @@ -0,0 +1,37 @@ +#include "fx_head.h" +#include <math.h> + +#define FX_POINT FX_S17_14 + +#define FX_Q_NUM (FX_POINT & 0xFF) // 14 + +// If you want calculate with high precision set 64 +#define FX_SYSTEM_INTEGER 64 // 32 or 64 +#define FX_SYSTEM_FLOAT 64 // 32 or 64 + +#define FX_DATA_TYPE signed int + + +typedef int fx_s17_14; +typedef fx_s17_14 fixed; + +#define fromDouble(d) ((fixed)((d)*DOUBLE_Q_VALUE)) +#define toDouble(d) ((double)(d)*DOUBLE_1_Q_VALUE) +#define fromFloat(d) ((fixed)((d)*FLOAT_Q_VALUE)) +#define toFloat(d) ((float)(d)*FLOAT_1_Q_VALUE) + +// CONSTANTS +#define FLOAT_Q_VALUE (float)(1<<FX_Q_NUM) +#define DOUBLE_Q_VALUE (double)(1<<FX_Q_NUM) +#define FLOAT_1_Q_VALUE (float)(1.0f/FLOAT_Q_VALUE) +#define DOUBLE_1_Q_VALUE (double)(1.0f/DOUBLE_Q_VALUE) +#define FX_PI fromDOUBLE(M_PI) + +// One of FX_OP_FLOAT, FX_OP_PRECISION, FX_OP_FAIR, FX_OP_PERFORMANCE +#define FX_OP_PREFERENCE FX_OP_FLOAT + +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); + diff --git a/precisiontest/testcodediv.c b/precisiontest/testcodediv.c new file mode 100644 index 0000000..7b85356 --- /dev/null +++ b/precisiontest/testcodediv.c @@ -0,0 +1,21 @@ +#include "fx_s17_14.h" +#include <stdio.h> + +int main() +{ + double a = 29.2653, b = 13.4598; + + int div1, div2, div3, div4; + div1 = fxDiv_float(fromDouble(a), fromDouble(b)); + div2 = fxDiv_precision(fromDouble(a), fromDouble(b)); + div3 = fxDiv_fair(fromDouble(a), fromDouble(b)); + div4 = fxDiv_performance(fromDouble(a), fromDouble(b)); + + fprintf(stdout, "================================================================================================= \n"); + fprintf(stdout, "value : %.15f fxDiv_float : %.15f diff : %.15f \n", 29.2653 / 13.4598, toDouble(div1), (29.2653 / 13.4598) - toDouble(div1)); + fprintf(stdout, "value : %.15f fxDiv_precision : %.15f diff : %.15f \n", 29.2653 / 13.4598, toDouble(div2), (29.2653 / 13.4598) - toDouble(div2)); + fprintf(stdout, "value : %.15f fxDiv_fair : %.15f diff : %.15f \n", 29.2653 / 13.4598, toDouble(div3), (29.2653 / 13.4598) - toDouble(div3)); + fprintf(stdout, "value : %.15f fxDiv_performance : %.15f diff : %.15f \n", 29.2653 / 13.4598, toDouble(div4), (29.2653 / 13.4598) - toDouble(div4)); + fprintf(stdout, "================================================================================================= \n"); + return 0; +} diff --git a/precisiontest/testcodemul.c b/precisiontest/testcodemul.c new file mode 100644 index 0000000..0ad6e5b --- /dev/null +++ b/precisiontest/testcodemul.c @@ -0,0 +1,21 @@ +#include "fx_s17_14.h" +#include <stdio.h> + +int main() +{ + double a = 21.468, b = 17.297; + + int mul1, mul2, mul3, mul4; + mul1 = fxMul_float(fromDouble(a), fromDouble(b)); + mul2 = fxMul_precision(fromDouble(a), fromDouble(b)); + mul3 = fxMul_fair(fromDouble(a), fromDouble(b)); + mul4 = fxMul_performance(fromDouble(a), fromDouble(b)); + + fprintf(stdout, "================================================================================================= \n"); + fprintf(stdout, "value : %.15f fxMul_float : %.15f diff : %.15f \n", 21.468 * 17.297, toDouble(mul1), (21.468 * 17.297) - toDouble(mul1)); + fprintf(stdout, "value : %.15f fxMul_precision : %.15f diff : %.15f \n", 21.468 * 17.297, toDouble(mul2), (21.468 * 17.297) - toDouble(mul2)); + fprintf(stdout, "value : %.15f fxMul_fair : %.15f diff : %.15f \n", 21.468 * 17.297, toDouble(mul3), (21.468 * 17.297) - toDouble(mul3)); + fprintf(stdout, "value : %.15f fxMul_performance : %.15f diff : %.15f \n", 21.468 * 17.297, toDouble(mul4), (21.468 * 17.297) - toDouble(mul4)); + fprintf(stdout, "================================================================================================= \n"); + return 0; +} diff --git a/speedtest/fx_head.h b/speedtest/fx_head.h new file mode 100644 index 0000000..6d9bd26 --- /dev/null +++ b/speedtest/fx_head.h @@ -0,0 +1,79 @@ +#pragma once + +// Fixed with signed long long +#define FX_S28_35 ((1<<16) | (28<<8) | (35)) +#define FX_S29_34 ((1<<16) | (29<<8) | (34)) +#define FX_S30_33 ((1<<16) | (30<<8) | (33)) +#define FX_S31_32 ((1<<16) | (31<<8) | (32)) +#define FX_S32_31 ((1<<16) | (32<<8) | (31)) +#define FX_S33_30 ((1<<16) | (33<<8) | (30)) +#define FX_S34_29 ((1<<16) | (34<<8) | (29)) +#define FX_S35_28 ((1<<16) | (35<<8) | (28)) +// Fixed with unsigned long long +#define FX_U29_35 ((0<<16) | (29<<8) | (35)) +#define FX_U30_34 ((0<<16) | (30<<8) | (34)) +#define FX_U31_33 ((0<<16) | (31<<8) | (33)) +#define FX_U32_32 ((0<<16) | (32<<8) | (32)) +#define FX_U33_31 ((0<<16) | (33<<8) | (31)) +#define FX_U34_30 ((0<<16) | (34<<8) | (30)) +#define FX_U35_29 ((0<<16) | (35<<8) | (29)) +#define FX_U36_28 ((0<<16) | (36<<8) | (28)) +// Fixed with signed int +#define FX_S12_19 ((1<<16) | (12<<8) | (19)) +#define FX_S13_18 ((1<<16) | (13<<8) | (18)) +#define FX_S14_17 ((1<<16) | (14<<8) | (17)) +#define FX_S15_16 ((1<<16) | (15<<8) | (16)) +#define FX_S16_15 ((1<<16) | (16<<8) | (15)) +#define FX_S17_14 ((1<<16) | (17<<8) | (14)) +#define FX_S18_13 ((1<<16) | (18<<8) | (13)) +#define FX_S19_12 ((1<<16) | (19<<8) | (12)) +// Fixed with unsigned int +#define FX_S13_19 ((0<<16) | (13<<8) | (19)) +#define FX_S14_18 ((0<<16) | (14<<8) | (18)) +#define FX_S15_17 ((0<<16) | (15<<8) | (17)) +#define FX_S16_16 ((0<<16) | (16<<8) | (16)) +#define FX_S17_15 ((0<<16) | (17<<8) | (15)) +#define FX_S18_14 ((0<<16) | (18<<8) | (14)) +#define FX_S19_13 ((0<<16) | (19<<8) | (13)) +#define FX_S20_12 ((0<<16) | (20<<8) | (12)) +// Fixed with signed short +#define FX_S04_11 ((1<<16) | (4<<8) | (11)) +#define FX_S05_10 ((1<<16) | (5<<8) | (10)) +#define FX_S06_09 ((1<<16) | (6<<8) | (9)) +#define FX_S07_08 ((1<<16) | (7<<8) | (8)) +#define FX_S08_07 ((1<<16) | (8<<8) | (7)) +#define FX_S09_06 ((1<<16) | (9<<8) | (6)) +#define FX_S10_05 ((1<<16) | (10<<8) | (5)) +#define FX_S11_04 ((1<<16) | (11<<8) | (4)) +// Fixed with unsigned short +#define FX_S05_11 ((0<<16) | (5<<8) | (11)) +#define FX_S06_10 ((0<<16) | (6<<8) | (10)) +#define FX_S07_09 ((0<<16) | (7<<8) | (9)) +#define FX_S08_08 ((0<<16) | (8<<8) | (8)) +#define FX_S09_07 ((0<<16) | (9<<8) | (7)) +#define FX_S10_06 ((0<<16) | (10<<8) | (6)) +#define FX_S11_05 ((0<<16) | (11<<8) | (5)) +#define FX_S12_04 ((0<<16) | (12<<8) | (4)) +// Fixed with signed char +#define FX_S00_07 ((1<<16) | (0<<8) | (7)) +#define FX_S01_06 ((1<<16) | (1<<8) | (6)) +#define FX_S02_05 ((1<<16) | (2<<8) | (5)) +#define FX_S03_04 ((1<<16) | (3<<8) | (4)) +#define FX_S04_03 ((1<<16) | (4<<8) | (3)) +#define FX_S05_02 ((1<<16) | (5<<8) | (2)) +#define FX_S06_01 ((1<<16) | (6<<8) | (1)) +// #define FX_S07_00 ((1<<16) | (7<<8) | (0)) // It is same as unsigned char +// Fixed with unsigned char +#define FX_S00_08 ((0<<16) | (0<<8) | (8)) +#define FX_S01_07 ((0<<16) | (1<<8) | (7)) +#define FX_S02_06 ((0<<16) | (2<<8) | (6)) +#define FX_S03_05 ((0<<16) | (3<<8) | (5)) +#define FX_S04_04 ((0<<16) | (4<<8) | (4)) +#define FX_S05_03 ((0<<16) | (5<<8) | (3)) +#define FX_S06_02 ((0<<16) | (6<<8) | (2)) +#define FX_S07_01 ((0<<16) | (7<<8) | (1)) +// Operation Preference +#define FX_OP_FLOAT 1 +#define FX_OP_PRECISION 2 +#define FX_OP_FAIR 3 +#define FX_OP_PERFORMANCE 4 diff --git a/speedtest/fx_s17_14.c b/speedtest/fx_s17_14.c new file mode 100644 index 0000000..88bf98c --- /dev/null +++ b/speedtest/fx_s17_14.c @@ -0,0 +1,104 @@ +#include "fx_head.h" +#include "fx_s17_14.h" + +#define fxADD(a,b) ((a)+(b)) +#define fxSUB(a,b) ((a)-(b)) +#define FX_Q_NUM_H (FX_Q_NUM/2) +#define FX_Q_NUM_HA (FX_Q_NUM_H-FX_Q_NUM_H/2) +#define FX_Q_NUM_HB (FX_Q_NUM_H/2) +/* +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); +*/ + +// float function +fixed fxAdd_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) + toDouble(b)); +} + +fixed fxSub_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) - toDouble(b)); +} + +fixed fxMul_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) * toDouble(b)); +} + +fixed fxDiv_float(fixed a, fixed b) +{ + return fromDouble(toDouble(a) / toDouble(b)); +} + +// precision function +fixed fxAdd_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) + toFloat(b)); +} + +fixed fxSub_precision(fixed a, fixed b) +{ + return fromFloat(toFloat(a) - toFloat(b)); +} + +fixed fxMul_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la * lb) >> FX_Q_NUM; +} + +fixed fxDiv_precision(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la << FX_Q_NUM) / lb; +} + +// fair function +fixed fxAdd_fair(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_fair(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la >> FX_Q_NUM_HA) * (lb >> FX_Q_NUM_HB)) >> FX_Q_NUM_H; +} + +fixed fxDiv_fair(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / lb) << FX_Q_NUM_H; +} + +// performance function +fixed fxAdd_performance(fixed a, fixed b) +{ + return fxADD(a,b); +} + +fixed fxSub_performance(fixed a, fixed b) +{ + return fxSUB(a,b); +} + +fixed fxMul_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return (la>>FX_Q_NUM_H)*(lb>>FX_Q_NUM_H); +} + +fixed fxDiv_performance(fixed a, fixed b) +{ + long long la = a, lb = b; + return ((la << FX_Q_NUM_H) / (lb >> FX_Q_NUM_H)); +} diff --git a/speedtest/fx_s17_14.h b/speedtest/fx_s17_14.h new file mode 100644 index 0000000..c7900f1 --- /dev/null +++ b/speedtest/fx_s17_14.h @@ -0,0 +1,37 @@ +#include "fx_head.h" +#include <math.h> + +#define FX_POINT FX_S17_14 + +#define FX_Q_NUM (FX_POINT & 0xFF) // 14 + +// If you want calculate with high precision set 64 +#define FX_SYSTEM_INTEGER 64 // 32 or 64 +#define FX_SYSTEM_FLOAT 64 // 32 or 64 + +#define FX_DATA_TYPE signed int + + +typedef int fx_s17_14; +typedef fx_s17_14 fixed; + +#define fromDouble(d) ((fixed)((d)*DOUBLE_Q_VALUE)) +#define toDouble(d) ((double)(d)*DOUBLE_1_Q_VALUE) +#define fromFloat(d) ((fixed)((d)*FLOAT_Q_VALUE)) +#define toFloat(d) ((float)(d)*FLOAT_1_Q_VALUE) + +// CONSTANTS +#define FLOAT_Q_VALUE (float)(1<<FX_Q_NUM) +#define DOUBLE_Q_VALUE (double)(1<<FX_Q_NUM) +#define FLOAT_1_Q_VALUE (float)(1.0f/FLOAT_Q_VALUE) +#define DOUBLE_1_Q_VALUE (double)(1.0f/DOUBLE_Q_VALUE) +#define FX_PI fromDOUBLE(M_PI) + +// One of FX_OP_FLOAT, FX_OP_PRECISION, FX_OP_FAIR, FX_OP_PERFORMANCE +#define FX_OP_PREFERENCE FX_OP_FLOAT + +extern fixed fxAdd_float(), fxAdd_precision(), fxAdd_fair(), fxAdd_performance(); +extern fixed fxSub_float(), fxSub_precision(), fxSub_fair(), fxSub_performance(); +extern fixed fxMul_float(), fxMul_precision(), fxMul_fair(), fxMul_performance(); +extern fixed fxDiv_float(), fxDiv_precision(), fxDiv_fair(), fxDiv_performance(); + diff --git a/speedtest/testcodediv.c b/speedtest/testcodediv.c new file mode 100644 index 0000000..f79dac1 --- /dev/null +++ b/speedtest/testcodediv.c @@ -0,0 +1,22 @@ +#include "fx_s17_14.h" +#include <stdio.h> + +int main() +{ + double i; + int div1, div2, div3, div4; + for ( i = -362; i < -0.000001; i+=0.0001) + { + div1 = fxDiv_float(fromDouble(i), fromDouble(i)); + div2 = fxDiv_precision(fromDouble(i), fromDouble(i)); + div3 = fxDiv_fair(fromDouble(i), fromDouble(i)); + div4 = fxDiv_performance(fromDouble(i), fromDouble(i)); + + fprintf(stdout, "%f / %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(div1)); + fprintf(stdout, "%f / %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(div2)); + fprintf(stdout, "%f / %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(div3)); + fprintf(stdout, "%f / %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(div4)); + fprintf(stdout, "=============================== \n"); + } + return 0; +} diff --git a/speedtest/testcodediv.txt b/speedtest/testcodediv.txt new file mode 100644 index 0000000..94ace4b --- /dev/null +++ b/speedtest/testcodediv.txt @@ -0,0 +1,162 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 77.06 0.50 0.50 main + 9.25 0.56 0.06 3620000 16.60 16.60 fxDiv_float + 6.16 0.60 0.04 3620000 11.07 11.07 fxDiv_fair + 4.62 0.63 0.03 3620000 8.30 8.30 fxDiv_performance + 3.08 0.65 0.02 3620000 5.53 5.53 fxDiv_precision + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) for 1.54% of 0.65 seconds + +index % time self children called name + <spontaneous> +[1] 100.0 0.50 0.15 main [1] + 0.06 0.00 3620000/3620000 fxDiv_float [2] + 0.04 0.00 3620000/3620000 fxDiv_fair [3] + 0.03 0.00 3620000/3620000 fxDiv_performance [4] + 0.02 0.00 3620000/3620000 fxDiv_precision [5] +----------------------------------------------- + 0.06 0.00 3620000/3620000 main [1] +[2] 9.2 0.06 0.00 3620000 fxDiv_float [2] +----------------------------------------------- + 0.04 0.00 3620000/3620000 main [1] +[3] 6.2 0.04 0.00 3620000 fxDiv_fair [3] +----------------------------------------------- + 0.03 0.00 3620000/3620000 main [1] +[4] 4.6 0.03 0.00 3620000 fxDiv_performance [4] +----------------------------------------------- + 0.02 0.00 3620000/3620000 main [1] +[5] 3.1 0.02 0.00 3620000 fxDiv_precision [5] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `<spontaneous>' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [3] fxDiv_fair [4] fxDiv_performance [1] main + [2] fxDiv_float [5] fxDiv_precision diff --git a/speedtest/testcodemul.c b/speedtest/testcodemul.c new file mode 100644 index 0000000..9e89855 --- /dev/null +++ b/speedtest/testcodemul.c @@ -0,0 +1,22 @@ +#include "fx_s17_14.h" +#include <stdio.h> + +int main() +{ + double i; + int mul1, mul2, mul3, mul4; + for ( i = -362; i < 362; i+=0.001) + { + mul1 = fxMul_float(fromDouble(i), fromDouble(i)); + mul2 = fxMul_precision(fromDouble(i), fromDouble(i)); + mul3 = fxMul_fair(fromDouble(i), fromDouble(i)); + mul4 = fxMul_performance(fromDouble(i), fromDouble(i)); + + fprintf(stdout, "%f * %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(mul1)); + fprintf(stdout, "%f * %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(mul2)); + fprintf(stdout, "%f * %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(mul3)); + fprintf(stdout, "%f * %f = %.15f \n", fromDouble(i), fromDouble(i), toDouble(mul4)); + fprintf(stdout, "=============================== \n"); + } + return 0; +} diff --git a/speedtest/testcodemul.txt b/speedtest/testcodemul.txt new file mode 100644 index 0000000..3317d81 --- /dev/null +++ b/speedtest/testcodemul.txt @@ -0,0 +1,162 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 87.66 0.07 0.07 main + 12.52 0.08 0.01 724001 13.84 13.84 fxMul_float + 0.00 0.08 0.00 724001 0.00 0.00 fxMul_fair + 0.00 0.08 0.00 724001 0.00 0.00 fxMul_performance + 0.00 0.08 0.00 724001 0.00 0.00 fxMul_precision + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) for 12.48% of 0.08 seconds + +index % time self children called name + <spontaneous> +[1] 100.0 0.07 0.01 main [1] + 0.01 0.00 724001/724001 fxMul_float [2] + 0.00 0.00 724001/724001 fxMul_precision [5] + 0.00 0.00 724001/724001 fxMul_fair [3] + 0.00 0.00 724001/724001 fxMul_performance [4] +----------------------------------------------- + 0.01 0.00 724001/724001 main [1] +[2] 12.5 0.01 0.00 724001 fxMul_float [2] +----------------------------------------------- + 0.00 0.00 724001/724001 main [1] +[3] 0.0 0.00 0.00 724001 fxMul_fair [3] +----------------------------------------------- + 0.00 0.00 724001/724001 main [1] +[4] 0.0 0.00 0.00 724001 fxMul_performance [4] +----------------------------------------------- + 0.00 0.00 724001/724001 main [1] +[5] 0.0 0.00 0.00 724001 fxMul_precision [5] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `<spontaneous>' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [3] fxMul_fair [4] fxMul_performance [1] main + [2] fxMul_float [5] fxMul_precision diff --git a/speedtest/testdiv_32.txt b/speedtest/testdiv_32.txt new file mode 100644 index 0000000..a70ab95 --- /dev/null +++ b/speedtest/testdiv_32.txt @@ -0,0 +1,175 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 72.32 0.78 0.78 main + 12.98 0.92 0.14 __divdi3 + 9.73 1.03 0.11 3620000 29.04 29.04 fxDiv_float + 1.85 1.05 0.02 3620000 5.53 5.53 fxDiv_precision + 1.85 1.07 0.02 __x86.get_pc_thunk.bx + 0.93 1.08 0.01 3620000 2.77 2.77 fxDiv_fair + 0.46 1.08 0.01 fxMul_float + 0.00 1.08 0.00 3620000 0.00 0.00 fxDiv_performance + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) for 0.92% of 1.08 seconds + +index % time self children called name + <spontaneous> +[1] 84.7 0.78 0.14 main [1] + 0.11 0.00 3620000/3620000 fxDiv_float [3] + 0.02 0.00 3620000/3620000 fxDiv_precision [4] + 0.01 0.00 3620000/3620000 fxDiv_fair [6] + 0.00 0.00 3620000/3620000 fxDiv_performance [8] +----------------------------------------------- + <spontaneous> +[2] 13.0 0.14 0.00 __divdi3 [2] +----------------------------------------------- + 0.11 0.00 3620000/3620000 main [1] +[3] 9.7 0.11 0.00 3620000 fxDiv_float [3] +----------------------------------------------- + 0.02 0.00 3620000/3620000 main [1] +[4] 1.9 0.02 0.00 3620000 fxDiv_precision [4] +----------------------------------------------- + <spontaneous> +[5] 1.9 0.02 0.00 __x86.get_pc_thunk.bx [5] +----------------------------------------------- + 0.01 0.00 3620000/3620000 main [1] +[6] 0.9 0.01 0.00 3620000 fxDiv_fair [6] +----------------------------------------------- + <spontaneous> +[7] 0.5 0.01 0.00 fxMul_float [7] +----------------------------------------------- + 0.00 0.00 3620000/3620000 main [1] +[8] 0.0 0.00 0.00 3620000 fxDiv_performance [8] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `<spontaneous>' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [2] __divdi3 [3] fxDiv_float [7] fxMul_float + [5] __x86.get_pc_thunk.bx [8] fxDiv_performance [1] main + [6] fxDiv_fair [4] fxDiv_precision diff --git a/speedtest/testdiv_64.txt b/speedtest/testdiv_64.txt new file mode 100644 index 0000000..3da672f --- /dev/null +++ b/speedtest/testdiv_64.txt @@ -0,0 +1,162 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 74.05 0.34 0.34 main + 10.89 0.39 0.05 3620000 13.84 13.84 fxDiv_float + 6.53 0.42 0.03 3620000 8.30 8.30 fxDiv_performance + 6.53 0.45 0.03 3620000 8.30 8.30 fxDiv_fair + 2.18 0.46 0.01 3620000 2.77 2.77 fxDiv_precision + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) for 2.17% of 0.46 seconds + +index % time self children called name + <spontaneous> +[1] 100.0 0.34 0.12 main [1] + 0.05 0.00 3620000/3620000 fxDiv_float [2] + 0.03 0.00 3620000/3620000 fxDiv_performance [3] + 0.03 0.00 3620000/3620000 fxDiv_fair [4] + 0.01 0.00 3620000/3620000 fxDiv_precision [5] +----------------------------------------------- + 0.05 0.00 3620000/3620000 main [1] +[2] 10.9 0.05 0.00 3620000 fxDiv_float [2] +----------------------------------------------- + 0.03 0.00 3620000/3620000 main [1] +[3] 6.5 0.03 0.00 3620000 fxDiv_performance [3] +----------------------------------------------- + 0.03 0.00 3620000/3620000 main [1] +[4] 6.5 0.03 0.00 3620000 fxDiv_fair [4] +----------------------------------------------- + 0.01 0.00 3620000/3620000 main [1] +[5] 2.2 0.01 0.00 3620000 fxDiv_precision [5] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `<spontaneous>' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [4] fxDiv_fair [3] fxDiv_performance [1] main + [2] fxDiv_float [5] fxDiv_precision diff --git a/speedtest/testmul_32.txt b/speedtest/testmul_32.txt new file mode 100644 index 0000000..55ea5e2 --- /dev/null +++ b/speedtest/testmul_32.txt @@ -0,0 +1,162 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 87.61 0.21 0.21 main + 8.34 0.23 0.02 724001 27.66 27.66 fxMul_float + 4.17 0.24 0.01 724001 13.83 13.83 fxMul_performance + 0.00 0.24 0.00 724001 0.00 0.00 fxMul_fair + 0.00 0.24 0.00 724001 0.00 0.00 fxMul_precision + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) for 4.16% of 0.24 seconds + +index % time self children called name + <spontaneous> +[1] 100.0 0.21 0.03 main [1] + 0.02 0.00 724001/724001 fxMul_float [2] + 0.01 0.00 724001/724001 fxMul_performance [3] + 0.00 0.00 724001/724001 fxMul_precision [5] + 0.00 0.00 724001/724001 fxMul_fair [4] +----------------------------------------------- + 0.02 0.00 724001/724001 main [1] +[2] 8.3 0.02 0.00 724001 fxMul_float [2] +----------------------------------------------- + 0.01 0.00 724001/724001 main [1] +[3] 4.2 0.01 0.00 724001 fxMul_performance [3] +----------------------------------------------- + 0.00 0.00 724001/724001 main [1] +[4] 0.0 0.00 0.00 724001 fxMul_fair [4] +----------------------------------------------- + 0.00 0.00 724001/724001 main [1] +[5] 0.0 0.00 0.00 724001 fxMul_precision [5] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `<spontaneous>' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [4] fxMul_fair [3] fxMul_performance [1] main + [2] fxMul_float [5] fxMul_precision diff --git a/speedtest/testmul_64.txt b/speedtest/testmul_64.txt new file mode 100644 index 0000000..84e1128 --- /dev/null +++ b/speedtest/testmul_64.txt @@ -0,0 +1,162 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 90.17 0.09 0.09 main + 10.02 0.10 0.01 724001 13.84 13.84 fxMul_float + 0.00 0.10 0.00 724001 0.00 0.00 fxMul_fair + 0.00 0.10 0.00 724001 0.00 0.00 fxMul_performance + 0.00 0.10 0.00 724001 0.00 0.00 fxMul_precision + + % the percentage of the total running time of the +time program used by this function. + +cumulative a running sum of the number of seconds accounted + seconds for by this function and those listed above it. + + self the number of seconds accounted for by this +seconds function alone. This is the major sort for this + listing. + +calls the number of times this function was invoked, if + this function is profiled, else blank. + + self the average number of milliseconds spent in this +ms/call function per call, if this function is profiled, + else blank. + + total the average number of milliseconds spent in this +ms/call function and its descendents per call, if this + function is profiled, else blank. + +name the name of the function. This is the minor sort + for this listing. The index shows the location of + the function in the gprof listing. If the index is + in parenthesis it shows where it would appear in + the gprof listing if it were to be printed. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + + Call graph (explanation follows) + + +granularity: each sample hit covers 2 byte(s) for 9.98% of 0.10 seconds + +index % time self children called name + <spontaneous> +[1] 100.0 0.09 0.01 main [1] + 0.01 0.00 724001/724001 fxMul_float [2] + 0.00 0.00 724001/724001 fxMul_precision [5] + 0.00 0.00 724001/724001 fxMul_fair [3] + 0.00 0.00 724001/724001 fxMul_performance [4] +----------------------------------------------- + 0.01 0.00 724001/724001 main [1] +[2] 10.0 0.01 0.00 724001 fxMul_float [2] +----------------------------------------------- + 0.00 0.00 724001/724001 main [1] +[3] 0.0 0.00 0.00 724001 fxMul_fair [3] +----------------------------------------------- + 0.00 0.00 724001/724001 main [1] +[4] 0.0 0.00 0.00 724001 fxMul_performance [4] +----------------------------------------------- + 0.00 0.00 724001/724001 main [1] +[5] 0.0 0.00 0.00 724001 fxMul_precision [5] +----------------------------------------------- + + This table describes the call tree of the program, and was sorted by + the total amount of time spent in each function and its children. + + Each entry in this table consists of several lines. The line with the + index number at the left hand margin lists the current function. + The lines above it list the functions that called this function, + and the lines below it list the functions this one called. + This line lists: + index A unique number given to each element of the table. + Index numbers are sorted numerically. + The index number is printed next to every function name so + it is easier to look up where the function is in the table. + + % time This is the percentage of the `total' time that was spent + in this function and its children. Note that due to + different viewpoints, functions excluded by options, etc, + these numbers will NOT add up to 100%. + + self This is the total amount of time spent in this function. + + children This is the total amount of time propagated into this + function by its children. + + called This is the number of times the function was called. + If the function called itself recursively, the number + only includes non-recursive calls, and is followed by + a `+' and the number of recursive calls. + + name The name of the current function. The index number is + printed after it. If the function is a member of a + cycle, the cycle number is printed between the + function's name and the index number. + + + For the function's parents, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the function into this parent. + + children This is the amount of time that was propagated from + the function's children into this parent. + + called This is the number of times this parent called the + function `/' the total number of times the function + was called. Recursive calls to the function are not + included in the number after the `/'. + + name This is the name of the parent. The parent's index + number is printed after it. If the parent is a + member of a cycle, the cycle number is printed between + the name and the index number. + + If the parents of the function cannot be determined, the word + `<spontaneous>' is printed in the `name' field, and all the other + fields are blank. + + For the function's children, the fields have the following meanings: + + self This is the amount of time that was propagated directly + from the child into the function. + + children This is the amount of time that was propagated from the + child's children to the function. + + called This is the number of times the function called + this child `/' the total number of times the child + was called. Recursive calls by the child are not + listed in the number after the `/'. + + name This is the name of the child. The child's index + number is printed after it. If the child is a + member of a cycle, the cycle number is printed + between the name and the index number. + + If there are any cycles (circles) in the call graph, there is an + entry for the cycle-as-a-whole. This entry shows who called the + cycle (as parents) and the members of the cycle (as children.) + The `+' recursive calls entry shows the number of function calls that + were internal to the cycle, and the calls entry for each member shows, + for that member, how many times it was called from other members of + the cycle. + +Copyright (C) 2012-2018 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + +Index by function name + + [3] fxMul_fair [4] fxMul_performance [1] main + [2] fxMul_float [5] fxMul_precision -- GitLab