Skip to content

Commit fb91332

Browse files
committed
update tests; force SCS build in CI so tests work; change SCS dump routine to use fprintf
1 parent 06c457b commit fb91332

File tree

8 files changed

+433
-339
lines changed

8 files changed

+433
-339
lines changed

.github/workflows/single-platform.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,44 @@ jobs:
5757
sed -E -i \
5858
-e 's/^(ENABLE_MPI[[:space:]]*\?=[[:space:]]*).*/\1true/' \
5959
-e 's/^(ENABLE_OPENMP[[:space:]]*\?=[[:space:]]*).*/\1false/' \
60+
-e 's/^(MTX_FMT[[:space:]]*\?=[[:space:]]*).*/\SCS/' \
6061
-e "s/^(TOOLCHAIN[[:space:]]*\?=[[:space:]]*).*/\1${TOOLCHAIN}/" \
6162
config.mk
6263
6364
make
65+
66+
- name: List exes after build
67+
run: |
68+
echo "Current directory: $(pwd)"
69+
echo "Contents:"
70+
find . -type f -executable
71+
72+
- name: Upload Executables
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: executable-${{ matrix.compiler }}
76+
path: |
77+
$(pwd)/sparseBench-SCS-${{ matrix.compiler }}
78+
79+
# runTests:
80+
# runs-on: ubuntu-latest
81+
# needs: build
82+
# strategy:
83+
# matrix:
84+
# compiler: [GCC, ICC, CLANG]
85+
86+
# steps:
87+
# - uses: actions/checkout@v4
88+
89+
# - name: Download Executables
90+
# uses: actions/download-artifact@v4
91+
# with:
92+
# name: executable-${{ matrix.compiler }}
93+
# path: ./executables
94+
95+
# - name: Run Tests
96+
# run: |
97+
# chmod +x ./executables/*
98+
# ./executables/executable1 --test
99+
# ./executables/executable2 --test
100+
# ./executables/executable3 --test

src/comm.c

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -753,53 +753,54 @@ void commMatrixDump(Comm* c, Matrix* m)
753753
}
754754
#endif /* ifdef CRS */
755755
#ifdef SCS
756-
printf("m->startRow = %d\n", m->startRow);
757-
printf("m->stopRow = %d\n", m->stopRow);
758-
printf("m->totalNr = %d\n", m->totalNr);
759-
printf("m->totalNnz = %d\n", m->totalNnz);
760-
printf("m->nr = %d\n", m->nr);
761-
printf("m->nc = %d\n", m->nc);
762-
printf("m->nnz = %d\n", m->nnz);
763-
printf("m->C = %d\n", m->C);
764-
printf("m->sigma = %d\n", m->sigma);
765-
printf("m->nChunks = %d\n", m->nChunks);
766-
printf("m->nrPadded = %d\n", m->nrPadded);
756+
fprintf(c->logFile, "m->startRow = %d\n", m->startRow);
757+
fprintf(c->logFile, "m->stopRow = %d\n", m->stopRow);
758+
fprintf(c->logFile, "m->totalNr = %d\n", m->totalNr);
759+
fprintf(c->logFile, "m->totalNnz = %d\n", m->totalNnz);
760+
fprintf(c->logFile, "m->nr = %d\n", m->nr);
761+
fprintf(c->logFile, "m->nc = %d\n", m->nc);
762+
fprintf(c->logFile, "m->nnz = %d\n", m->nnz);
763+
fprintf(c->logFile, "m->C = %d\n", m->C);
764+
fprintf(c->logFile, "m->sigma = %d\n", m->sigma);
765+
fprintf(c->logFile, "m->nChunks = %d\n", m->nChunks);
766+
fprintf(c->logFile, "m->nrPadded = %d\n", m->nrPadded);
767+
fprintf(c->logFile, "m->nElems = %d\n", m->nElems);
767768

768769
// Dump permutation arrays
769-
printf("oldToNewPerm: ");
770+
fprintf(c->logFile, "oldToNewPerm: ");
770771
for (int i = 0; i < m->nr; ++i) {
771-
printf("%d, ", m->oldToNewPerm[i]);
772+
fprintf(c->logFile, "%d, ", m->oldToNewPerm[i]);
772773
}
773-
printf("\n");
774-
printf("newToOldPerm: ");
774+
fprintf(c->logFile, "\n");
775+
fprintf(c->logFile, "newToOldPerm: ");
775776
for (int i = 0; i < m->nr; ++i) {
776-
printf("%d, ", m->newToOldPerm[i]);
777+
fprintf(c->logFile, "%d, ", m->newToOldPerm[i]);
777778
}
778-
printf("\n");
779+
fprintf(c->logFile, "\n");
779780

780781
// Dump chunk data
781-
printf("chunkLens: ");
782+
fprintf(c->logFile, "chunkLens: ");
782783
for (int i = 0; i < m->nChunks; ++i) {
783-
printf("%d, ", m->chunkLens[i]);
784+
fprintf(c->logFile, "%d, ", m->chunkLens[i]);
784785
}
785-
printf("\n");
786-
printf("chunkPtr: ");
786+
fprintf(c->logFile, "\n");
787+
fprintf(c->logFile, "chunkPtr: ");
787788
for (int i = 0; i < m->nChunks + 1; ++i) {
788-
printf("%d, ", m->chunkPtr[i]);
789+
fprintf(c->logFile, "%d, ", m->chunkPtr[i]);
789790
}
790-
printf("\n");
791+
fprintf(c->logFile, "\n");
791792

792793
// Dump matrix data
793-
printf("colInd: ");
794+
fprintf(c->logFile, "colInd: ");
794795
for (int i = 0; i < m->nElems; ++i) {
795-
printf("%d, ", m->colInd[i]);
796+
fprintf(c->logFile, "%d, ", m->colInd[i]);
796797
}
797-
printf("\n");
798-
printf("val: ");
798+
fprintf(c->logFile, "\n");
799+
fprintf(c->logFile, "val: ");
799800
for (int i = 0; i < m->nElems; ++i) {
800-
printf("%f, ", m->val[i]);
801+
fprintf(c->logFile, "%f, ", m->val[i]);
801802
}
802-
printf("\n");
803+
fprintf(c->logFile, "\n");
803804
#endif /* ifdef SCS */
804805
}
805806

src/matrix-SCS.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void convertMatrix(Matrix* m, GMatrix* im)
3939
m->nnz = im->nnz;
4040
m->nChunks = (m->nr + m->C - 1) / m->C;
4141
m->nrPadded = m->nChunks * m->C;
42-
m->C = (CG_UINT)1;
43-
m->sigma = (CG_UINT)1;
42+
// m->C = (CG_UINT)1;
43+
// m->sigma = (CG_UINT)1;
4444

4545
// (Temporary array) Assign an index to each row to use for row sorting
4646
SellCSigmaPair* elemsPerRow = (SellCSigmaPair*)allocate(ARRAY_ALIGNMENT,

tests/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include ../config.mk
55
include ../mk/include_$(TOOLCHAIN).mk
66

77
BUILD_DIR=../build
8-
TC_DIR=${BUILD_DIR}/$(TOOLCHAIN)
8+
TC_DIR=${BUILD_DIR}/$(MTX_FMT)-$(TOOLCHAIN)
99

1010
# List of test modules
1111
MOD1=matrix
@@ -23,7 +23,7 @@ MOD2_OBJECTS=${MOD2}/spmvSCS.o ${MOD2}/solverTests.o
2323
OBJECTS := $(shell echo $(MOD1_OBJECTS) $(MOD2_OBJECTS) | tr ' ' '\n' | sort -u | tr '\n' ' ')
2424

2525
# Always leave debugging flag on
26-
CFLAGS=-g
26+
CFLAGS=-g $(DEFINES)
2727

2828
# Only enable OpenMP if it defined in the parent config.mk
2929
ifeq ($(strip $(ENABLE_OPENMP)),true)

tests/common.h

Lines changed: 94 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,68 @@
44
#include <stdio.h>
55
#include <string.h>
66

7-
#define SET_ARGS(i, C_val, sigma_val) \
8-
{ \
9-
args[i]->C = (C_val); \
10-
args[i]->sigma = (sigma_val); \
11-
}
7+
#define SET_ARGS(i, C_val, sigma_val) \
8+
{ \
9+
args[i]->C = (C_val); \
10+
args[i]->sigma = (sigma_val); \
11+
}
1212

1313
typedef int (*TestFunc)(void* config, const char* dataDir);
1414

1515
typedef struct {
16-
const char* name;
17-
TestFunc func;
16+
const char* name;
17+
TestFunc func;
1818
} Test;
1919

2020
typedef struct {
21-
int C;
22-
int sigma;
21+
int C;
22+
int sigma;
2323
} Args;
2424

2525
#ifndef BUILD_MATRIX_FILE_PATH
26-
#define BUILD_MATRIX_FILE_PATH(entry, dir, expect, C_str, sigma_str, path) \
27-
{ \
28-
strcpy((path), "data/"); \
29-
strcat((path), (dir)); \
30-
strcat((path), (entry)->d_name); \
31-
strcat((path), "_C_"); \
32-
strcat((path), (C_str)); \
33-
strcat((path), "_sigma_"); \
34-
strcat((path), (sigma_str)); \
35-
strcat((path), (expect)); \
36-
}
26+
#define BUILD_MATRIX_FILE_PATH(entry, dir, expect, C_str, sigma_str, path) \
27+
{ \
28+
strcpy((path), "data/"); \
29+
strcat((path), (dir)); \
30+
strcat((path), (entry)->d_name); \
31+
strcat((path), "_C_"); \
32+
strcat((path), (C_str)); \
33+
strcat((path), "_sigma_"); \
34+
strcat((path), (sigma_str)); \
35+
strcat((path), (expect)); \
36+
}
3737
#endif
3838

3939
#ifndef FORMAT_AND_STRIP_MATRIX_FILE
40-
#define FORMAT_AND_STRIP_MATRIX_FILE(A, entry, C_str, sigma_str) \
41-
{ \
42-
sprintf((C_str), "%d", (A).C); \
43-
sprintf((sigma_str), "%d", (A).sigma); \
44-
char *dot = strrchr((entry)->d_name, '.'); \
45-
if (dot != NULL) { \
46-
*dot = '\0'; \
47-
} \
48-
}
40+
#define FORMAT_AND_STRIP_MATRIX_FILE(A, entry, C_str, sigma_str, arguments) \
41+
{ \
42+
sprintf((C_str), "%d", arguments->C); \
43+
sprintf((sigma_str), "%d", arguments->sigma); \
44+
char* dot = strrchr((entry)->d_name, '.'); \
45+
if (dot != NULL) { \
46+
*dot = '\0'; \
47+
} \
48+
}
4949
#endif
5050

5151
#ifndef BUILD_VECTOR_FILE_PATH
52-
#define BUILD_VECTOR_FILE_PATH(entry, dir, expect, path) \
53-
{ \
54-
strcpy((path), "data/"); \
55-
strcat((path), (dir)); \
56-
strcat((path), (entry)->d_name); \
57-
strcat((path), (expect)); \
58-
}
52+
#define BUILD_VECTOR_FILE_PATH(entry, dir, expect, path) \
53+
{ \
54+
strcpy((path), "data/"); \
55+
strcat((path), (dir)); \
56+
strcat((path), (entry)->d_name); \
57+
strcat((path), (expect)); \
58+
}
5959
#endif
6060

6161
#ifndef FORMAT_AND_STRIP_VECTOR_FILE
62-
#define FORMAT_AND_STRIP_VECTOR_FILE(entry) \
63-
{ \
64-
char *dot = strrchr((entry)->d_name, '.'); \
65-
if (dot != NULL) { \
66-
*dot = '\0'; \
67-
} \
68-
}
62+
#define FORMAT_AND_STRIP_VECTOR_FILE(entry) \
63+
{ \
64+
char* dot = strrchr((entry)->d_name, '.'); \
65+
if (dot != NULL) { \
66+
*dot = '\0'; \
67+
} \
68+
}
6969
#endif
7070

7171
#ifndef STR_LEN
@@ -77,54 +77,57 @@ int sigma;
7777
#define ARRAY_ALIGNMENT 64
7878
#endif
7979

80-
static int diff_files(const char *expectedData, const char *reportedData) {
81-
FILE *f1 = fopen(expectedData, "r");
82-
FILE *f2 = fopen(reportedData, "r");
83-
84-
if (f1 == NULL || f2 == NULL) {
85-
perror("Error opening file");
86-
return 1;
87-
}
88-
89-
char line1[2048], line2[2048];
90-
int line_number = 1; // Line number counter
91-
92-
// Compare lines until one of the files ends
93-
while (fgets(line1, sizeof(line1), f1) != NULL && fgets(line2, sizeof(line2), f2) != NULL) {
94-
if (strcmp(line1, line2) != 0) { // If the lines are different
95-
printf("Files differ at line %d:\n", line_number);
96-
printf("File 1 (%s): %s\n", expectedData, line1);
97-
printf("File 2 (%s): %s\n", reportedData, line2);
98-
fclose(f1);
99-
fclose(f2);
100-
return 1; // Return 1 as soon as a difference is found
101-
}
102-
line_number++;
103-
}
104-
105-
// Handle case where one file has more lines
106-
if (fgets(line1, sizeof(line1), f1) != NULL || fgets(line2, sizeof(line2), f2) != NULL) {
107-
printf("Files differ at line %d:\n", line_number);
108-
if (fgets(line1, sizeof(line1), f1) != NULL) {
109-
printf("File 1 (%s): %s\n", expectedData, line1);
110-
} else {
111-
printf("File 1 (%s): (no more lines)\n", expectedData);
112-
}
113-
114-
if (fgets(line2, sizeof(line2), f2) != NULL) {
115-
printf("File 2 (%s): %s\n", reportedData, line2);
116-
} else {
117-
printf("File 2 (%s): (no more lines)\n", reportedData);
118-
}
119-
120-
fclose(f1);
121-
fclose(f2);
122-
return 1; // Files are different if one ends before the other
123-
}
124-
125-
fclose(f1);
126-
fclose(f2);
127-
return 0; // Files are identical
80+
static int diff_files(const char* expectedData, const char* reportedData)
81+
{
82+
FILE* f1 = fopen(expectedData, "r");
83+
FILE* f2 = fopen(reportedData, "r");
84+
85+
if (f1 == NULL || f2 == NULL) {
86+
perror("Error opening file");
87+
return 1;
88+
}
89+
90+
char line1[2048], line2[2048];
91+
int line_number = 1; // Line number counter
92+
93+
// Compare lines until one of the files ends
94+
while (fgets(line1, sizeof(line1), f1) != NULL &&
95+
fgets(line2, sizeof(line2), f2) != NULL) {
96+
if (strcmp(line1, line2) != 0) { // If the lines are different
97+
printf("Files differ at line %d:\n", line_number);
98+
printf("File 1 (%s): %s\n", expectedData, line1);
99+
printf("File 2 (%s): %s\n", reportedData, line2);
100+
fclose(f1);
101+
fclose(f2);
102+
return 1; // Return 1 as soon as a difference is found
103+
}
104+
line_number++;
105+
}
106+
107+
// Handle case where one file has more lines
108+
if (fgets(line1, sizeof(line1), f1) != NULL ||
109+
fgets(line2, sizeof(line2), f2) != NULL) {
110+
printf("Files differ at line %d:\n", line_number);
111+
if (fgets(line1, sizeof(line1), f1) != NULL) {
112+
printf("File 1 (%s): %s\n", expectedData, line1);
113+
} else {
114+
printf("File 1 (%s): (no more lines)\n", expectedData);
115+
}
116+
117+
if (fgets(line2, sizeof(line2), f2) != NULL) {
118+
printf("File 2 (%s): %s\n", reportedData, line2);
119+
} else {
120+
printf("File 2 (%s): (no more lines)\n", reportedData);
121+
}
122+
123+
fclose(f1);
124+
fclose(f2);
125+
return 1; // Files are different if one ends before the other
126+
}
127+
128+
fclose(f1);
129+
fclose(f2);
130+
return 0; // Files are identical
128131
}
129132

130133
#endif //__COMMON_H_

0 commit comments

Comments
 (0)