[petsc-users] How to use PETSc real version and complex version simultaneously?

gaochenyi14 gaochenyi14 at 163.com
Thu Apr 6 11:19:18 CDT 2023


Thanks for the hint.

I did a naive test and managed to use the same function with different typedefs. Basically, it is relied on that C has no name mangling while C++ has name mangling. Could this trick applies to PETSc? The files for the test are attached. The procedure for compilation is in the `main.cpp`

Best regards,

C.-Y. GAO

> On Apr 6, 2023, at 02:04, Matthew Knepley <knepley at gmail.com> wrote:
> 
> On Wed, Apr 5, 2023 at 1:59 PM gaochenyi14 <gaochenyi14 at 163.com <mailto:gaochenyi14 at 163.com>> wrote:
> Hi,
> 
> I rely on PETSc to deal with real and complex sparse matrices of dimension 1e4 * 1e4 or above. I want to use real version when only real matrices are involved, to achieve better performance, and use complex version only when complex matrices get involved. But in the manual it says different versions can not be used at the same time. Can this restriction be circumvented? If not, where does the restriction come from?
> 
> It is possible to do this, but it is cumbersome. You would have to compile both versions of the library, dlopen() them, and get the symbols you need. A group at Purdue has done this, but it is involved.
> 
> We use typedefs to change between real and complex. It would not be difficult to allow storage in several types. However, prescribing how one type interactes with another, particularly when data is passed in or out, is challenging. This difficulty does not go away with templates since it is about type interaction, not polymorphism.
> 
>   Thanks,
> 
>      Matt
>  
> All the best,
> C.-Y. GAO
> 
> 
> -- 
> 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/20230407/4aa078a8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: name-conflict.zip
Type: application/zip
Size: 1339 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230407/4aa078a8/attachment.zip>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230407/4aa078a8/attachment-0001.html>


More information about the petsc-users mailing list