Skip to content

Commit a917e95

Browse files
committed
Formatted
1 parent 33ba3c2 commit a917e95

File tree

7 files changed

+196
-191
lines changed

7 files changed

+196
-191
lines changed

check/TestLpSolvers.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
const bool dev_run = false;
66

7-
87
void testDualObjective(const std::string model) {
98
HighsStatus return_status;
109

check/TestMipSolver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,8 @@ TEST_CASE("issue-2171", "[highs_test_mip_solver]") {
822822
}
823823

824824
TEST_CASE("issue-2204", "[highs_test_mip_solver]") {
825-
std::string filename = std::string(HIGHS_DIR) + "/check/instances/issue-2204.mps";
825+
std::string filename =
826+
std::string(HIGHS_DIR) + "/check/instances/issue-2204.mps";
826827
Highs highs;
827828
highs.setOptionValue("output_flag", dev_run);
828829
highs.setOptionValue("mip_rel_gap", 0);

check/TestPdlp.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#include "HCheckConfig.h"
2+
#include "HConfig.h"
23
#include "Highs.h"
34
#include "SpecialLps.h"
45
#include "catch.hpp"
56

6-
#include "HConfig.h"
7-
87
const bool dev_run = false;
98
const double double_equal_tolerance = 1e-3;
109

@@ -97,21 +96,21 @@ TEST_CASE("pdlp-distillation-lp", "[pdlp]") {
9796
// optimal = false;
9897
// }
9998

100-
optimal = false;
99+
optimal = false;
101100

102-
run_status = highs.run();
103-
if (dev_run) highs.writeSolution("", 1);
104-
REQUIRE(std::abs(info.objective_function_value - optimal_objective) <
105-
double_equal_tolerance);
106-
if (optimal) {
107-
REQUIRE(run_status == HighsStatus::kOk);
108-
REQUIRE(highs.getModelStatus() == HighsModelStatus::kOptimal);
109-
} else {
110-
REQUIRE(run_status == HighsStatus::kWarning);
111-
REQUIRE(highs.getModelStatus() == HighsModelStatus::kUnknown);
112-
}
101+
run_status = highs.run();
102+
if (dev_run) highs.writeSolution("", 1);
103+
REQUIRE(std::abs(info.objective_function_value - optimal_objective) <
104+
double_equal_tolerance);
105+
if (optimal) {
106+
REQUIRE(run_status == HighsStatus::kOk);
107+
REQUIRE(highs.getModelStatus() == HighsModelStatus::kOptimal);
108+
} else {
109+
REQUIRE(run_status == HighsStatus::kWarning);
110+
REQUIRE(highs.getModelStatus() == HighsModelStatus::kUnknown);
111+
}
113112

114-
// IG todo add iteration count
113+
// IG todo add iteration count
115114
// HighsInt pdlp_iteration_count = highs.getInfo().pdlp_iteration_count;
116115
// REQUIRE(pdlp_iteration_count > 0);
117116
// REQUIRE(pdlp_iteration_count == 160);

check/cublas_example.cpp

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,76 @@
1-
//Example 2. Application Using C and cuBLAS: 0-based indexing
1+
// Example 2. Application Using C and cuBLAS: 0-based indexing
22
//-----------------------------------------------------------
3+
#include <cuda_runtime.h>
4+
#include <math.h>
35
#include <stdio.h>
46
#include <stdlib.h>
5-
#include <math.h>
6-
#include <cuda_runtime.h>
7+
78
#include "cublas_v2.h"
89
#define M 6
910
#define N 5
10-
#define IDX2C(i,j,ld) (((j)*(ld))+(i))
11+
#define IDX2C(i, j, ld) (((j) * (ld)) + (i))
1112

12-
static __inline__ void modify (cublasHandle_t handle, float *m, int ldm, int n, int p, int q, float alpha, float beta){
13-
cublasSscal (handle, n-q, &alpha, &m[IDX2C(p,q,ldm)], ldm);
14-
cublasSscal (handle, ldm-p, &beta, &m[IDX2C(p,q,ldm)], 1);
13+
static __inline__ void modify(cublasHandle_t handle, float* m, int ldm, int n,
14+
int p, int q, float alpha, float beta) {
15+
cublasSscal(handle, n - q, &alpha, &m[IDX2C(p, q, ldm)], ldm);
16+
cublasSscal(handle, ldm - p, &beta, &m[IDX2C(p, q, ldm)], 1);
1517
}
1618

17-
int main (void){
18-
cudaError_t cudaStat;
19-
cublasStatus_t stat;
20-
cublasHandle_t handle;
21-
int i, j;
22-
float* devPtrA;
23-
float* a = 0;
24-
a = (float *)malloc (M * N * sizeof (*a));
25-
if (!a) {
26-
printf ("host memory allocation failed");
27-
return EXIT_FAILURE;
28-
}
29-
for (j = 0; j < N; j++) {
30-
for (i = 0; i < M; i++) {
31-
a[IDX2C(i,j,M)] = (float)(i * N + j + 1);
32-
}
33-
}
34-
cudaStat = cudaMalloc ((void**)&devPtrA, M*N*sizeof(*a));
35-
if (cudaStat != cudaSuccess) {
36-
printf ("device memory allocation failed");
37-
free (a);
38-
return EXIT_FAILURE;
39-
}
40-
stat = cublasCreate(&handle);
41-
if (stat != CUBLAS_STATUS_SUCCESS) {
42-
printf ("CUBLAS initialization failed\n");
43-
free (a);
44-
cudaFree (devPtrA);
45-
return EXIT_FAILURE;
19+
int main(void) {
20+
cudaError_t cudaStat;
21+
cublasStatus_t stat;
22+
cublasHandle_t handle;
23+
int i, j;
24+
float* devPtrA;
25+
float* a = 0;
26+
a = (float*)malloc(M * N * sizeof(*a));
27+
if (!a) {
28+
printf("host memory allocation failed");
29+
return EXIT_FAILURE;
30+
}
31+
for (j = 0; j < N; j++) {
32+
for (i = 0; i < M; i++) {
33+
a[IDX2C(i, j, M)] = (float)(i * N + j + 1);
4634
}
47-
stat = cublasSetMatrix (M, N, sizeof(*a), a, M, devPtrA, M);
48-
if (stat != CUBLAS_STATUS_SUCCESS) {
49-
printf ("data download failed");
50-
free (a);
51-
cudaFree (devPtrA);
52-
cublasDestroy(handle);
53-
return EXIT_FAILURE;
54-
}
55-
modify (handle, devPtrA, M, N, 1, 2, 16.0f, 12.0f);
56-
stat = cublasGetMatrix (M, N, sizeof(*a), devPtrA, M, a, M);
57-
if (stat != CUBLAS_STATUS_SUCCESS) {
58-
printf ("data upload failed");
59-
free (a);
60-
cudaFree (devPtrA);
61-
cublasDestroy(handle);
62-
return EXIT_FAILURE;
63-
}
64-
cudaFree (devPtrA);
35+
}
36+
cudaStat = cudaMalloc((void**)&devPtrA, M * N * sizeof(*a));
37+
if (cudaStat != cudaSuccess) {
38+
printf("device memory allocation failed");
39+
free(a);
40+
return EXIT_FAILURE;
41+
}
42+
stat = cublasCreate(&handle);
43+
if (stat != CUBLAS_STATUS_SUCCESS) {
44+
printf("CUBLAS initialization failed\n");
45+
free(a);
46+
cudaFree(devPtrA);
47+
return EXIT_FAILURE;
48+
}
49+
stat = cublasSetMatrix(M, N, sizeof(*a), a, M, devPtrA, M);
50+
if (stat != CUBLAS_STATUS_SUCCESS) {
51+
printf("data download failed");
52+
free(a);
53+
cudaFree(devPtrA);
6554
cublasDestroy(handle);
66-
for (j = 0; j < N; j++) {
67-
for (i = 0; i < M; i++) {
68-
printf ("%7.0f", a[IDX2C(i,j,M)]);
69-
}
70-
printf ("\n");
71-
}
55+
return EXIT_FAILURE;
56+
}
57+
modify(handle, devPtrA, M, N, 1, 2, 16.0f, 12.0f);
58+
stat = cublasGetMatrix(M, N, sizeof(*a), devPtrA, M, a, M);
59+
if (stat != CUBLAS_STATUS_SUCCESS) {
60+
printf("data upload failed");
7261
free(a);
73-
return EXIT_SUCCESS;
62+
cudaFree(devPtrA);
63+
cublasDestroy(handle);
64+
return EXIT_FAILURE;
65+
}
66+
cudaFree(devPtrA);
67+
cublasDestroy(handle);
68+
for (j = 0; j < N; j++) {
69+
for (i = 0; i < M; i++) {
70+
printf("%7.0f", a[IDX2C(i, j, M)]);
71+
}
72+
printf("\n");
73+
}
74+
free(a);
75+
return EXIT_SUCCESS;
7476
}

check/cublas_gpu_start.cpp

Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,88 @@
1-
//Example 2. Application Using C and cuBLAS: 0-based indexing
1+
// Example 2. Application Using C and cuBLAS: 0-based indexing
22
//-----------------------------------------------------------
3+
#include <cuda_runtime.h>
4+
#include <math.h>
35
#include <stdio.h>
46
#include <stdlib.h>
5-
#include <math.h>
7+
68
#include <iostream>
7-
#include <cuda_runtime.h>
9+
810
#include "cublas_v2.h"
911
#define N 5
1012

13+
int main(void) {
14+
cudaError_t cudaStat;
15+
cublasStatus_t stat;
16+
cublasHandle_t handle;
17+
int i;
18+
float* devPtrA;
19+
float* a = 0;
20+
a = (float*)malloc(N * sizeof(*a));
21+
if (!a) {
22+
printf("host memory allocation failed");
23+
return EXIT_FAILURE;
24+
}
1125

12-
int main (void){
13-
cudaError_t cudaStat;
14-
cublasStatus_t stat;
15-
cublasHandle_t handle;
16-
int i;
17-
float* devPtrA;
18-
float* a = 0;
19-
a = (float *)malloc (N * sizeof (*a));
20-
if (!a) {
21-
printf ("host memory allocation failed");
22-
return EXIT_FAILURE;
23-
}
26+
for (i = 0; i < N; i++) a[i] = (float)(i * N);
27+
for (i = 0; i < N; i++) printf("%7.0f", a[(i)]);
28+
std::cout << std::endl;
2429

25-
for (i = 0; i < N; i++)
26-
a[i] = (float)(i * N);
27-
for (i = 0; i < N; i++)
28-
printf ("%7.0f", a[(i)]);
29-
std::cout << std::endl;
30-
31-
cudaStat = cudaMalloc ((void**)&devPtrA, N*sizeof(*a));
32-
if (cudaStat != cudaSuccess) {
33-
printf ("device memory allocation failed");
34-
free (a);
35-
return EXIT_FAILURE;
36-
}
37-
stat = cublasCreate(&handle);
38-
if (stat != CUBLAS_STATUS_SUCCESS) {
39-
printf ("CUBLAS initialization failed\n");
40-
free (a);
41-
cudaFree (devPtrA);
42-
return EXIT_FAILURE;
43-
}
30+
cudaStat = cudaMalloc((void**)&devPtrA, N * sizeof(*a));
31+
if (cudaStat != cudaSuccess) {
32+
printf("device memory allocation failed");
33+
free(a);
34+
return EXIT_FAILURE;
35+
}
36+
stat = cublasCreate(&handle);
37+
if (stat != CUBLAS_STATUS_SUCCESS) {
38+
printf("CUBLAS initialization failed\n");
39+
free(a);
40+
cudaFree(devPtrA);
41+
return EXIT_FAILURE;
42+
}
4443

45-
stat = cublasSetVector(N, sizeof(*a), a, 1, devPtrA, 1);
46-
if (stat != CUBLAS_STATUS_SUCCESS) {
47-
printf ("data download failed");
48-
free (a);
49-
cudaFree (devPtrA);
50-
cublasDestroy(handle);
51-
return EXIT_FAILURE;
52-
}
44+
stat = cublasSetVector(N, sizeof(*a), a, 1, devPtrA, 1);
45+
if (stat != CUBLAS_STATUS_SUCCESS) {
46+
printf("data download failed");
47+
free(a);
48+
cudaFree(devPtrA);
49+
cublasDestroy(handle);
50+
return EXIT_FAILURE;
51+
}
5352

54-
float r;
55-
56-
cublasStatus_t status = cublasSnrm2(handle, N, devPtrA, 1, &r);
57-
if (stat != CUBLAS_STATUS_SUCCESS) {
58-
printf ("error at dnorm");
59-
free (a);
60-
cudaFree (devPtrA);
61-
cublasDestroy(handle);
62-
return EXIT_FAILURE;
63-
}
53+
float r;
6454

65-
std::cout << "Snorm: " << r << std::endl << std::endl;
55+
cublasStatus_t status = cublasSnrm2(handle, N, devPtrA, 1, &r);
56+
if (stat != CUBLAS_STATUS_SUCCESS) {
57+
printf("error at dnorm");
58+
free(a);
59+
cudaFree(devPtrA);
60+
cublasDestroy(handle);
61+
return EXIT_FAILURE;
62+
}
6663

67-
float * b;
68-
b = (float *)malloc (N * sizeof (*b));
64+
std::cout << "Snorm: " << r << std::endl << std::endl;
6965

70-
stat = cublasGetVector(N, sizeof(*a), devPtrA, 1, b, 1);
71-
if (stat != CUBLAS_STATUS_SUCCESS) {
72-
printf ("data upload failed");
73-
free (a);
74-
cudaFree (devPtrA);
75-
cublasDestroy(handle);
76-
return EXIT_FAILURE;
77-
}
66+
float* b;
67+
b = (float*)malloc(N * sizeof(*b));
7868

79-
cudaFree (devPtrA);
69+
stat = cublasGetVector(N, sizeof(*a), devPtrA, 1, b, 1);
70+
if (stat != CUBLAS_STATUS_SUCCESS) {
71+
printf("data upload failed");
72+
free(a);
73+
cudaFree(devPtrA);
8074
cublasDestroy(handle);
75+
return EXIT_FAILURE;
76+
}
8177

82-
for (i = 0; i < N; i++) {
83-
printf ("%7.0f", b[(i)]);
84-
}
85-
printf ("\n");
78+
cudaFree(devPtrA);
79+
cublasDestroy(handle);
8680

87-
free(a);
88-
return EXIT_SUCCESS;
81+
for (i = 0; i < N; i++) {
82+
printf("%7.0f", b[(i)]);
83+
}
84+
printf("\n");
85+
86+
free(a);
87+
return EXIT_SUCCESS;
8988
}

src/lp_data/HighsOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ class HighsOptions : public HighsOptionsStruct {
788788

789789
record_int = new OptionRecordInt(
790790
"simplex_scale_strategy",
791-
"Simplex scaling strategy: off / choose / equilibration (default) / forced "
791+
"Simplex scaling strategy: off / choose / equilibration (default) / "
792+
"forced "
792793
"equilibration / max value (0/1/2/3/4)",
793794
advanced, &simplex_scale_strategy, kSimplexScaleStrategyMin,
794795
kSimplexScaleStrategyEquilibration, kSimplexScaleStrategyMax);

0 commit comments

Comments
 (0)