12 #include <Eigen/CXX11/Tensor> 20 for (int32_t j = 0; j < 25000; ++j) {
21 const int32_t fast_div = j / div_by_one;
22 const int32_t slow_div = j / 1;
23 VERIFY_IS_EQUAL(fast_div, slow_div);
27 for (int32_t i = 2; i < 25000; ++i) {
30 for (int32_t j = 0; j < 25000; ++j) {
31 const int32_t fast_div = j / div;
32 const int32_t slow_div = j / i;
33 VERIFY_IS_EQUAL(fast_div, slow_div);
38 for (int32_t i = 2; i < 25000; ++i) {
41 for (int32_t j = 0; j < 25000; ++j) {
42 const int32_t fast_div = j / div;
43 const int32_t slow_div = j / i;
44 VERIFY_IS_EQUAL(fast_div, slow_div);
52 for (uint32_t i = 1; i < 25000; ++i) {
55 for (uint32_t j = 0; j < 25000; ++j) {
56 const uint32_t fast_div = j / div;
57 const uint32_t slow_div = j / i;
58 VERIFY_IS_EQUAL(fast_div, slow_div);
66 for (int64_t i = 1; i < 25000; ++i) {
69 for (int64_t j = 0; j < 25000; ++j) {
70 const int64_t fast_div = j / div;
71 const int64_t slow_div = j / i;
72 VERIFY_IS_EQUAL(fast_div, slow_div);
80 for (uint64_t i = 1; i < 25000; ++i) {
83 for (uint64_t j = 0; j < 25000; ++j) {
84 const uint64_t fast_div = j / div;
85 const uint64_t slow_div = j / i;
86 VERIFY_IS_EQUAL(fast_div, slow_div);
92 for (
int expon = 1; expon < 31; expon++) {
93 int32_t div = (1 << expon);
94 for (
int num_expon = 0; num_expon < 32; num_expon++) {
95 int32_t start_num = (1 << num_expon) - 100;
96 int32_t end_num = (1 << num_expon) + 100;
99 for (int32_t num = start_num; num < end_num; num++) {
102 int32_t result = num/div;
103 int32_t result_op = divider.
divide(num);
104 VERIFY_IS_EQUAL(result_op, result);
111 for (
int expon = 0; expon < 63; expon++) {
112 int64_t div = (1ull << expon);
113 for (
int num_expon = 0; num_expon < 63; num_expon++) {
114 int64_t start_num = (1ull << num_expon) - 10;
115 int64_t end_num = (1ull << num_expon) + 10;
118 for (int64_t num = start_num; num < end_num; num++) {
120 int64_t result = num/div;
121 int64_t result_op = divider.
divide(num);
122 VERIFY_IS_EQUAL(result_op, result);
130 int64_t div = 209715200;
131 int64_t num = 3238002688ll;
133 int64_t result = num/div;
134 int64_t result_op = divider.
divide(num);
135 VERIFY_IS_EQUAL(result, result_op);
void test_cxx11_tensor_intdiv()
void test_unsigned_32bit()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T divide(const T numerator) const
void test_unsigned_64bit()