-#define SMPI_SAMPLE_LOOP(global, iters, thres) \
- for (smpi_sample_1(global, __FILE__, __LINE__, iters, thres); smpi_sample_2(global, __FILE__, __LINE__); \
- smpi_sample_3(global, __FILE__, __LINE__))
-#define SMPI_SAMPLE_LOCAL(iters, thres) SMPI_SAMPLE_LOOP(0, iters, thres)
-#define SMPI_SAMPLE_GLOBAL(iters, thres) SMPI_SAMPLE_LOOP(1, iters, thres)
-
+#define SMPI_ITER_NAME1(line) iter_count##line
+#define SMPI_ITER_NAME(line) SMPI_ITER_NAME1(line)
+#define SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, global, iters, thres)\
+ int SMPI_ITER_NAME(__LINE__)=0;\
+ {loop_init;\
+ while(loop_end){\
+ SMPI_ITER_NAME(__LINE__)++;\
+ loop_iter;\
+ }} \
+ for(loop_init; \
+ loop_end ? (smpi_sample_1(global, __FILE__, __LINE__, iters, thres), (smpi_sample_2(global, __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__)))) :\
+ smpi_sample_exit(global, __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__));\
+ smpi_sample_3(global, __FILE__, __LINE__),loop_iter)
+#define SMPI_SAMPLE_LOCAL(loop_init, loop_end, loop_iter, iters, thres) SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, 0, iters, thres)
+#define SMPI_SAMPLE_GLOBAL(loop_init, loop_end, loop_iter,iters, thres) SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, 1, iters, thres)