HSA-Libraries / Bolt

Bolt is a C++ template library optimized for GPUs. Bolt provides high-performance library implementations for common algorithms such as scan, reduce, transform, and sort.
Other
372 stars 65 forks source link

Bolt1.2: bolt::cl::min_element and bolt::cl::max_element having issues while using device_vector with iterator. #213

Open jhkumar opened 10 years ago

jhkumar commented 10 years ago

This issue can be observed only with the bolt i,e, when calling bolt::min_element and bolt::max_element on device_vector. For std::min_element and std::max_element it is working fine.

CODE:

//code for BOLT_MIN_ELEMENT:

TEST(sanity_min_element_2bolt_cl_device_vect_loop, ints_loop){ int size = 10; bolt::cl::device_vector intStdVect (size); bolt::cl::device_vector intBoltVect (size);

for (int i = 0 ; i < size; i++){
    intBoltVect[i] = (int)std::rand()%65535 ;
     intStdVect[i] = intBoltVect[i];
}

bolt::cl::device_vector<int>::iterator std_min_ele; 
for (int i = 0 ; i < 1000; i++){
            std_min_ele = std::min_element (intStdVect.begin(), intStdVect.end());
}

bolt::cl::device_vector<int>::iterator bolt_min_ele;  
for (int i = 0 ; i < 1000; i++){
    bolt_min_ele =  bolt::cl::min_element(intBoltVect.begin(), intBoltVect.end());
}
EXPECT_EQ(*std_min_ele, *bolt_min_ele)<<std::endl;

}

// code for BOLT_MAX_ELEMENT:

TEST(sanity_max_element_2bolt_cl_device_vect_loop, ints_loop){ int size = 10; bolt::cl::device_vector intStdVect (size); bolt::cl::device_vector intBoltVect (size);

for (int i = 0 ; i < size; i++){
    intBoltVect[i] = (int)std::rand()%65535 ;
     intStdVect[i] = intBoltVect[i];
}

bolt::cl::device_vector<int>::iterator std_min_ele; 
for (int i = 0 ; i < 1000; i++){
            std_max_ele = std::max_element (intStdVect.begin(), intStdVect.end());
}

bolt::cl::device_vector<int>::iterator bolt_min_ele;  
for (int i = 0 ; i < 1000; i++){
    bolt_max_ele =  bolt::cl::max_element(intBoltVect.begin(), intBoltVect.end());
}
EXPECT_EQ(*std_max_ele, *bolt_max_ele)<<std::endl;

}