44 elif test -n "$NUMBER_OF_PROCESSORS"; then |
44 elif test -n "$NUMBER_OF_PROCESSORS"; then |
45 # On windows, look in the env |
45 # On windows, look in the env |
46 NUM_CORES=$NUMBER_OF_PROCESSORS |
46 NUM_CORES=$NUMBER_OF_PROCESSORS |
47 FOUND_CORES=yes |
47 FOUND_CORES=yes |
48 fi |
48 fi |
49 |
|
50 # For c/c++ code we run twice as many concurrent build |
|
51 # jobs than we have cores, otherwise we will stall on io. |
|
52 CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` |
|
53 |
49 |
54 if test "x$FOUND_CORES" = xyes; then |
50 if test "x$FOUND_CORES" = xyes; then |
55 AC_MSG_RESULT([$NUM_CORES]) |
51 AC_MSG_RESULT([$NUM_CORES]) |
56 else |
52 else |
57 AC_MSG_RESULT([could not detect number of cores, defaulting to 1]) |
53 AC_MSG_RESULT([could not detect number of cores, defaulting to 1]) |
96 fi |
92 fi |
97 ]) |
93 ]) |
98 |
94 |
99 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], |
95 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], |
100 [ |
96 [ |
101 # How many cores do we have on this build system? |
97 # How many cores do we have on this build system? |
102 AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], |
98 AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], |
103 [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) |
99 [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) |
104 if test "x$with_num_cores" = x; then |
100 if test "x$with_num_cores" = x; then |
105 # The number of cores were not specified, try to probe them. |
101 # The number of cores were not specified, try to probe them. |
106 BPERF_CHECK_CORES |
102 BPERF_CHECK_CORES |
107 else |
103 else |
108 NUM_CORES=$with_num_cores |
104 NUM_CORES=$with_num_cores |
109 CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` |
105 fi |
110 fi |
106 AC_SUBST(NUM_CORES) |
111 AC_SUBST(NUM_CORES) |
|
112 AC_SUBST(CONCURRENT_BUILD_JOBS) |
|
113 ]) |
107 ]) |
114 |
108 |
115 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], |
109 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], |
116 [ |
110 [ |
117 # How much memory do we have on this build system? |
111 # How much memory do we have on this build system? |
118 AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], |
112 AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], |
119 [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) |
113 [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) |
120 if test "x$with_memory_size" = x; then |
114 if test "x$with_memory_size" = x; then |
121 # The memory size was not specified, try to probe it. |
115 # The memory size was not specified, try to probe it. |
122 BPERF_CHECK_MEMORY_SIZE |
116 BPERF_CHECK_MEMORY_SIZE |
123 else |
117 else |
124 MEMORY_SIZE=$with_memory_size |
118 MEMORY_SIZE=$with_memory_size |
125 fi |
119 fi |
126 AC_SUBST(MEMORY_SIZE) |
120 AC_SUBST(MEMORY_SIZE) |
|
121 ]) |
|
122 |
|
123 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS], |
|
124 [ |
|
125 # Provide a decent default number of parallel jobs for make depending on |
|
126 # number of cores, amount of memory and machine architecture. |
|
127 AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs], |
|
128 [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])]) |
|
129 if test "x$with_jobs" = x; then |
|
130 # Number of jobs was not specified, calculate. |
|
131 AC_MSG_CHECKING([for appropriate number of jobs to run in parallel]) |
|
132 # Approximate memory in GB, rounding up a bit. |
|
133 memory_gb=`expr $MEMORY_SIZE / 1100` |
|
134 # Pick the lowest of memory in gb and number of cores. |
|
135 if test "$memory_gb" -lt "$NUM_CORES"; then |
|
136 JOBS="$memory_gb" |
|
137 else |
|
138 JOBS="$NUM_CORES" |
|
139 # On bigger machines, leave some room for other processes to run |
|
140 if test "$JOBS" -gt "4"; then |
|
141 JOBS=`expr $JOBS '*' 90 / 100` |
|
142 fi |
|
143 fi |
|
144 # Cap number of jobs to 16 |
|
145 if test "$JOBS" -gt "16"; then |
|
146 JOBS=16 |
|
147 fi |
|
148 AC_MSG_RESULT([$JOBS]) |
|
149 else |
|
150 JOBS=$with_jobs |
|
151 fi |
|
152 AC_SUBST(JOBS) |
127 ]) |
153 ]) |
128 |
154 |
129 AC_DEFUN([BPERF_SETUP_CCACHE], |
155 AC_DEFUN([BPERF_SETUP_CCACHE], |
130 [ |
156 [ |
131 AC_ARG_ENABLE([ccache], |
157 AC_ARG_ENABLE([ccache], |