Binary search

machineauthorcommitcommit dateplatformtimechecksumcheckrel timebonus

The input consists of an ordered sequence idata with isize elements and an unordered sequence odata with osize elements. The assignment is to distribute the odata into (isize+1) buckets, whose border values are defined by idata. In the bucket number k, elements are greater or equal to idata[k-1] and less than idata[k].

        typedef std::int32_t data_element;
        
        template< typename policy>
        class bsearch_inner {
        public:
            bsearch_inner( const data_element * idata, std::size_t isize);
        };
    
        template< typename policy>
        class bsearch_outer { 
        public:
            bsearch_outer( const bsearch_inner< policy> & inner, std::size_t osize);
    
            void bucketize( const data_element * odata);
            
            typedef std::pair< const data_element *, std::size_t> bucket_rv;
    
            bucket_rv bucket( std::size_t k) const;
        };
    

Test parameters

isize and osize parameters are explained above. isize is iterated through the set { 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576 }, osize through the set { 1024, 16384, 262144 }, resulting in 24 test configurations on each platform. In Debug mode, only 6 of them are used.

repeats is an auto-adjusted parameter, used to increase running time by repeatedly calling compute. The range of the parameter is set so that the expected run time ranges from fractions of a second to seconds (stopped by the auto-adjustment mechanism after exceeding a second).