[petsc-users] Issue with single precision complex numbers in petsc4py

Peng Sun psun at outlook.com
Thu Oct 13 18:16:43 CDT 2022


Hi Matt,

Please see the following screenshot.  Yes, I exported the PETSC_ARCH variable before running the script.  Note the "Invalid MIT-MAGIC-COOKIE-1 key" string is related to the X server and in all Python printout, not on PETSc.

[cid:95e2940b-842a-4f1b-a542-bad8737d3b38]

Best regards,
Peng Sun
________________________________
From: Matthew Knepley <knepley at gmail.com>
Sent: Thursday, October 13, 2022 3:57 PM
To: Peng Sun <psun at outlook.com>
Cc: Stefano Zampini <stefano.zampini at gmail.com>; petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py

On Thu, Oct 13, 2022 at 5:27 PM Peng Sun <psun at outlook.com<mailto:psun at outlook.com>> wrote:
Hi Stefano,

Sure, please see the following.  The PETSC_ARCH field is empty in the printout despite the fact that it was set to 'arch-linux-c-opt' in the shell.

{'PETSC_DIR': '/home/pesun/.emopt', 'PETSC_ARCH': ''}

Can you show the whole output?

Also, did you remember to 'export' it so that it goes to subshells?

   Matt

Best regards,
Peng Sun
________________________________
From: Stefano Zampini <stefano.zampini at gmail.com<mailto:stefano.zampini at gmail.com>>
Sent: Thursday, October 13, 2022 1:57 PM
To: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>
Cc: Peng Sun <psun at outlook.com<mailto:psun at outlook.com>>; petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov> <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>>
Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py

Matt

Yes, petsc4py does the right thing. This is probably. Picking up the wrong PETSc arch.

Peng, can you please run this?

import petsc4py
petsc4py.init()
print(petsc4py.get_config())

On Oct 13, 2022, at 11:23 PM, Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>> wrote:

Lisandro,

PETSc is compiled for single. Does petsc4py respect this, or does it always use double for getArray() and friends?

  Thanks,

     Matt

On Thu, Oct 13, 2022 at 11:42 AM Peng Sun <psun at outlook.com<mailto:psun at outlook.com>> wrote:
Hi Matt,

Sure, please see the attached configure.log file.  Thanks!

Best regards,
Peng Sun


________________________________
From: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>
Sent: Thursday, October 13, 2022 6:34 AM
To: Peng Sun <psun at outlook.com<mailto:psun at outlook.com>>
Cc: petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov> <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>>
Subject: Re: [petsc-users] Issue with single precision complex numbers in petsc4py

First send configure.log so we can see the setup.

  Thanks,

      Matt

On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <psun at outlook.com<mailto:psun at outlook.com>> wrote:

Dear PETSc community,


I have a question regarding the single precision complex numbers of petsc4py.  I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision.


Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128.  Could anybody please help me?  Thanks!


import petsc4py
import sys
petsc4py.init(sys.argv)
from petsc4py import PETSc

da=PETSc.DA().create(sizes=[2,2,2],dof=1,stencil_type=0,stencil_width=1,boundary_type=1)
da_1 = da.createGlobalVec()
print(petsc4py.PETSc.ComplexType)
print(da_1.getArray().dtype)




Best regards,

Peng Sun


--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>


--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>



--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221013/858d7db9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 30445 bytes
Desc: image.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221013/858d7db9/attachment-0001.png>


More information about the petsc-users mailing list