24 #define INT_MAX 2147483647 27 #define INFINITY INT_MAX 29 typedef enum {
false=0,
true=1}
bool;
31 #pragma map generate_hw 0 34 bellmanford(
int source[
N_dest],
int dest[N_dest],
int weight [N_dest],
int distance[
N_dist],
int edgecount,
int nodecount,
int src)
37 bool succeeded =
true;
39 for (i=0; i < nodecount; ++i)
43 for (i=0; i < nodecount; ++i) {
44 for (j=0; j < edgecount; ++j) {
46 int new_distance =
distance[source[j]] + weight[j];
47 if (new_distance <
distance[dest[j]])
53 for (i=0; i < edgecount; ++i) {
65 int *source, *dest, *weight, *dist, i, edgecount, nodecount, src, success;
72 source = (
int*) malloc( 10 *
sizeof(
int ) );
73 dest = (
int*) malloc( edgecount *
sizeof(
int ) );
74 weight = (
int*) malloc( edgecount *
sizeof(
int ) );
75 dist = (
int*) malloc( nodecount *
sizeof(
int ) );
77 source[0] = 0; dest[0] = 1; weight[0] = 5;
78 source[1] = 0; dest[1] = 2; weight[1] = 8;
79 source[2] = 0; dest[2] = 3; weight[2] = -4;
80 source[3] = 1; dest[3] = 0; weight[3] = -2;
81 source[4] = 2; dest[4] = 1; weight[4] = -3;
82 source[5] = 2; dest[5] = 3; weight[5] = 9;
83 source[6] = 3; dest[6] = 1; weight[6] = 7;
84 source[7] = 3; dest[7] = 4; weight[7] = 2;
85 source[8] = 4; dest[8] = 0; weight[8] = 6;
86 source[9] = 4; dest[9] = 2; weight[9] = 7;
92 source = (
int*) malloc( 21 *
sizeof(
int ) );
93 dest = (
int*) malloc( edgecount *
sizeof(
int ) );
94 weight = (
int*) malloc( edgecount *
sizeof(
int ) );
95 dist = (
int*) malloc( nodecount *
sizeof(
int ) );
97 source[0] = 0; dest[0] = 2; weight[0] = 2;
98 source[1] = 0; dest[1] = 13; weight[1] = 30;
99 source[2] = 1; dest[2] = 12; weight[2] = -2;
100 source[3] = 2; dest[3] = 1; weight[3] = -1;
101 source[4] = 2; dest[4] = 11; weight[4] = 9;
102 source[5] = 3; dest[5] = 13; weight[5] = -10;
103 source[6] = 3; dest[6] = 10; weight[6] = 7;
104 source[7] = 5; dest[7] = 3; weight[7] = 3;
105 source[8] = 5; dest[8] = 6; weight[8] = 2;
106 source[9] = 6; dest[9] = 8; weight[9] = 3;
107 source[10] = 7; dest[10] = 6; weight[10] = -4;
108 source[11] = 7; dest[11] = 8; weight[11] = 6;
109 source[12] = 8; dest[12] = 7; weight[12] = 3;
110 source[13] = 9; dest[13] = 7; weight[13] = 2;
111 source[14] = 9; dest[14] = 4; weight[14] = -5;
112 source[15] = 10; dest[15] = 11; weight[15] = 1;
113 source[16] = 10; dest[16] = 14; weight[16] = 2;
114 source[17] = 11; dest[17] = 5; weight[17] = 8;
115 source[18] = 12; dest[18] = 0; weight[18] = -3;
116 source[19] = 13; dest[19] = 9; weight[19] = 3;
117 source[20] = 14; dest[20] = 1; weight[20] = 6;
121 #pragma map call_hw VIRTEX5 0 122 success = bellmanford(source, dest, weight, dist, edgecount, nodecount, src);
130 if (success !=
false)
_Bool __attribute__((noinline))
TYPE distance(TYPE position_x[nAtoms], TYPE position_y[nAtoms], TYPE position_z[nAtoms], int i, int j)