xref: /petsc/src/sys/classes/viewer/impls/ams/amsopen.c (revision ec957ece147126e1303fa8daf36bd57228a49e96)
15c6c1daeSBarry Smith 
207475bc1SBarry Smith #include <petsc-private/viewerimpl.h>   /*I  "petscsys.h"  */
338dc1537SBarry Smith #include <petscviewerams.h>
45c6c1daeSBarry Smith 
55c6c1daeSBarry Smith #undef __FUNCT__
65c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerAMSOpen"
75c6c1daeSBarry Smith /*@C
85c6c1daeSBarry Smith     PetscViewerAMSOpen - Opens an AMS memory snooper PetscViewer.
95c6c1daeSBarry Smith 
105c6c1daeSBarry Smith     Collective on MPI_Comm
115c6c1daeSBarry Smith 
125c6c1daeSBarry Smith     Input Parameters:
13*ec957eceSBarry Smith .   comm - the MPI communicator
145c6c1daeSBarry Smith 
155c6c1daeSBarry Smith     Output Parameter:
165c6c1daeSBarry Smith .   lab - the PetscViewer
175c6c1daeSBarry Smith 
185c6c1daeSBarry Smith     Options Database Keys:
195c6c1daeSBarry Smith +   -ams_port <port number> - port number where you are running AMS client
20f05ece33SBarry Smith .   -xxx_view ams - publish the object xxx
21*ec957eceSBarry Smith -   -xxx_ams_block - blocks the program at the end of a critical point (for KSP and SNES it is the end of a solve) until
22f05ece33SBarry Smith                     the user unblocks the the problem with an external tool that access the object with the AMS
235c6c1daeSBarry Smith 
245c6c1daeSBarry Smith     Level: advanced
255c6c1daeSBarry Smith 
265c6c1daeSBarry Smith     Fortran Note:
275c6c1daeSBarry Smith     This routine is not supported in Fortran.
285c6c1daeSBarry Smith 
295c6c1daeSBarry Smith 
305c6c1daeSBarry Smith     Notes:
31f05ece33SBarry Smith     Unlike other viewers that only access the object being viewed on the call to XXXView(object,viewer) the AMS viewer allows
32f05ece33SBarry Smith     one to view the object asynchronously as the program continues to run. One can remove AMS access to the object with a call to
33f05ece33SBarry Smith     PetscObjectAMSViewOff().
3438dc1537SBarry Smith 
355c6c1daeSBarry Smith     Information about the AMS is available via http://www.mcs.anl.gov/ams.
365c6c1daeSBarry Smith 
375c6c1daeSBarry Smith    Concepts: AMS
38f05ece33SBarry Smith    Concepts: Argonne Memory Snooper
395c6c1daeSBarry Smith    Concepts: Asynchronous Memory Snooper
405c6c1daeSBarry Smith 
41f05ece33SBarry Smith .seealso: PetscViewerDestroy(), PetscViewerStringSPrintf(), PETSC_VIEWER_AMS_(), PetscObjectAMSBlock(),
42f05ece33SBarry Smith           PetscObjectAMSViewOff(), PetscObjectAMSTakeAccess(), PetscObjectAMSGrantAccess()
435c6c1daeSBarry Smith 
445c6c1daeSBarry Smith @*/
45*ec957eceSBarry Smith PetscErrorCode PetscViewerAMSOpen(MPI_Comm comm,PetscViewer *lab)
465c6c1daeSBarry Smith {
475c6c1daeSBarry Smith   PetscErrorCode ierr;
485c6c1daeSBarry Smith 
495c6c1daeSBarry Smith   PetscFunctionBegin;
505c6c1daeSBarry Smith   ierr = PetscViewerCreate(comm,lab);CHKERRQ(ierr);
515c6c1daeSBarry Smith   ierr = PetscViewerSetType(*lab,PETSCVIEWERAMS);CHKERRQ(ierr);
525c6c1daeSBarry Smith   PetscFunctionReturn(0);
535c6c1daeSBarry Smith }
54bfb97211SBarry Smith 
55bfb97211SBarry Smith #undef __FUNCT__
56bfb97211SBarry Smith #define __FUNCT__ "PetscObjectViewAMS"
57bfb97211SBarry Smith /*@C
58bfb97211SBarry Smith    PetscObjectViewAMS - View the base portion of any object with an AMS viewer
59bfb97211SBarry Smith 
60bfb97211SBarry Smith    Collective on PetscObject
61bfb97211SBarry Smith 
62bfb97211SBarry Smith    Input Parameters:
63bfb97211SBarry Smith +  obj - the Petsc variable
64bfb97211SBarry Smith          Thus must be cast with a (PetscObject), for example,
65bfb97211SBarry Smith          PetscObjectSetName((PetscObject)mat,name);
66bfb97211SBarry Smith -  viewer - the AMS viewer
67bfb97211SBarry Smith 
68bfb97211SBarry Smith    Level: advanced
69bfb97211SBarry Smith 
70bfb97211SBarry Smith    Concepts: publishing object
71bfb97211SBarry Smith 
72f05ece33SBarry Smith .seealso: PetscObjectSetName(), PetscObjectAMSViewOff()
73bfb97211SBarry Smith 
74bfb97211SBarry Smith @*/
75bfb97211SBarry Smith PetscErrorCode  PetscObjectViewAMS(PetscObject obj,PetscViewer viewer)
76bfb97211SBarry Smith {
77bfb97211SBarry Smith   PetscErrorCode ierr;
78bfb97211SBarry Smith 
79bfb97211SBarry Smith   PetscFunctionBegin;
80bfb97211SBarry Smith   PetscValidHeader(obj,1);
81bfb97211SBarry Smith   if (obj->classid == PETSC_VIEWER_CLASSID) PetscFunctionReturn(0);
82*ec957eceSBarry Smith   if (obj->amsmem) PetscFunctionReturn(0);
83bfb97211SBarry Smith   ierr = PetscObjectName(obj);CHKERRQ(ierr);
84bfb97211SBarry Smith 
85*ec957eceSBarry Smith   PetscStackCallAMS(AMS_Memory_Create,(obj->name,&obj->amsmem));
86*ec957eceSBarry Smith   PetscStackCallAMS(AMS_New_Field,(obj->amsmem,"Class",&obj->class_name,1,AMS_READ,AMS_STRING));
87*ec957eceSBarry Smith   PetscStackCallAMS(AMS_New_Field,(obj->amsmem,"Type",&obj->type_name,1,AMS_READ,AMS_STRING));
88*ec957eceSBarry Smith   PetscStackCallAMS(AMS_New_Field,(obj->amsmem,"Id",&obj->id,1,AMS_READ,AMS_INT));
89*ec957eceSBarry Smith   PetscStackCallAMS(AMS_New_Field,(obj->amsmem,"ParentId",&obj->parentid,1,AMS_READ,AMS_INT));
90*ec957eceSBarry Smith   PetscStackCallAMS(AMS_New_Field,(obj->amsmem,"Name",&obj->name,1,AMS_READ,AMS_STRING));
91*ec957eceSBarry Smith   PetscStackCallAMS(AMS_New_Field,(obj->amsmem,"Publish Block",&obj->amspublishblock,1,AMS_READ,AMS_BOOLEAN));
92*ec957eceSBarry Smith   PetscStackCallAMS(AMS_New_Field,(obj->amsmem,"Block",&obj->amsblock,1,AMS_WRITE,AMS_BOOLEAN));
93bfb97211SBarry Smith   PetscFunctionReturn(0);
94bfb97211SBarry Smith }
95