diff --git a/extra/fx_head.h b/extra/fx_head.h new file mode 100644 index 0000000000000000000000000000000000000000..6d9bd26a9b71c0b8d449d09e20b903517d71bad4 --- /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 0000000000000000000000000000000000000000..88bf98c00db247af166dbec3a161b30615586f0f --- /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 0000000000000000000000000000000000000000..c7900f127da0cc2e5e33a9428fc9be885d7f5cf6 --- /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 0000000000000000000000000000000000000000..dbfec7b9835a93608e89a377ca1052453e7faf18 --- /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 0000000000000000000000000000000000000000..e1ba5ce2672467e9a0cd0d675c798e10e448b6a1 --- /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 Binary files /dev/null and b/extra/test differ diff --git a/extra/test.c b/extra/test.c new file mode 100644 index 0000000000000000000000000000000000000000..a1ca9ca63d31ac98376945f1345ab70bcf802066 --- /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 0000000000000000000000000000000000000000..b763ad4df88dab61e80abb67fb5cae36a0583c9d --- /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 0000000000000000000000000000000000000000..6d9bd26a9b71c0b8d449d09e20b903517d71bad4 --- /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 0000000000000000000000000000000000000000..88bf98c00db247af166dbec3a161b30615586f0f --- /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 0000000000000000000000000000000000000000..c7900f127da0cc2e5e33a9428fc9be885d7f5cf6 --- /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 0000000000000000000000000000000000000000..1593d67ab8f80c6c0592e18a6e476c371aeaaa62 --- /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 0000000000000000000000000000000000000000..6d9bd26a9b71c0b8d449d09e20b903517d71bad4 --- /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 0000000000000000000000000000000000000000..88bf98c00db247af166dbec3a161b30615586f0f --- /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 0000000000000000000000000000000000000000..c7900f127da0cc2e5e33a9428fc9be885d7f5cf6 --- /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 0000000000000000000000000000000000000000..0bfcfa2ba764cd9a5055fb360c287989925fc368 --- /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 0000000000000000000000000000000000000000..6d9bd26a9b71c0b8d449d09e20b903517d71bad4 --- /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 0000000000000000000000000000000000000000..88bf98c00db247af166dbec3a161b30615586f0f --- /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 0000000000000000000000000000000000000000..c7900f127da0cc2e5e33a9428fc9be885d7f5cf6 --- /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 0000000000000000000000000000000000000000..7b853564f6b05cf4ca84b8dd1b7713510f394448 --- /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 0000000000000000000000000000000000000000..0ad6e5bc42d0e075aadb80673e6ebe2a8b61b305 --- /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 0000000000000000000000000000000000000000..6d9bd26a9b71c0b8d449d09e20b903517d71bad4 --- /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 0000000000000000000000000000000000000000..88bf98c00db247af166dbec3a161b30615586f0f --- /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 0000000000000000000000000000000000000000..c7900f127da0cc2e5e33a9428fc9be885d7f5cf6 --- /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 0000000000000000000000000000000000000000..f79dac1029578c8212ac82a9ca4cc7836fd62265 --- /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 0000000000000000000000000000000000000000..94ace4b662d4383baa022b69032ee39a2c21d679 --- /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 0000000000000000000000000000000000000000..9e8985563d4f9cab66fe397e1d5ef44c8ac184e7 --- /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 0000000000000000000000000000000000000000..3317d81f34a2f43949395c647f53026a818e8547 --- /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 0000000000000000000000000000000000000000..a70ab958cdcaa56decfdfebb803144e630d9b15d --- /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 0000000000000000000000000000000000000000..3da672f4225486564b08eb6ce26b72bfaa6a4ab6 --- /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 0000000000000000000000000000000000000000..55ea5e22a27b32aff2b6532a68e5e81d75b8b8c5 --- /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 0000000000000000000000000000000000000000..84e11280ae186531c9e614864bda588acaa2b6b4 --- /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