Comments (3)
Yes, I think you have the right idea.
One thing to keep in mind is to avoid doing Memory
operations in the OMP parallel regions that force the host pointer to be registered with the memory-manager -- basically the registration is most probably not thread-safe. For example, if you create a Vector
and make it reference another Vector
with Vector::MakeRef
then this will call Memory::MakeAlias
which will call the method to register the "base" pointer with the memory manager (in cases like yours when the globally-set "device" memory type is actual device memory type like cuda or hip). I'm not 100% sure that this will absolutely cause a problem but it might.
One feature that should help is that all device allocations are lazy -- the actual device memory allocation does not happen before you actually request the device pointer with a call like Vector::Read
or Vector::ReadWrite
.
from mfem.
Yes, we have not really considered thread safety in the Memory
and MemoryManager
classes -- basically allocations are never done inside mfem::forall*
calls, so none of the MFEM backends need it.
I guess you have a coarser grain parallelism via OpenMP on CPU in mind to need thread safety. Since this is just on CPU, isn't the standard host allocator (memory type HOST
) sufficient? That should work fine in threaded environment as you pointed out. If you need to have a build where this mode of execution is supported along with other modes like cuda
with Umpire allocators -- that should be possible -- you can configure the memory manager with what memory types to use at the beginning of the program.
from mfem.
That's exactly right about the use case I have in mind. I can be assured that I won't ever call Memory::Read
or Write
inside a parallel region with the device memory class, but I do want to be able to call it with the host class in some coarse-grained cases. One use case is to be able to call FiniteElementSpace::GetElementDofs
or Mesh::GetElementTransformation
inside an OpenMP parallel region, used to set up a data structure which will eventually (outside of the OpenMP loop) be used on the GPU.
This is helpful suggestion, yes I think HOST
is always sufficient for the host. Would the correct way to achieve this be to call, before configuring the Device
, Device::SetMemoryTypes(MemoryType::HOST, device_mem_type)
(where device_mem_type
could be any memory type, including DEVICE
, MANAGED
, DEVICE_DEBUG
, etc.)? This should work, as long as I don't have ":uvm"
in my device string or set Backend::DEBUG_DEVICE
, which would cause Device::UpdateMemoryTypeAndClass
to override my setting of the host_mem_type
to something not thread safe.
Do I have the right idea? Thanks a lot for your help!
from mfem.
Related Issues (20)
- Element integral HOT 3
- Best approach to implement electrostatic solver with divergence-free current density HOT 1
- Regarding implementation of Dirichlet conditions in Example 1 HOT 2
- Create `ParMesh` in cascading way HOT 2
- Applying Dirichlet DG Boundary condition to scalar in L2-space HOT 4
- Convert an RT space GridFunction to an ND space GridFunction HOT 2
- How to convert mfem:BlockVector to HypreParVector ?
- Some quesitons about the ImplicitSolve() from ex9p HOT 4
- Accelerate the assemble of ParLinearform
- On the use of GPUs for time dependent Non Linear problem HOT 1
- Problem with HypreBoomerAMG
- Memory leak with Memory move assignment operator? HOT 4
- Does ex18/ex18p: DG Euler Equations support 3D case? HOT 2
- Cuda-enabled Hypre singleton finalized after CUDA driver is shutting down
- 【bug】A bug with respect to the DG_FECollection HOT 1
- About building a NC mesh HOT 1
- Advice for Computing a Nullspace Projection in Parallel? HOT 1
- Feature: Support MatrixCoefficient in DGDiffusion with PA
- about NC meshing: "MFEM NC mesh v1.0", 3 questions
- How's the data assembled for DiffusionIntegrator's partial assembly in PADiffusionSetup2D<3> HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mfem.