/*
 * oclh_hd_srr.clh
 *      Author: havock
 */
#if !defined(_OCLH_OCL_COMPILER_)
#define __global
#define __private
#define __kernel
#endif /* !defined(_OCLH_OCL_COMPILER_) */

#ifndef OCLH_HD_SRR_CLH_
#define OCLH_HD_SRR_CLH_ 1
#include <oclh_hd_std_types.clh>

int32_t  _ghdf_sumFromAtoB_i32(__private const int32_t a,
                               __private const int32_t b);
uint64_t _ghdf_sumFromAtoB_u64(__private const uint64_t a,
                               __private const uint64_t b);
int32_t  _ghdf_getMaxOfInt32s( __private const int32_t* const pi32Vals,
                               __private const uint64_t       u64NofVals);
int32_t  _ghdf_getMaxOf2Int32s(__private const int32_t a,
                               __private const int32_t b);

int32_t _ghdf_sumFromAtoB_i32(__private const int32_t a,
                              __private const int32_t b) {
    const int32_t d=b-a, s=b+a;
    return((d%2)? /* i assume that -1 is TRUE ))) */
            (s*((d+1)/2)):
            ((s-1)*(d/2)+b));
}
uint64_t _ghdf_sumFromAtoB_u64(__private const uint64_t a,
                               __private const uint64_t b) {
    const uint64_t d=b-a, s=b+a;
    return((d%2ul)? /* i assume that -1 is TRUE ))) */
            (s*((d+1ul)/2ul)):
            ((s-1ul)*(d/2ul)+b));
}
int32_t _ghdf_getMaxOfInt32s(__private const int32_t* const pi32Vals,
                             __private const uint64_t       u64NofVals) {
    __private int32_t i32Max=pi32Vals[0];
    __private uint64_t i=1ul;
    for(i=1ul; i<u64NofVals; i++) if(i32Max<pi32Vals[i]) i32Max=pi32Vals[i];
    return(i32Max);
}
int32_t _ghdf_getMaxOf2Int32s(__private const int32_t a,
                              __private const int32_t b) {
    return((a>b)?a:b);
}
#endif /* OCLH_HD_SRR_CLH_ */
