From b859fba80fc8119b2f2d5ccb9ef7de13d96e3ba3 Mon Sep 17 00:00:00 2001 From: ripley Date: Thu, 20 Jul 2023 11:57:10 +0000 Subject: [PATCH] resolve some warnings from Intel Fortran git-svn-id: https://svn.r-project.org/R/trunk@84712 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/manual/R-admin.texi | 77 +++++++++++++++++++++++---------- src/library/stats/src/hclust.f | 5 ++- src/library/stats/src/kmns.f | 4 +- src/library/stats/src/loessf.f | 2 +- src/library/stats/src/portsrc.f | 2 +- 5 files changed, 61 insertions(+), 29 deletions(-) diff --git a/doc/manual/R-admin.texi b/doc/manual/R-admin.texi index 6a846de82e3..a3ddd2b22c7 100644 --- a/doc/manual/R-admin.texi +++ b/doc/manual/R-admin.texi @@ -1222,7 +1222,7 @@ confused compiler messages. LLVM supports another type of LTO called `Thin LTO' as well as a similar implementation to GCC, sometimes called `Full LTO'. (See -@uref{https://clang.llvm.org/docs/ThinLTO.html}.) Currently the only +@uref{https://clang.llvm.org/docs/ThinLTO.html}.) Currently the LLVM compiler relevant to @R{} is @command{clang} for which this can be selected by setting macro @samp{LTO=-flto=thin}. LLVM has @example @@ -1247,6 +1247,17 @@ code compiled with @command{gfortran}. It is said to be particularly beneficial to use @option{-O3} for @command{clang} in conjunction with LTO. +It seems that @command{flang} may support LTO, but with no documentation +as yet. + +The 2020s versions of Intel's C/C++ compilers are based on LLVM and as +such support LLVM-style LTO, both `full' and `thin'. This might use +something like +@example +LTO=-flto=thin -flto-jobs=8 +@end example + + @node LTO for package checking, , LTO with LLVM, Link-Time Optimization @subsubsection LTO for package checking @@ -3893,7 +3904,7 @@ these have been tried they did not work with the default compilers used for @R{} on those platforms. The following examples have been used with MKL versions 10.3 to -2023.1.0, for GCC compilers on @cputype{x86_64} CPUs. (See also +2023.2.0, for GCC compilers on @cputype{x86_64} CPUs. (See also @ref{Intel compilers}.) To use a sequential version of MKL we used @@ -5015,30 +5026,34 @@ tested with @R{}. @node Intel compilers, , flang, Linux @subsection Intel compilers +@menu +* `Classic compilers':: +@end menu + In late 2020 Intel revamped their C/C++ compilers (and later their Fortran compiler) to use an LLVM back-end. Those compilers are only for @cputype{x86_64}: the earlier compilers (now branded `Classic') also supported @cputype{ix86} and 32-bit builds on @cputype{x86_64}. The compilers are now all under Intel's `oneAPI' brand. The revamped -ones are @command{icx}, @command{icpx} and @command{ifx}; the classic -compilers were @command{icc}, @command{icpc} and @command{ifort}. The -former are identiifed by the C/C++ macro @code{__INTEL_LLVM_COMPILER}, -the latter by @code{__INTEL_COMPILER}. +ones are @command{icx}, @command{icpx} and @command{ifx}; they +are identiifed by the C/C++ macro @code{__INTEL_LLVM_COMPILER} (and do +not define @code{__INTEL_COMPILER}). Standalone installers (which are free-of-charge) are available from @uref{https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html}: they are also part of the oneAPI Base and HPC (for Fortran) ToolKits. -We tried the LLVM-based compilers in openAPI 2023.1.0 using +We tried the LLVM-based compilers in oneAPI 2023.2.0 using @example IP=/path/to/compilers/bin/intel64 CC=$IP/icx CXX=$IP/icpx FC=$IP/ifx -CFLAGS="-O3 -fp-model precise" -FFLAGS="-O3 -fp-model precise" -CXXFLAGS="-O3 -fp-model precise" +CFLAGS="-O3 -fp-model precise -Wall" +FFLAGS="-O3 -fp-model precise -warn all,noexternals" +FCFLAGS="-free -O3 -fp-model precise -warn all,noexternals" +CXXFLAGS="-O3 -fp-model precise -Wall" LDFLAGS="-L/path/to/compilers/compiler/lib/intel64_lin -L/usr/local/lib64" @end example @noindent @@ -5049,15 +5064,37 @@ Intel document building @R with MKL: for the Intel compilers this needs something like @example MKL_LIB_PATH=/path/to/intel_mkl/mkl/lib/intel64 -export LD_LIBRARY_PATH=$MKL_LIB_PATH +INTEL_LIB_PATH /path/to/compiler/linux/compiler/lib/intel64_lin +export LD_LIBRARY_PATH $@{MKL_LIB_PATH@}:$@{INTEL_LIB_PATH@} MKL="-L$@{MKL_LIB_PATH@} -lmkl_intel_lp64 -lmkl_core -lmkl_sequential" ./configure --with-blas="$MKL" --with-lapack @end example @noindent -and the build passed it checks. It may also be possible to use +and the build passed its checks. It may also be possible to use a compiler option like @option{-qmkl=sequential}. -The earlier compilers remained available until the second half of 2023. +One quirk is that the Intel Fortran compilers do not accept @file{.f95} +files, only @file{.f90} for free-format Fortran. @command{configure} +adds @option{-Tf} which tells the compiler this is indeed a Fortran file +(and needs to immediately precede the file name), but @option{-free} is +needed to say it is free-format. Hence setting the @code{FCFLAGS} +macro. +@c https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-2/file-extensions.html + +The compilers have many options, some of which are still under +development for the new compilers. As the C/C++ and Fortran compilers +have different origins for their front-ends, there is little consistency +in their options. The new compilers support clang-style LTO, at least +for C/C++. + +@node `Classic compilers', , Intel compilers, Intel compilers +@subsubsection `Classic compilers' + +The classic compilers were @command{icc}, @command{icpc} and +@command{ifort}. They are identiifed by the C/C++ macro +@code{__INTEL_COMPILER}. + +The classic compilers remained available until the second half of 2023. Version 2021.9.0 (shipped as part of oneAPI 2023.1.0) was tested in July 2023 using @@ -5068,23 +5105,15 @@ CXX=$IP/icpc FC=$IP/ifort CFLAGS="-O3 -ip -fp-model precise" FFLAGS="-O3 -fp-model precise" -FCFLAGS="-free -O3 -fp-model precise" CXXFLAGS="-O3 -fp-model precise" LDFLAGS="-L/path/to/compilers/compiler/lib/intel64_lin -L/usr/local/lib64" @end example @noindent but also segfaulted in the checks. -One quirk is that the Intel Fortran comoilers do not accept @file{.f95} -files, only @file{.f90} for free-format Fortran. @command{configure} -adds @option{-Tf} which tells the compiler this is indeed a Fortran -file, but @option{-free} is needed to say it is free-format. Hence -setting the @code{FCFLAGS} macro. -@c https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-2/file-extensions.html - -There have been no other recent reports on the use of Intel compilers: -this section is left in case it provides helpful hints for people using -the 'classic' compilers while they are still available. +There have been no other recent reports on the use of these compilers: +the rest of this section is left in case it provides helpful hints for +people using them while they are still available. Brian Ripley used version 9.0 of the compilers for @cputype{x86_64} on Fedora Core 5 with diff --git a/src/library/stats/src/hclust.f b/src/library/stats/src/hclust.f index ac89259e6a8..2289b9db626 100644 --- a/src/library/stats/src/hclust.f +++ b/src/library/stats/src/hclust.f @@ -173,10 +173,11 @@ SUBROUTINE HCLUST(N,LEN,IOPT,IA,IB,CRIT,MEMBR,NN,DISNN, DISS) c FIX: the rest of the else clause is a fix by JB to ensure c correct nearest neighbours are found when a non-monotone c clustering method (e.g. the centroid methods) are used - if(DISS(IND1) .lt. DISNN(K)) then ! find nearest neighbour of i2 + if(DISS(IND1) .lt. DISNN(K)) then +c find nearest neighbour of i2 DISNN(K) = DISS(IND1) NN(K) = I2 - end if + endif ENDIF ENDIF END DO diff --git a/src/library/stats/src/kmns.f b/src/library/stats/src/kmns.f index c504a95efa8..8c19e6543ae 100644 --- a/src/library/stats/src/kmns.f +++ b/src/library/stats/src/kmns.f @@ -351,6 +351,7 @@ SUBROUTINE QTRAN(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, INTEGER ICOUN,ISTEP,I,L1,L2,J DOUBLE PRECISION BIG,DA,DB,DD,AL1,ALW,AL2,ALT,R2,DE external kmnsQpr + INTEGER iMaxQtr C C Define BIG to be a very large positive number C @@ -365,7 +366,8 @@ SUBROUTINE QTRAN(A, M, N, C, K, IC1, IC2, NC, AN1, AN2, NCP, D, 10 continue DO I = 1, M - if(iTrace .gt. 0 .and. ISTEP .ge. 1 .and. I .eq. 1) ! only from second "round" on + if(iTrace .gt. 0 .and. ISTEP .ge. 1 .and. I .eq. 1) +c only from second "round" on + call kmnsQpr(ISTEP, ICOUN, NCP, K, iTrace) ICOUN = ICOUN + 1 ISTEP = ISTEP + 1 diff --git a/src/library/stats/src/loessf.f b/src/library/stats/src/loessf.f index 4cbd348fd35..983057ad09c 100644 --- a/src/library/stats/src/loessf.f +++ b/src/library/stats/src/loessf.f @@ -1998,7 +1998,7 @@ subroutine ehg129(l,u,d,x,pi,n,sigma) c {called only from ehg127} purpose...?... subroutine ehg137(z,leaf,nleaf,d,ncmax,a,xi,lo,hi) - integer d,nleaf + integer d,nleaf,ncmax integer leaf(256),a(ncmax),hi(ncmax),lo(ncmax),pstack(20) DOUBLE PRECISION z(d),xi(ncmax) diff --git a/src/library/stats/src/portsrc.f b/src/library/stats/src/portsrc.f index 61492622149..27a9a13a5c0 100644 --- a/src/library/stats/src/portsrc.f +++ b/src/library/stats/src/portsrc.f @@ -2339,7 +2339,7 @@ SUBROUTINE I7SHFT(N, K, X) C *** LAST LINE OF I7SHFT FOLLOWS *** END SUBROUTINE S7ETR(M,N,NPAIRS,INDROW,JPNTR,INDCOL,IPNTR,IWA) - INTEGER M,N + INTEGER M,N,NPAIRS INTEGER INDROW(NPAIRS),JPNTR(N+1),INDCOL(NPAIRS),IPNTR(M+1), * IWA(M) C **********