Skip to content

Commit b0ca0d2

Browse files
committed
Generalizing configure openmp treatment following data.table: part 3
1 parent 31c5e2f commit b0ca0d2

File tree

2 files changed

+53
-49
lines changed

2 files changed

+53
-49
lines changed

configure

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,11 @@ int main() {
32693269
}
32703270
EOF
32713271

3272+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether on Linux" >&5
3273+
printf %s "checking whether on Linux... " >&6; }
32723274
if test x"${SYSKERNEL}" = x"Linux"; then
3275+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
3276+
printf "%s\n" "yes" >&6; }
32733277

32743278
## Check if R is configured to compile OpenMP programs out-of-the-box.
32753279
if test x"${can_use_openmp}" = x"no"; then
@@ -3280,13 +3284,13 @@ printf %s "checking whether R CMD SHLIB can already compile OpenMP programs... "
32803284
if test x"$?" = x"0"; then
32813285
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
32823286
printf "%s\n" "yes" >&6; }
3283-
openmp_already_works="yes"
3287+
#openmp_already_works="yes"
32843288
arma_have_openmp="#define ARMA_USE_OPENMP 1"
32853289
can_use_openmp="yes"
32863290
else
32873291
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
32883292
printf "%s\n" "no" >&6; }
3289-
openmp_already_works="no"
3293+
#openmp_already_works="no"
32903294
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
32913295
can_use_openmp="no"
32923296
fi
@@ -3301,7 +3305,7 @@ printf %s "checking whether R CMD SHLIB can compile OpenMP via -fopenmp... " >&6
33013305
if test x"$?" = x"0"; then
33023306
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
33033307
printf "%s\n" "yes" >&6; }
3304-
openmp_already_works="yes"
3308+
#openmp_already_works="yes"
33053309
arma_have_openmp="#define ARMA_USE_OPENMP 1"
33063310
can_use_openmp="yes"
33073311
# keep any entries user may have set
@@ -3310,14 +3314,21 @@ printf "%s\n" "yes" >&6; }
33103314
else
33113315
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
33123316
printf "%s\n" "no" >&6; }
3313-
openmp_already_works="no"
3317+
#openmp_already_works="no"
33143318
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
33153319
can_use_openmp="no"
33163320
fi
33173321
fi
3318-
fi
3322+
else
3323+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
3324+
printf "%s\n" "no" >&6; }
3325+
fi # if Linux
33193326

3327+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether on macOS" >&5
3328+
printf %s "checking whether on macOS... " >&6; }
33203329
if test x"${SYSKERNEL}" = x"Darwin"; then
3330+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
3331+
printf "%s\n" "yes" >&6; }
33213332

33223333
## Check if R is configured to compile OpenMP programs using -Xclang -fopenmp
33233334
if test x"${can_use_openmp}" = x"no"; then
@@ -3328,7 +3339,7 @@ printf %s "checking whether R CMD SHLIB can compile OpenMP programs using '-Xcla
33283339
if test x"$?" = x"0"; then
33293340
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
33303341
printf "%s\n" "yes" >&6; }
3331-
openmp_already_works="yes"
3342+
#openmp_already_works="yes"
33323343
arma_have_openmp="#define ARMA_USE_OPENMP 1"
33333344
can_use_openmp="yes"
33343345
# keep any entries user may have set
@@ -3337,36 +3348,21 @@ printf "%s\n" "yes" >&6; }
33373348
else
33383349
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
33393350
printf "%s\n" "no" >&6; }
3340-
openmp_already_works="no"
3351+
#openmp_already_works="no"
33413352
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
33423353
can_use_openmp="no"
33433354
fi
33443355
fi
3345-
fi
3356+
else
3357+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
3358+
printf "%s\n" "no" >&6; }
3359+
fi # if macOS
33463360

33473361
## Go back home.
33483362
cd "${owd}"
33493363
rm -rf "${BUILDDIR}"
33503364

33513365

3352-
if test x"${can_use_openmp}" = x"yes"; then
3353-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenMP" >&5
3354-
printf %s "checking for OpenMP... " >&6; }
3355-
## if R has -fopenmp we should be good
3356-
allldflags=$(${R_HOME}/bin/R CMD config --ldflags)
3357-
hasOpenMP=$(echo ${allldflags} | grep -- -fopenmp)
3358-
if test x"${hasOpenMP}" = x""; then
3359-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: missing" >&5
3360-
printf "%s\n" "missing" >&6; }
3361-
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
3362-
openmp_flag=""
3363-
else
3364-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found and suitable" >&5
3365-
printf "%s\n" "found and suitable" >&6; }
3366-
arma_have_openmp="#define ARMA_USE_OPENMP 1"
3367-
openmp_flag='$(SHLIB_OPENMP_CXXFLAGS)'
3368-
fi
3369-
fi
33703366

33713367
## now use all these
33723368
ARMA_HAVE_OPENMP="${arma_have_openmp}"

configure.ac

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ int main() {
6666
}
6767
EOF
6868

69+
AC_MSG_CHECKING([whether on Linux])
6970
if test x"${SYSKERNEL}" = x"Linux"; then
71+
AC_MSG_RESULT([yes])
7072

7173
## Check if R is configured to compile OpenMP programs out-of-the-box.
7274
if test x"${can_use_openmp}" = x"no"; then
@@ -75,12 +77,12 @@ if test x"${SYSKERNEL}" = x"Linux"; then
7577
"${R_HOME}/bin/R" CMD SHLIB test-omp.cpp >/dev/null 2>&1
7678
if test x"$?" = x"0"; then
7779
AC_MSG_RESULT([yes])
78-
openmp_already_works="yes"
80+
#openmp_already_works="yes"
7981
arma_have_openmp="#define ARMA_USE_OPENMP 1"
8082
can_use_openmp="yes"
8183
else
8284
AC_MSG_RESULT([no])
83-
openmp_already_works="no"
85+
#openmp_already_works="no"
8486
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
8587
can_use_openmp="no"
8688
fi
@@ -93,22 +95,26 @@ if test x"${SYSKERNEL}" = x"Linux"; then
9395
PKG_CXXFLAGS="${PKG_CXXFLAGS} -fopenmp" PKG_LIBS="${PKG_LIBS} -fopen" "${R_HOME}/bin/R" CMD SHLIB -fopenmp test-omp.cpp >/dev/null 2>&1
9496
if test x"$?" = x"0"; then
9597
AC_MSG_RESULT([yes])
96-
openmp_already_works="yes"
98+
#openmp_already_works="yes"
9799
arma_have_openmp="#define ARMA_USE_OPENMP 1"
98100
can_use_openmp="yes"
99101
# keep any entries user may have set
100102
PKG_CXXFLAGS="${PKG_CXXFLAGS} -fopenmp"
101103
PKG_LIBS="${PKG_LIBS} -fopenmp"
102104
else
103105
AC_MSG_RESULT([no])
104-
openmp_already_works="no"
106+
#openmp_already_works="no"
105107
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
106108
can_use_openmp="no"
107109
fi
108110
fi
109-
fi
111+
else
112+
AC_MSG_RESULT([no])
113+
fi # if Linux
110114

115+
AC_MSG_CHECKING([whether on macOS])
111116
if test x"${SYSKERNEL}" = x"Darwin"; then
117+
AC_MSG_RESULT([yes])
112118

113119
## Check if R is configured to compile OpenMP programs using -Xclang -fopenmp
114120
if test x"${can_use_openmp}" = x"no"; then
@@ -117,20 +123,22 @@ if test x"${SYSKERNEL}" = x"Darwin"; then
117123
PKG_CXXFLAGS="${PKG_CXXFLAGS} -Xclang -fopenmp" PKG_LIBS="${PKG_LIBS} -lomp" "${R_HOME}/bin/R" CMD SHLIB test-omp.cpp >/dev/null 2>&1
118124
if test x"$?" = x"0"; then
119125
AC_MSG_RESULT([yes])
120-
openmp_already_works="yes"
126+
#openmp_already_works="yes"
121127
arma_have_openmp="#define ARMA_USE_OPENMP 1"
122128
can_use_openmp="yes"
123129
# keep any entries user may have set
124130
PKG_CXXFLAGS="${PKG_CXXFLAGS} -Xclang -fopenmp"
125131
PKG_LIBS="${PKG_LIBS} -lomp"
126132
else
127133
AC_MSG_RESULT([no])
128-
openmp_already_works="no"
134+
#openmp_already_works="no"
129135
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
130136
can_use_openmp="no"
131137
fi
132138
fi
133-
fi
139+
else
140+
AC_MSG_RESULT([no])
141+
fi # if macOS
134142

135143
## Go back home.
136144
cd "${owd}"
@@ -152,21 +160,21 @@ dnl else
152160
dnl AC_MSG_RESULT([not found])
153161
dnl fi
154162

155-
if test x"${can_use_openmp}" = x"yes"; then
156-
AC_MSG_CHECKING([for OpenMP])
157-
## if R has -fopenmp we should be good
158-
allldflags=$(${R_HOME}/bin/R CMD config --ldflags)
159-
hasOpenMP=$(echo ${allldflags} | grep -- -fopenmp)
160-
if test x"${hasOpenMP}" = x""; then
161-
AC_MSG_RESULT([missing])
162-
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
163-
openmp_flag=""
164-
else
165-
AC_MSG_RESULT([found and suitable])
166-
arma_have_openmp="#define ARMA_USE_OPENMP 1"
167-
openmp_flag='$(SHLIB_OPENMP_CXXFLAGS)'
168-
fi
169-
fi
163+
dnl if test x"${can_use_openmp}" = x"yes"; then
164+
dnl AC_MSG_CHECKING([for OpenMP])
165+
dnl ## if R has -fopenmp we should be good
166+
dnl allldflags=$(${R_HOME}/bin/R CMD config --ldflags)
167+
dnl hasOpenMP=$(echo ${allldflags} | grep -- -fopenmp)
168+
dnl if test x"${hasOpenMP}" = x""; then
169+
dnl AC_MSG_RESULT([missing])
170+
dnl arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
171+
dnl openmp_flag=""
172+
dnl else
173+
dnl AC_MSG_RESULT([found and suitable])
174+
dnl arma_have_openmp="#define ARMA_USE_OPENMP 1"
175+
dnl openmp_flag='$(SHLIB_OPENMP_CXXFLAGS)'
176+
dnl fi
177+
dnl fi
170178

171179
## now use all these
172180
AC_SUBST([ARMA_HAVE_OPENMP], ["${arma_have_openmp}"])

0 commit comments

Comments
 (0)