Re: [petsc-users] using real and complex together

2020-05-26 Thread Sam Guo
Thanks

On Tuesday, May 26, 2020, Stefano Zampini  wrote:

> All the solvers/matrices/vectors works for PetscScalar types (i.e. in your
> case complex)
> If you need to solve for the real part only, you can duplicate the matrix
> and call MatRealPart to zero out the imaginary part. But the solve will
> always run in the complex space
> You should not be worried about doubling the memory for a matrix (i.e.
> real and imaginary part)
>
>
> On May 26, 2020, at 11:28 PM, Sam Guo  wrote:
>
> complex version is needed since matrix sometimes is real and sometimes is
> complex. I want to solve real matrix without allocating memory for
> imaginary part((except eigen pairs).
>
> On Tuesday, May 26, 2020, Zhang, Hong  wrote:
>
>> You can build PETSc with complex version, and declare some variables as
>> 'PETSC_REAL'.
>> Hong
>>
>> --
>> *From:* petsc-users  on behalf of Sam
>> Guo 
>> *Sent:* Tuesday, May 26, 2020 1:00 PM
>> *To:* PETSc 
>> *Subject:* [petsc-users] using real and complex together
>>
>> Dear PETSc dev team,
>>Can I use both real and complex versions together?
>>
>> Thanks,
>> Sam
>>
>
>


Re: [petsc-users] using real and complex together

2020-05-26 Thread Stefano Zampini
All the solvers/matrices/vectors works for PetscScalar types (i.e. in your case 
complex)
If you need to solve for the real part only, you can duplicate the matrix and 
call MatRealPart to zero out the imaginary part. But the solve will always run 
in the complex space
You should not be worried about doubling the memory for a matrix (i.e. real and 
imaginary part)


> On May 26, 2020, at 11:28 PM, Sam Guo  wrote:
> 
> complex version is needed since matrix sometimes is real and sometimes is 
> complex. I want to solve real matrix without allocating memory for imaginary 
> part((except eigen pairs).
> 
> On Tuesday, May 26, 2020, Zhang, Hong  > wrote:
> You can build PETSc with complex version, and declare some variables as 
> 'PETSC_REAL'.
> Hong
> 
> From: petsc-users  > on behalf of Sam Guo 
> mailto:sam@cd-adapco.com>>
> Sent: Tuesday, May 26, 2020 1:00 PM
> To: PETSc mailto:petsc-users@mcs.anl.gov>>
> Subject: [petsc-users] using real and complex together
>  
> Dear PETSc dev team,
>Can I use both real and complex versions together?
> 
> Thanks,
> Sam



Re: [petsc-users] using real and complex together

2020-05-26 Thread Jacob Faibussowitsch
> complex version is needed since matrix sometimes is real and sometimes is 
> complex. 
PetscScalar is a flexible datatype, it will be real if PETSc is configured 
without complex support and include complex if PETSc is configured with 
complex. 

>  I want to solve real matrix without allocating memory for imaginary 
> part((except eigen pairs).

If you only want to use the real component of a PetscScalar you can use 
PetscRealPart() 
https://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Sys/PetscRealPart.html 

 to extract it. 

Best regards,

Jacob Faibussowitsch
(Jacob Fai - booss - oh - vitch)
Cell: (312) 694-3391

> On May 26, 2020, at 3:28 PM, Sam Guo  wrote:
> 
> complex version is needed since matrix sometimes is real and sometimes is 
> complex. I want to solve real matrix without allocating memory for imaginary 
> part((except eigen pairs).
> 
> On Tuesday, May 26, 2020, Zhang, Hong  > wrote:
> You can build PETSc with complex version, and declare some variables as 
> 'PETSC_REAL'.
> Hong
> 
> From: petsc-users  > on behalf of Sam Guo 
> mailto:sam@cd-adapco.com>>
> Sent: Tuesday, May 26, 2020 1:00 PM
> To: PETSc mailto:petsc-users@mcs.anl.gov>>
> Subject: [petsc-users] using real and complex together
>  
> Dear PETSc dev team,
>Can I use both real and complex versions together?
> 
> Thanks,
> Sam



Re: [petsc-users] using real and complex together

2020-05-26 Thread Sam Guo
complex version is needed since matrix sometimes is real and sometimes is
complex. I want to solve real matrix without allocating memory for
imaginary part((except eigen pairs).

On Tuesday, May 26, 2020, Zhang, Hong  wrote:

> You can build PETSc with complex version, and declare some variables as
> 'PETSC_REAL'.
> Hong
>
> --
> *From:* petsc-users  on behalf of Sam
> Guo 
> *Sent:* Tuesday, May 26, 2020 1:00 PM
> *To:* PETSc 
> *Subject:* [petsc-users] using real and complex together
>
> Dear PETSc dev team,
>Can I use both real and complex versions together?
>
> Thanks,
> Sam
>


Re: [petsc-users] error when configuring petsc with Intel Compilers 2019 update 3

2020-05-26 Thread Junchao Zhang
Please be aware that Intel MPI 2019 u3 has a lot of bugs when you look into
a bug. You better upgrade Intel Parallel Studio to the latest version.

--Junchao Zhang


On Tue, May 26, 2020 at 2:41 PM Alfredo Jaramillo 
wrote:

> Thanks for the tip! I will look into it.
>
> regards
> Alfredo
>
>
> On Tue, May 26, 2020 at 4:39 PM Matthew Knepley  wrote:
>
>> On Tue, May 26, 2020 at 3:15 PM Alfredo Jaramillo <
>> ajaramillopa...@gmail.com> wrote:
>>
>>> Thank you Matthew!
>>>
>>> I need this version to work on my computer in order to look for a bug
>>> that appears in a cluster.
>>> I'm not sure how to make it work, I will try with an older Linux
>>> distribution.
>>>
>>
>> If you are just looking for a bug, maybe a Docker container would allow
>> easier experimentation?
>>
>>   Thanks,
>>
>>  Matt
>>
>>
>>> regards
>>> Alfredo
>>>
>>> On Tue, May 26, 2020 at 1:02 PM Matthew Knepley 
>>> wrote:
>>>
 On Tue, May 26, 2020 at 11:23 AM Alfredo Jaramillo <
 ajaramillopa...@gmail.com> wrote:

> hello dear PETSc team,
>
> I'm trying to install PETSc with the 2019 update 3 Intel Parallel
> Studio. When starting the configuration process there appears the next
> message:
>
>
>
>
>
>
>
> *TESTING: checkFortran90Array from
> config.compilersFortran(/opt/petsc-3.13.0/config/BuildSystem/config/compilersFortran.py:211)***
>UNABLE to CONFIGURE with GIVEN OPTIONS(see configure.log for
> details):---Could
> not check Fortran pointer
> arguments
>
> the configuration log is attached to this message
>
> I would be very thankful of any kind help on this matter
>

 It seems like headers in /usr/include are conflicting with your new
 compiler.

 Executing: mpiicc -c -o
 /tmp/petsc-n__j58ih/config.compilersFortran/conftest.o
 -I/tmp/petsc-n__j58ih/config.libraries
 -I/tmp/petsc-n__j58ih/config.setCompilers
 -I/tmp/petsc-n__j58ih/config.compilers
 -I/tmp/petsc-n__j58ih/config.utilities.closure
 -I/tmp/petsc-n__j58ih/config.compilersFortran  -fPIC -O3 -march=native
 -mtune=native  /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c
 Possible ERROR while running compiler: exit code 2
 stderr:
 In file included from /usr/include/bits/floatn.h(119),
  from /usr/include/stdlib.h(55),
  from
 /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
 /usr/include/bits/floatn-common.h(214): error: invalid combination of
 type specifiers
   typedef float _Float32;
 ^

 In file included from /usr/include/bits/floatn.h(119),
  from /usr/include/stdlib.h(55),
  from
 /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
 /usr/include/bits/floatn-common.h(251): error: invalid combination of
 type specifiers
   typedef double _Float64;
  ^

 In file included from /usr/include/bits/floatn.h(119),
  from /usr/include/stdlib.h(55),
  from
 /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
 /usr/include/bits/floatn-common.h(268): error: invalid combination of
 type specifiers
   typedef double _Float32x;
  ^

 In file included from /usr/include/bits/floatn.h(119),
  from /usr/include/stdlib.h(55),
  from
 /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
 /usr/include/bits/floatn-common.h(285): error: invalid combination of
 type specifiers
   typedef long double _Float64x;
   ^

 compilation aborted for
 /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c (code 2)
 Source:
 #include "confdefs.h"
 #include "conffix.h"
 #include
 #include 
 void f90arraytest_(void* a1, void* a2,void* a3, void* i)
 {
   printf("arrays [%p %p %p]\n",a1,a2,a3);
   fflush(stdout);
   return;
 }
 void f90ptrtest_(void* a1, void* a2,void* a3, void* i, void* p1 ,void*
 p2, void* p3)
 {
   printf("arrays [%p %p %p]\n",a1,a2,a3);
   if ((p1 == p3) && (p1 != p2)) {
 printf("pointers match! [%p %p] [%p]\n",p1,p3,p2);
 fflush(stdout);
   } else {
 printf("pointers do not match! [%p %p] [%p]\n",p1,p3,p2);
 fflush(stdout);
 exit(111);
   }
   return;
 }

   Thanks,

  Matt

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

Re: [petsc-users] using real and complex together

2020-05-26 Thread Zhang, Hong via petsc-users
You can build PETSc with complex version, and declare some variables as 
'PETSC_REAL'.
Hong


From: petsc-users  on behalf of Sam Guo 

Sent: Tuesday, May 26, 2020 1:00 PM
To: PETSc 
Subject: [petsc-users] using real and complex together

Dear PETSc dev team,
   Can I use both real and complex versions together?

Thanks,
Sam


Re: [petsc-users] error when configuring petsc with Intel Compilers 2019 update 3

2020-05-26 Thread Alfredo Jaramillo
Thank you Matthew!

I need this version to work on my computer in order to look for a bug that
appears in a cluster.
I'm not sure how to make it work, I will try with an older Linux
distribution.

regards
Alfredo

On Tue, May 26, 2020 at 1:02 PM Matthew Knepley  wrote:

> On Tue, May 26, 2020 at 11:23 AM Alfredo Jaramillo <
> ajaramillopa...@gmail.com> wrote:
>
>> hello dear PETSc team,
>>
>> I'm trying to install PETSc with the 2019 update 3 Intel Parallel Studio.
>> When starting the configuration process there appears the next message:
>>
>>
>>
>>
>>
>>
>>
>> *TESTING: checkFortran90Array from
>> config.compilersFortran(/opt/petsc-3.13.0/config/BuildSystem/config/compilersFortran.py:211)***
>>UNABLE to CONFIGURE with GIVEN OPTIONS(see configure.log for
>> details):---Could
>> not check Fortran pointer
>> arguments
>>
>> the configuration log is attached to this message
>>
>> I would be very thankful of any kind help on this matter
>>
>
> It seems like headers in /usr/include are conflicting with your new
> compiler.
>
> Executing: mpiicc -c -o
> /tmp/petsc-n__j58ih/config.compilersFortran/conftest.o
> -I/tmp/petsc-n__j58ih/config.libraries
> -I/tmp/petsc-n__j58ih/config.setCompilers
> -I/tmp/petsc-n__j58ih/config.compilers
> -I/tmp/petsc-n__j58ih/config.utilities.closure
> -I/tmp/petsc-n__j58ih/config.compilersFortran  -fPIC -O3 -march=native
> -mtune=native  /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c
> Possible ERROR while running compiler: exit code 2
> stderr:
> In file included from /usr/include/bits/floatn.h(119),
>  from /usr/include/stdlib.h(55),
>  from
> /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
> /usr/include/bits/floatn-common.h(214): error: invalid combination of type
> specifiers
>   typedef float _Float32;
> ^
>
> In file included from /usr/include/bits/floatn.h(119),
>  from /usr/include/stdlib.h(55),
>  from
> /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
> /usr/include/bits/floatn-common.h(251): error: invalid combination of type
> specifiers
>   typedef double _Float64;
>  ^
>
> In file included from /usr/include/bits/floatn.h(119),
>  from /usr/include/stdlib.h(55),
>  from
> /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
> /usr/include/bits/floatn-common.h(268): error: invalid combination of type
> specifiers
>   typedef double _Float32x;
>  ^
>
> In file included from /usr/include/bits/floatn.h(119),
>  from /usr/include/stdlib.h(55),
>  from
> /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
> /usr/include/bits/floatn-common.h(285): error: invalid combination of type
> specifiers
>   typedef long double _Float64x;
>   ^
>
> compilation aborted for
> /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c (code 2)
> Source:
> #include "confdefs.h"
> #include "conffix.h"
> #include
> #include 
> void f90arraytest_(void* a1, void* a2,void* a3, void* i)
> {
>   printf("arrays [%p %p %p]\n",a1,a2,a3);
>   fflush(stdout);
>   return;
> }
> void f90ptrtest_(void* a1, void* a2,void* a3, void* i, void* p1 ,void* p2,
> void* p3)
> {
>   printf("arrays [%p %p %p]\n",a1,a2,a3);
>   if ((p1 == p3) && (p1 != p2)) {
> printf("pointers match! [%p %p] [%p]\n",p1,p3,p2);
> fflush(stdout);
>   } else {
> printf("pointers do not match! [%p %p] [%p]\n",p1,p3,p2);
> fflush(stdout);
> exit(111);
>   }
>   return;
> }
>
>   Thanks,
>
>  Matt
>
> Alfredo
>>
> --
> 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/
> 
>


[petsc-users] using real and complex together

2020-05-26 Thread Sam Guo
Dear PETSc dev team,
   Can I use both real and complex versions together?

Thanks,
Sam


Re: [petsc-users] error when configuring petsc with Intel Compilers 2019 update 3

2020-05-26 Thread Matthew Knepley
On Tue, May 26, 2020 at 11:23 AM Alfredo Jaramillo <
ajaramillopa...@gmail.com> wrote:

> hello dear PETSc team,
>
> I'm trying to install PETSc with the 2019 update 3 Intel Parallel Studio.
> When starting the configuration process there appears the next message:
>
>
>
>
>
>
>
> *TESTING: checkFortran90Array from
> config.compilersFortran(/opt/petsc-3.13.0/config/BuildSystem/config/compilersFortran.py:211)***
>UNABLE to CONFIGURE with GIVEN OPTIONS(see configure.log for
> details):---Could
> not check Fortran pointer
> arguments
>
> the configuration log is attached to this message
>
> I would be very thankful of any kind help on this matter
>

It seems like headers in /usr/include are conflicting with your new
compiler.

Executing: mpiicc -c -o
/tmp/petsc-n__j58ih/config.compilersFortran/conftest.o
-I/tmp/petsc-n__j58ih/config.libraries
-I/tmp/petsc-n__j58ih/config.setCompilers
-I/tmp/petsc-n__j58ih/config.compilers
-I/tmp/petsc-n__j58ih/config.utilities.closure
-I/tmp/petsc-n__j58ih/config.compilersFortran  -fPIC -O3 -march=native
-mtune=native  /tmp/petsc-n__j58ih/config.compilersFortran/conftest.c
Possible ERROR while running compiler: exit code 2
stderr:
In file included from /usr/include/bits/floatn.h(119),
 from /usr/include/stdlib.h(55),
 from
/tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
/usr/include/bits/floatn-common.h(214): error: invalid combination of type
specifiers
  typedef float _Float32;
^

In file included from /usr/include/bits/floatn.h(119),
 from /usr/include/stdlib.h(55),
 from
/tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
/usr/include/bits/floatn-common.h(251): error: invalid combination of type
specifiers
  typedef double _Float64;
 ^

In file included from /usr/include/bits/floatn.h(119),
 from /usr/include/stdlib.h(55),
 from
/tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
/usr/include/bits/floatn-common.h(268): error: invalid combination of type
specifiers
  typedef double _Float32x;
 ^

In file included from /usr/include/bits/floatn.h(119),
 from /usr/include/stdlib.h(55),
 from
/tmp/petsc-n__j58ih/config.compilersFortran/conftest.c(4):
/usr/include/bits/floatn-common.h(285): error: invalid combination of type
specifiers
  typedef long double _Float64x;
  ^

compilation aborted for
/tmp/petsc-n__j58ih/config.compilersFortran/conftest.c (code 2)
Source:
#include "confdefs.h"
#include "conffix.h"
#include
#include 
void f90arraytest_(void* a1, void* a2,void* a3, void* i)
{
  printf("arrays [%p %p %p]\n",a1,a2,a3);
  fflush(stdout);
  return;
}
void f90ptrtest_(void* a1, void* a2,void* a3, void* i, void* p1 ,void* p2,
void* p3)
{
  printf("arrays [%p %p %p]\n",a1,a2,a3);
  if ((p1 == p3) && (p1 != p2)) {
printf("pointers match! [%p %p] [%p]\n",p1,p3,p2);
fflush(stdout);
  } else {
printf("pointers do not match! [%p %p] [%p]\n",p1,p3,p2);
fflush(stdout);
exit(111);
  }
  return;
}

  Thanks,

 Matt

Alfredo
>
-- 
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/ 


Re: [petsc-users] Gather and Broadcast Parallel Vectors in k-means algorithm

2020-05-26 Thread Eda Oktay
Dear Richard,

I believe I don't need centroids. I just need cluster indices which
corresponds to idx.

What I am trying to do is this:

Step 6: Cluster the points (y_i) i=1,...,n in R^k with the k-means
algorithm into clusters C_1,...,C_k.
Output: Clusters A_1,,A_k with A_i = {j | y_j in C_i}

where y_i is the row vector of a matrix whose columns are eigenvectors

In order to cluster y_i, I think I just need idx from MATLAB since it shows
clustering indices.

Thanks,

Eda

Mills, Richard Tran , 23 May 2020 Cmt, 02:39 tarihinde
şunu yazdı:

> Hi Eda,
>
> If you are using the MATLAB k-means function, calling it like
>
>   idx = kmeans(X,k)
>
> will give you the index set, but if you do
>
>   [idx,C] = kmeans(X,k)
>
> then you will also get a matrix C which contains the cluster centroids. Is
> this not what you need?
>
> --Richard
>
> On 5/22/20 10:38 AM, Eda Oktay wrote:
>
> I am sorry, I used VecDuplictaeVecs not MatDuplicateVecs
>
> Eda Oktay , 22 May 2020 Cum, 20:31 tarihinde şunu
> yazdı:
>
>> Dear Richard,
>>
>> Thank you for your email. From MATLAB's kmeans() function I believe I got
>> the final clustering index set, not centroids. What I am trying to do is to
>> cluster vectors created by MatDuplicateVecs() according to the index set
>> (whose type is not IS since I took it from MATLAB) that I obtained from
>> MATLAB. I am trying to cluster these vectors however since they are
>> parallel, I couldn't understand how to cluster them.
>>
>> Normally, I have to be independent from MATLAB so I will try your
>> suggestion, grateful for that. However, because of my limited
>> knowledge about PETSc and parallel computing, I am not able to figure out
>> how to cluster parallel vectors according to an index set.
>>
>> Thanks,
>>
>> Eda
>>
>> Mills, Richard Tran , 30 Nis 2020 Per, 02:07 tarihinde
>> şunu yazdı:
>>
>>> Hi Eda,
>>>
>>> Thanks for your reply. I'm still trying to understand why you say you
>>> need to duplicate the row vectors across all processes. When I have
>>> implemented parallel k-means, I don't duplicate the row vectors. (This
>>> would be very unscalable and largely defeat the point of doing this with
>>> MPI parallelism in the first place.)
>>>
>>> Earlier in this email thread, you said that you have used Matlab to get
>>> cluster IDs for each row vector. Are you trying to then use this
>>> information to calculate the cluster centroids from inside your PETSc
>>> program? If so, you can do this by having each MPI rank do the following:
>>> For cluster i in 0 to (k-1), calculate the element-wise sum of all of the
>>> local rows that belong to cluster i, then use MPI_Allreduce() to calculate
>>> the global elementwise sum of all the local sums (this array will be
>>> replicated across all MPI ranks), and finally divide by the number of
>>> members of that cluster to get the centroid. Note that MPI_Allreduce()
>>> doesn't work on PETSc objects, but simple arrays, so you'll want to use
>>> something like MatGetValues() or MatGetRow() to access the elements of your
>>> row vectors.
>>>
>>> Let me know if I am misunderstanding what you are aiming to do, or if I
>>> am misunderstanding something.
>>>
>>> It sounds like you would benefit from having some routines in PETSc to
>>> do k-means (or other) clustering, by the way?
>>>
>>> Best regards,
>>> Richard
>>>
>>> On 4/29/20 3:47 AM, Eda Oktay wrote:
>>>
>>> Dear Richard,
>>>
>>> I am trying to use spectral clustering algorithm by using k-means
>>> clustering algorithm at some point. I am doing this by producing a matrix
>>> consisting of eigenvectors (of the adjacency matrix of the graph that I
>>> want to partition), then forming row vectors of this matrix. This is the
>>> part that I am using parallel vector. By using the output from k-means, I
>>> am trying to cluster these row vectors. To cluster these vectors, I think I
>>> need all row vectors in all processes. I wanted to use sequential vectors,
>>> however, I couldn't find a different way that I form row vectors of a
>>> matrix.
>>>
>>> I am trying to use VecScatterCreateToAll, however, since my vector is
>>> parallel crated by VecDuplicateVecs, my input is not in correct type, so I
>>> get error. I still can't get how can I use this function in parallel vector
>>> created by VecDuplicateVecs.
>>>
>>> Thank you all for your help.
>>>
>>> Eda
>>>
>>> Mills, Richard Tran , 7 Nis 2020 Sal, 01:51 tarihinde
>>> şunu yazdı:
>>>
 Hi Eda,

 I think that you probably want to use VecScatter routines, as Junchao
 has suggested, instead of the lower level star forest for this. I
 believe that VecScatterCreateToZero() is what you want for the
 broadcast
 problem you describe, in the second part of your question. I'm not sure
 what you are trying to do in the first part. Taking a parallel vector
 and then copying its entire contents to a sequential vector residing on
 each process is not scalable, and a lot of the design that has gone
 into
 PETSc