diff --git a/gprof/Makefile b/gprof/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..784a7f4158727c695b059a7ee56b7cf127e7d573 --- /dev/null +++ b/gprof/Makefile @@ -0,0 +1,19 @@ +SRCS := test.c fx_s1516_double.c fx_s1516_longlong.c +OBJS = $(SRCS:.c=.o) +CC = gcc +CFLAGS = -Wall + +fx_test: $(OBJS) + $(CC) -o $@ $^ -lm + +test.o: test.c + $(CC) $(CFLAGS) -c $^ + +fx_s1516_double.o: fx_s1516_double.c + $(CC) -c $^ + +fx_s1516_longlong.o: fx_s1516_longlong.c + $(CC) -c $^ + +clean: + rm $(OBJS) fx_test \ No newline at end of file diff --git a/gprof/README.md b/gprof/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d402b0090d6e8d8748e7024fc666e5400c9380bb --- /dev/null +++ b/gprof/README.md @@ -0,0 +1,144 @@ +# Battle C Team project - Team 3 + +## Team members + +| Name | Student ID | +| :----: | :--------: | +| 남도현 | 201620921 | +| 이장원 | 201920756 | +| 이화진 | 201723268 | +| 황영준 | 201420989 | + + + +## Fixed Point + +### What is Fixed point? + +- 흔히 사용되는 부동 소수점 방식과 다르게 소수점의 위치를 고정해 놓고 실수를 표현하는 방법이다. +- 구현이 간편하지만 표현가능한 수의 범위가 좁고 정밀도가 낮다는 단점이 존재한다. + + + +## fx_s1516 - fixed point number + +### fx_s1516 + + + +- 총 32 Bit이며, 맨 앞의 1Bit는 부호를 나타내는 비트로 사용한다. +- 그 뒤의 15 Bit는 정수부, 16 Bit는 소수부를 표현한다. + +### values - min, max, resolution + +- minimum value: -32768 (= -2^15) +- maximum value: 32767.9999847 (= 2^15 - 1/2^16) +- resolution: 0.00001525878 (= 1/2^16) + + + +## fx_s1516 Library + +### macros + +| Macro | Description | +| ------------------- | ----------------------------------------- | +| P2_16 | 고정소수점 표현을 위해 필요한 2^16을 정의 | +| e | math.h의 M_E를 활용하여 자연상수 e를 정의 | +| fx_s1516_PI | math.h의 M_PI를 활용하여 원주율 PI를 정의 | +| fx_s1516_INVERSE_PI | 앞서 정의한 PI의 역을 정의 | + +### functions + +| Name | Return type | Parameters | Description | +| ---------------- | ----------- | --------------------- | ------------------------------------------------- | +| double_to_fx | double | double a | double형 a값을 fx_s1516형으로 형 변환 | +| fx_to_double | double | fx_s1516 a | fx_s1516형 a값을 double형으로 형 변환 | +| fx_s1516_add | double | double a, double b | fx_s1516 연산으로 a + b값을 계산 | +| fx_s1516_sub | double | double a, double b | fx_s1516 연산으로 a - b값을 계산 | +| fx_s1516_mul | double | double a, double b | fx_s1516 연산으로 a * b값을 계산 | +| fx_s1516_div | double | double a, double b | fx_s1516 연산으로 a / b값을 계산 | +| degree_to_radian | double | fx_s1516 a | fx_s1516형 a값을 radian 값으로 변환 | +| fx_s1516_sin | double | double a | 라디안 값을 받아 fx_s1516 연산으로 sin값을 계산 | +| fx_s1516_sqrt | double | double a | fx_s1516 연산으로 a의 제곱근 계산 | +| fx_s1516_pow | double | double a, double b | fx_s1516 연산으로 a의 b거듭제곱을 계산 | +| fx_s1516_log | double | double a, double b | fx_s1516 연산으로 b를 밑으로 하는 a의 로그를 계산 | +| baselog | double | double a, double base | base를 밑으로 하는 a의 로그를 계산 | + + + +## make + +### descriptions + +- 다수의 모듈로 구성된 프로그램을 효율적으로 유지하고, 관리할 수 있도록 도와주는 도구이다. +- 여러 파일들 간 의존성을 저장하고 수정된 파일에 연관된 것들만 재 컴파일할 수 있다. +- 자주 쓰는 명령어를 정의해 자동화할 수 있다. + +### codes + +- macro: 일반 코딩에서 변수 선언과 같이 단순한 매크로에 여러 파일 혹은 링크 명령어들을 지정할 수 있다. + + ```makefile + SRCS := test.c fx_s1516_double.c + OBJS = $(SRCS:.c=.o) + CC = gcc + CFLAGS = -c -Wall -g + ``` + + - macro 선언에는 '='과 ':=' 표현 중 아무거나 한 개를 쓰면 된다. + - $(SRCS:.c=.o)는 SRCS 중에서 .c로 끝나느 파일을 .o로 바꾸어 할당한다는 뜻이다. + +- Internal Macro: 기본적으로 내장되어 있는 매크로를 뜻하며 재정의 할 수 없다. + + | name | description | + | ---- | ------------------------------------------------ | + | $@ | 현재 target명 | + | $? | 현재 target보다 더 최근에 갱신된 dependency 명단 | + | $< | dependency중 첫 번째 파일명 | + | $^ | 현재 모든 dependency 명단 | + +- Pre-defined Macro: Internal Macro와 같이 내장되어 있으나 재정의할 수 있다. + + ```makefile + CC = gcc + ``` + + - CC는 기본적으로 ```cc```로 선언되어 있지만 ```gcc```로 재정의하여 사용하였다. + +- target과 dependency(pre-requirement): terminal에서 make 명령어 바로 뒤에 올 수 있는 것을 target, 해당 타겟이 실행되기 위해 필요한 것을 dependency라고 한다. + + ```makefile + fx_x1516_double: $(OBJS) + $(CC) -o $@ $^ + ``` + + - 매크로를 사용할 때 매크로 이름이 2글자 이상이면 괄호() 또는 중괄호{}로 감싸주어야 한다. + - target과 dependency 바로 밑에 해당 타겟이 호출되면 실행될 터미널 명령어를 정의할 수 있는데 앞에는 무조건 ```tab```을 넣어주어야 한다. + +- dummy target: dependency 없이 정의된 target을 뜻한다. + + ```makefile + clean: + -rm $(OBJS) + rm fx_s1516_double + + dep: + $(CC) -M $(SRCS) + ``` + + - clean은 ```make```로 생성되었던 *.o 파일들과 fx_s1516_double 실행 파일을 삭제한다. + - 터미널 명령을 정의할 때 맨 앞에 ```-```를 삽입하면 해당 명령어가 정상 실행되지 않더라도 다음 줄의 명령어를 실행한다. + - dep는 컴파일 할 명령어에서 사용하고 있는 헤더를 자동으로 찾아서 매핑해주는 역할을 한다. + +### commands + +- ```make```: *.c 파일을 컴파일하여 *.o 파일을 만들고, fx_s1516_double 실행 파일을 생성한다. +- ```make clean```: *.o 파일과 fx_s1516_double 실행 파일을 제거한다. + +### + +## References + +###### Randy Yates, Fixed-Point Arithmetic: An Introudction. pp6-pp11 + diff --git a/gprof/div_result.txt b/gprof/div_result.txt new file mode 100644 index 0000000000000000000000000000000000000000..faa24f53b7be01176c8f042d050e8d4282f58f19 --- /dev/null +++ b/gprof/div_result.txt @@ -0,0 +1,186 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 28.28 1.10 1.10 __udivmoddi4 + 25.96 2.11 1.01 __divsi3 + 15.94 2.73 0.62 main + 12.08 3.20 0.47 10000001 47.00 59.00 fx_s1516_double_div + 4.37 3.37 0.17 10000001 17.00 17.00 fx_s1516_longlong_div0 + 4.11 3.53 0.16 10000001 16.00 16.00 fx_s1516_longlong_div1 + 3.08 3.65 0.12 10000001 12.00 12.00 double_to_fx + 3.08 3.77 0.12 10000001 12.00 12.00 fx_s1516_longlong_div2 + 3.08 3.89 0.12 __aeabi_ldivmod + 0.00 3.89 0.00 2 0.00 0.00 fx_to_double + + % 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-2017 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 4 byte(s) for 0.26% of 3.89 seconds + +index % time self children called name + <spontaneous> +[1] 42.7 0.62 1.04 main [1] + 0.47 0.12 10000001/10000001 fx_s1516_double_div [4] + 0.17 0.00 10000001/10000001 fx_s1516_longlong_div0 [5] + 0.16 0.00 10000001/10000001 fx_s1516_longlong_div1 [6] + 0.12 0.00 10000001/10000001 fx_s1516_longlong_div2 [8] + 0.00 0.00 2/2 fx_to_double [10] +----------------------------------------------- + <spontaneous> +[2] 28.3 1.10 0.00 __udivmoddi4 [2] +----------------------------------------------- + <spontaneous> +[3] 26.0 1.01 0.00 __divsi3 [3] +----------------------------------------------- + 0.47 0.12 10000001/10000001 main [1] +[4] 15.2 0.47 0.12 10000001 fx_s1516_double_div [4] + 0.12 0.00 10000001/10000001 double_to_fx [7] +----------------------------------------------- + 0.17 0.00 10000001/10000001 main [1] +[5] 4.4 0.17 0.00 10000001 fx_s1516_longlong_div0 [5] +----------------------------------------------- + 0.16 0.00 10000001/10000001 main [1] +[6] 4.1 0.16 0.00 10000001 fx_s1516_longlong_div1 [6] +----------------------------------------------- + 0.12 0.00 10000001/10000001 fx_s1516_double_div [4] +[7] 3.1 0.12 0.00 10000001 double_to_fx [7] +----------------------------------------------- + 0.12 0.00 10000001/10000001 main [1] +[8] 3.1 0.12 0.00 10000001 fx_s1516_longlong_div2 [8] +----------------------------------------------- + <spontaneous> +[9] 3.1 0.12 0.00 __aeabi_ldivmod [9] +----------------------------------------------- + 0.00 0.00 2/2 main [1] +[10] 0.0 0.00 0.00 2 fx_to_double [10] +----------------------------------------------- + + 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-2017 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 + + [9] __aeabi_ldivmod [4] fx_s1516_double_div [10] fx_to_double + [3] __divsi3 [5] fx_s1516_longlong_div0 [1] main + [2] __udivmoddi4 [6] fx_s1516_longlong_div1 + [7] double_to_fx [8] fx_s1516_longlong_div2 diff --git a/gprof/fx_s1516_double.c b/gprof/fx_s1516_double.c new file mode 100644 index 0000000000000000000000000000000000000000..4ebe7a99b68dcaa876cbc2dace16fbe0a8a97e7e --- /dev/null +++ b/gprof/fx_s1516_double.c @@ -0,0 +1,51 @@ +// fx_s1516_double.c file +#include "fx_s1516_double.h" + +double double_to_fx(double a) { + return ((a) * P2_16); +} + +double fx_to_double(fx_s1516 a) { + return ((double)(a) / P2_16); +} + +double fx_s1516_double_add(double a, double b){ + return double_to_fx((a) + (b)); +} + +double fx_s1516_double_sub(double a, double b){ + return double_to_fx((a) - (b)); +} + +double fx_s1516_double_mul(double a, double b) { + return double_to_fx((a) * (b) * P2_16); +} + +double fx_s1516_double_div(double a, double b) { + return double_to_fx((a) / (b) / P2_16); +} + +double degree_to_radian(double a) { + return ((a) * fx_s1516_PI / 180); +} + +double fx_s1516_double_sin(double a) { + return double_to_fx(sin(a * P2_16) / (P2_16)); +} + +double fx_s1516_double_sqrt(double a) { + return double_to_fx(sqrt(a) / sqrt(P2_16)); +} + +double fx_s1516_double_pow(double a, double b) { + return double_to_fx(pow(a, (double)b) * pow(P2_16, (double)b - 1)); +} + +double fx_s1516_double_log(double a, double b) { + return double_to_fx(baselog(a * P2_16, b) / (P2_16)); +} + +double baselog(double a, double base) +{ + return log(a) / log(base); +} \ No newline at end of file diff --git a/gprof/fx_s1516_double.h b/gprof/fx_s1516_double.h new file mode 100644 index 0000000000000000000000000000000000000000..7dc96719004c92cca2783fb8b7befa583921a88f --- /dev/null +++ b/gprof/fx_s1516_double.h @@ -0,0 +1,26 @@ +#pragma once +#define __FX_S1516_DOUBLE_H + +typedef int fx_s1516; + +#define _USE_MATH_DEFINES +#include <math.h> +#include <stdio.h> +#define P2_16 65536 +#define fP2_16 65536.0 +#define e M_E +#define fx_s1516_PI M_PI +#define fx_s1516_INVERSE_PI 1/M_PI + +extern double double_to_fx(double a); +extern double fx_to_double(fx_s1516 a); +extern double baselog(double a, double base); +extern double fx_s1516_double_add(double a, double b); +extern double fx_s1516_double_sub(double a, double b); +extern double fx_s1516_double_mul(double a, double b); +extern double fx_s1516_double_div(double a, double b); +extern double fx_s1516_double_sqrt(double a); +extern double fx_s1516_double_pow(double a, double b); +extern double fx_s1516_double_log(double a, double b); +extern double degree_to_radian(double a); +extern double fx_s1516_double_sin(double a); diff --git a/gprof/fx_s1516_longlong.c b/gprof/fx_s1516_longlong.c new file mode 100644 index 0000000000000000000000000000000000000000..cb8813e4c76a2ef3c1cedd19c0ff61e33e43cad2 --- /dev/null +++ b/gprof/fx_s1516_longlong.c @@ -0,0 +1,182 @@ +//fx_1516_longlong.c file +#include "fx_s1516_longlong.h" + +#define FX32_90 0x005A0000 +#define FX32_180 0x00B40000 +#define FX32_360 0x01680000 + +// sin table +const fixed32 fx32_SinTable[92] = + { + 0,1143,2287,3429,4571,5711,6850,7986,9120,10252,11380,12504,13625,14742,15854,16961,18064,19160,20251,21336,22414,23486,24550,25606,26655, 27696,28729,29752, + 30767,31772,32768,33753,34728,35693,36647,37589,38521,39440,40347,41243,42125,42995,43852,44695,45525,46340,47142, 47929,48702,49460,50203,50931,51643,52339, + 53019,53683,54331,54963,55577,56175,56755,57319,57864,58393,58903,59395,59870,60326,60763, 61183,61583,61965,62328,62672,62997,63302,63589,63856,64103,64331, + 64540,64729,64898,65047,65176,65286,65376,65446,65496,65526,65536,65526 + }; +int sqrt_lut[1025] = + { + 0x00000001,0x01000000,0x016A09E6,0x01BB67AE,0x02000000,0x023C6EF3,0x027311C2,0x02A54FF5,0x02D413CC,0x03000000,0x03298B07,0x03510E52,0x0376CF5D,0x039B0568,0x03BDDD42,0x03DF7BD6,0x04000000,0x041F83D9,0x043E1DB3,0x045BE0CD,0x0478DDE6,0x049523AE, + 0x04B0BF16,0x04CBBB9D,0x04E62385,0x05000000,0x05195957,0x0532370B,0x054A9FEA,0x05629A29,0x057A2B74,0x05915901,0x05A82799,0x05BE9BA8,0x05D4B943,0x05EA8434,0x06000000,0x06152FEC,0x062A1709,0x063EB830,0x0653160E,0x06673326,0x067B11D2,0x068EB44A,0x06A21CA4,0x06B54CDA, + 0x06C846C7,0x06DB0C2E,0x06ED9EBA,0x07000000,0x07123180,0x072434A7,0x07360AD1,0x0747B548,0x07593547,0x076A8BFB,0x077BBA84,0x078CC1F3,0x079DA34E,0x07AE5F91,0x07BEF7AC,0x07CF6C85,0x07DFBEFA,0x07EFEFDF,0x08000000,0x080FF01F,0x081FC0FB,0x082F7347,0x083F07B3,0x084E7EE6, + 0x085DD983,0x086D1826,0x087C3B66,0x088B43D4,0x089A31FD,0x08A90668,0x08B7C19A,0x08C66410,0x08D4EE47,0x08E360B5,0x08F1BBCD,0x09000000,0x090E2DB8,0x091C4560,0x092A475C,0x09383410,0x09460BDC,0x0953CF1D,0x09617E2C,0x096F1963,0x097CA116,0x098A1598,0x0997773A,0x09A4C64B, + 0x09B20318,0x09BF2DEA,0x09CC470A,0x09D94EBE,0x09E6454C,0x09F32AF7,0x0A000000,0x0A0CC4A6,0x0A197927,0x0A261DC1,0x0A32B2AF,0x0A3F382A,0x0A4BAE6A,0x0A5815A7,0x0A646E17,0x0A70B7ED,0x0A7CF35D,0x0A89209A,0x0A953FD4,0x0AA1513C,0x0AAD5500,0x0AB94B4D,0x0AC53452,0x0AD11039, + 0x0ADCDF2E,0x0AE8A15B,0x0AF456E9,0x0B000000,0x0B0B9CC7,0x0B172D66,0x0B22B202,0x0B2E2AC1,0x0B3997C6,0x0B44F936,0x0B504F33,0x0B5B99DF,0x0B66D95D,0x0B720DCD,0x0B7D3750,0x0B885605,0x0B936A0C,0x0B9E7382,0x0BA97286,0x0BB46736,0x0BBF51AE,0x0BCA320B,0x0BD50868,0x0BDFD4E2, + 0x0BEA9792,0x0BF55093,0x0C000000,0x0C0AA5F1,0x0C154280,0x0C1FD5C5,0x0C2A5FD9,0x0C34E0D4,0x0C3F58CC,0x0C49C7D9,0x0C542E12,0x0C5E8B8D,0x0C68E05F,0x0C732C9E,0x0C7D7060,0x0C87ABB9,0x0C91DEBF,0x0C9C0984,0x0CA62C1D,0x0CB0469E,0x0CBA5919,0x0CC463A2,0x0CCE664C,0x0CD86129, + 0x0CE2544B,0x0CEC3FC3,0x0CF623A5,0x0D000000,0x0D09D4E5,0x0D13A267,0x0D1D6895,0x0D27277F,0x0D30DF36,0x0D3A8FCA,0x0D443949,0x0D4DDBC5,0x0D57774B,0x0D610BEB,0x0D6A99B4,0x0D7420B4,0x0D7DA0FA,0x0D871A93,0x0D908D8E,0x0D99F9F8,0x0DA35FE0,0x0DACBF52,0x0DB6185C,0x0DBF6B0A, + 0x0DC8B76B,0x0DD1FD8A,0x0DDB3D74,0x0DE47735,0x0DEDAADA,0x0DF6D86F,0x0E000000,0x0E092197,0x0E123D42,0x0E1B530C,0x0E246300,0x0E2D6D28,0x0E367191,0x0E3F7045,0x0E48694E,0x0E515CB8,0x0E5A4A8D,0x0E6332D8,0x0E6C15A2,0x0E74F2F6,0x0E7DCADD,0x0E869D63,0x0E8F6A90,0x0E98326E, + 0x0EA0F507,0x0EA9B264,0x0EB26A8F,0x0EBB1D90,0x0EC3CB71,0x0ECC743B,0x0ED517F7,0x0EDDB6AE,0x0EE65068,0x0EEEE52E,0x0EF77508,0x0F000000,0x0F08861C,0x0F110766,0x0F1983E6,0x0F21FBA3,0x0F2A6EA6,0x0F32DCF6,0x0F3B469C,0x0F43AB9F,0x0F4C0C07,0x0F5467DB,0x0F5CBF22,0x0F6511E5, + 0x0F6D602A,0x0F75A9F9,0x0F7DEF58,0x0F863050,0x0F8E6CE6,0x0F96A522,0x0F9ED90B,0x0FA708A8,0x0FAF33FE,0x0FB75B16,0x0FBF7DF5,0x0FC79CA3,0x0FCFB724,0x0FD7CD81,0x0FDFDFBF,0x0FE7EDE4,0x0FEFF7F7,0x0FF7FDFE,0x10000000,0x1007FE00,0x100FF807,0x1017EE1A,0x101FE03F,0x1027CE7B, + 0x102FB8D4,0x10379F51,0x103F81F6,0x104760C9,0x104F3BD0,0x10571310,0x105EE68E,0x1066B651,0x106E825D,0x10764AB8,0x107E0F66,0x1085D06E,0x108D8DD3,0x1095479C,0x109CFDCD,0x10A4B06B,0x10AC5F7C,0x10B40B04,0x10BBB307,0x10C3578C,0x10CAF896,0x10D2962A,0x10DA304D,0x10E1C704, + 0x10E95A53,0x10F0EA3F,0x10F876CC,0x11000000,0x110785DD,0x110F0869,0x111687A8,0x111E039F,0x11257C51,0x112CF1C3,0x113463FA,0x113BD2F9,0x11433EC4,0x114AA760,0x11520CD1,0x11596F1A,0x1160CE41,0x11682A48,0x116F8334,0x1176D909,0x117E2BCA,0x11857B7B,0x118CC821,0x119411BF, + 0x119B5859,0x11A29BF2,0x11A9DC8F,0x11B11A32,0x11B854E0,0x11BF8C9D,0x11C6C16B,0x11CDF34E,0x11D5224A,0x11DC4E63,0x11E3779B,0x11EA9DF7,0x11F1C179,0x11F8E226,0x12000000,0x12071B0A,0x120E3349,0x121548BF,0x121C5B70,0x12236B5F,0x122A788F,0x12318304,0x12388AC0,0x123F8FC6, + 0x1246921A,0x124D91BF,0x12548EB9,0x125B8909,0x126280B3,0x126975BA,0x12706821,0x127757EB,0x127E451B,0x12852FB4,0x128C17B9,0x1292FD2C,0x1299E011,0x12A0C06A,0x12A79E3A,0x12AE7984,0x12B5524A,0x12BC2891,0x12C2FC59,0x12C9CDA6,0x12D09C7B,0x12D768DA,0x12DE32C6,0x12E4FA41, + 0x12EBBF4F,0x12F281F2,0x12F9422C,0x13000000,0x1306BB70,0x130D747F,0x13142B30,0x131ADF85,0x13219181,0x13284125,0x132EEE75,0x13359973,0x133C4221,0x1342E881,0x13498C97,0x13502E64,0x1356CDEB,0x135D6B2E,0x13640630,0x136A9EF2,0x13713577,0x1377C9C2,0x137E5BD4,0x1384EBAF, + 0x138B7957,0x139204CD,0x13988E14,0x139F152D,0x13A59A1A,0x13AC1CDF,0x13B29D7D,0x13B91BF6,0x13BF984C,0x13C61282,0x13CC8A99,0x13D30094,0x13D97474,0x13DFE63D,0x13E655EE,0x13ECC38C,0x13F32F17,0x13F99893,0x14000000,0x14066560,0x140CC8B6,0x14132A04,0x1419894C,0x141FE68F, + 0x142641CF,0x142C9B0E,0x1432F24F,0x14394793,0x143F9ADC,0x1445EC2B,0x144C3B83,0x145288E6,0x1458D455,0x145F1DD2,0x1465655F,0x146BAAFD,0x1471EEAF,0x14783076,0x147E7054,0x1484AE4B,0x148AEA5C,0x1491248A,0x14975CD5,0x149D9340,0x14A3C7CC,0x14A9FA7B,0x14B02B4F,0x14B65A49, + 0x14BC876B,0x14C2B2B7,0x14C8DC2E,0x14CF03D2,0x14D529A4,0x14DB4DA6,0x14E16FDA,0x14E79042,0x14EDAEDE,0x14F3CBB1,0x14F9E6BB,0x15000000,0x1506177F,0x150C2D3B,0x15124135,0x1518536F,0x151E63EA,0x152472A7,0x152A7FA9,0x15308AF1,0x15369480,0x153C9C57,0x1542A278,0x1548A6E5, + 0x154EA99F,0x1554AAA7,0x155AAA00,0x1560A7A9,0x1566A3A5,0x156C9DF5,0x1572969B,0x15788D98,0x157E82EC,0x1584769B,0x158A68A4,0x1590590A,0x159647CD,0x159C34F0,0x15A22073,0x15A80A57,0x15ADF29F,0x15B3D94B,0x15B9BE5D,0x15BFA1D6,0x15C583B6,0x15CB6401,0x15D142B6,0x15D71FD8, + 0x15DCFB67,0x15E2D564,0x15E8ADD2,0x15EE84B0,0x15F45A01,0x15FA2DC6,0x16000000,0x1605D0AF,0x160B9FD6,0x16116D75,0x1617398F,0x161D0423,0x1622CD33,0x162894C1,0x162E5ACD,0x16341F58,0x1639E265,0x163FA3F3,0x16456405,0x164B229B,0x1650DFB6,0x16569B58,0x165C5582,0x16620E35, + 0x1667C571,0x166D7B39,0x16732F8D,0x1678E26E,0x167E93DD,0x168443DC,0x1689F26C,0x168F9F8D,0x16954B41,0x169AF589,0x16A09E66,0x16A645D9,0x16ABEBE3,0x16B19084,0x16B733BF,0x16BCD594,0x16C27605,0x16C81511,0x16CDB2BB,0x16D34F03,0x16D8E9EB,0x16DE8372,0x16E41B9B,0x16E9B267, + 0x16EF47D6,0x16F4DBE9,0x16FA6EA1,0x17000000,0x17059005,0x170B1EB4,0x1710AC0B,0x1716380C,0x171BC2B9,0x17214C12,0x1726D418,0x172C5ACC,0x1731E02E,0x17376441,0x173CE704,0x1742687A,0x1747E8A2,0x174D677D,0x1752E50D,0x17586153,0x175DDC4E,0x17635602,0x1768CE6D,0x176E4591, + 0x1773BB6F,0x17793008,0x177EA35D,0x1784156E,0x1789863D,0x178EF5CA,0x17946416,0x1799D123,0x179F3CF0,0x17A4A77F,0x17AA10D1,0x17AF78E6,0x17B4DFC0,0x17BA455F,0x17BFA9C4,0x17C50CEF,0x17CA6EE3,0x17CFCF9F,0x17D52F24,0x17DA8D73,0x17DFEA8E,0x17E54674,0x17EAA126,0x17EFFAA7, + 0x17F552F5,0x17FAAA12,0x18000000,0x180554BD,0x180AA84C,0x180FFAAE,0x18154BE2,0x181A9BEA,0x181FEAC6,0x18253878,0x182A8500,0x182FD05F,0x18351A95,0x183A63A3,0x183FAB8B,0x1844F24C,0x184A37E8,0x184F7C60,0x1854BFB3,0x185A01E3,0x185F42F1,0x186482DD,0x1869C1A8,0x186EFF53, + 0x18743BDE,0x1879774A,0x187EB199,0x1883EAC9,0x188922DE,0x188E59D6,0x18938FB3,0x1898C475,0x189DF81E,0x18A32AAD,0x18A85C24,0x18AD8C84,0x18B2BBCC,0x18B7E9FE,0x18BD171A,0x18C24321,0x18C76E13,0x18CC97F2,0x18D1C0BE,0x18D6E878,0x18DC0F20,0x18E134B6,0x18E6593D,0x18EB7CB4, + 0x18F09F1C,0x18F5C075,0x18FAE0C1,0x19000000,0x19051E32,0x190A3B58,0x190F5773,0x19147284,0x19198C8B,0x191EA589,0x1923BD7E,0x1928D46B,0x192DEA50,0x1932FF2F,0x19381308,0x193D25DB,0x194237AA,0x19474874,0x194C583A,0x195166FE,0x195674BF,0x195B817E,0x19608D3C,0x196597F9, + 0x196AA1B6,0x196FAA74,0x1974B233,0x1979B8F3,0x197EBEB6,0x1983C37C,0x1988C745,0x198DCA13,0x1992CBE5,0x1997CCBC,0x199CCC99,0x19A1CB7D,0x19A6C967,0x19ABC659,0x19B0C253,0x19B5BD55,0x19BAB761,0x19BFB076,0x19C4A896,0x19C99FC1,0x19CE95F7,0x19D38B39,0x19D87F87,0x19DD72E3, + 0x19E2654C,0x19E756C4,0x19EC474A,0x19F136DF,0x19F62584,0x19FB1339,0x1A000000,0x1A04EBD7,0x1A09D6C0,0x1A0EC0BC,0x1A13A9CB,0x1A1891ED,0x1A1D7924,0x1A225F6E,0x1A2744CE,0x1A2C2943,0x1A310CCF,0x1A35EF71,0x1A3AD12A,0x1A3FB1FA,0x1A4491E3,0x1A4970E4,0x1A4E4EFE,0x1A532C32, + 0x1A580880,0x1A5CE3E9,0x1A61BE6C,0x1A66980C,0x1A6B70C7,0x1A70489F,0x1A751F94,0x1A79F5A6,0x1A7ECAD7,0x1A839F26,0x1A887293,0x1A8D4521,0x1A9216CE,0x1A96E79C,0x1A9BB78A,0x1AA0869A,0x1AA554CC,0x1AAA2220,0x1AAEEE97,0x1AB3BA31,0x1AB884EF,0x1ABD4ED1,0x1AC217D7,0x1AC6E003, + 0x1ACBA754,0x1AD06DCB,0x1AD53369,0x1AD9F82D,0x1ADEBC19,0x1AE37F2D,0x1AE84169,0x1AED02CD,0x1AF1C35B,0x1AF68312,0x1AFB41F4,0x1B000000,0x1B04BD36,0x1B097998,0x1B0E3526,0x1B12EFE0,0x1B17A9C7,0x1B1C62DB,0x1B211B1C,0x1B25D28B,0x1B2A8929,0x1B2F3EF5,0x1B33F3F1,0x1B38A81C, + 0x1B3D5B77,0x1B420E03,0x1B46BFC0,0x1B4B70AE,0x1B5020CE,0x1B54D020,0x1B597EA4,0x1B5E2C5B,0x1B62D946,0x1B678565,0x1B6C30B8,0x1B70DB3F,0x1B7584FC,0x1B7A2DED,0x1B7ED615,0x1B837D73,0x1B882408,0x1B8CC9D3,0x1B916ED6,0x1B961311,0x1B9AB684,0x1B9F592F,0x1BA3FB14,0x1BA89C32, + 0x1BAD3C8A,0x1BB1DC1B,0x1BB67AE8,0x1BBB18EF,0x1BBFB632,0x1BC452B0,0x1BC8EE6B,0x1BCD8962,0x1BD22395,0x1BD6BD06,0x1BDB55B5,0x1BDFEDA1,0x1BE484CC,0x1BE91B36,0x1BEDB0DE,0x1BF245C7,0x1BF6D9EF,0x1BFB6D57,0x1C000000,0x1C0491E9,0x1C092314,0x1C0DB381,0x1C12432F,0x1C16D220, + 0x1C1B6054,0x1C1FEDCB,0x1C247A85,0x1C290684,0x1C2D91C6,0x1C321C4D,0x1C36A619,0x1C3B2F2A,0x1C3FB780,0x1C443F1D,0x1C48C600,0x1C4D4C29,0x1C51D19A,0x1C565651,0x1C5ADA51,0x1C5F5D98,0x1C63E028,0x1C686201,0x1C6CE322,0x1C71638D,0x1C75E342,0x1C7A6240,0x1C7EE08A,0x1C835E1D, + 0x1C87DAFC,0x1C8C5727,0x1C90D29D,0x1C954D5F,0x1C99C76D,0x1C9E40C8,0x1CA2B971,0x1CA73166,0x1CABA8AA,0x1CB01F3B,0x1CB4951B,0x1CB90A49,0x1CBD7EC7,0x1CC1F293,0x1CC665B0,0x1CCAD81C,0x1CCF49D9,0x1CD3BAE6,0x1CD82B44,0x1CDC9AF3,0x1CE109F4,0x1CE57847,0x1CE9E5EC,0x1CEE52E3, + 0x1CF2BF2D,0x1CF72ACA,0x1CFB95BB,0x1D000000,0x1D046998,0x1D08D285,0x1D0D3AC6,0x1D11A25C,0x1D160948,0x1D1A6F89,0x1D1ED520,0x1D233A0D,0x1D279E51,0x1D2C01EB,0x1D3064DC,0x1D34C725,0x1D3928C5,0x1D3D89BE,0x1D41EA0E,0x1D4649B7,0x1D4AA8B9,0x1D4F0714,0x1D5364C8,0x1D57C1D6, + 0x1D5C1E3E,0x1D607A01,0x1D64D51E,0x1D692F95,0x1D6D8968,0x1D71E296,0x1D763B20,0x1D7A9306,0x1D7EEA48,0x1D8340E7,0x1D8796E3,0x1D8BEC3C,0x1D9040F2,0x1D949505,0x1D98E877,0x1D9D3B47,0x1DA18D76,0x1DA5DF03,0x1DAA2FEF,0x1DAE803B,0x1DB2CFE6,0x1DB71EF1,0x1DBB6D5C,0x1DBFBB28, + 0x1DC40854,0x1DC854E2,0x1DCCA0D0,0x1DD0EC20,0x1DD536D2,0x1DD980E6,0x1DDDCA5C,0x1DE21335,0x1DE65B70,0x1DEAA30F,0x1DEEEA11,0x1DF33076,0x1DF77640,0x1DFBBB6E,0x1E000000,0x1E0443F6,0x1E088752,0x1E0CCA12,0x1E110C39,0x1E154DC4,0x1E198EB6,0x1E1DCF0E,0x1E220ECD,0x1E264DF2, + 0x1E2A8C7E,0x1E2ECA71,0x1E3307CC,0x1E37448E,0x1E3B80B9,0x1E3FBC4B,0x1E43F746,0x1E4831AA,0x1E4C6B77,0x1E50A4AD,0x1E54DD4C,0x1E591556,0x1E5D4CC9,0x1E6183A6,0x1E65B9ED,0x1E69EFA0,0x1E6E24BD,0x1E725945,0x1E768D39,0x1E7AC099,0x1E7EF364,0x1E83259B,0x1E87573F,0x1E8B884F, + 0x1E8FB8CC,0x1E93E8B7,0x1E98180E,0x1E9C46D3,0x1EA07506,0x1EA4A2A7,0x1EA8CFB6,0x1EACFC33,0x1EB1281F,0x1EB5537B,0x1EB97E45,0x1EBDA87F,0x1EC1D228,0x1EC5FB41,0x1ECA23CA,0x1ECE4BC4,0x1ED2732E,0x1ED69A09,0x1EDAC054,0x1EDEE611,0x1EE30B40,0x1EE72FE0,0x1EEB53F2,0x1EEF7776, + 0x1EF39A6C,0x1EF7BCD5,0x1EFBDEB1,0x1F000000,0x1F0420C1,0x1F0840F7,0x1F0C60A0,0x1F107FBD,0x1F149E4D,0x1F18BC53,0x1F1CD9CC,0x1F20F6BB,0x1F25131E,0x1F292EF7,0x1F2D4A45,0x1F316508,0x1F357F42,0x1F3998F1,0x1F3DB217,0x1F41CAB3,0x1F45E2C6,0x1F49FA4F,0x1F4E1150,0x1F5227C8, + 0x1F563DB7,0x1F5A531E,0x1F5E67FD,0x1F627C54,0x1F669024,0x1F6AA36C,0x1F6EB62D,0x1F72C866,0x1F76DA19,0x1F7AEB45,0x1F7EFBEB,0x1F830C0B,0x1F871BA4,0x1F8B2AB8,0x1F8F3946,0x1F93474E,0x1F9754D1,0x1F9B61D0,0x1F9F6E49,0x1FA37A3E,0x1FA785AE,0x1FAB909A,0x1FAF9B02,0x1FB3A4E7, + 0x1FB7AE47,0x1FBBB724,0x1FBFBF7E,0x1FC3C755,0x1FC7CEA9,0x1FCBD57A,0x1FCFDBC9,0x1FD3E196,0x1FD7E6E0,0x1FDBEBA9,0x1FDFEFEF,0x1FE3F3B5,0x1FE7F6F9,0x1FEBF9BC,0x1FEFFBFD,0x1FF3FDBF,0x1FF7FEFF,0x1FFBFFBF,0x20000000 + }; + +fx_s1516 longlong_to_fx(long long a) +{ + return (a * 65536); +} + +long long fx_to_longlong(fx_s1516 a) +{ + return (a / 65536); +} + +fx_s1516 fx_s1516_longlong_mul0(fx_s1516 a, fx_s1516 b) +{ + return (fixed32)(((fixed64)a * b) >> 16); +} + +fx_s1516 fx_s1516_longlong_mul1(fx_s1516 a, fx_s1516 b) +{ + return (fixed32)((a * b) >> 16); // no fixed +} + +fx_s1516 fx_s1516_longlong_mul2(fx_s1516 a, fx_s1516 b) +{ + return (fixed32)((a >> 8) * (b >> 8)); +} + +fx_s1516 fx_s1516_longlong_mul3(fx_s1516 a, fx_s1516 b) +{ + return (fixed32)((a >> 10) * (b >> 6)); +} + +fx_s1516 fx_s1516_longlong_mul4(fx_s1516 a, fx_s1516 b) +{ + return (fixed32)((a >> 4) * (b >> 4) >> 8); +} + +//mul���� (fixed) conversion ���ϸ� : ���ڰ� -1 ���� 1�� (�۰�)����ȭ �Ǿ������� ������ ������. +// fixed�� �ٿ��� ���� �غ��� +// ����Ʈ ���굵 �������� +// for ���� ���� �������� +// ���� ���� ���� �ź��� ���� ū�ű��� �� �־�� + +// ������ ���� : shift �������� ������ ���� 0�� �Ǿ� ������ �� �����Ƿ� �����ؾ� �Ѵ�. +fx_s1516 fx_s1516_longlong_div0(fx_s1516 a, fx_s1516 b) +{ + return (fixed32)(((fixed64)a << 16) / b); +} + +/* +* a(�������� ��)�� long long���� ij����, 16bit shift ���� �� b(������ ��)�� ���� +* long long ij����: int(32bit)�� a�� long long(64bit)�� ij���������ν� �ӵ��� ���������� 16bit shift ������ �� �� �������� �ս��� ���� �� �ִ�. +* fx_s1516_longlong�� ������ ��Ģ�����̹Ƿ� a�� b�� ����� ������ �����̰ų� �Ǽ������� ������� �� �Ҽ����� ������ �������� ��� ���������� Ŀ���� ������ �̰��� �����ϰ��� �̸� a�� 16bit shift ��Ų �� b�� ������. +*/ + +fx_s1516 fx_s1516_longlong_div1(fx_s1516 a, fx_s1516 b) +{ + return (fixed32)(((a << 8) / b) << 8); // ������ �ս�, ū ���ڿ� ���ؼ��� ������ ŭ +} + +/* +* long long���� ij�������� �ʰ� int������ ������� ������ ���� �ӵ��� ������. +* ū ���� ��� �������� �ս��� ���� �� �ִ�. +* Overflow ���ɼ��� �۾�����. +*/ + +fx_s1516 fx_s1516_longlong_div2(fx_s1516 a, fx_s1516 b) +{ + return (fixed32)(a / (b >> 16)); +} + +/* +* div1�� ���� long long���� ij�������� �ʾұ� ������ ���� �ӵ��� ������. +* Overflow�� ��Ȯ���� ����. +* b(������ ��)�� ���� ���� ��� �������� �ս��� ũ��. +*/ + +fx_s1516 fx_s1516_longlong_sin(fx_s1516 fa) +{ + int sign = 1; + fixed32 ret0, diff; + int idx; + if (fa < 0) + { + sign = -1; + fa *= -1; + } + fa = fa % FX32_360; + if (fa >= FX32_180) + { + sign *= -1; + fa -= FX32_180; + } + if (fa > FX32_90) + fa = FX32_180 - fa; + idx = fa >> 16; + ret0 = fx32_SinTable[idx]; + diff = fx32_SinTable[idx + 1] - ret0; + return (fixed32)(sign *(ret0 + ((diff*(fa & 0xFFFF)) >> 16))); +} + +fx_s1516 fx_s1516_longlong_sqrt(fx_s1516 fa) +{ + int s = 16; + int fr, ans; + if (fa < 1024) + { + if (fa <= 0) + return(0); // Error it must Return NaN + return ((sqrt_lut[fa]) >> 16); + } + do { + fa >>= 2; + --s; + } while (fa >= 1024 * 64); // 6 bit of fractional Data + fr = fa & 0x3F; + fa >>= 6; + s -= 3; + ans = sqrt_lut[fa]; + ans += ((sqrt_lut[fa + 1] - ans)*fr) >> 6; + return (fixed32)(ans >> s); +} \ No newline at end of file diff --git a/gprof/fx_s1516_longlong.h b/gprof/fx_s1516_longlong.h new file mode 100644 index 0000000000000000000000000000000000000000..eb2f2bf28bc986e0661c7703d401b97c784c3d9f --- /dev/null +++ b/gprof/fx_s1516_longlong.h @@ -0,0 +1,21 @@ +//fx_1516_longlong.h file +#pragma once + +#include <stdio.h> + +typedef int fx_s1516; +typedef long fixed32; +typedef long long fixed64; + +extern fx_s1516 longlong_to_fx(long long a); +extern long long fx_to_longlong(fx_s1516 a); +extern fx_s1516 fx_s1516_longlong_mul0(fx_s1516 a, fx_s1516 b); +extern fx_s1516 fx_s1516_longlong_mul1(fx_s1516 a, fx_s1516 b); +extern fx_s1516 fx_s1516_longlong_mul2(fx_s1516 a, fx_s1516 b); +extern fx_s1516 fx_s1516_longlong_mul3(fx_s1516 a, fx_s1516 b); +extern fx_s1516 fx_s1516_longlong_mul4(fx_s1516 a, fx_s1516 b); +extern fx_s1516 fx_s1516_longlong_div0(fx_s1516 a, fx_s1516 b); +extern fx_s1516 fx_s1516_longlong_div1(fx_s1516 a, fx_s1516 b); +extern fx_s1516 fx_s1516_longlong_div2(fx_s1516 a, fx_s1516 b); +extern fx_s1516 fx_s1516_longlong_sin(fx_s1516 fa); +extern fx_s1516 fx_s1516_longlong_sqrt(fx_s1516 fa); \ No newline at end of file diff --git a/gprof/mul_result.txt b/gprof/mul_result.txt new file mode 100644 index 0000000000000000000000000000000000000000..90f4f7143b1ee00cee1ce384ae68d15af05ed155 --- /dev/null +++ b/gprof/mul_result.txt @@ -0,0 +1,183 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 47.21 1.10 1.10 main + 11.59 1.37 0.27 10000001 27.00 27.00 fx_s1516_longlong_mul4 + 10.73 1.62 0.25 10000001 25.00 40.00 fx_s1516_double_mul + 10.30 1.86 0.24 10000001 24.00 24.00 fx_s1516_longlong_mul0 + 6.44 2.01 0.15 10000001 15.00 15.00 double_to_fx + 5.15 2.13 0.12 10000001 12.00 12.00 fx_s1516_longlong_mul3 + 4.29 2.23 0.10 10000001 10.00 10.00 fx_s1516_longlong_mul1 + 4.29 2.33 0.10 10000001 10.00 10.00 fx_s1516_longlong_mul2 + 0.00 2.33 0.00 2 0.00 0.00 fx_to_double + + % 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-2017 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 4 byte(s) for 0.43% of 2.33 seconds + +index % time self children called name + <spontaneous> +[1] 100.0 1.10 1.23 main [1] + 0.25 0.15 10000001/10000001 fx_s1516_double_mul [2] + 0.27 0.00 10000001/10000001 fx_s1516_longlong_mul4 [3] + 0.24 0.00 10000001/10000001 fx_s1516_longlong_mul0 [4] + 0.12 0.00 10000001/10000001 fx_s1516_longlong_mul3 [6] + 0.10 0.00 10000001/10000001 fx_s1516_longlong_mul1 [7] + 0.10 0.00 10000001/10000001 fx_s1516_longlong_mul2 [8] + 0.00 0.00 2/2 fx_to_double [9] +----------------------------------------------- + 0.25 0.15 10000001/10000001 main [1] +[2] 17.2 0.25 0.15 10000001 fx_s1516_double_mul [2] + 0.15 0.00 10000001/10000001 double_to_fx [5] +----------------------------------------------- + 0.27 0.00 10000001/10000001 main [1] +[3] 11.6 0.27 0.00 10000001 fx_s1516_longlong_mul4 [3] +----------------------------------------------- + 0.24 0.00 10000001/10000001 main [1] +[4] 10.3 0.24 0.00 10000001 fx_s1516_longlong_mul0 [4] +----------------------------------------------- + 0.15 0.00 10000001/10000001 fx_s1516_double_mul [2] +[5] 6.4 0.15 0.00 10000001 double_to_fx [5] +----------------------------------------------- + 0.12 0.00 10000001/10000001 main [1] +[6] 5.2 0.12 0.00 10000001 fx_s1516_longlong_mul3 [6] +----------------------------------------------- + 0.10 0.00 10000001/10000001 main [1] +[7] 4.3 0.10 0.00 10000001 fx_s1516_longlong_mul1 [7] +----------------------------------------------- + 0.10 0.00 10000001/10000001 main [1] +[8] 4.3 0.10 0.00 10000001 fx_s1516_longlong_mul2 [8] +----------------------------------------------- + 0.00 0.00 2/2 main [1] +[9] 0.0 0.00 0.00 2 fx_to_double [9] +----------------------------------------------- + + 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-2017 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 + + [5] double_to_fx [7] fx_s1516_longlong_mul1 [3] fx_s1516_longlong_mul4 + [2] fx_s1516_double_mul [8] fx_s1516_longlong_mul2 [9] fx_to_double + [4] fx_s1516_longlong_mul0 [6] fx_s1516_longlong_mul3 [1] main diff --git a/gprof/sin_result.txt b/gprof/sin_result.txt new file mode 100644 index 0000000000000000000000000000000000000000..fe0886d442873adeef63c309ffe56672568183d8 --- /dev/null +++ b/gprof/sin_result.txt @@ -0,0 +1,167 @@ +Flat profile: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ns/call ns/call name + 28.64 0.59 0.59 main + 26.21 1.13 0.54 10000001 54.00 54.00 fx_s1516_longlong_sin + 18.93 1.52 0.39 10000001 39.00 58.00 fx_s1516_double_sin + 16.99 1.87 0.35 10000001 35.00 35.00 degree_to_radian + 9.22 2.06 0.19 10000001 19.00 19.00 double_to_fx + 0.00 2.06 0.00 1 0.00 0.00 fx_to_double + + % 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-2017 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 4 byte(s) for 0.49% of 2.06 seconds + +index % time self children called name + <spontaneous> +[1] 100.0 0.59 1.47 main [1] + 0.39 0.19 10000001/10000001 fx_s1516_double_sin [2] + 0.54 0.00 10000001/10000001 fx_s1516_longlong_sin [3] + 0.35 0.00 10000001/10000001 degree_to_radian [4] + 0.00 0.00 1/1 fx_to_double [6] +----------------------------------------------- + 0.39 0.19 10000001/10000001 main [1] +[2] 28.2 0.39 0.19 10000001 fx_s1516_double_sin [2] + 0.19 0.00 10000001/10000001 double_to_fx [5] +----------------------------------------------- + 0.54 0.00 10000001/10000001 main [1] +[3] 26.2 0.54 0.00 10000001 fx_s1516_longlong_sin [3] +----------------------------------------------- + 0.35 0.00 10000001/10000001 main [1] +[4] 17.0 0.35 0.00 10000001 degree_to_radian [4] +----------------------------------------------- + 0.19 0.00 10000001/10000001 fx_s1516_double_sin [2] +[5] 9.2 0.19 0.00 10000001 double_to_fx [5] +----------------------------------------------- + 0.00 0.00 1/1 main [1] +[6] 0.0 0.00 0.00 1 fx_to_double [6] +----------------------------------------------- + + 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-2017 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] degree_to_radian [2] fx_s1516_double_sin [6] fx_to_double + [5] double_to_fx [3] fx_s1516_longlong_sin [1] main diff --git a/gprof/sqrt_result.txt b/gprof/sqrt_result.txt new file mode 100644 index 0000000000000000000000000000000000000000..cce5a1755e5377b663c6eb3280a25b869c480529 --- /dev/null +++ b/gprof/sqrt_result.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 + 47.83 0.55 0.55 main + 28.70 0.88 0.33 10000001 33.00 43.00 fx_s1516_double_sqrt + 14.78 1.05 0.17 10000001 17.00 17.00 fx_s1516_longlong_sqrt + 8.70 1.15 0.10 10000001 10.00 10.00 double_to_fx + 0.00 1.15 0.00 1 0.00 0.00 fx_to_double + + % 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-2017 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 4 byte(s) for 0.87% of 1.15 seconds + +index % time self children called name + <spontaneous> +[1] 100.0 0.55 0.60 main [1] + 0.33 0.10 10000001/10000001 fx_s1516_double_sqrt [2] + 0.17 0.00 10000001/10000001 fx_s1516_longlong_sqrt [3] + 0.00 0.00 1/1 fx_to_double [5] +----------------------------------------------- + 0.33 0.10 10000001/10000001 main [1] +[2] 37.4 0.33 0.10 10000001 fx_s1516_double_sqrt [2] + 0.10 0.00 10000001/10000001 double_to_fx [4] +----------------------------------------------- + 0.17 0.00 10000001/10000001 main [1] +[3] 14.8 0.17 0.00 10000001 fx_s1516_longlong_sqrt [3] +----------------------------------------------- + 0.10 0.00 10000001/10000001 fx_s1516_double_sqrt [2] +[4] 8.7 0.10 0.00 10000001 double_to_fx [4] +----------------------------------------------- + 0.00 0.00 1/1 main [1] +[5] 0.0 0.00 0.00 1 fx_to_double [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-2017 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] double_to_fx [3] fx_s1516_longlong_sqrt [1] main + [2] fx_s1516_double_sqrt [5] fx_to_double diff --git a/gprof/test.c b/gprof/test.c new file mode 100644 index 0000000000000000000000000000000000000000..ad78a8832bb6ccb88dd461a71c20a68ad7b93347 --- /dev/null +++ b/gprof/test.c @@ -0,0 +1,118 @@ +#include "fx_s1516_double.h" +#include "fx_s1516_longlong.h" + +int main() +{ + double sum = 0; + int i; + +#ifdef fx_mul + fx_s1516 a = 30000; + fx_s1516 b = 50000; + + double fa = fx_to_double(a); + double fb = fx_to_double(b); + + printf("%lf\n", fx_s1516_double_mul(fa, fb) / P2_16); + printf("%d\n", fx_s1516_longlong_mul0(a, b)); + printf("%d\n", fx_s1516_longlong_mul1(a, b)); + printf("%d\n", fx_s1516_longlong_mul2(a, b)); + printf("%d\n", fx_s1516_longlong_mul3(a, b)); + printf("%d\n", fx_s1516_longlong_mul4(a, b)); + + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_double_mul(fa, fb); + } + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_longlong_mul0(a, b); + } + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_longlong_mul1(a, b); + } + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_longlong_mul2(a, b); + } + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_longlong_mul3(a, b); + } + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_longlong_mul4(a, b); + } +#endif + +#ifdef fx_div + fx_s1516 a = 1000000; + fx_s1516 b = 500000; + + double fa = fx_to_double(a); + double fb = fx_to_double(b); + + printf("%lf\n", fx_s1516_double_div(fa, fb) * P2_16); + printf("%d\n", fx_s1516_longlong_div0(a, b)); + printf("%d\n", fx_s1516_longlong_div1(a, b)); + printf("%d\n", fx_s1516_longlong_div2(a, b)); + + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_double_div(fa, fb); + } + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_longlong_div0(a, b); + } + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_longlong_div1(a, b); + } + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_longlong_div2(a, b); + } +#endif + +#ifdef fx_sin + fx_s1516 a = 30; + + double fa = fx_to_double(a); + + printf("%lf\n", fx_s1516_double_sin(degree_to_radian(fa))); + printf("%lf\n", fx_s1516_longlong_sin(a * P2_16) / fP2_16); + + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_double_sin(degree_to_radian(fa)); + } + for (i = 0; i < 10000000; i++) + { + sum += (fx_s1516_longlong_sin(a * P2_16) / fP2_16); + } +#endif + +#ifdef fx_sqrt + fx_s1516 a = 123; + + double fa = fx_to_double(a); + + printf("%lf\n", fx_s1516_double_sqrt(fa)); + printf("%lf\n", fx_s1516_longlong_sqrt(a) / 256.0); + + for (i = 0; i < 10000000; i++) + { + sum += fx_s1516_double_sqrt(fa); + } + for (i = 0; i < 10000000; i++) + { + sum += (fx_s1516_longlong_sqrt(a) / 256.0); + } +#endif + + printf("%lf", sum); + + return 0; +}