Comments (9)
The branch with the suggested fix is called "issue14".
from firedrake.
You probably want to implement the copy using fnew.assign(f). This will
cause the copy to be implemented in a PyOP2 kernel with the effect that, in
the GPU case, you avoid a spurious copy back to host.
from firedrake.
I don't think that's correct. By just grabbing dat.val and using it as val,
you'll get two Functions which point to the same data space. I think you
want to create the new dat without Val and do the copy after.
from firedrake.
Good point.
I extended the test case to check that indeed a deep copy is created:
from firedrake import *
mesh = UnitIntervalMesh(2)
V = FunctionSpace(mesh, "CG", 1)
f = Function(V)
f.interpolate(Expression("1"))
assert (f.dat.vec.array == [1, 1, 1]).all() # Passes
g = Function(f)
print g.dat.vec.array
assert (g.dat.vec.array == [1, 1, 1]).all() # Fails
# Check that g is indeed a deep copy
f.dat.vec[:] = np.array([2, 2, 2])
assert (f.dat.vec.array == [2, 2, 2]).all()
assert (g.dat.vec.array == [1, 1, 1]).all()
Will work on a fix.
from firedrake.
FWIW, you should look at data in dats with:
f.dat.data_ro
The vec
property is the petsc vector which won't play nicely with GPU implementations at the moment (CUDA doesn't currently use petsc).
Oh, and if you're going to write to things use f.dat.data
.
So I'd write the test like:
m = UnitIntervalMesh(2)
V = FunctionSpace(m, 'CG', 1)
f = Function(V)
f.interpolate(Expression("1"))
assert (f.dat.data_ro == 1.0).all()
g = Function(f)
assert (g.dat.data_ro == 1.0).all()
g.interpolate(Expression("2"))
assert (g.dat.data_ro == 2.0).all()
assert (f.dat.data_ro == 1.0).all()
from firedrake.
In general, that's true. But in this case you shouldn't directly access the
data at all, but instead employ a par loop to do the copy.
from firedrake.
I meant in terms of the testing part.
from firedrake.
ok, will change that.
from firedrake.
Closed by 3af7d4b
from firedrake.
Related Issues (20)
- Network Inpainting via Optimal Transport HOT 1
- BUG: pyadjiont.ReducedFunctional.__call__ doesn't notice mesh.coordinates changes HOT 6
- Zenodo release HOT 1
- BUG: Arity zero `Action` weights ignored in assembly HOT 2
- BUG: incorrect assembly of constant zero forms HOT 2
- BUG: Performance regression on CI HOT 2
- BUG: LinearEigenproblem/Solver does not work for mixed problems with fieldsplit
- BUG: CellDiameter on extruded meshes no longer works HOT 10
- Install: Problems when installing Firedrake on Mac HOT 1
- INSTALL:Can't install Firedrake on Mac HOT 7
- Fully integrate TinyASM functionality into Firedrake
- Create a Zenodo release for M4R project. HOT 3
- superconvergence HOT 7
- tqdm HOT 1
- When calculating with Firedrake, the calculation is aborted. How do I resolve it? HOT 5
- Spatial Convergence Order of Unsteady Problems HOT 1
- BUG: VTKFile fails in parallel after creating a mesh with mpi.COMM_SELF in a single process HOT 6
- BUG: `-log_view` reports mismatch between objects created and destroyed when running with multiple procs HOT 7
- `utils._new_uid` should be collective over a communicator
- BUG: CheckpointFile mesh saving crash HOT 4
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 firedrake.