Skip to content

Commit e1d1477

Browse files
authored
Merge pull request ERGO-Code#2493 from ERGO-Code/valgrind-example
Reset global scheduler in C and Cpp examples
2 parents 9e4d8c4 + 313b07a commit e1d1477

File tree

3 files changed

+90
-1
lines changed

3 files changed

+90
-1
lines changed

.github/workflows/valgrind.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,82 @@ jobs:
9292
--output-on-failure \
9393
2>&1 | tee logfile2
9494
95+
- name: Check log for Errors
96+
working-directory: ${{runner.workspace}}/build
97+
shell: bash
98+
run: |
99+
cat logfile2
100+
OUTPUT='ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)'
101+
if grep -q "$OUTPUT" logfile2; then
102+
exit 0
103+
fi
104+
exit 1
105+
106+
examples:
107+
runs-on: ${{ matrix.os }}
108+
strategy:
109+
matrix:
110+
os: [ubuntu-latest]
111+
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- name: Install Valgrind
116+
run: sudo apt-get update && sudo apt-get install valgrind
117+
118+
- name: Create Build Environment
119+
run: cmake -E make_directory ${{runner.workspace}}/build
120+
121+
- name: Configure CMake All
122+
shell: bash
123+
working-directory: ${{runner.workspace}}/build
124+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug
125+
126+
- name: Build All
127+
working-directory: ${{runner.workspace}}/build
128+
shell: bash
129+
run: |
130+
cmake --build . --parallel
131+
132+
- name: Test cpp example
133+
working-directory: ${{runner.workspace}}/build
134+
shell: bash
135+
run: |
136+
valgrind \
137+
--leak-check=full \
138+
--show-leak-kinds=all \
139+
--track-origins=yes \
140+
-s \
141+
./bin/call_highs_from_cpp \
142+
--timeout 1000 \
143+
--output-on-failure \
144+
2>&1 | tee logfile2
145+
146+
- name: Check log for Errors
147+
working-directory: ${{runner.workspace}}/build
148+
shell: bash
149+
run: |
150+
cat logfile2
151+
OUTPUT='ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)'
152+
if grep -q "$OUTPUT" logfile2; then
153+
exit 0
154+
fi
155+
exit 1
156+
157+
- name: Test C example
158+
working-directory: ${{runner.workspace}}/build
159+
shell: bash
160+
run: |
161+
valgrind \
162+
--leak-check=full \
163+
--show-leak-kinds=all \
164+
--track-origins=yes \
165+
-s \
166+
./bin/call_highs_from_c_minimal \
167+
--timeout 1000 \
168+
--output-on-failure \
169+
2>&1 | tee logfile2
170+
95171
- name: Check log for Errors
96172
working-directory: ${{runner.workspace}}/build
97173
shell: bash

examples/call_highs_from_cpp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,7 @@ int main() {
172172
cout << endl;
173173
}
174174

175+
highs.resetGlobalScheduler(true);
176+
175177
return 0;
176178
}

highs/interfaces/highs_c_api.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ HighsInt Highs_lpCall(const HighsInt num_col, const HighsInt num_row,
6161
if (copy_row_basis) row_basis_status[i] = (HighsInt)basis.row_status[i];
6262
}
6363
}
64+
65+
highs.resetGlobalScheduler(true);
66+
6467
return (HighsInt)status;
6568
}
6669

@@ -104,6 +107,8 @@ HighsInt Highs_mipCall(const HighsInt num_col, const HighsInt num_row,
104107
}
105108
}
106109

110+
highs.resetGlobalScheduler(true);
111+
107112
return (HighsInt)status;
108113
}
109114

@@ -160,12 +165,18 @@ HighsInt Highs_qpCall(
160165
if (copy_row_basis) row_basis_status[i] = (HighsInt)basis.row_status[i];
161166
}
162167
}
168+
169+
highs.resetGlobalScheduler(true);
170+
163171
return (HighsInt)status;
164172
}
165173

166174
void* Highs_create(void) { return new Highs(); }
167175

168-
void Highs_destroy(void* highs) { delete (Highs*)highs; }
176+
void Highs_destroy(void* highs) {
177+
Highs::resetGlobalScheduler(true);
178+
delete (Highs*)highs;
179+
}
169180

170181
const char* Highs_version(void) { return highsVersion(); }
171182
HighsInt Highs_versionMajor(void) { return highsVersionMajor(); }

0 commit comments

Comments
 (0)