I want to use C Reducer.
I write this code.
-----------------------------------------------------------------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
void MakeRandData(unsigned int* pData, unsigned int nSize)
{
srand((unsigned int)time(NULL));
for(unsigned int i =0; i < nSize; i++)
pData[i] = rand()%(nSize-1);
unsigned int nMsxPos= rand()%(nSize);
pData[nMsxPos] = nSize;
printf("Max value po %d.rn",nMsxPos);
}
int FindMaxIndex(unsigned int* pData, unsigned int nSize)
{
int nMax = 0, nFindIndex = 0;
CILK_C_REDUCER_MAX_INDEX(re_nIndex,int, -1);
CILK_C_REDUCER_MAX(re_nMax, int, 0);
cilk_for(int i =0; i < nSize; i++)
{
if(pData[i] > REDUCER_VIEW(re_nMax))
{
REDUCER_VIEW(re_nMax) = pData[i];
REDUCER_VIEW(re_nIndex) = i; // error
}
}
re_nIndex = REDUCER_VIEW(re_nIndex); //error
nMax = REDUCER_VIEW(re_nMax);
return nFindIndex;
}
int _tmain(int argc, _TCHAR* argv[])
{
const unsigned int MAX_COUNT = 100000000;
unsigned int* pNData;
unsigned int nFindMaxPos;
pNData = new unsigned int [MAX_COUNT];
MakeRandData(&pNData[0], MAX_COUNT);
nFindMaxPos = FindMaxIndex(&pNData[0], MAX_COUNT);
printf("max value posision is %d.rn",nFindMaxPos);
delete [] pNData;
return 0;
}-----------------------------------------------------------------------------------------------------------------------------
this program occur error!
I don't understand. why do this program occur error?
How can I successfully this program


