Loading hls/auto/auto_compile.c +x+30 Changes for hls/auto/auto_compile.c: 30 added lines, 0 removed lines. Original line number Diff line number Diff line #include <stdio.h> #include <stdlib.h> #define STRLEN 65536 int main(void){ char q[STRLEN], command[STRLEN]; char dir[64] = "../lines128_length256"; FILE *fp; fp = fopen("q.txt", "r"); if(fp == NULL){ printf("File does not exist.\n"); exit(1); } int counter = 1; while(1){ if(fscanf(fp, "%s", q) == EOF) break; printf("Q. %d\n", counter++); sprintf(command, "./%s/sim.exe %s", dir, q); //printf("(command) %s\n", command); int ret = system(command); printf("ret: %d\n", ret); } fclose(fp); return 0; } hls/lines128_length256/main.cpp +7 −2 Changes for hls/lines128_length256/main.cpp: 7 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include "router.hpp" #define PRINT_SOLUTION int main(int argc, char *argv[]) { using namespace std; Loading Loading @@ -50,9 +51,11 @@ int main(int argc, char *argv[]) { seed = atoi(argv[2]); } #ifdef PRINT_SOLUTION int size_x = (boardstr[1] - '0') * 10 + (boardstr[2] - '0'); int size_y = (boardstr[4] - '0') * 10 + (boardstr[5] - '0'); int size_z = (boardstr[7] - '0'); #endif // ソルバ実行 ap_int<32> status; Loading @@ -68,6 +71,7 @@ int main(int argc, char *argv[]) { cout << "status = " << (int)status << endl; cout << "elapsed = " << ((double)(clock_done - clock_start) / CLOCKS_PER_SEC) << endl << endl; #ifdef PRINT_SOLUTION // 解表示 cout << "SOLUTION" << endl; cout << "========" << endl; Loading @@ -80,12 +84,13 @@ int main(int argc, char *argv[]) { cout << ","; } int i = ((x * MAX_WIDTH + y) << BITWIDTH_Z) | z; //cout << setfill('0') << setw(2) << right << (unsigned int)(unsigned char)(boardstr[i]); cout << (unsigned int)(unsigned char)(boardstr[i]); cout << setfill('0') << setw(3) << right << (unsigned int)(unsigned char)(boardstr[i]); //cout << (unsigned int)(unsigned char)(boardstr[i]); } cout << endl; } } #endif return 0; } hls/lines128_length256/router.cpp +31 −23 Changes for hls/lines128_length256/router.cpp: 31 added lines, 23 removed lines. Original line number Diff line number Diff line Loading @@ -244,6 +244,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat ap_uint<8> last_target = 255; // [Step 2] Rip-up 再ルーティング cout << "Rip-up Routing" << endl; ROUTING: for (ap_uint<16> round = 1; round <= 32768 /* = (2048 * 16) */; round++) { #pragma HLS LOOP_TRIPCOUNT min=1 max=4000 avg=50 Loading Loading @@ -284,8 +285,6 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat #pragma HLS LOOP_TRIPCOUNT min=1 max=255 avg=50 weights[paths[target][j]] = 1; } // 対象ラインのスタートの重みも一旦リセット あとで (*) で戻す weights[starts[target]] = 1; // (2) 重みを更新 ap_uint<8> current_round_weight = new_weight(round); Loading @@ -303,10 +302,18 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat } } } WEIGHT_TERMINAL: for (ap_uint<8> i = 0; i < (ap_uint<8>)(line_num); i++) { #pragma HLS LOOP_TRIPCOUNT min=2 max=127 avg=50 weights[starts[i]] = MAX_WEIGHT; weights[goals[i]] = MAX_WEIGHT; } // 対象ラインのスタートの重みも一旦リセット あとで (*) で戻す weights[starts[target]] = 1; // 経路探索 #ifdef DEBUG_PRINT cout << "LINE #" << (int)(target + 1) << endl; cout << "(round: " << round << ")" << "LINE #" << (int)(target + 1) << endl; #endif search(&(paths_size[target]), paths[target], starts[target], goals[target], weights); Loading Loading @@ -611,18 +618,18 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start ap_uint<16> t = prev[goal]; #ifdef DEBUG_PRINT int dbg_start_xy = start >> BITWIDTH_Z; int dbg_start_x = dbg_start_xy / MAX_WIDTH; int dbg_start_y = dbg_start_xy % MAX_WIDTH; int dbg_start_z = start & BITMASK_Z; int dbg_goal_xy = goal >> BITWIDTH_Z; int dbg_goal_x = dbg_goal_xy / MAX_WIDTH; int dbg_goal_y = dbg_goal_xy % MAX_WIDTH; int dbg_goal_z = goal & BITMASK_Z; cout << "(" << dbg_start_x << ", " << dbg_start_y << ", " << dbg_start_z << ") #" << start << " -> " << "(" << dbg_goal_x << ", " << dbg_goal_y << ", " << dbg_goal_z << ") #" << goal << endl; //int dbg_start_xy = start >> BITWIDTH_Z; //int dbg_start_x = dbg_start_xy / MAX_WIDTH; //int dbg_start_y = dbg_start_xy % MAX_WIDTH; //int dbg_start_z = start & BITMASK_Z; //int dbg_goal_xy = goal >> BITWIDTH_Z; //int dbg_goal_x = dbg_goal_xy / MAX_WIDTH; //int dbg_goal_y = dbg_goal_xy % MAX_WIDTH; //int dbg_goal_z = goal & BITMASK_Z; //cout << "(" << dbg_start_x << ", " << dbg_start_y << ", " << dbg_start_z << ") #" << start << " -> " // << "(" << dbg_goal_x << ", " << dbg_goal_y << ", " << dbg_goal_z << ") #" << goal << endl; #endif // バックトラック Loading @@ -633,11 +640,11 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start #pragma HLS PIPELINE II=2 #ifdef DEBUG_PRINT int t_xy = prev[t] >> BITWIDTH_Z; int t_x = t_xy / MAX_WIDTH; int t_y = t_xy % MAX_WIDTH; int t_z = prev[t] & BITMASK_Z; cout << " via " << "(" << t_x << ", " << t_y << ", " << t_z << ") #" << prev[t] << " dist=" << dist[t] << endl; //int t_xy = prev[t] >> BITWIDTH_Z; //int t_x = t_xy / MAX_WIDTH; //int t_y = t_xy % MAX_WIDTH; //int t_z = prev[t] & BITMASK_Z; //cout << " via " << "(" << t_x << ", " << t_y << ", " << t_z << ") #" << prev[t] << " dist=" << dist[t] << endl; #endif path[p] = t; // 記録 Loading @@ -648,8 +655,8 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start *path_size = p; #ifdef DEBUG_PRINT cout << "max_path_len = " << p << endl; cout << "max_pq_len = " << max_pq_len << endl; //cout << "max_path_len = " << p << endl; //cout << "max_pq_len = " << max_pq_len << endl; #endif } Loading @@ -675,6 +682,7 @@ void pq_push(ap_uint<16> priority, ap_uint<16> data, ap_uint<12> *pq_len, ap_uin #pragma HLS INLINE (*pq_len)++; if ((*pq_len) == 0) { (*pq_len)--; } // Queue is full -> Last element is automatically removed ap_uint<12> i = (*pq_len); // target ap_uint<12> p = (*pq_len) >> 1; // i.e., (*pq_len) / 2; // 親 PQ_PUSH_LOOP: Loading Loading @@ -707,7 +715,7 @@ void pq_pop(ap_uint<16> *ret_priority, ap_uint<16> *ret_data, ap_uint<12> *pq_le ap_uint<16> last_priority = (ap_uint<16>)(pq_nodes[*pq_len] & PQ_PRIORITY_MASK); // 末尾ノードの優先度 PQ_POP_LOOP: while (1) { while (!(i >> 11)) { // (2018.08.25) Loop condition fixed #pragma HLS LOOP_TRIPCOUNT min=1 max=8 avg=4 //#pragma HLS PIPELINE //#pragma HLS UNROLL factor=2 Loading Loading
hls/auto/auto_compile.c +x+30 Changes for hls/auto/auto_compile.c: 30 added lines, 0 removed lines. Original line number Diff line number Diff line #include <stdio.h> #include <stdlib.h> #define STRLEN 65536 int main(void){ char q[STRLEN], command[STRLEN]; char dir[64] = "../lines128_length256"; FILE *fp; fp = fopen("q.txt", "r"); if(fp == NULL){ printf("File does not exist.\n"); exit(1); } int counter = 1; while(1){ if(fscanf(fp, "%s", q) == EOF) break; printf("Q. %d\n", counter++); sprintf(command, "./%s/sim.exe %s", dir, q); //printf("(command) %s\n", command); int ret = system(command); printf("ret: %d\n", ret); } fclose(fp); return 0; }
hls/lines128_length256/main.cpp +7 −2 Changes for hls/lines128_length256/main.cpp: 7 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include "router.hpp" #define PRINT_SOLUTION int main(int argc, char *argv[]) { using namespace std; Loading Loading @@ -50,9 +51,11 @@ int main(int argc, char *argv[]) { seed = atoi(argv[2]); } #ifdef PRINT_SOLUTION int size_x = (boardstr[1] - '0') * 10 + (boardstr[2] - '0'); int size_y = (boardstr[4] - '0') * 10 + (boardstr[5] - '0'); int size_z = (boardstr[7] - '0'); #endif // ソルバ実行 ap_int<32> status; Loading @@ -68,6 +71,7 @@ int main(int argc, char *argv[]) { cout << "status = " << (int)status << endl; cout << "elapsed = " << ((double)(clock_done - clock_start) / CLOCKS_PER_SEC) << endl << endl; #ifdef PRINT_SOLUTION // 解表示 cout << "SOLUTION" << endl; cout << "========" << endl; Loading @@ -80,12 +84,13 @@ int main(int argc, char *argv[]) { cout << ","; } int i = ((x * MAX_WIDTH + y) << BITWIDTH_Z) | z; //cout << setfill('0') << setw(2) << right << (unsigned int)(unsigned char)(boardstr[i]); cout << (unsigned int)(unsigned char)(boardstr[i]); cout << setfill('0') << setw(3) << right << (unsigned int)(unsigned char)(boardstr[i]); //cout << (unsigned int)(unsigned char)(boardstr[i]); } cout << endl; } } #endif return 0; }
hls/lines128_length256/router.cpp +31 −23 Changes for hls/lines128_length256/router.cpp: 31 added lines, 23 removed lines. Original line number Diff line number Diff line Loading @@ -244,6 +244,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat ap_uint<8> last_target = 255; // [Step 2] Rip-up 再ルーティング cout << "Rip-up Routing" << endl; ROUTING: for (ap_uint<16> round = 1; round <= 32768 /* = (2048 * 16) */; round++) { #pragma HLS LOOP_TRIPCOUNT min=1 max=4000 avg=50 Loading Loading @@ -284,8 +285,6 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat #pragma HLS LOOP_TRIPCOUNT min=1 max=255 avg=50 weights[paths[target][j]] = 1; } // 対象ラインのスタートの重みも一旦リセット あとで (*) で戻す weights[starts[target]] = 1; // (2) 重みを更新 ap_uint<8> current_round_weight = new_weight(round); Loading @@ -303,10 +302,18 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat } } } WEIGHT_TERMINAL: for (ap_uint<8> i = 0; i < (ap_uint<8>)(line_num); i++) { #pragma HLS LOOP_TRIPCOUNT min=2 max=127 avg=50 weights[starts[i]] = MAX_WEIGHT; weights[goals[i]] = MAX_WEIGHT; } // 対象ラインのスタートの重みも一旦リセット あとで (*) で戻す weights[starts[target]] = 1; // 経路探索 #ifdef DEBUG_PRINT cout << "LINE #" << (int)(target + 1) << endl; cout << "(round: " << round << ")" << "LINE #" << (int)(target + 1) << endl; #endif search(&(paths_size[target]), paths[target], starts[target], goals[target], weights); Loading Loading @@ -611,18 +618,18 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start ap_uint<16> t = prev[goal]; #ifdef DEBUG_PRINT int dbg_start_xy = start >> BITWIDTH_Z; int dbg_start_x = dbg_start_xy / MAX_WIDTH; int dbg_start_y = dbg_start_xy % MAX_WIDTH; int dbg_start_z = start & BITMASK_Z; int dbg_goal_xy = goal >> BITWIDTH_Z; int dbg_goal_x = dbg_goal_xy / MAX_WIDTH; int dbg_goal_y = dbg_goal_xy % MAX_WIDTH; int dbg_goal_z = goal & BITMASK_Z; cout << "(" << dbg_start_x << ", " << dbg_start_y << ", " << dbg_start_z << ") #" << start << " -> " << "(" << dbg_goal_x << ", " << dbg_goal_y << ", " << dbg_goal_z << ") #" << goal << endl; //int dbg_start_xy = start >> BITWIDTH_Z; //int dbg_start_x = dbg_start_xy / MAX_WIDTH; //int dbg_start_y = dbg_start_xy % MAX_WIDTH; //int dbg_start_z = start & BITMASK_Z; //int dbg_goal_xy = goal >> BITWIDTH_Z; //int dbg_goal_x = dbg_goal_xy / MAX_WIDTH; //int dbg_goal_y = dbg_goal_xy % MAX_WIDTH; //int dbg_goal_z = goal & BITMASK_Z; //cout << "(" << dbg_start_x << ", " << dbg_start_y << ", " << dbg_start_z << ") #" << start << " -> " // << "(" << dbg_goal_x << ", " << dbg_goal_y << ", " << dbg_goal_z << ") #" << goal << endl; #endif // バックトラック Loading @@ -633,11 +640,11 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start #pragma HLS PIPELINE II=2 #ifdef DEBUG_PRINT int t_xy = prev[t] >> BITWIDTH_Z; int t_x = t_xy / MAX_WIDTH; int t_y = t_xy % MAX_WIDTH; int t_z = prev[t] & BITMASK_Z; cout << " via " << "(" << t_x << ", " << t_y << ", " << t_z << ") #" << prev[t] << " dist=" << dist[t] << endl; //int t_xy = prev[t] >> BITWIDTH_Z; //int t_x = t_xy / MAX_WIDTH; //int t_y = t_xy % MAX_WIDTH; //int t_z = prev[t] & BITMASK_Z; //cout << " via " << "(" << t_x << ", " << t_y << ", " << t_z << ") #" << prev[t] << " dist=" << dist[t] << endl; #endif path[p] = t; // 記録 Loading @@ -648,8 +655,8 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start *path_size = p; #ifdef DEBUG_PRINT cout << "max_path_len = " << p << endl; cout << "max_pq_len = " << max_pq_len << endl; //cout << "max_path_len = " << p << endl; //cout << "max_pq_len = " << max_pq_len << endl; #endif } Loading @@ -675,6 +682,7 @@ void pq_push(ap_uint<16> priority, ap_uint<16> data, ap_uint<12> *pq_len, ap_uin #pragma HLS INLINE (*pq_len)++; if ((*pq_len) == 0) { (*pq_len)--; } // Queue is full -> Last element is automatically removed ap_uint<12> i = (*pq_len); // target ap_uint<12> p = (*pq_len) >> 1; // i.e., (*pq_len) / 2; // 親 PQ_PUSH_LOOP: Loading Loading @@ -707,7 +715,7 @@ void pq_pop(ap_uint<16> *ret_priority, ap_uint<16> *ret_data, ap_uint<12> *pq_le ap_uint<16> last_priority = (ap_uint<16>)(pq_nodes[*pq_len] & PQ_PRIORITY_MASK); // 末尾ノードの優先度 PQ_POP_LOOP: while (1) { while (!(i >> 11)) { // (2018.08.25) Loop condition fixed #pragma HLS LOOP_TRIPCOUNT min=1 max=8 avg=4 //#pragma HLS PIPELINE //#pragma HLS UNROLL factor=2 Loading