When Real spaces are used in a form and setting threads to larger than 1 the assemble does not return a correct value.
The following test scripts illustrates the problem:
##############################
from dolfin import *
mesh = UnitCube(10, 10, 10)
V=FunctionSpace(mesh, "CG", 1)*FunctionSpace(mesh, "R", 0)
v0, v1=TestFunctions(V)
formR = (v0+v1)*dx
form = v0*dx
num_threads = 2
parameters.num_threads = num_threads
print "norm with R: %.8f, should be same as"%(assemble(formR).norm("l2"))
parameters.num_threads = 0
print "norm with R no threads: %.8f"%(assemble(formR).norm("l2"))
parameters.num_threads = num_threads
print "norm without R: %.8f, should be same as"%(assemble(form).norm("l2"))
parameters.num_threads = 0
print "norm without R no threads: %.8f"%(assemble(form).norm("l2"))
This is not surprising as the global dofs are not "protected" by the colored mesh, as they are present on each cell... I guess we need to assemble the global dofs independently on each thread, and then add them in a thread safe manner at the end of the assemble.
While complicating the assemble of global dofs it might speed up the insertion of the dofs for the PETsc backend :)