Permalink
Browse files

Revision 4: Used different version of generic multipliers in unrolled…

… versions
  • Loading branch information...
pzemtsov committed May 6, 2014
1 parent f8f0313 commit 1999ca98b6308ff9107e8ebf789e5615f822012e
Showing with 54 additions and 43 deletions.
  1. +10 −13 e1.cpp
  2. +44 −30 mymacros.h
View
23 e1.cpp
@@ -1,6 +1,7 @@
/** Revision 1: Created. Converted all non-inlined versions from Java to C++
Revision 2: Converted all unrolled versions from Java to C++
Revision 3: Used generic multipliers in unrolled versions
+ Revision 4: Used different version of generic multipliers in unrolled versions
*/
#include <cassert>
@@ -166,6 +167,8 @@ class Unrolled_1 : public Demux
}
};
+#define MOVE_TIMESLOT_J(offset) MOVE_TIMESLOT (j + offset)
+
class Unrolled_1_2 : public Demux
{
public:
@@ -176,7 +179,7 @@ class Unrolled_1_2 : public Demux
assert (src_length == NUM_TIMESLOTS * DST_SIZE);
for (unsigned j = 0; j < NUM_TIMESLOTS; j+=2) {
- DUP_2_ (MOVE_TIMESLOT, j);
+ DUP_2 (MOVE_TIMESLOT_J);
}
}
};
@@ -190,7 +193,7 @@ class Unrolled_1_4 : public Demux
assert (DST_SIZE == 64);
assert (src_length == NUM_TIMESLOTS * DST_SIZE);
for (unsigned j = 0; j < NUM_TIMESLOTS; j+=4) {
- DUP_4_ (MOVE_TIMESLOT, j);
+ DUP_4 (MOVE_TIMESLOT_J);
}
}
};
@@ -204,7 +207,7 @@ class Unrolled_1_8 : public Demux
assert (DST_SIZE == 64);
assert (src_length == NUM_TIMESLOTS * DST_SIZE);
for (unsigned j = 0; j < NUM_TIMESLOTS; j+=8) {
- DUP_8_ (MOVE_TIMESLOT, j);
+ DUP_8 (MOVE_TIMESLOT_J);
}
}
};
@@ -218,10 +221,12 @@ class Unrolled_1_16 : public Demux
assert (DST_SIZE == 64);
assert (src_length == NUM_TIMESLOTS * DST_SIZE);
for (unsigned j = 0; j < NUM_TIMESLOTS; j+=16) {
- DUP_16_ (MOVE_TIMESLOT, j);
+ DUP_16 (MOVE_TIMESLOT_J);
}
}
};
+
+#undef MOVE_TIMESLOT_J
class Unrolled_2_Full : public Demux
{
@@ -244,15 +249,7 @@ class Unrolled_3 : public Demux
assert (src_length % NUM_TIMESLOTS == 0);
#define CALL_DEMUX(i) demux_##i (src, dst[i])
-
- CALL_DEMUX ( 0); CALL_DEMUX ( 1); CALL_DEMUX ( 2); CALL_DEMUX ( 3);
- CALL_DEMUX ( 4); CALL_DEMUX ( 5); CALL_DEMUX ( 6); CALL_DEMUX ( 7);
- CALL_DEMUX ( 8); CALL_DEMUX ( 9); CALL_DEMUX (10); CALL_DEMUX (11);
- CALL_DEMUX (12); CALL_DEMUX (13); CALL_DEMUX (14); CALL_DEMUX (15);
- CALL_DEMUX (16); CALL_DEMUX (17); CALL_DEMUX (18); CALL_DEMUX (19);
- CALL_DEMUX (20); CALL_DEMUX (21); CALL_DEMUX (22); CALL_DEMUX (23);
- CALL_DEMUX (24); CALL_DEMUX (25); CALL_DEMUX (26); CALL_DEMUX (27);
- CALL_DEMUX (28); CALL_DEMUX (29); CALL_DEMUX (30); CALL_DEMUX (31);
+ DUP_32 (CALL_DEMUX);
#undef CALL_DEMUX
}
View
@@ -1,35 +1,49 @@
// duplicators for macros with one parameter;
// DUP_4(p) will be expanded as equivalent of p(0);p(1);p(2);p(3);
-// DUP_4_(p, 10) will be expanded as equivalent of p(10);p(11);p(12);p(13);
-
-#define DUP_2_(macro, index) do { macro (index); macro (index+1); } while (0)
-#define DUP_4_(macro, index) do { DUP_2_ (macro, index); DUP_2_ (macro, index+2); } while (0)
-#define DUP_8_(macro, index) do { DUP_4_ (macro, index); DUP_4_ (macro, index+4); } while (0)
-#define DUP_16_(macro, index) do { DUP_8_ (macro, index); DUP_8_ (macro, index+8); } while (0)
-#define DUP_32_(macro, index) do { DUP_16_(macro, index); DUP_16_(macro, index+16);} while (0)
-#define DUP_64_(macro, index) do { DUP_32_(macro, index); DUP_32_(macro, index+32);} while (0)
-
-#define DUP_2(macro) DUP_2_ (macro, 0)
-#define DUP_4(macro) DUP_4_ (macro, 0)
-#define DUP_8(macro) DUP_8_ (macro, 0)
-#define DUP_16(macro) DUP_16_(macro, 0)
-#define DUP_32(macro) DUP_32_(macro, 0)
-#define DUP_64(macro) DUP_64_(macro, 0)
+
+#define DUP_2(m) do { m( 0); m( 1); } while (0)
+#define DUP_4(m) do { DUP_2(m); m( 2); m( 3); } while (0)
+#define DUP_8(m) do { DUP_4(m); m( 4); m( 5); m( 6); m( 7); } while (0)
+
+#define DUP_16(m) do { DUP_8(m); m( 8); m( 9); m(10); m(11);\
+ m(12); m(13); m(14); m(15); } while (0)
+
+#define DUP_32(m) do { DUP_16(m); m(16); m(17); m(18); m(19);\
+ m(20); m(21); m(22); m(23);\
+ m(24); m(25); m(26); m(27);\
+ m(28); m(29); m(30); m(31); } while (0)
+
+#define DUP_64(m) do { DUP_32(m); m(32); m(33); m(34); m(35);\
+ m(36); m(37); m(38); m(39);\
+ m(40); m(41); m(42); m(43);\
+ m(44); m(45); m(46); m(47);\
+ m(48); m(49); m(50); m(51);\
+ m(52); m(53); m(54); m(55);\
+ m(56); m(57); m(58); m(59);\
+ m(60); m(61); m(62); m(63); } while (0)
+
// duplicators for macros with two parameters;
// DUP2_4(p, j) will be expanded as equivalent of p(0,j);p(1,j);p(2,j);p(3,j);
-// DUP2_4_(p, 10, j) will be expanded as equivalent of p(10,j);p(11,j);p(12,j);p(13,j);
-
-#define DUP2_2_(macro, index, param) do { macro (index, param); macro (index+1, param); } while (0)
-#define DUP2_4_(macro, index, param) do { DUP2_2_ (macro, index, param); DUP2_2_ (macro, index+2, param); } while (0)
-#define DUP2_8_(macro, index, param) do { DUP2_4_ (macro, index, param); DUP2_4_ (macro, index+4, param); } while (0)
-#define DUP2_16_(macro, index, param) do { DUP2_8_ (macro, index, param); DUP2_8_ (macro, index+8, param); } while (0)
-#define DUP2_32_(macro, index, param) do { DUP2_16_(macro, index, param); DUP2_16_(macro, index+16, param);} while (0)
-#define DUP2_64_(macro, index, param) do { DUP2_32_(macro, index, param); DUP2_32_(macro, index+32, param);} while (0)
-
-#define DUP2_2(macro, param) DUP2_2_ (macro, 0, param)
-#define DUP2_4(macro, param) DUP2_4_ (macro, 0, param)
-#define DUP2_8(macro, param) DUP2_8_ (macro, 0, param)
-#define DUP2_16(macro, param) DUP2_16_(macro, 0, param)
-#define DUP2_32(macro, param) DUP2_32_(macro, 0, param)
-#define DUP2_64(macro, param) DUP2_64_(macro, 0, param)
+
+#define DUP2_2(m,j) do { m( 0,j); m( 1,j); } while (0)
+#define DUP2_4(m,j) do { DUP2_2(m,j); m( 2,j); m( 3,j); } while (0)
+#define DUP2_8(m,j) do { DUP2_4(m,j); m( 4,j); m( 5,j); m( 6,j); m( 7,j); } while (0)
+
+#define DUP2_16(m,j) do { DUP2_8(m,j); m( 8,j); m( 9,j); m(10,j); m(11,j);\
+ m(12,j); m(13,j); m(14,j); m(15,j); } while (0)
+
+#define DUP2_32(m,j) do { DUP2_16(m,j); m(16,j); m(17,j); m(18,j); m(19,j);\
+ m(20,j); m(21,j); m(22,j); m(23,j);\
+ m(24,j); m(25,j); m(26,j); m(27,j);\
+ m(28,j); m(29,j); m(30,j); m(31,j); } while (0)
+
+#define DUP2_64(m,j) do { DUP2_32(m,j); m(32,j); m(33,j); m(34,j); m(35,j);\
+ m(36,j); m(37,j); m(38,j); m(39,j);\
+ m(40,j); m(41,j); m(42,j); m(43,j);\
+ m(44,j); m(45,j); m(46,j); m(47,j);\
+ m(48,j); m(49,j); m(50,j); m(51,j);\
+ m(52,j); m(53,j); m(54,j); m(55,j);\
+ m(56,j); m(57,j); m(58,j); m(59,j);\
+ m(60,j); m(61,j); m(62,j); m(63,j); } while (0)
+

0 comments on commit 1999ca9

Please sign in to comment.