-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Using an expression for the input vector currently fails. I didn't dive too far trying to figure out where to intervene to, presumably, lift the expression into a temporary, as it seemed most efficient to get some guidance from @perrydv .
We might decide to punt on this (though I expect it won't be hard to address), in which case we should/can easily error trap this in an informative fashion.
nc <- nClass(
Cpublic = list(
go = nFunction(
fun = function(x = 'numericVector',y='numericVector') {
z <- parallel_reduce('pairmin', x+y, 100)
return(z)
},
returnType = 'numericScalar'
)
)
)
> Cnc <- nCompile(nc)
To-do: Care needed to filter interfaced methods by exportMembers names.
Error: No variable named: +
I'll also note as related that with some machinations one can break parallel_for with expressions for the extent of the looping, such as the following, which fails at C++ compilation. (However, using simply length(x) is fine, so this is an edge case, I think.)
nc <- nClass(
Cpublic = list(
go = nFunction(
fun = function(x = 'numericVector') {
y <- x
two <- 2
parallel_for(i, 1:length(x+y),
{y[i] <- 2 * x[i]},
c("x"), ## copy for each thread
c("y")) ## share across threads
return(y)
},
returnType = 'numericVector'
)
)
)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels