OP2/PyOP2 — pull request #69 by wence- (2012-10-01 10:14:05+00:00)
Title: RO accessors on Dat objects

This adds a Dat.data_ro property to Dat objects

This is a promise from the programmer that she will not update the data behind our back. To make things a little harder to do so, we set the numpy flag WRITEABLE to False.

This flag is also set to False when we hit the Dat in a par_loop, to make it a little more difficult to shoot oneself in the foot.

That is the following code now raises a runtime error:

````python

d = op2.Dat(...)
f = d.data
f[0] = 1 # this is fine
op2.par_loop(..., d(...)...)
f[0] = 2 # raises RuntimeError
g = d.data_ro # doesn't set a dirty flag
g[2] = 2 # raises RuntimeError
op2.par_loop(..., d(...), ...) # d doesn't have to be uploaded again
````

Do we want this property on Global objects too?

Nicolas, I don't understand how the opencl backends decides when it needs to reupload data to the device, so this probably doesn't minimise host device transfers in that backend.