aboutsummaryrefslogtreecommitdiff
path: root/rcc-legacy/tests/performance/08_floyd-2.sy
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-06-08 17:10:31 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-06-08 17:10:31 +0800
commit72af0dedf9e18911da65b9a5c4906689e868d9fc (patch)
tree2ecbad93f96ab8ad7e26dc02cd02d802f853ab97 /rcc-legacy/tests/performance/08_floyd-2.sy
parent8faf6d290d6703b1775e0ad7a8928a4ebea4b11b (diff)
downloadrcc-project-72af0dedf9e18911da65b9a5c4906689e868d9fc.tar.gz
rcc-project-72af0dedf9e18911da65b9a5c4906689e868d9fc.tar.xz
[legacy] Add functional and performance test suites
Diffstat (limited to 'rcc-legacy/tests/performance/08_floyd-2.sy')
-rw-r--r--rcc-legacy/tests/performance/08_floyd-2.sy76
1 files changed, 76 insertions, 0 deletions
diff --git a/rcc-legacy/tests/performance/08_floyd-2.sy b/rcc-legacy/tests/performance/08_floyd-2.sy
new file mode 100644
index 0000000..f7abb0a
--- /dev/null
+++ b/rcc-legacy/tests/performance/08_floyd-2.sy
@@ -0,0 +1,76 @@
+const int maxlen = 2097152;
+int temp[maxlen], w[maxlen], dst[maxlen], c[maxlen];
+
+int getvalue(int a[], int n, int i, int j)
+{
+ if (i < 0 || i >= n || j < 0 || j >= n) return -1;
+ return a[i*n + j];
+}
+
+void mem_move(int src[], int dst[], int n){
+ int i = 0;
+ while (i < n){
+ dst[i] = src[i];
+ i = i + 1;
+ }
+}
+
+void floyd(int w[], int dst[], int n)
+{
+ int k = 0;
+ while (k < n) {
+ int i = 0;
+ while (i < n) {
+ temp[i*n + k] = getvalue(w, n, i, k);
+ i = i + 1;
+ }
+ k = k + 1;
+ }
+ k = 0;
+ while (k < n) {
+ int i = 0;
+ while (i < n) {
+ int j = 0;
+ while (j < n) {
+ if (getvalue(temp, n, i, k) >= 0 && getvalue(temp, n, k, j) >= 0) {
+ if (getvalue(temp, n, i, j) < 0) {
+ temp[i*n + j] = getvalue(temp, n, i, k) + getvalue(temp, n, k, j);
+ }
+ else {
+ if (temp[i*n + j] > getvalue(temp, n, i, k) + getvalue(temp, n, k, j)) {
+ temp[i*n + j] = getvalue(temp, n, i, k) + getvalue(temp, n, k, j);
+ }
+ }
+ }
+
+ j = j + 1;
+
+ }
+ i = i + 1;
+
+ }
+ k = k + 1;
+ }
+ mem_move(temp, dst, n*n);
+}
+
+int main()
+{
+ int n = getint();
+ getarray(w);
+
+ starttime();
+ floyd(w, dst, n);
+ stoptime();
+ putarray(n * n, dst);
+ // int i=0, j=0;
+ // while (i < n) {
+ // while (j < n) {
+ // putint(dst[i * n + j]);
+ // putch(10);
+ // j = j + 1;
+ // }
+ // i = i + 1;
+ // }
+ return 0;
+}