Hello,

Karl Rupp <r...@iue.tuwien.ac.at> writes:
> This is a matter of explicit vs. implicit. Assume the following
> (pseudo-)code:
>
>  viennacl::context ctx1(...);
>  viennacl::context ctx2(...);
>
>  viennacl::vector<T> x(10, ctx1);
>  viennacl::vector<T> y(10, ctx2);
>  viennacl::vector<T> z(10, ctx2);
>
> At this point the user *explicitly* created the vectors in the two
> different contexts. Now let's continue with the current behavior:
>
>  y += z; // okay
>  x = y;  // error, not in same context
>  y += z; // still okay
>
> In order to make 'x = y;' a valid expression, the user would have to
> explicitly migrate y to ctx1. Now let's look at the same code with an
> implicit transfer:
>
>  y += z; // okay
>  x = y;  // y implicitly migrated to ctx1
>  y += z; // y in ctx1 -> z also migrated to ctx1
>
> in the end, all three vectors end up in ctx1, even though the user
> explicitly created them in two different contexts. Surprising?

Yes, surprising! Why do we want to support these implicit transfers? I'm
only talking about operations where all the operands are on the same
context. I agree that other cases are harder, but I'm not intending to
support that sort of thing yet. And even if ViennaCL didn't want to
support implicit transfers and I did, I could just do it in Python ;)

> The primary reason why an explicit switch_context() is currently in
> place is that I haven't thought through all such possible obstacles
> and how do handle these in the least error-prone way, hence used this
> conservative approach.

So just don't handle these implicit transfers?

> On the other hand, I agree that it is often
> convenient to just implicitly transfer data between contexts. 

Perhaps, but this is not what I'm desiring here!

> What we
> can use in the future is to allow implicit context switches, yet
> provide a debug facility which triggers warnings if a context is
> switched implicitly. This could be a preprocessor define, or (more
> flexible) a member variable which prints to an ostream, or even a
> callback function.

This would work, too. But all I'm advocating right now is saying, we'll
infer the 'current_context' from the operands and assume it's the same
for all the operands.


Night night,

Toby


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
ViennaCL-devel mailing list
ViennaCL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to