diff --git a/application/pr/build.mk b/application/pr/build.mk index eae5554..977380a 100644 --- a/application/pr/build.mk +++ b/application/pr/build.mk @@ -1,4 +1,4 @@ -HAVE_FULL_SLR=true +HAVE_FULL_SLR=false #scatter-gather kernel HAVE_VERTEX_ACTIVE_BIT=false @@ -6,7 +6,7 @@ HAVE_EDGE_PROP=false HAVE_UNSIGNED_PROP=false #apply kernel -HAVE_APPLY=true +HAVE_APPLY=false CUSTOMIZE_APPLY=false HAVE_APPLY_OUTDEG=true diff --git a/application/pr/l2.h b/application/pr/l2.h index 2e65a7a..9002751 100644 --- a/application/pr/l2.h +++ b/application/pr/l2.h @@ -44,18 +44,18 @@ inline prop_t applyCalculation( prop_t tProp, { prop_t old_score = source; - prop_t new_score = arg + ((kDampFixPoint * tProp) >> 7); + prop_t new_score = arg + ((kDampFixPoint * tProp)); prop_t tmp; if (outDeg != 0) { - tmp = (1 << 7 ) / outDeg; + tmp = (1.0f ) / outDeg; } else { tmp = 0; } - prop_t update = (new_score * tmp) >> 7; + prop_t update = (new_score * tmp); extra = (new_score - old_score) > 0 ? (new_score - old_score) : (old_score - new_score) ; diff --git a/config.h b/config.h index 290e74d..f9b930b 100644 --- a/config.h +++ b/config.h @@ -5,12 +5,10 @@ #include -#if HAVE_UNSIGNED_PROP -typedef unsigned int prop_t; -#else -typedef int prop_t; -#endif +typedef float prop_t; + +typedef union {prop_t f; unsigned int ui;} prop_union_t; #define BLK_SIZE (512*1024) #define VERTEX_MAX (BLK_SIZE) diff --git a/libfpga/fpga_cache.h b/libfpga/fpga_cache.h index e835081..b40ff46 100644 --- a/libfpga/fpga_cache.h +++ b/libfpga/fpga_cache.h @@ -293,6 +293,7 @@ void streamDelayScheme2(hls::stream &in, hls::stream } + void updateVertexCache(uint16 *input, hls::stream &cmdStream, hls::stream &cacheStream) @@ -416,11 +417,12 @@ readCacheInner: for (int k = 0; k < EDGE_NUM; k ++) { #pragma HLS latency min=1 max=3 tmp = vertexScoreCache[k][bit][address]; } - + prop_union_t u; if (vertex_index & 0x01) - tuples[unit_cycle].data[k].y = tmp.range(63, 32); + u.ui = tmp.range(63, 32); else - tuples[unit_cycle].data[k].y = tmp.range(31, 0); + u.ui = tmp.range(31, 0); + tuples[unit_cycle].data[k].y = u.f; #if CAHCE_FETCH_DEBUG if (tuples[unit_cycle].data[k].y != vertex_index) { diff --git a/libfpga/fpga_process_edge.h b/libfpga/fpga_process_edge.h index b6e6f2a..0fb5228 100644 --- a/libfpga/fpga_process_edge.h +++ b/libfpga/fpga_process_edge.h @@ -127,18 +127,24 @@ void dstPropertyProcess( else origin_value = updated_value.range(31, 0); - origin_value = PROP_COMPUTE_STAGE3(origin_value, tmp_data.y); + prop_union_t in; + prop_union_t out; + + in.ui = origin_value; + + + out.f = PROP_COMPUTE_STAGE3(in.f, tmp_data.y); uint_uram tmp; if (idx & 0x01) { - tmp.range(63, 32) = origin_value; + tmp.range(63, 32) = out.ui; tmp.range(31, 0) = updated_value.range(31, 0); } else { tmp.range(63, 32) = updated_value.range(63, 32); - tmp.range(31, 0) = origin_value; + tmp.range(31, 0) = out.ui; } tmpVPropBuffer[(idx >> 1)] = tmp; } diff --git a/libfpga/fpga_raw_solver.h b/libfpga/fpga_raw_solver.h index 1ea8de8..caabc0e 100644 --- a/libfpga/fpga_raw_solver.h +++ b/libfpga/fpga_raw_solver.h @@ -66,10 +66,120 @@ void processEdgesReorderStreamScheme1(hls::stream &in , hls::stream write_to_stream(out, tmp_data); } +#define ABS_DIFF(a,b) ((a>b)?(a-b):(b-a)) + + +#define flush_one_buffer { \ + last_index = local_buffer[wid].x; \ + if (ABS_DIFF(last_index, local_buffer[wid].x) > (DISTANCE * PE_NUM)) \ + { \ + int2_token send_token; \ + send_token.data = local_buffer[wid]; \ + send_token.flag = FLAG_RESET; \ + write_to_stream(out, send_token); \ + } \ + else \ + { \ + int tmp_index = local_buffer[wid].x; \ + int2_token send_token; \ + send_token.data.x = tmp_index; \ + send_token.data.y = 0; \ + send_token.flag = FLAG_RESET; \ + for (int i = 0; i < DISTANCE; i++) \ + { \ + write_to_stream(out, send_token); \ + } \ + } \ + wid ++; \ +} + + + -/* 4 distance */ void rawSolver(hls::stream &in , hls::stream &out) { +#pragma HLS function_instantiate variable=in + +#define DISTANCE (8) + int2 local_buffer[DISTANCE]; +#pragma HLS dependence variable=local_buffer inter false + + ap_uint<1> end_flag; + + uint_raw rid, wid; + uint_raw last_index; + + wid = 0; + rid = 0; + end_flag = 0; + last_index = ENDFLAG; + + for (int i = 0; i < DISTANCE ; i++) + { + local_buffer[i].x = 0; + local_buffer[i].y = 0; + } + + +solver: while (true) + { + int2_token in_token; +flow: while (true) + { +#pragma HLS PIPELINE II=2 + int2 tmp_data; + + read_from_stream(in, in_token); + tmp_data = in_token.data; + uint_raw dstVidx = tmp_data.x; + + if ((dstVidx & ( ENDFLAG - 1 )) == (ENDFLAG - 1) || (in_token.flag == FLAG_SET)) + { + end_flag = FLAG_SET; + break; + } + if ((last_index == ENDFLAG) || (ABS_DIFF(last_index , tmp_data.x) > (DISTANCE * PE_NUM))) + { + int2_token send_token; + send_token.data = tmp_data; + send_token.flag = FLAG_RESET; + write_to_stream(out, send_token); + last_index = send_token.data.x; + } + else + { + local_buffer[rid] = tmp_data; + rid ++; + if (rid - wid >= DISTANCE - 1) + { + break; + } + } + } + if (end_flag == FLAG_SET) + { + int remaining = (rid - wid); + for (int k = 0; k < remaining ; k++) + { + flush_one_buffer; + } + break; + } + else + { + flush_one_buffer; + } + } + empty_stream(in); + + int2_token send_token; + send_token.flag = FLAG_SET; + write_to_stream(out, send_token); +} + +/* 4 distance */ +void rawSolver2(hls::stream &in , hls::stream &out) +{ #pragma HLS function_instantiate variable=in int2 local_buffer[5]; #pragma HLS ARRAY_PARTITION variable=local_buffer dim=0 complete @@ -114,7 +224,7 @@ void rawSolver(hls::stream &in , hls::stream &out) { break; } - for (int i = 0; i < 4; i++) +accumlate: for (int i = 0; i < 4; i++) { #pragma HLS UNROLL if ((vaild_flag[i] == 1) && (local_buffer[i].x == dstVidx)) diff --git a/libfpga/graph_fpga.h b/libfpga/graph_fpga.h index 726bdb5..15b865c 100755 --- a/libfpga/graph_fpga.h +++ b/libfpga/graph_fpga.h @@ -76,11 +76,7 @@ typedef ap_uint<64> uint_uram; typedef struct __int2__ { int x; -#if HAVE_UNSIGNED_PROP - uint_raw y; -#else - int y; -#endif + prop_t y; } int2;