Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfdea253

Browse files
Compiler optimizations for page checksum code.
Ants Aasma and Jeff Davis
1 parent3d53173 commitfdea253

File tree

5 files changed

+169
-0
lines changed

5 files changed

+169
-0
lines changed

‎config/c-compiler.m4

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,31 @@ undefine([Ac_cachevar])dnl
242242

243243

244244

245+
# PGAC_PROG_CC_VAR_OPT
246+
# -----------------------
247+
# Given a variable name and a string, check if the compiler supports
248+
# the string as a command-line option. If it does, add the string to
249+
# the given variable.
250+
AC_DEFUN([PGAC_PROG_CC_VAR_OPT],
251+
[define([Ac_cachevar],[AS_TR_SH([pgac_cv_prog_cc_cflags_$2])])dnl
252+
AC_CACHE_CHECK([whether $CC supports$2],[Ac_cachevar],
253+
[pgac_save_CFLAGS=$CFLAGS
254+
CFLAGS="$pgac_save_CFLAGS$2"
255+
ac_save_c_werror_flag=$ac_c_werror_flag
256+
ac_c_werror_flag=yes
257+
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
258+
[Ac_cachevar=yes],
259+
[Ac_cachevar=no])
260+
ac_c_werror_flag=$ac_save_c_werror_flag
261+
CFLAGS="$pgac_save_CFLAGS"])
262+
if test x"$Ac_cachevar" = x"yes"; then
263+
$1="${$1}$2"
264+
fi
265+
undefine([Ac_cachevar])dnl
266+
])# PGAC_PROG_CC_CFLAGS_OPT
267+
268+
269+
245270
# PGAC_PROG_CC_LDFLAGS_OPT
246271
# ------------------------
247272
# Given a string, check if the compiler supports the string as a

‎configure

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ autodepend
731731
TAS
732732
GCC
733733
CPP
734+
CFLAGS_VECTOR
734735
SUN_STUDIO_CC
735736
OBJEXT
736737
EXEEXT
@@ -3944,6 +3945,11 @@ else
39443945
fi
39453946
fi
39463947

3948+
# set CFLAGS_VECTOR from the environment, if available
3949+
if test "$ac_env_CFLAGS_VECTOR_set" = set; then
3950+
CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
3951+
fi
3952+
39473953
# Some versions of GCC support some additional useful warning flags.
39483954
# Check whether they are supported, and add them to CFLAGS if so.
39493955
# ICC pretends to be GCC but it's lying; it doesn't support these flags,
@@ -4376,6 +4382,127 @@ if test x"$pgac_cv_prog_cc_cflags__fexcess_precision_standard" = x"yes"; then
43764382
CFLAGS="$CFLAGS -fexcess-precision=standard"
43774383
fi
43784384

4385+
# Optimization flags for specific files that benefit from vectorization
4386+
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -funroll-loops" >&5
4387+
$as_echo_n "checking whether $CC supports -funroll-loops... " >&6; }
4388+
if test "${pgac_cv_prog_cc_cflags__funroll_loops+set}" = set; then
4389+
$as_echo_n "(cached) " >&6
4390+
else
4391+
pgac_save_CFLAGS=$CFLAGS
4392+
CFLAGS="$pgac_save_CFLAGS -funroll-loops"
4393+
ac_save_c_werror_flag=$ac_c_werror_flag
4394+
ac_c_werror_flag=yes
4395+
cat >conftest.$ac_ext <<_ACEOF
4396+
/* confdefs.h. */
4397+
_ACEOF
4398+
cat confdefs.h >>conftest.$ac_ext
4399+
cat >>conftest.$ac_ext <<_ACEOF
4400+
/* end confdefs.h. */
4401+
4402+
int
4403+
main ()
4404+
{
4405+
4406+
;
4407+
return 0;
4408+
}
4409+
_ACEOF
4410+
rm -f conftest.$ac_objext
4411+
if { (ac_try="$ac_compile"
4412+
case "(($ac_try" in
4413+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4414+
*) ac_try_echo=$ac_try;;
4415+
esac
4416+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4417+
$as_echo "$ac_try_echo") >&5
4418+
(eval "$ac_compile") 2>conftest.er1
4419+
ac_status=$?
4420+
grep -v '^ *+' conftest.er1 >conftest.err
4421+
rm -f conftest.er1
4422+
cat conftest.err >&5
4423+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4424+
(exit $ac_status); } && {
4425+
test -z "$ac_c_werror_flag" ||
4426+
test ! -s conftest.err
4427+
} && test -s conftest.$ac_objext; then
4428+
pgac_cv_prog_cc_cflags__funroll_loops=yes
4429+
else
4430+
$as_echo "$as_me: failed program was:" >&5
4431+
sed 's/^/| /' conftest.$ac_ext >&5
4432+
4433+
pgac_cv_prog_cc_cflags__funroll_loops=no
4434+
fi
4435+
4436+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4437+
ac_c_werror_flag=$ac_save_c_werror_flag
4438+
CFLAGS="$pgac_save_CFLAGS"
4439+
fi
4440+
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__funroll_loops" >&5
4441+
$as_echo "$pgac_cv_prog_cc_cflags__funroll_loops" >&6; }
4442+
if test x"$pgac_cv_prog_cc_cflags__funroll_loops" = x"yes"; then
4443+
CFLAGS_VECTOR="${CFLAGS_VECTOR} -funroll-loops"
4444+
fi
4445+
4446+
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -ftree-vectorize" >&5
4447+
$as_echo_n "checking whether $CC supports -ftree-vectorize... " >&6; }
4448+
if test "${pgac_cv_prog_cc_cflags__ftree_vectorize+set}" = set; then
4449+
$as_echo_n "(cached) " >&6
4450+
else
4451+
pgac_save_CFLAGS=$CFLAGS
4452+
CFLAGS="$pgac_save_CFLAGS -ftree-vectorize"
4453+
ac_save_c_werror_flag=$ac_c_werror_flag
4454+
ac_c_werror_flag=yes
4455+
cat >conftest.$ac_ext <<_ACEOF
4456+
/* confdefs.h. */
4457+
_ACEOF
4458+
cat confdefs.h >>conftest.$ac_ext
4459+
cat >>conftest.$ac_ext <<_ACEOF
4460+
/* end confdefs.h. */
4461+
4462+
int
4463+
main ()
4464+
{
4465+
4466+
;
4467+
return 0;
4468+
}
4469+
_ACEOF
4470+
rm -f conftest.$ac_objext
4471+
if { (ac_try="$ac_compile"
4472+
case "(($ac_try" in
4473+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4474+
*) ac_try_echo=$ac_try;;
4475+
esac
4476+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4477+
$as_echo "$ac_try_echo") >&5
4478+
(eval "$ac_compile") 2>conftest.er1
4479+
ac_status=$?
4480+
grep -v '^ *+' conftest.er1 >conftest.err
4481+
rm -f conftest.er1
4482+
cat conftest.err >&5
4483+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4484+
(exit $ac_status); } && {
4485+
test -z "$ac_c_werror_flag" ||
4486+
test ! -s conftest.err
4487+
} && test -s conftest.$ac_objext; then
4488+
pgac_cv_prog_cc_cflags__ftree_vectorize=yes
4489+
else
4490+
$as_echo "$as_me: failed program was:" >&5
4491+
sed 's/^/| /' conftest.$ac_ext >&5
4492+
4493+
pgac_cv_prog_cc_cflags__ftree_vectorize=no
4494+
fi
4495+
4496+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4497+
ac_c_werror_flag=$ac_save_c_werror_flag
4498+
CFLAGS="$pgac_save_CFLAGS"
4499+
fi
4500+
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__ftree_vectorize" >&5
4501+
$as_echo "$pgac_cv_prog_cc_cflags__ftree_vectorize" >&6; }
4502+
if test x"$pgac_cv_prog_cc_cflags__ftree_vectorize" = x"yes"; then
4503+
CFLAGS_VECTOR="${CFLAGS_VECTOR} -ftree-vectorize"
4504+
fi
4505+
43794506
elif test "$ICC" = yes; then
43804507
# Intel's compiler has a bug/misoptimization in checking for
43814508
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
@@ -4627,6 +4754,9 @@ fi
46274754

46284755
fi
46294756

4757+
CFLAGS_VECTOR=$CFLAGS_VECTOR
4758+
4759+
46304760
# supply -g if --enable-debug
46314761
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
46324762
CFLAGS="$CFLAGS -g"

‎configure.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,11 @@ else
400400
fi
401401
fi
402402

403+
# set CFLAGS_VECTOR from the environment, if available
404+
if test "$ac_env_CFLAGS_VECTOR_set" = set; then
405+
CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
406+
fi
407+
403408
# Some versions of GCC support some additional useful warning flags.
404409
# Check whether they are supported, and add them to CFLAGS if so.
405410
# ICC pretends to be GCC but it's lying; it doesn't support these flags,
@@ -419,6 +424,9 @@ if test "$GCC" = yes -a "$ICC" = no; then
419424
PGAC_PROG_CC_CFLAGS_OPT([-fwrapv])
420425
# Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
421426
PGAC_PROG_CC_CFLAGS_OPT([-fexcess-precision=standard])
427+
# Optimization flags for specific files that benefit from vectorization
428+
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
429+
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
422430
elif test "$ICC" = yes; then
423431
# Intel's compiler has a bug/misoptimization in checking for
424432
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
@@ -434,6 +442,8 @@ elif test "$PORTNAME" = "hpux"; then
434442
PGAC_PROG_CC_CFLAGS_OPT([+Olibmerrno])
435443
fi
436444

445+
AC_SUBST(CFLAGS_VECTOR, $CFLAGS_VECTOR)
446+
437447
# supply -g if --enable-debug
438448
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
439449
CFLAGS="$CFLAGS -g"

‎src/Makefile.global.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ CC = @CC@
219219
GCC = @GCC@
220220
SUN_STUDIO_CC = @SUN_STUDIO_CC@
221221
CFLAGS = @CFLAGS@
222+
CFLAGS_VECTOR = @CFLAGS_VECTOR@
222223

223224
# Kind-of compilers
224225

‎src/backend/storage/page/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ include $(top_builddir)/src/Makefile.global
1515
OBJS = bufpage.o checksum.o itemptr.o
1616

1717
include$(top_srcdir)/src/backend/common.mk
18+
19+
# important optimizations flags for checksum.c
20+
checksum.o: CFLAGS += ${CFLAGS_VECTOR}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp