Karim Belabas on Sat, 25 Jun 2022 18:48:48 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: FORTRAN memory issues and use of the sum function 'somme'
|
- To: "Brereton, Ashley" <A.Brereton@liverpool.ac.uk>
- Subject: Re: FORTRAN memory issues and use of the sum function 'somme'
- From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
- Date: Sat, 25 Jun 2022 18:48:43 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1656175725; c=relaxed/relaxed; bh=JeD7GGzew13ZE1ggAWMiXB7VcolGt/763zowMi07Oto=; h=DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; b=BlKbjHLQFiyE1QKtnBNny9zbEcmxAoDPoe/yfHGi/NqNH8dCdODpDGmDAwYiuEAqLbIXMjX05h0kVyiYSz475Gf96HeAzkfdcIQL/fg16CEsp23uEWTJDfYXgCSeoajmiW6NihVCGxnPkjdfxyFApe+6CwoTjhlwHoU0FjRkUb17Rojl2xLNXvqdt1/VN6ygNTzaiZbh1A88HVMh1cuGy90SFGqbkffjIHDHLypbW37v4uwnOWh7r162t2lK+xguvb5QIXgwwBd6ARm5+2akEQTcHjR7BtjDlmf5ICVzT9U8zEMSRHr2jzImktne5AZH5zOMAoKbcC40SU7BK9Y+QygObniW4yU5qjX/uUB4tWEHFGBhVfnPoY+dAYkbJ8AWL68iDs2HkEopotbBdUHorkwc2jngbIWamn23jshIVQ5++KRf/PMT/O7nlgnEzR5fZPcAV2q4R8tYqWoWT6vq5d0AMTfBdRmDwkTLnmq2moajjOgoxhYjSNKJNPMxCoTTMFGV93tN0/+PbnbJ7mCwgYrdfLy3IvgB+RAsKwPW8UXPLcskzBxMlTl+7vsLSF6HQpSLPUY2dPNNLTmxM0f9LoPM/P8b3vAU9klovrTFvf09MVxDDVUw4rf93D/H7YMScqUdtuk0nuxdfr5lAUKI9YpZHj7f5Cqs/9jZZoO1qIU=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1656175725; cv=none; b=BAaQz/nNj9qu1z2k4SGz9Z8Xw1v4TlifFyWiTqwy3JGn8G3NtUy/6amEZVN26pkYMT6lXhTxdo3kIWLADJeQYB6BMtOGrftooLNqDD8++rYjS4cIJdMAP5ixu02DdXSrQbOiFzw07bj+zepHUxliqXLk/ngWRR4mglT5LJtFiL8+/xpEPllwe6+UvabBiwU/HvQFEnIsj+mWkC3rVvXw6CbHjsXYPV6Sxd7S0visfFHruXIqYaDgI0nda9m08CfAKhq88zETrjCBlQYswsbpZNI1atnDKeZOgKKPD7btbHqUY+IhZVGNqZQd4+gkpoQfjAikGuTseb7iIPEExRdNMS0F6SQFkZqTc9B3aI0uT76qqW+19LJGILmzyl6wBk3MU9s4CdsQUsxuBIAPDmiRAGnU1yJvunGq5rYhFD4tN4JYKXD3bN3l+yNoXcv3BcqWqRjKughiLLkc9yk6ddyXkffNdzZ6pWGXtyosPcZmpqC8b9lP2B+4cKUrYbwE02OKBLYtY6odkod0X8X2/tkwl2Q5/Ux7lyw+FaS7IvFkDIE8Vj8HX4kkjTAVcMGZHxagJNfEhkSujA2MEiOJe8Tx0pVAh9OzfiOm+MsuCqXcMCxuoiCMJKnDpqSbdq+ihlYUYbT1vW90zwIdYmob8dGopbjPtLFwQjznlIXOL6OCk7k=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Cc: "pari-users@pari.math.u-bordeaux.fr" <pari-users@pari.math.u-bordeaux.fr>
- Delivery-date: Sat, 25 Jun 2022 18:48:48 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1656175725; bh=JeD7GGzew13ZE1ggAWMiXB7VcolGt/763zowMi07Oto=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ik40LjH3eA+Zf9Bmtjhlc2naUPCx8Mb7awio+nz9Ss8PKx+hT5qEXY57XiAQZ3NUa dmRFvdRsntgyN+rY4uYjP+yz9eIZvrZ9QsWLjOl3vCXNWXchR2ADMrjCMenm4z8WeT DcUJnhzTfb8cu8SJ+js/cWrj6cJLFCvTiOHKB399XqDlSc716vMN02vAPA0tD2ohkp IiLD30/S5mv398uOHD60xIqXSeyf9F5xU28TdRL9ZIRugjoTbo8BnI++dPeydyOyG7 OpsPAmGHa/CknRbOig0jsVsNQajs6Jckb4NCwkbqqiXnkJV6xuGxFOf0qRfPgoxqDE 1Nlviyqmed4oYEzCOOWv05Nse3UcERpzcBnZ9Xen/hzQRqaoO9w6JqMJ78jodoWY9l kKvQ1iBPsQGFslCB34FR7CQOIZovT3oWfv0M+kG58oBjrxzd6l+KhvMNdNZpmkC/su UwB8LdV/RBUP7JBrIU49PStzs7WMi6UpsQ9R4Kf5aB57cTHhz24X3cUhPQMwXftY36 WpMdpG3Lo03uY2M76B23mzGlE6iwkmD52SrDlQI8ZYPTHfcAmeY4eLoc20J7A4IAqd tucuyYQfpfCDWWd16GjcpxKTPudQR43ZbvhQ6vkYs5vqi2TJvpgaHG6FtVrzO8W3OZ lhBG+LXcmxkbHfhl59mW6wns=
- In-reply-to: <CWLP265MB1908E0F9E58954F218A5FE6DC6B79@CWLP265MB1908.GBRP265.PROD.OUTLOOK.COM>
- Mail-followup-to: "Brereton, Ashley" <A.Brereton@liverpool.ac.uk>, "pari-users@pari.math.u-bordeaux.fr" <pari-users@pari.math.u-bordeaux.fr>
- References: <CWLP265MB1908E0F9E58954F218A5FE6DC6B79@CWLP265MB1908.GBRP265.PROD.OUTLOOK.COM>
Hi,
there many ways to answer you general question (I would advise to
start by reading 4.3 Garbage collection in the User's Guide to the PARI
library to understand our model, then the examples at 4.3.3), but in
order to sum glog(X) for X=1:N, why not use glngamma(N +1) ?
This will be *much* faster and use essentially no memory.
Cheers,
K.B.
* Brereton, Ashley [2022-06-25 18:13]:
> Hi there,
>
> I was hoping somebody could help with an issue with memory usage.
>
> My code is written in Fortran. In my code, I have a (simplified) loop (see below). The code fails because the pari stack size isn't big enough.
>
> It seems like 'u' is stored at a new memory address for each loop iteration, and so the memory fills up - though I may be wrong!
>
> If I am indeed correct, my question is, does anybody know how to either:
>
> a) overwrite at the same memory address or
> b) clear the memory (I tried to use allocatable for 'u' and deallocate inside the loop, but with no success).
>
>
> My loop will be used for a simple sum: glog(X) for X=1:N, how do I use the 'somme' function in my Fortran code? This is the gadd function for reference. I'm hoping the somme function can get around the memory issue!
>
> !
> type(C_PTR) function gadd( x , y) bind(C,name='gadd')
> import C_PTR
> type(C_PTR), VALUE :: x
> type(C_PTR), VALUE :: y
> end function gadd
> !
>
> Any help would be greatly appreciated!
>
> Thank you in advance,
> Ash
>
>
>
>
>
> %%%%%%%%%%%%%%%
>
> use ISO_C_BINDING, only : C_PTR
> use PARI
>
> type(C_PTR) :: u
> integer(kind=C_LONG) :: I
> integer(kind=C_LONG) :: prec = 10 ! 152 decimal digits
>
>
> CALL pari_init(10000000_8, 2_8)
>
>
> DO I=1_8,100000_8
>
> u = stor(I,prec)
>
> ENDDO
>
>
> CALL pari_close()
>
>
> %%%%%%%%%%%%%%%
--
Karim Belabas, IMB (UMR 5251), Université de Bordeaux
Vice-président en charge du Numérique
T: (+33) 05 40 00 29 77; http://www.math.u-bordeaux.fr/~kbelabas/
`