Functions that can take and return arrays
-
2012년 2월 12일 일요일 오후 10:59I've got a problem domain on the CPU right now which takes and returns an array of T and U. Both T and U meet the requirements for AMP use, and the function isn't very complex (meets the requirements), and it can be called several thousand or more times on a given run, so it seemed like an ideal candidate for GPU parallelisation. Unfortunately, I can't seem to find any means in AMP which effectively takes, or returns, an array. Any suggestions or is this too much to expect from the GPU?
모든 응답
-
2012년 2월 13일 월요일 오전 1:06
Hi DeadMG
First of all, a host side function (restrict(cpu) function) can take and return concurrency::array. However, please be aware that copy operation for concurrency::array is a deep copy, just like STL containers (e.g. std::vector). It effectively allocate and create a new array and copy the content from the old array. It's very costly. Also any computation performed on the new array will not take effect on old array, as expected. So in most cases, you probably never want to do something like this. So normally, you'd want pass by reference instead of by value.
Since the copy semantics invovles an allocation of new array container, which could not be achieved on GPU. The copy constructor and assignment operator of concurrency::array are intentionally not allowed in restrict(amp). So on GPU (restrict(amp) world), you could never take/return an array.
Thanks,
Weirong
- 답변으로 제안됨 DanielMothMicrosoft Employee, Owner 2012년 2월 15일 수요일 오전 2:42
- 답변으로 표시됨 DanielMothMicrosoft Employee, Owner 2012년 4월 6일 금요일 오전 7:26
-
2012년 2월 15일 수요일 오전 2:23소유자
This question has been answered by Weirong, and I just wanted to add that you can also use array_view objects, in addition to the option fo passing references of arrays.
Cheers
Daniel
http://www.danielmoth.com/Blog/
- 답변으로 표시됨 DanielMothMicrosoft Employee, Owner 2012년 4월 6일 금요일 오전 7:26

