1 #include "../../interface/cupmdevice.hpp" 2 #include <algorithm> 3 #include <csetjmp> // for cuda mpi awareness 4 #include <csignal> // SIGSEGV 5 #include <iterator> 6 #include <type_traits> 7 8 #if PetscDefined(USE_LOG) 9 PETSC_INTERN PetscErrorCode PetscLogInitialize(void); 10 #else 11 #define PetscLogInitialize() 0 12 #endif 13 14 namespace Petsc 15 { 16 17 namespace Device 18 { 19 20 namespace CUPM 21 { 22 23 // internal "impls" class for CUPMDevice. Each instance represents a single cupm device 24 template <DeviceType T> 25 class Device<T>::DeviceInternal 26 { 27 const int id_; 28 bool devInitialized_ = false; 29 cupmDeviceProp_t dprop_; // cudaDeviceProp appears to be an actual struct, i.e. you can't 30 // initialize it with nullptr or NULL (i've tried) 31 32 PETSC_CXX_COMPAT_DECL(bool CUPMAwareMPI_()); 33 34 public: 35 // default constructor 36 explicit constexpr DeviceInternal(int dev) noexcept : id_(dev) { } 37 38 // gather all relevant information for a particular device, a cupmDeviceProp_t is 39 // usually sufficient here 40 PETSC_NODISCARD PetscErrorCode initialize() noexcept; 41 PETSC_NODISCARD PetscErrorCode configure() noexcept; 42 PETSC_NODISCARD PetscErrorCode view(PetscViewer) const noexcept; 43 PETSC_NODISCARD PetscErrorCode finalize() noexcept; 44 45 PETSC_NODISCARD auto id() const -> decltype(id_) { return id_; } 46 PETSC_NODISCARD auto initialized() const -> decltype(devInitialized_) { return devInitialized_; } 47 PETSC_NODISCARD auto prop() const -> const decltype(dprop_)& { return dprop_; } 48 49 // factory 50 PETSC_CXX_COMPAT_DECL(std::unique_ptr<DeviceInternal> makeDevice(int i)) 51 { 52 return std::unique_ptr<DeviceInternal>(new DeviceInternal(i)); 53 } 54 }; 55 56 // the goal here is simply to get the cupm backend to create its context, not to do any type of 57 // modification of it, or create objects (since these may be affected by subsequent 58 // configuration changes) 59 template <DeviceType T> 60 PetscErrorCode Device<T>::DeviceInternal::initialize() noexcept 61 { 62 cupmError_t cerr; 63 64 PetscFunctionBegin; 65 if (devInitialized_) PetscFunctionReturn(0); 66 devInitialized_ = true; 67 // need to do this BEFORE device has been set, although if the user 68 // has already done this then we just ignore it 69 if (cupmSetDeviceFlags(cupmDeviceMapHost) == cupmErrorSetOnActiveProcess) { 70 // reset the error if it was cupmErrorSetOnActiveProcess 71 const auto PETSC_UNUSED unused = cupmGetLastError(); 72 } else {CHKERRCUPM(cupmGetLastError());} 73 // cuda 5.0+ will create a context when cupmSetDevice is called 74 if (cupmSetDevice(id_) != cupmErrorDeviceAlreadyInUse) CHKERRCUPM(cupmGetLastError()); 75 // forces cuda < 5.0 to initialize a context 76 cerr = cupmFree(nullptr);CHKERRCUPM(cerr); 77 // where is this variable defined and when is it set? who knows! but it is defined and set 78 // at this point. either way, each device must make this check since I guess MPI might not be 79 // aware of all of them? 80 if (use_gpu_aware_mpi) { 81 // For OpenMPI, we could do a compile time check with 82 // "defined(PETSC_HAVE_OMPI_MAJOR_VERSION) && defined(MPIX_CUDA_AWARE_SUPPORT) && 83 // MPIX_CUDA_AWARE_SUPPORT" to see if it is CUDA-aware. However, recent versions of IBM 84 // Spectrum MPI (e.g., 10.3.1) on Summit meet above conditions, but one has to use jsrun 85 // --smpiargs=-gpu to really enable GPU-aware MPI. So we do the check at runtime with a 86 // code that works only with GPU-aware MPI. 87 if (PetscUnlikely(!CUPMAwareMPI_())) { 88 (*PetscErrorPrintf)("PETSc is configured with GPU support, but your MPI is not GPU-aware. For better performance, please use a GPU-aware MPI.\n"); 89 (*PetscErrorPrintf)("If you do not care, add option -use_gpu_aware_mpi 0. To not see the message again, add the option to your .petscrc, OR add it to the env var PETSC_OPTIONS.\n"); 90 (*PetscErrorPrintf)("If you do care, for IBM Spectrum MPI on OLCF Summit, you may need jsrun --smpiargs=-gpu.\n"); 91 (*PetscErrorPrintf)("For OpenMPI, you need to configure it --with-cuda (https://www.open-mpi.org/faq/?category=buildcuda)\n"); 92 (*PetscErrorPrintf)("For MVAPICH2-GDR, you need to set MV2_USE_CUDA=1 (http://mvapich.cse.ohio-state.edu/userguide/gdr/)\n"); 93 (*PetscErrorPrintf)("For Cray-MPICH, you need to set MPICH_RDMA_ENABLED_CUDA=1 (https://www.olcf.ornl.gov/tutorials/gpudirect-mpich-enabled-cuda/)\n"); 94 PETSCABORT(PETSC_COMM_SELF,PETSC_ERR_LIB); 95 } 96 } 97 PetscFunctionReturn(0); 98 } 99 100 template <DeviceType T> 101 PetscErrorCode Device<T>::DeviceInternal::configure() noexcept 102 { 103 cupmError_t cerr; 104 PetscErrorCode ierr; 105 106 PetscFunctionBegin; 107 PetscAssertFalse(!devInitialized_,PETSC_COMM_SELF,PETSC_ERR_COR,"Device %d being configured before it was initialized",id_); 108 // why on EARTH nvidia insists on making otherwise informational states into 109 // fully-fledged error codes is beyond me. Why couldn't a pointer to bool argument have 110 // sufficed?!?!?! 111 if (cupmSetDevice(id_) != cupmErrorDeviceAlreadyInUse) CHKERRCUPM(cupmGetLastError()); 112 // need to update the device properties 113 cerr = cupmGetDeviceProperties(&dprop_,id_);CHKERRCUPM(cerr); 114 ierr = PetscInfo(nullptr,"Configured device %d\n",id_);CHKERRQ(ierr); 115 PetscFunctionReturn(0); 116 } 117 118 template <DeviceType T> 119 PetscErrorCode Device<T>::DeviceInternal::view(PetscViewer viewer) const noexcept 120 { 121 PetscBool iascii; 122 PetscErrorCode ierr; 123 124 PetscFunctionBegin; 125 PetscAssertFalse(!devInitialized_,PETSC_COMM_SELF,PETSC_ERR_COR,"Device %d being viewed before it was initialized or configured",id_); 126 ierr = PetscObjectTypeCompare(PetscObjectCast(viewer),PETSCVIEWERASCII,&iascii);CHKERRQ(ierr); 127 if (iascii) { 128 MPI_Comm comm; 129 PetscMPIInt rank; 130 PetscViewer sviewer; 131 132 ierr = PetscObjectGetComm(PetscObjectCast(viewer),&comm);CHKERRQ(ierr); 133 ierr = MPI_Comm_rank(comm,&rank);CHKERRMPI(ierr); 134 ierr = PetscViewerGetSubViewer(viewer,PETSC_COMM_SELF,&sviewer);CHKERRQ(ierr); 135 ierr = PetscViewerASCIIPrintf(sviewer,"[%d] device %d: %s\n",rank,id_,dprop_.name);CHKERRQ(ierr); 136 ierr = PetscViewerASCIIPushTab(sviewer);CHKERRQ(ierr); 137 ierr = PetscViewerASCIIPrintf(sviewer,"Compute capability: %d.%d\n",dprop_.major,dprop_.minor);CHKERRQ(ierr); 138 ierr = PetscViewerASCIIPrintf(sviewer,"Multiprocessor Count: %d\n",dprop_.multiProcessorCount);CHKERRQ(ierr); 139 ierr = PetscViewerASCIIPrintf(sviewer,"Maximum Grid Dimensions: %d x %d x %d\n",dprop_.maxGridSize[0],dprop_.maxGridSize[1],dprop_.maxGridSize[2]);CHKERRQ(ierr); 140 ierr = PetscViewerASCIIPrintf(sviewer,"Maximum Block Dimensions: %d x %d x %d\n",dprop_.maxThreadsDim[0],dprop_.maxThreadsDim[1],dprop_.maxThreadsDim[2]);CHKERRQ(ierr); 141 ierr = PetscViewerASCIIPrintf(sviewer,"Maximum Threads Per Block: %d\n",dprop_.maxThreadsPerBlock);CHKERRQ(ierr); 142 ierr = PetscViewerASCIIPrintf(sviewer,"Warp Size: %d\n",dprop_.warpSize);CHKERRQ(ierr); 143 ierr = PetscViewerASCIIPrintf(sviewer,"Total Global Memory (bytes): %zu\n",dprop_.totalGlobalMem);CHKERRQ(ierr); 144 ierr = PetscViewerASCIIPrintf(sviewer,"Total Constant Memory (bytes): %zu\n",dprop_.totalConstMem);CHKERRQ(ierr); 145 ierr = PetscViewerASCIIPrintf(sviewer,"Shared Memory Per Block (bytes): %zu\n",dprop_.sharedMemPerBlock);CHKERRQ(ierr); 146 ierr = PetscViewerASCIIPrintf(sviewer,"Multiprocessor Clock Rate (KHz): %d\n",dprop_.clockRate);CHKERRQ(ierr); 147 ierr = PetscViewerASCIIPrintf(sviewer,"Memory Clock Rate (KHz): %d\n",dprop_.memoryClockRate);CHKERRQ(ierr); 148 ierr = PetscViewerASCIIPrintf(sviewer,"Memory Bus Width (bits): %d\n",dprop_.memoryBusWidth);CHKERRQ(ierr); 149 ierr = PetscViewerASCIIPrintf(sviewer,"Peak Memory Bandwidth (GB/s): %f\n",2.0*dprop_.memoryClockRate*(dprop_.memoryBusWidth/8)/1.0e6);CHKERRQ(ierr); 150 ierr = PetscViewerASCIIPrintf(sviewer,"Can map host memory: %s\n",dprop_.canMapHostMemory ? "PETSC_TRUE" : "PETSC_FALSE");CHKERRQ(ierr); 151 ierr = PetscViewerASCIIPrintf(sviewer,"Can execute multiple kernels concurrently: %s\n",dprop_.concurrentKernels ? "PETSC_TRUE" : "PETSC_FALSE");CHKERRQ(ierr); 152 ierr = PetscViewerASCIIPopTab(sviewer);CHKERRQ(ierr); 153 ierr = PetscViewerFlush(sviewer);CHKERRQ(ierr); 154 ierr = PetscViewerRestoreSubViewer(viewer,PETSC_COMM_SELF,&sviewer);CHKERRQ(ierr); 155 ierr = PetscViewerFlush(viewer);CHKERRQ(ierr); 156 } 157 PetscFunctionReturn(0); 158 } 159 160 static std::jmp_buf cupmMPIAwareJumpBuffer; 161 static bool cupmMPIAwareJumpBufferSet; 162 163 // godspeed to anyone that attempts to call this function 164 void SilenceVariableIsNotNeededAndWillNotBeEmittedWarning_ThisFunctionShouldNeverBeCalled() 165 { 166 PETSCABORT(MPI_COMM_NULL,INT_MAX); 167 if (cupmMPIAwareJumpBufferSet) (void)cupmMPIAwareJumpBuffer; 168 } 169 170 #define CHKCUPMAWARE(expr) if (PetscUnlikely((expr) != cupmSuccess)) return false; 171 172 template <DeviceType T> 173 PETSC_CXX_COMPAT_DEFN(bool Device<T>::DeviceInternal::CUPMAwareMPI_()) 174 { 175 constexpr int bufSize = 2; 176 constexpr int hbuf[bufSize] = {1,0}; 177 int *dbuf = nullptr; 178 constexpr auto bytes = bufSize*sizeof(*dbuf); 179 auto awareness = false; 180 cupmError_t cerr; 181 PetscErrorCode ierr; 182 const auto cupmSignalHandler = [](int signal, void *ptr) -> PetscErrorCode { 183 if ((signal == SIGSEGV) && cupmMPIAwareJumpBufferSet) std::longjmp(cupmMPIAwareJumpBuffer,1); 184 return PetscSignalHandlerDefault(signal,ptr); 185 }; 186 187 PetscFunctionBegin; 188 cerr = cupmMalloc(reinterpret_cast<void**>(&dbuf),bytes);CHKCUPMAWARE(cerr); 189 cerr = cupmMemcpy(dbuf,hbuf,bytes,cupmMemcpyHostToDevice);CHKCUPMAWARE(cerr); 190 ierr = PetscPushSignalHandler(cupmSignalHandler,nullptr);CHKERRABORT(PETSC_COMM_SELF,ierr); 191 cupmMPIAwareJumpBufferSet = true; 192 if (setjmp(cupmMPIAwareJumpBuffer)) { 193 // if a segv was triggered in the MPI_Allreduce below, it is very likely due to MPI not 194 // being GPU-aware 195 awareness = false; 196 // control flow up until this point: 197 // 1. CUPMDevice<T>::CUPMDeviceInternal::MPICUPMAware__() 198 // 2. MPI_Allreduce 199 // 3. SIGSEGV 200 // 4. PetscSignalHandler_Private 201 // 5. cupmSignalHandler (lambda function) 202 // 6. here 203 // PetscSignalHandler_Private starts with PetscFunctionBegin and is pushed onto the stack 204 // so we must undo this. This would be most naturally done in cupmSignalHandler, however 205 // the C/C++ standard dictates: 206 // 207 // After invoking longjmp(), non-volatile-qualified local objects should not be accessed if 208 // their values could have changed since the invocation of setjmp(). Their value in this 209 // case is considered indeterminate, and accessing them is undefined behavior. 210 // 211 // so for safety (since we don't know what PetscStackPop may try to read/declare) we do it 212 // outside of the longjmp control flow 213 PetscStackPop; 214 } else if (!MPI_Allreduce(dbuf,dbuf+1,1,MPI_INT,MPI_SUM,PETSC_COMM_SELF)) awareness = true; 215 cupmMPIAwareJumpBufferSet = false; 216 ierr = PetscPopSignalHandler();CHKERRABORT(PETSC_COMM_SELF,ierr); 217 cerr = cupmFree(dbuf);CHKCUPMAWARE(cerr); 218 PetscFunctionReturn(awareness); 219 } 220 221 template <DeviceType T> 222 PetscErrorCode Device<T>::DeviceInternal::finalize() noexcept 223 { 224 PetscFunctionBegin; 225 devInitialized_ = false; 226 PetscFunctionReturn(0); 227 } 228 229 template <DeviceType T> 230 PetscErrorCode Device<T>::finalize_() noexcept 231 { 232 PetscFunctionBegin; 233 if (!initialized_) PetscFunctionReturn(0); 234 for (auto&& device : devices_) { 235 if (device) { 236 const auto ierr = device->finalize();CHKERRQ(ierr); 237 device.reset(); 238 } 239 } 240 defaultDevice_ = PETSC_CUPM_DEVICE_NONE; // disabled by default 241 initialized_ = false; 242 PetscFunctionReturn(0); 243 } 244 245 // these functions should be named identically to the option they produce where "CUPMTYPE" and 246 // "cupmtype" are the uppercase and lowercase string versions of the cupm backend respectively 247 template <DeviceType T> 248 PETSC_CXX_COMPAT_DECL(PETSC_CONSTEXPR_14 const char* PetscDevice_CUPMTYPE_Options()) 249 { 250 switch (T) { 251 case DeviceType::CUDA: return "PetscDevice CUDA Options"; 252 case DeviceType::HIP: return "PetscDevice HIP Options"; 253 } 254 } 255 256 template <DeviceType T> 257 PETSC_CXX_COMPAT_DECL(PETSC_CONSTEXPR_14 const char* device_enable_cupmtype()) 258 { 259 switch (T) { 260 case DeviceType::CUDA: return "-device_enable_cuda"; 261 case DeviceType::HIP: return "-device_enable_hip"; 262 } 263 } 264 265 template <DeviceType T> 266 PETSC_CXX_COMPAT_DECL(PETSC_CONSTEXPR_14 const char* device_select_cupmtype()) 267 { 268 switch (T) { 269 case DeviceType::CUDA: return "-device_select_cuda"; 270 case DeviceType::HIP: return "-device_select_hip"; 271 } 272 } 273 274 template <DeviceType T> 275 PETSC_CXX_COMPAT_DECL(PETSC_CONSTEXPR_14 const char* device_view_cupmtype()) 276 { 277 switch (T) { 278 case DeviceType::CUDA: return "-device_view_cuda"; 279 case DeviceType::HIP: return "-device_view_hip"; 280 } 281 } 282 283 template <DeviceType T> 284 PetscErrorCode Device<T>::initialize(MPI_Comm comm, PetscInt *defaultDeviceId, PetscDeviceInitType *defaultInitType) noexcept 285 { 286 PetscInt initTypeCUPM = *defaultInitType,id = *defaultDeviceId; 287 PetscBool view = PETSC_FALSE,flg; 288 int ndev; 289 cupmError_t cerr; 290 PetscErrorCode ierr; 291 292 PetscFunctionBegin; 293 if (initialized_) PetscFunctionReturn(0); 294 initialized_ = true; 295 ierr = PetscRegisterFinalize(finalize_);CHKERRQ(ierr); 296 297 { 298 // the functions to populate the command line strings are named after the string they return 299 ierr = PetscOptionsBegin(comm,nullptr,PetscDevice_CUPMTYPE_Options<T>(),"Sys");CHKERRQ(ierr); 300 ierr = PetscOptionsEList(device_enable_cupmtype<T>(),"How (or whether) to initialize a device","CUPMDevice<CUPMDeviceType>::initialize()",PetscDeviceInitTypes,3,PetscDeviceInitTypes[initTypeCUPM],&initTypeCUPM,nullptr);CHKERRQ(ierr); 301 ierr = PetscOptionsRangeInt(device_select_cupmtype<T>(),"Which device to use. Pass " PetscStringize(PETSC_DECIDE) " to have PETSc decide or (given they exist) [0-NUM_DEVICE) for a specific device","PetscDeviceCreate",id,&id,nullptr,PETSC_DECIDE,std::numeric_limits<decltype(defaultDevice_)>::max());CHKERRQ(ierr); 302 ierr = PetscOptionsBool(device_view_cupmtype<T>(),"Display device information and assignments (forces eager initialization)",nullptr,view,&view,&flg);CHKERRQ(ierr); 303 ierr = PetscOptionsEnd();CHKERRQ(ierr); 304 } 305 306 cerr = cupmGetDeviceCount(&ndev); 307 // post-process the options and lay the groundwork for initialization if needs be 308 if (PetscUnlikely((cerr == cupmErrorStubLibrary) || (cerr == cupmErrorNoDevice))) { 309 if (PetscUnlikely((initTypeCUPM == PETSC_DEVICE_INIT_EAGER) || (view && flg))) { 310 const auto name = cupmGetErrorName(cerr); 311 const auto desc = cupmGetErrorString(cerr); 312 const auto backend = cupmName(); 313 SETERRQ(comm,PETSC_ERR_USER_INPUT,"Cannot eagerly initialize %s, as doing so results in %s error %d (%s) : %s",backend,backend,static_cast<PetscErrorCode>(cerr),name,desc); 314 } 315 id = -cerr; 316 cerr = cupmGetLastError(); // reset error 317 initTypeCUPM = PETSC_DEVICE_INIT_NONE; 318 } else CHKERRCUPM(cerr); 319 320 if (initTypeCUPM == PETSC_DEVICE_INIT_NONE) { 321 if ((id > 0) || (id == PETSC_DECIDE)) id = PETSC_CUPM_DEVICE_NONE; 322 } else { 323 ierr = PetscDeviceCheckDeviceCount_Internal(ndev);CHKERRQ(ierr); 324 if (id == PETSC_DECIDE) { 325 if (ndev) { 326 PetscMPIInt rank; 327 328 ierr = MPI_Comm_rank(comm,&rank);CHKERRMPI(ierr); 329 id = rank % ndev; 330 } else id = 0; 331 } 332 view = static_cast<decltype(view)>(view && flg); 333 if (view) initTypeCUPM = PETSC_DEVICE_INIT_EAGER; 334 } 335 336 static_assert(std::is_same<PetscMPIInt,decltype(defaultDevice_)>::value,""); 337 // id is PetscInt, _defaultDevice is int 338 ierr = PetscMPIIntCast(id,&defaultDevice_);CHKERRQ(ierr); 339 if (initTypeCUPM == PETSC_DEVICE_INIT_EAGER) { 340 devices_[defaultDevice_] = DeviceInternal::makeDevice(defaultDevice_); 341 ierr = devices_[defaultDevice_]->initialize();CHKERRQ(ierr); 342 ierr = devices_[defaultDevice_]->configure();CHKERRQ(ierr); 343 if (view) { 344 PetscViewer vwr; 345 346 ierr = PetscLogInitialize();CHKERRQ(ierr); 347 ierr = PetscViewerASCIIGetStdout(comm,&vwr);CHKERRQ(ierr); 348 ierr = devices_[defaultDevice_]->view(vwr);CHKERRQ(ierr); 349 } 350 } 351 352 // record the results of the initialization 353 *defaultInitType = static_cast<PetscDeviceInitType>(initTypeCUPM); 354 *defaultDeviceId = id; 355 PetscFunctionReturn(0); 356 } 357 358 template <DeviceType T> 359 PetscErrorCode Device<T>::getDevice(PetscDevice device, PetscInt id) const noexcept 360 { 361 PetscErrorCode ierr; 362 363 PetscFunctionBegin; 364 if (PetscUnlikelyDebug(defaultDevice_ < 0)) { 365 PetscCheckFalse(defaultDevice_ == PETSC_CUPM_DEVICE_NONE,PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Trying to retrieve a %s PetscDevice when it has been disabled",cupmName()); 366 const auto cerr = static_cast<cupmError_t>(-defaultDevice_); 367 368 SETERRQ(PETSC_COMM_SELF,PETSC_ERR_GPU,"Cannot lazily initialize PetscDevice: %s error %d (%s) : %s",cupmName(),static_cast<PetscErrorCode>(cerr),cupmGetErrorName(cerr),cupmGetErrorString(cerr)); 369 } 370 if (id == PETSC_DECIDE) id = defaultDevice_; 371 PetscAssert(static_cast<std::size_t>(id) < devices_.size(),PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Only supports %zu number of devices but trying to get device with id %" PetscInt_FMT,devices_.size(),id); 372 if (devices_[id]) { 373 PetscAssert(id == devices_[id]->id(),PETSC_COMM_SELF,PETSC_ERR_PLIB,"Entry %" PetscInt_FMT " contains device with mismatching id %d",id,devices_[id]->id()); 374 } else devices_[id] = DeviceInternal::makeDevice(id); 375 ierr = devices_[id]->initialize();CHKERRQ(ierr); 376 device->deviceId = devices_[id]->id(); // technically id = _devices[id]->_id here 377 device->ops->createcontext = create_; 378 device->ops->configure = this->configureDevice; 379 device->ops->view = this->viewDevice; 380 PetscFunctionReturn(0); 381 } 382 383 template <DeviceType T> 384 PetscErrorCode Device<T>::configureDevice(PetscDevice device) noexcept 385 { 386 PetscErrorCode ierr; 387 388 PetscFunctionBegin; 389 ierr = devices_[device->deviceId]->configure();CHKERRQ(ierr); 390 PetscFunctionReturn(0); 391 } 392 393 template <DeviceType T> 394 PetscErrorCode Device<T>::viewDevice(PetscDevice device, PetscViewer viewer) noexcept 395 { 396 PetscErrorCode ierr; 397 398 PetscFunctionBegin; 399 // now this __shouldn't__ reconfigure the device, but there is a petscinfo call to indicate 400 // it is being reconfigured 401 ierr = devices_[device->deviceId]->configure();CHKERRQ(ierr); 402 ierr = devices_[device->deviceId]->view(viewer);CHKERRQ(ierr); 403 PetscFunctionReturn(0); 404 } 405 406 // explicitly instantiate the classes 407 #if PetscDefined(HAVE_CUDA) 408 template class Device<DeviceType::CUDA>; 409 #endif 410 #if PetscDefined(HAVE_HIP) 411 template class Device<DeviceType::HIP>; 412 #endif 413 414 } // namespace CUPM 415 416 } // namespace Device 417 418 } // namespace Petsc 419