From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id 0925F3858D35 for ; Tue, 30 Apr 2024 07:30:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0925F3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0925F3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714462215; cv=none; b=mdsYdEMqRBExQ2PpsSHaob6fEZk6AzX6tgA3y3/KSZhNA/HktfV9+PRTx0JmN6TAeSBup1CJh4O2CWokQQw5euySin2RqxuhtzOjQRE61TsCManPoD6aJewDXzmQLIRqwjmba3rVfmB1ZZFnhiTPxAPJyKaD1NnR/q/9H8cackU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714462215; c=relaxed/simple; bh=v1X78qXRx7NIuP1jb/c79zpyFKbq0KFFAmjEZLcatNo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=FF79Ly6R77hyIa32PLzXTTetLZaSQ5V4L+8Bxzh1g7UJqmj09PnYri7u7NDCts2yAGPqdDiJh/3ssp5X6jNyD2cLCU8sHCA1yiRl9JvA56+ZzJ3b/clJi3mg2OeAtw7kyRO2fdk0D64xKvyMsCkcd6BiECrsxW8+OPeRDTx4Bgc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2dd7e56009cso69481581fa.3 for ; Tue, 30 Apr 2024 00:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714462211; x=1715067011; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sLlbQBeixBNpOiEhKUIYuWaM7DzlSwrH8aWAFXW/gnQ=; b=Xf+SMLhz+hfYw1IFNiIwN70dqj9YgifrcGU/PWICzn3UI1pn6lx3b/aYZ2z6kuP5GG DKijZZMnKuToEtGOkjGW8rhPgS9Z3OCl+OnDVmHdIBMTxwr0CciVoQbZVHN3q8QXMWQW 1tyyStTVtVM0d2vgY3o6vhjrAv14WRDTEvLvMEg25iGPf7Z1wXY1OV5/C3gxO6ff00fe TszEN6ms66SHQAw9esMuBtxd1RHi+SAc77msk1jPCpz+ZMdG43sH8zLkX0phI1PtWyHG 0MqO95EYnsKR/Db7XUHM8O2ZFs6vzYqbpJx4P78ACGKqDgIVFTzZRdO1dBfDOOHsmknJ ZVhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714462211; x=1715067011; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sLlbQBeixBNpOiEhKUIYuWaM7DzlSwrH8aWAFXW/gnQ=; b=wVbeVVh6qv+VNb9+JjBrqFo+5dyh8IdPJlO1TyDvyL/Lx6YgexbbLtrkfdt2BMBcHQ GSR5J0Z0lB5Q2lmNPmm4cYY2wl397OuoE/R+xEgOQWqbrANhrUBRq4vRLuFD+xSibCOq 3te+UroMCCmKyhR5wQmiIq8XBasmpPA/Pv/h1exLKr52R+fgCfnc4wVX7j6tT7Z6nuSm /xpL9Al1Ld8nCazAUYlhbX9Q6bZfJj2cTSE1n2fyOO5TMXLdDwB711ms5VVs64g+y5r6 zdU8x7Wb4oedwjfFWGxG/Huf63qwNDDEVSD6PIHZFxnvz2oFoh1vJYI8qJSbH++w/FWB /yzA== X-Forwarded-Encrypted: i=1; AJvYcCVwfalBzCBBch++ERDleXAKistaUVfeHRbXqFVpCzLAOqbmqulF0YdSGPwlGEU5VH4bP3CgZFRrXthLr7TifsHkwJd2WUViuw== X-Gm-Message-State: AOJu0YxPriMOY03LaLSm9IkU53mTp6zJZ+ukF/rLifkbaYlVk+m4N7Nj MQpNkODJpX8sifLTdA+Z4M/PAgZph6tIRiwpwC6Apsz51k7mHLpWQiW39JZkklI0cnCXVB9qIjc q3EaSihhSk5S52/Sg0iYkW6pVg0I= X-Google-Smtp-Source: AGHT+IE9TqP2FOaLWluozrovRS7neNkfNrTpH3h1XqGHWRUKJ8tp+hu2cH2bKG+8pkKc0IjNgMXxsj+VRGWKaNArRUQ= X-Received: by 2002:a2e:b6cd:0:b0:2da:c37f:655e with SMTP id m13-20020a2eb6cd000000b002dac37f655emr8986404ljo.16.1714462211105; Tue, 30 Apr 2024 00:30:11 -0700 (PDT) MIME-Version: 1.0 References: <20240429134515.4140169-1-hongtao.liu@intel.com> In-Reply-To: From: Richard Biener Date: Tue, 30 Apr 2024 09:30:00 +0200 Message-ID: Subject: Re: [PATCH] Don't assert for IFN_COND_{MIN, MAX} in vect_transform_reduction To: "H.J. Lu" Cc: liuhongt , gcc-patches@gcc.gnu.org, crazylht@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Apr 29, 2024 at 5:30=E2=80=AFPM H.J. Lu wrote= : > > On Mon, Apr 29, 2024 at 6:47=E2=80=AFAM liuhongt = wrote: > > > > The Fortran standard does not specify what the result of the MAX > > and MIN intrinsics are if one of the arguments is a NaN. So it > > should be ok to tranform reduction for IFN_COND_MIN with vectorized > > COND_MIN and REDUC_MIN. > > The commit subject isn't very clear. This patch isn't about "Don't asse= rt > for IFN_COND_{MIN,MAX}". It allows IFN_COND_{MIN,MAX} in > vect_transform_reduction. Well, we allow it elsewhere, we just fail to enumerate all COND_* we allow here correctly. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > Ok for trunk and backport to GCC14? OK for trunk and branch. Thanks, Richard. > > > > gcc/ChangeLog: > > > > PR 114883 > > * tree-vect-loop.cc (vect_transform_reduction): Don't assert > > for IFN_COND_{MIN, MAX}. > > > > gcc/testsuite/ChangeLog: > > > > * gfortran.dg/pr114883.f90: New test. > > --- > > gcc/testsuite/gfortran.dg/pr114883.f90 | 191 +++++++++++++++++++++++++ > > gcc/tree-vect-loop.cc | 3 +- > > 2 files changed, 193 insertions(+), 1 deletion(-) > > create mode 100644 gcc/testsuite/gfortran.dg/pr114883.f90 > > > > diff --git a/gcc/testsuite/gfortran.dg/pr114883.f90 b/gcc/testsuite/gfo= rtran.dg/pr114883.f90 > > new file mode 100644 > > index 00000000000..86b664a521e > > --- /dev/null > > +++ b/gcc/testsuite/gfortran.dg/pr114883.f90 > > @@ -0,0 +1,191 @@ > > +! { dg-do compile } > > +! { dg-options "-O3" } > > +! { dg-additional-options "-march=3Dx86-64-v4" { target { x86_64-*-* i= ?86-*-* } } } > > + > > +module ndrop > > + > > + > > + implicit none > > + > > + private > > + save > > + > > + public dropmixnuc > > + > > + real(8) :: npv(1011) ! number per volume concentration > > + real(8) :: alogsig(1011) ! natl log of geometric standard dev of aer= osol > > + > > + type qqcw_type > > + real(8), pointer :: fldcw(:,:) > > + end type qqcw_type > > + > > +contains > > + > > + subroutine dropmixnuc(lchnk, ncol, temp, & > > + cldn,cldo, & > > + raer, dtmicro & > > + ) > > + implicit none > > + > > + ! input > > + > > + integer, intent(in) :: lchnk ! chunk identifier > > + integer, intent(in) :: ncol ! number of columns > > + ! type(physics_state), intent(in) :: state ! Physics sta= te variables > > + real(8), intent(in) :: dtmicro ! time step for microph= ysics (s) > > + real(8), intent(in) :: temp(1,1011) ! temperature (K) > > + real(8), intent(in) :: cldo(1,1011) ! cloud fraction on previou= s time step > > + real(8), intent(in) :: cldn(1,1011) ! cloud fraction > > + real(8), intent(in) :: raer(1,1011,1011) ! aerosol mass, number mi= xing ratios > > + > > + > > + type(qqcw_type) :: QQCW(1011) > > + > > + real(8) depvel(1,1011)! deposition velocity for droplets (m/s) > > + real(8) wtke(1,1011) ! turbulent vertical velocity at base of = layer k (m/s) > > + real(8) wtke_cen(1,1011) ! turbulent vertical velocity at center o= f layer k (m/s) > > + real(8) zn(1011) ! g/pdel (m2/g) for layer > > + real(8) zs(1011) ! inverse of distance between levels (m) > > + real(8), parameter :: zkmin=3D0.01_8,zkmax=3D100._8 > > + real(8) cs(1,1011) ! air density (kg/m3) > > + real(8) dz(1,1011) ! geometric thickness of layers (m) > > + real(8) zero > > + > > + real(8) wdiab ! diabatic vertical velocity > > + real(8), parameter :: wmixmin =3D 0.1 ! minimum turbulence vertica= l velocity (m/s) > > + ! real(8), parameter :: wmixmin =3D 0.2 ! minimum turbulence= vertical velocity (m/s) > > + ! real(8), parameter :: wmixmin =3D 1.0 ! minimum turbulence = vertical velocity (m/s) > > + real(8) ekk(0:1011) ! density*diffusivity for droplets (kg/m= 3 m2/s) > > + real(8), parameter :: sq2pi=3D2.5066283_8 > > + real(8) dtinv > > + > > + integer km1,kp1 > > + real(8) wbar,wmix,wmin,wmax > > + real(8) dumc > > + real(8) fac_srflx > > + real(8) surfrate(1011) ! surface exchange rate (/s) > > + real(8) surfratemax ! max surfrate for all species treated he= re > > + real(8) dtmin,tinv,dtt > > + integer nsubmix,nsubmix_bnd > > + integer i,k,m > > + real(8) dtmix > > + real(8) pi > > + integer nnew,nsav,ntemp > > + real(8) ekkp(1011),ekkm(1011) ! zn*zs*density*diffusivity > > + integer count_submix(100) > > + save count_submix > > + real(8) nsource(1,1011) ! droplet number source (#/kg/s= ) > > + real(8) ndropmix(1,1011) ! droplet number mixing (#/kg/s= ) > > + real(8) ndropcol(1) ! column droplet number (#/m2) > > + > > + real(8) na(1),va(1),hy(1) > > + real(8) naermod(1011) ! (/m3) > > + real(8) hygro(1011) ! hygroscopicity of aerosol mode > > + real(8) vaerosol(1011) ! interstit+activated aerosol volume conc (= cm3/cm3) > > + real(8) :: taumix_internal_1011_inv ! 1/(internal mixing time scal= e for k=3D1011) (1/s) > > + real(8) :: cldo_tmp, cldn_tmp > > + real(8) :: tau_cld_regenerate > > + > > + integer ixndrop, l > > + integer, parameter :: psat=3D6 ! number of supersaturations to cal= c ccn concentration > > + real(8) :: supersat(psat)=3D & ! supersaturation (%) to determine= ccn concentration > > + (/0.02,0.05,0.1,0.2,0.5,1.0/) > > + real(8) ccn(1,1011,psat) ! number conc of aerosols activate= d at supersat > > + character(len=3D8), dimension(psat) :: ccn_name(psat)=3D & > > + (/'CCN1','CCN2','CCN3','CCN4','CCN5','CCN6'/) > > + real(8) arg > > + integer phase ! phase of aerosol > > + > > + > > + > > + arg =3D 1.0_8 > > + zero=3D0._8 > > + > > + > > + pi =3D 4._8*atan(1.0_8) > > + dtinv=3D1./dtmicro > > + > > + depvel(:,:) =3D 0.0_8 ! droplet number is done in pkg_cld_s= ediment, aerosols in mz_aerosols_intr > > + > > + overall_main_i_loop: & > > + do i=3D1,ncol > > + > > + surfratemax =3D 0.0_8 > > + nsav=3D1 > > + nnew=3D2 > > + surfrate(ixndrop)=3Ddepvel(i,ixndrop)/dz(i,1011) > > + surfratemax =3D max( surfratemax, surfrate(ixndrop) ) > > + tau_cld_regenerate =3D 3600.0_8 * 3.0_8 > > + > > + grow_shrink_main_k_loop: & > > + do k=3D1,1011 > > + km1=3Dmax0(k-1,1) > > + kp1=3Dmin0(k+1,1011) > > + > > + cldo_tmp =3D cldo(i,k) > > + cldn_tmp =3D cldn(i,k) * exp( -dtmicro/tau_cld_regenerate ) > > + cldo_tmp =3D cldn_tmp > > + cldn_tmp =3D cldn(i,k) > > + > > + if(cldn_tmp-cldo_tmp.gt.0.01)then > > + wbar=3Dwtke_cen(i,k) > > + wmix=3D0._8 > > + wmin=3D0._8 > > + wmax=3D10._8 > > + wdiab=3D0 > > + > > + phase=3D1 ! interstitial > > + do m=3D1,1011 > > + call loadaer(raer,qqcw,i,i,k,m,cs,npv(m),phase, & > > + na, va, hy ) > > + naermod(m)=3Dna(i) > > + vaerosol(m)=3Dva(i) > > + hygro(m)=3Dhy(i) > > + end do > > + dumc=3D(cldn_tmp-cldo_tmp) > > + endif > > + > > + enddo grow_shrink_main_k_loop > > + > > + ntemp=3Dnsav > > + nsav=3Dnnew > > + nnew=3Dntemp > > + dtmin=3Ddtmicro > > + ekk(0)=3D0.0 > > + ekk(1011)=3D0.0 > > + do k=3D1,1011 > > + km1=3Dmax0(k-1,1) > > + ekkp(k)=3Dzn(k)*ekk(k)*zs(k) > > + ekkm(k)=3Dzn(k)*ekk(k-1)*zs(km1) > > + tinv=3Dekkp(k)+ekkm(k) > > + > > + if(k.eq.1011)tinv=3Dtinv+surfratemax > > + if(k.eq.1011)tinv=3Dtinv+taumix_internal_1011_inv > > + > > + if(tinv.gt.1.e-6)then > > + dtt=3D1./tinv > > + dtmin=3Dmin(dtmin,dtt) > > + endif > > + enddo > > + dtmix=3D0.9*dtmin > > + nsubmix=3Ddtmicro/dtmix+1 > > + if(nsubmix>100)then > > + nsubmix_bnd=3D100 > > + else > > + nsubmix_bnd=3Dnsubmix > > + endif > > + count_submix(nsubmix_bnd)=3Dcount_submix(nsubmix_bnd)+1 > > + dtmix=3Ddtmicro/nsubmix > > + fac_srflx =3D -1.0/(zn(1011)*nsubmix) > > + > > + > > + ! call t_stopf ('nsubmix') > > + > > +enddo overall_main_i_loop > > +! end of main loop over i/longitude ..................................= .. > > + > > + > > +call ccncalc(lchnk,ncol,temp,cs,raer,qqcw,ccn,psat,supersat,alogsig,np= v) > > +return > > +end subroutine dropmixnuc > > +end module ndrop > > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > > index a6cf0a5546c..29c03c246d4 100644 > > --- a/gcc/tree-vect-loop.cc > > +++ b/gcc/tree-vect-loop.cc > > @@ -8505,7 +8505,8 @@ vect_transform_reduction (loop_vec_info loop_vinf= o, > > { > > gcc_assert (code =3D=3D IFN_COND_ADD || code =3D=3D IFN_COND_SUB > > || code =3D=3D IFN_COND_MUL || code =3D=3D IFN_COND_A= ND > > - || code =3D=3D IFN_COND_IOR || code =3D=3D IFN_COND_X= OR); > > + || code =3D=3D IFN_COND_IOR || code =3D=3D IFN_COND_X= OR > > + || code =3D=3D IFN_COND_MIN || code =3D=3D IFN_COND_M= AX); > > gcc_assert (op.num_ops =3D=3D 4 > > && (op.ops[reduc_index] > > =3D=3D op.ops[internal_fn_else_index ((internal_f= n) code)])); > > -- > > 2.31.1 > > > > > -- > H.J.