pastebin - collaborative debugging tool
rovema.kpaste.net RSS


sse_vs_387_perf_report2_20220919_002
Posted by Anonymous on Mon 19th Sep 2022 19:03
raw | new post

  1. gcc -std=c17 -m32 -mtune=generic  -mfpmath=sse -msse2  -g -Wall -O2 -fstrict-aliasing simple_mandel_bench1.c -lm -o simple_mandel_bench1.sse_gcc
  2. gcc -std=c17 -m32 -mtune=generic   -g -Wall -O2 -fstrict-aliasing simple_mandel_bench1.c -lm -o simple_mandel_bench1.nosse_gcc
  3. ksh93 -c 'set -o xtrace ; \
  4.         uname -a ; \
  5.         cat simple_mandel_bench1.c ; \
  6.         cat Makefile ; \
  7.         for i in simple_mandel_bench1.sse_gcc simple_mandel_bench1.nosse_gcc ; do time "./$i" ; done'
  8. + uname -a
  9. Linux DERFWNB4966 5.10.0-13-rt-686-pae #1 SMP PREEMPT_RT Debian 5.10.106-1 (2022-03-17) i686 GNU/Linux
  10. + cat simple_mandel_bench1.c
  11.  
  12. /*
  13.  * sse_vs_387_perf1/simple_mandel_bench1.c - simple mandelbrot code
  14.  *      used for benchmarking
  15.  *
  16.  * Based on http://svn.nrubsig.org/svn/people/gisburn/scripts/mandelbrotset1.sh
  17.  *
  18.  * Written by Roland Mainz <roland.mainz@nrubsig.org>
  19.  *
  20.  */
  21.  
  22. #define _XOPEN_SOURCE 600
  23.  
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include <stdint.h>
  27. #include <math.h>
  28.  
  29. static const char mandel_chars[] =
  30.         "..:-;!0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%@#";
  31.    
  32. #define MANDEL_Y_MIN (-12)
  33. #define MANDEL_Y_MAX (+18)
  34. #define MANDEL_X_MIN (-40)
  35. #define MANDEL_X_MAX (+102)
  36. #define MANDEL_X_SCALE (32)
  37. #define MANDEL_Y_SCALE (16)
  38.  
  39. // enforce FMA usage for testing if platform does not support it
  40. // #define FP_FAST_FMA 1
  41.  
  42. #define MY_MIN(x, y) ((x)<(y)?(x):(y))
  43.  
  44.  
  45. int main(int ac, char *av[])
  46. {
  47.         intmax_t k;
  48.         double i, j;
  49.         double r;
  50.         double x, y;
  51.        
  52.         (void)ac;
  53.         (void)av;
  54.        
  55. #if FP_FAST_FMA
  56.         (void)printf("# has fast FMA\n");
  57. #else
  58.         (void)printf("# does not have fast FMA\n");
  59. #endif /* FP_FAST_FMA */
  60.  
  61.         for(y=MANDEL_Y_MIN ; y < MANDEL_Y_MAX ; y++) {
  62.                 for(x=MANDEL_X_MIN ; x < MANDEL_X_MAX ; x++) {
  63.                         for(i=j=r=0.,k=0 ;
  64.                                 (((j*j + i*i)) < 11) && (k < 8388608UL) ;
  65.                                         k++) {
  66.                                 j=r*r - i*i - 2.+x/MANDEL_X_SCALE,
  67. #if FP_FAST_FMA
  68.                                 i=fma(2.*r, i, y/MANDEL_Y_SCALE);
  69. #else
  70.                                 i=2.*r*i + y/MANDEL_Y_SCALE;
  71. #endif /* FP_FAST_FMA */
  72.                                 r=j;
  73.                         }
  74.  
  75.                         (void)putchar_unlocked(
  76.                                 mandel_chars[(size_t)MY_MIN(k, (sizeof(mandel_chars)-2))]);
  77.                 }
  78.  
  79.                 (void)putchar_unlocked('\n');
  80.         }
  81.  
  82.         return EXIT_SUCCESS;
  83. }
  84. + cat Makefile
  85. #
  86. # sse_vs_387_perf1/Makefile
  87. #
  88.  
  89. CSTD=-std=c17
  90. ARCHFLAGS=-m32 -mtune=generic
  91. MATHSSEFLAGS=-mfpmath=sse -msse2 # -mfma
  92. #MATH387FLAGS=-mfpmath=387
  93. OPTFLAGS=-O2 -fstrict-aliasing
  94. CC=gcc
  95.  
  96. all: tests
  97.  
  98. #
  99. # we use mandelbrot for benchmarking because it uses lots of math
  100. # and is proven to be a good benchmark
  101. #
  102. simple_mandel_bench1.sse_$(CC): simple_mandel_bench1.c
  103.         $(CC) $(CSTD) $(ARCHFLAGS) $(MATHSSEFLAGS) -g -Wall $(OPTFLAGS) $< -lm -o $@
  104.  
  105. simple_mandel_bench1.nosse_$(CC): simple_mandel_bench1.c
  106.         $(CC) $(CSTD) $(ARCHFLAGS) $(MATH387FLAGS) -g -Wall $(OPTFLAGS) $< -lm -o $@
  107.  
  108.  
  109. #
  110. # run tests
  111. #
  112. # first we print outselves (sources and build config/Makefile)
  113. # so the output contains the accurate config used for testing,
  114. # then we run the tests, one time with SSE enabled and one time
  115. # with SSE disabled.
  116. #
  117. tests: \
  118.         simple_mandel_bench1.sse_$(CC) \
  119.         simple_mandel_bench1.nosse_$(CC)
  120.         ksh93 -c 'set -o xtrace ; \
  121.                 uname -a ; \
  122.                 cat simple_mandel_bench1.c ; \
  123.                 cat Makefile ; \
  124.                 for i in $^ ; do time "./$$i" ; done'
  125.  
  126. clean:
  127.         rm -f \
  128.                 simple_mandel_bench1.sse_$(CC) \
  129.                 simple_mandel_bench1.nosse_$(CC)
  130.  
  131. # EOF.
  132. + ./simple_mandel_bench1.sse_gcc
  133. # does not have fast FMA
  134. .:::::::::::::::::::::::::::::::::--------------------------;;;;;;;;;;;;;;;!!!!!!!!0000111112236g#######t43211000000!!!;;;;;;;----------------
  135. .::::::::::::::::::::::::::::::::-----------------------;;;;;;;;;;;;;;!!!!!!!!!!0001744i533455568h#####f86546321112330!!!;;;;;;---------------
  136. ::::::::::::::::::::::::::::::::---------------------;;;;;;;;;;;;;!!!!!!!!!!!!0000124kgnfh79###############f#c54c757630!!!;;;;;---------------
  137. :::::::::::::::::::::::::::::::-------------------;;;;;;;;;;;;!!!!!!!!!!!!!00000112236q#######################nb###m7510!!!;;;;;--------------
  138. :::::::::::::::::::::::::::::::----------------;;;;;;;;;;;;!!!!!!000000000000011123F68dL###########################c3210!!!;;;;;;-------------
  139. ::::::::::::::::::::::::::::::--------------;;;;;;;;;;;;!!!!!014111111111111111224aF#u############################Xd42110!!!;;;;;;------------
  140. :::::::::::::::::::::::::::::-------------;;;;;;;;;;;;!!!!!!0013932222373222222346gV###############################vcbx30!!!;;;;;;------------
  141. :::::::::::::::::::::::::::::------------;;;;;;;;;;;!!!!!!0001236aed756af6a644445a###################################t5200!!;;;;;;;-----------
  142. :::::::::::::::::::::::::::::----------;;;;;;;;;;!!!!!!!!000112348j##i####uVj7668####################################7810!!!;;;;;;;-----------
  143. ::::::::::::::::::::::::::::----------;;;;;;;;;!!!!!!000001222398e############Jac####################################7310!!!;;;;;;;-----------
  144. ::::::::::::::::::::::::::::----------;;;;!!!!!!00000011123i5567d###############l###################################b5100!!!;;;;;;;;----------
  145. ::::::::::::::::::::::::::::---------;;;!!!00012211112223347c##J################K##################################c31100!!!;;;;;;;;----------
  146. ::::::::::::::::::::::::::::---------;;;#########################################################################b6321000!!!;;;;;;;;----------
  147. ::::::::::::::::::::::::::::---------;;;!!!00012211112223347c##J################K##################################c31100!!!;;;;;;;;----------
  148. ::::::::::::::::::::::::::::----------;;;;!!!!!!00000011123i5567d###############l###################################b5100!!!;;;;;;;;----------
  149. ::::::::::::::::::::::::::::----------;;;;;;;;;!!!!!!000001222398e############Jac####################################7310!!!;;;;;;;-----------
  150. :::::::::::::::::::::::::::::----------;;;;;;;;;;!!!!!!!!000112348j##i####uVj7668####################################7810!!!;;;;;;;-----------
  151. :::::::::::::::::::::::::::::------------;;;;;;;;;;;!!!!!!0001236aed756af6a644445a###################################t5200!!;;;;;;;-----------
  152. :::::::::::::::::::::::::::::-------------;;;;;;;;;;;;!!!!!!0013932222373222222346gV###############################vcbx30!!!;;;;;;------------
  153. ::::::::::::::::::::::::::::::--------------;;;;;;;;;;;;!!!!!014111111111111111224aF#u############################Xd42110!!!;;;;;;------------
  154. :::::::::::::::::::::::::::::::----------------;;;;;;;;;;;;!!!!!!000000000000011123F68dL###########################c3210!!!;;;;;;-------------
  155. :::::::::::::::::::::::::::::::-------------------;;;;;;;;;;;;!!!!!!!!!!!!!00000112236q#######################nb###m7510!!!;;;;;--------------
  156. ::::::::::::::::::::::::::::::::---------------------;;;;;;;;;;;;;!!!!!!!!!!!!0000124kgnfh79###############f#c54c757630!!!;;;;;---------------
  157. .::::::::::::::::::::::::::::::::-----------------------;;;;;;;;;;;;;;!!!!!!!!!!0001744i533455568h#####f86546321112330!!!;;;;;;---------------
  158. .:::::::::::::::::::::::::::::::::--------------------------;;;;;;;;;;;;;;;!!!!!!!!0000111112236g#######t43211000000!!!;;;;;;;----------------
  159. ..:::::::::::::::::::::::::::::::::----------------------------;;;;;;;;;;;;;;;;!!!!!!!0000011135b######pyd210000!!!!!;;;;;;;------------------
  160. ..::::::::::::::::::::::::::::::::::------------------------------;;;;;;;;;;;;;;;;!!!!!!!!000113866d#Pb533100!!!!!!;;;;;;;;------------------:
  161. ...::::::::::::::::::::::::::::::::::-------------------------------;;;;;;;;;;;;;;;;;!!!!!!!000112358a532100!!!!!;;;;;;;;;------------------::
  162. ...::::::::::::::::::::::::::::::::::::--------------------------------;;;;;;;;;;;;;;;;;!!!!!!00113584e7#00!!!;;;;;;;;;;------------------::::
  163. ....::::::::::::::::::::::::::::::::::::----------------------------------;;;;;;;;;;;;;;;;!!!!!0014421000!!!;;;;;;;;;;-------------------:::::
  164.  
  165. real    1m8.48s
  166. user    1m8.84s
  167. sys     0m0.00s
  168. + ./simple_mandel_bench1.nosse_gcc
  169. # does not have fast FMA
  170. .:::::::::::::::::::::::::::::::::--------------------------;;;;;;;;;;;;;;;!!!!!!!!0000111112236g#######t43211000000!!!;;;;;;;----------------
  171. .::::::::::::::::::::::::::::::::-----------------------;;;;;;;;;;;;;;!!!!!!!!!!0001744i533455568h#####f86546321112330!!!;;;;;;---------------
  172. ::::::::::::::::::::::::::::::::---------------------;;;;;;;;;;;;;!!!!!!!!!!!!0000124kgnfh79###############f#c54c757630!!!;;;;;---------------
  173. :::::::::::::::::::::::::::::::-------------------;;;;;;;;;;;;!!!!!!!!!!!!!00000112236q#######################nb###m7510!!!;;;;;--------------
  174. :::::::::::::::::::::::::::::::----------------;;;;;;;;;;;;!!!!!!000000000000011123F68dL###########################c3210!!!;;;;;;-------------
  175. ::::::::::::::::::::::::::::::--------------;;;;;;;;;;;;!!!!!014111111111111111224aF#u############################Xd42110!!!;;;;;;------------
  176. :::::::::::::::::::::::::::::-------------;;;;;;;;;;;;!!!!!!0013932222373222222346gV###############################vcbx30!!!;;;;;;------------
  177. :::::::::::::::::::::::::::::------------;;;;;;;;;;;!!!!!!0001236aed756af6a644445a###################################t5200!!;;;;;;;-----------
  178. :::::::::::::::::::::::::::::----------;;;;;;;;;;!!!!!!!!000112348j##i####uVj7668####################################7810!!!;;;;;;;-----------
  179. ::::::::::::::::::::::::::::----------;;;;;;;;;!!!!!!000001222398e############Jac####################################7310!!!;;;;;;;-----------
  180. ::::::::::::::::::::::::::::----------;;;;!!!!!!00000011123i5567d###############l###################################b5100!!!;;;;;;;;----------
  181. ::::::::::::::::::::::::::::---------;;;!!!00012211112223347c##J################K##################################c31100!!!;;;;;;;;----------
  182. ::::::::::::::::::::::::::::---------;;;#########################################################################b6321000!!!;;;;;;;;----------
  183. ::::::::::::::::::::::::::::---------;;;!!!00012211112223347c##J################K##################################c31100!!!;;;;;;;;----------
  184. ::::::::::::::::::::::::::::----------;;;;!!!!!!00000011123i5567d###############l###################################b5100!!!;;;;;;;;----------
  185. ::::::::::::::::::::::::::::----------;;;;;;;;;!!!!!!000001222398e############Jac####################################7310!!!;;;;;;;-----------
  186. :::::::::::::::::::::::::::::----------;;;;;;;;;;!!!!!!!!000112348j##i####uVj7668####################################7810!!!;;;;;;;-----------
  187. :::::::::::::::::::::::::::::------------;;;;;;;;;;;!!!!!!0001236aed756af6a644445a###################################t5200!!;;;;;;;-----------
  188. :::::::::::::::::::::::::::::-------------;;;;;;;;;;;;!!!!!!0013932222373222222346gV###############################vcbx30!!!;;;;;;------------
  189. ::::::::::::::::::::::::::::::--------------;;;;;;;;;;;;!!!!!014111111111111111224aF#u############################Xd42110!!!;;;;;;------------
  190. :::::::::::::::::::::::::::::::----------------;;;;;;;;;;;;!!!!!!000000000000011123F68dL###########################c3210!!!;;;;;;-------------
  191. :::::::::::::::::::::::::::::::-------------------;;;;;;;;;;;;!!!!!!!!!!!!!00000112236q#######################nb###m7510!!!;;;;;--------------
  192. ::::::::::::::::::::::::::::::::---------------------;;;;;;;;;;;;;!!!!!!!!!!!!0000124kgnfh79###############f#c54c757630!!!;;;;;---------------
  193. .::::::::::::::::::::::::::::::::-----------------------;;;;;;;;;;;;;;!!!!!!!!!!0001744i533455568h#####f86546321112330!!!;;;;;;---------------
  194. .:::::::::::::::::::::::::::::::::--------------------------;;;;;;;;;;;;;;;!!!!!!!!0000111112236g#######t43211000000!!!;;;;;;;----------------
  195. ..:::::::::::::::::::::::::::::::::----------------------------;;;;;;;;;;;;;;;;!!!!!!!0000011135b######pyd210000!!!!!;;;;;;;------------------
  196. ..::::::::::::::::::::::::::::::::::------------------------------;;;;;;;;;;;;;;;;!!!!!!!!000113866d#Pb533100!!!!!!;;;;;;;;------------------:
  197. ...::::::::::::::::::::::::::::::::::-------------------------------;;;;;;;;;;;;;;;;;!!!!!!!000112358a532100!!!!!;;;;;;;;;------------------::
  198. ...::::::::::::::::::::::::::::::::::::--------------------------------;;;;;;;;;;;;;;;;;!!!!!!00113584e7#00!!!;;;;;;;;;;------------------::::
  199. ....::::::::::::::::::::::::::::::::::::----------------------------------;;;;;;;;;;;;;;;;!!!!!0014421000!!!;;;;;;;;;;-------------------:::::
  200.  
  201. real    1m37.89s
  202. user    1m38.34s
  203. sys     0m0.00s

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at