The error message went out while calculating and neither [dete] nor the wanted answer went out voluminously though it tried to change part instead of buildSum, to make buildMin, and to use it because I wanted to put out minimum value and the maximum value of the array by using Scan of Large Arrays of SAMPLE PROGRAM of NVIDIA CUDA SDK. Please teach the method of correcting the mistake.
device unsigned int buildMin(float *s_data)
{
unsigned int thid = threadIdx.x;
unsigned int stride = 1;
// build the sum in place up the tree
for (int d = blockDim.x; d > 0; d >>= 1)
{
__syncthreads();
if (thid < d)
{
int i = __mul24(__mul24(2, stride), thid);
int ai = i + stride - 1;
int bi = ai + stride;
ai += CONFLICT_FREE_OFFSET(ai);
bi += CONFLICT_FREE_OFFSET(bi);
if (s_data[bi]>s_data[ai]) {
s_data[bi] = s_data[ai];
}
I don’t quite understand the question, but since you only want the minimum of the array, and not all the intermediate results, you should look at the “reduction” sample in the SDK, not scan.
We will declare variable minElement and minElementPosition and initialize it with first element of inputArray and 0 respectively.
We will start traversing inputArray from index 0 to N -1 and compare each element with minElement. If minElement is more than current element, we will update minElement and minElementPosition with current element and current position respectively.
At any instant of time suppose we are at index i, then minElement will give the minimum element between array index 0 to i.
@AkbarKhan: If I understand your response correctly, your response is finding max. or min. sequentially, not parallelly. The OP asks for a parallel method.
@LongY: AkbarKhan is just spamming these forums trying to drum up publicity for the techchrashcourse.com site. It’s probably better if you just ignore the posting. (S)He dug up a 7 year old question to respond to which is almost certainly not relevant to the thread OP anymore.
Probably best just to leave it alone, not give it any more publicity.