2: #include <petsc-private/viewerimpl.h> /*I "petscsys.h" */
3: #include <petscviewerams.h>
7: /*@C
8: PetscViewerAMSOpen - Opens an AMS memory snooper PetscViewer.
10: Collective on MPI_Comm 12: Input Parameters:
13: + comm - the MPI communicator
14: - name - name of AMS communicator being created if NULL is passed defaults to PETSc
16: Output Parameter:
17: . lab - the PetscViewer 19: Options Database Keys:
20: + -ams_port <port number> - port number where you are running AMS client
21: . -xxx_view ams - publish the object xxx
22: . -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
23: the user unblocks the the problem with an external tool that access the object with the AMS
24: - -ams_java - open JAVA AMS client
26: Level: advanced
28: Fortran Note:
29: This routine is not supported in Fortran.
31: See the matlab/petsc directory in the AMS installation for one example of external
32: tools that can monitor PETSc objects that have been published.
34: Notes:
35: Unlike other viewers that only access the object being viewed on the call to XXXView(object,viewer) the AMS viewer allows
36: one to view the object asynchronously as the program continues to run. One can remove AMS access to the object with a call to
37: PetscObjectAMSViewOff().
39: Information about the AMS is available via http://www.mcs.anl.gov/ams.
41: Concepts: AMS
42: Concepts: Argonne Memory Snooper
43: Concepts: Asynchronous Memory Snooper
45: .seealso: PetscViewerDestroy(), PetscViewerStringSPrintf(), PETSC_VIEWER_AMS_(), PetscObjectAMSBlock(),
46: PetscObjectAMSViewOff(), PetscObjectAMSTakeAccess(), PetscObjectAMSGrantAccess()
48: @*/
49: PetscErrorCodePetscViewerAMSOpen(MPI_Comm comm,const char name[],PetscViewer *lab) 50: {
54: PetscViewerCreate(comm,lab);
55: PetscViewerSetType(*lab,PETSCVIEWERAMS);
56: PetscViewerAMSSetCommName(*lab,name);
57: return(0);
58: }
62: /*@C
63: PetscObjectViewAMS - View the base portion of any object with an AMS viewer
65: Collective on PetscObject 67: Input Parameters:
68: + obj - the Petsc variable
69: Thus must be cast with a (PetscObject), for example,
70: PetscObjectSetName((PetscObject)mat,name);
71: - viewer - the AMS viewer
73: Level: advanced
75: Concepts: publishing object
77: .seealso: PetscObjectSetName(), PetscObjectAMSViewOff()
79: @*/
80: PetscErrorCodePetscObjectViewAMS(PetscObject obj,PetscViewer viewer) 81: {
83: AMS_Memory amem;
84: AMS_Comm acomm;
88: if (obj->classid == PETSC_VIEWER_CLASSID) return(0);
89: if (obj->amsmem != -1) return(0);
90: PetscObjectName(obj);
92: PetscViewerAMSGetAMSComm(viewer,&acomm);
93: PetscStackCallAMS(AMS_Memory_create,(acomm,obj->name,&amem));
94: obj->amsmem = (int)amem;
96: PetscStackCallAMS(AMS_Memory_take_access,(amem));
97: PetscStackCallAMS(AMS_Memory_add_field,(amem,"Class",&obj->class_name,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF));
98: PetscStackCallAMS(AMS_Memory_add_field,(amem,"Type",&obj->type_name,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF));
99: PetscStackCallAMS(AMS_Memory_add_field,(amem,"Id",&obj->id,1,AMS_INT,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF));
100: PetscStackCallAMS(AMS_Memory_add_field,(amem,"ParentId",&obj->parentid,1,AMS_INT,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF));
101: PetscStackCallAMS(AMS_Memory_add_field,(amem,"Name",&obj->name,1,AMS_STRING,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF));
102: PetscStackCallAMS(AMS_Memory_add_field,(amem,"Publish Block",&obj->amspublishblock,1,AMS_BOOLEAN,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF));
103: PetscStackCallAMS(AMS_Memory_add_field,(amem,"Block",&obj->amsblock,1,AMS_BOOLEAN,AMS_WRITE,AMS_COMMON,AMS_REDUCT_UNDEF));
104: PetscStackCallAMS(AMS_Memory_publish,(amem));
105: PetscStackCallAMS(AMS_Memory_grant_access,(amem));
106: return(0);
107: }