Created
May 25, 2015 13:48
-
-
Save Diggsey/1b55018922accfbbbec3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AmpBug.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
#include <amp.h> | |
#include <iostream> | |
#include <iomanip> | |
using namespace concurrency; | |
struct wrapper { | |
public: | |
array_view<float, 1> m_field0; | |
array_view<float, 1> m_field1; | |
}; | |
struct test { | |
public: | |
wrapper m_elem0; | |
wrapper m_elem1; | |
inline wrapper operator[](int index) const restrict(amp) { | |
switch (index) { | |
case 0: return m_elem0; | |
case 1: return m_elem1; | |
} | |
} | |
}; | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
extent<1> size(8); | |
array<float, 1> data(size); | |
test input{ { data, data },{ data, data } }; | |
try { | |
parallel_for_each(size, [=](index<1> idx) restrict(amp) { | |
float data[2]; | |
for (int i = 0; i < 2; ++i) { | |
data[i] = input[i].m_field0[idx]; | |
} | |
}); | |
} catch (runtime_exception& ex) { | |
OutputDebugStringA(ex.what()); | |
DebugBreak(); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment