Skip to content

Commit

Permalink
Merge pull request #154 from davidsd/minor-fixes
Browse files Browse the repository at this point in the history
Minor improvements: new spectrum test, updated Macbook instructions
  • Loading branch information
vasdommes authored Nov 28, 2023
2 parents d6b948b + 9c480de commit de39a62
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 23 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ See [#114](https://github.com/davidsd/sdpb/pull/114), [#128](https://github.com/

- Updated installations
for [BU](docs/site_installs/Boston.md), [Caltech](docs/site_installs/Caltech.md), [Expanse](docs/site_installs/Expanse.md), [Harvard](docs/site_installs/Harvard.md),
and [Imperial College](docs/site_installs/Imperial.md) clusters.
and [Imperial College](docs/site_installs/Imperial.md) clusters, with example scripts.
- Added [Apple MacBook](docs/site_installs/Apple_MacBook.md) installation instructions.

See https://github.com/davidsd/sdpb/releases/tag/2.6.0 for the full changelog.

Expand Down
26 changes: 20 additions & 6 deletions docs/site_installs/Apple_MacBook.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Apple MacBook Air M2
# Apple MacBook

Chip: Apple M2
macOS: Ventura 13.6
These instructions have been tested for MacBook Air M2 and for MacBook Air 2017 (Intel i5).

The only difference is that for ARM processors you have to set `-arch arm64` compiler flag for sdpb (see below).

# Build SDPB from sources

Expand Down Expand Up @@ -36,13 +37,26 @@ using default Python 3, at least on some laptops.

## sdpb

### Checkout
git clone https://github.com/davidsd/sdpb.git
cd sdpb

### Configure

./waf configure --elemental-dir=$HOME/install --boost-dir=/opt/homebrew/opt/boost/ --gmpxx-dir=/opt/homebrew/Cellar/gmp/6.3.0/ --mpfr-dir=/opt/homebrew/Cellar/mpfr/4.2.1/ --rapidjson-dir=/opt/homebrew/Cellar/rapidjson/1.1.0 --libarchive-dir=/opt/homebrew/Cellar/libarchive/3.7.2/ --prefix=$HOME/install/sdpb-master

If waf fails to find some package, e.g. `boost`, check the installation directory by calling, e.g. `brew info boost` and
update `--boost-dir` argument above.

The above `./waf configure` command works or x86 processors (e.g. Intel i5), but may fail for or ARM processors (e.g.
M2) with linker warnings `found architecture 'arm64', required architecture 'x86_64` in `build/config.log`.
In that case, you should set `-arch arm64` flag explicitly:

CXXFLAGS="${CXXFLAGS} -arch arm64" LDFLAGS="${LDFLAGS} -arch arm64" ./waf configure --elemental-dir=$HOME/install --boost-dir=/opt/homebrew/opt/boost/ --gmpxx-dir=/opt/homebrew/Cellar/gmp/6.3.0/ --mpfr-dir=/opt/homebrew/Cellar/mpfr/4.2.1/ --rapidjson-dir=/opt/homebrew/Cellar/rapidjson/1.1.0 --libarchive-dir=/opt/homebrew/Cellar/libarchive/3.7.2/ --prefix=$HOME/install/sdpb-master

### Compile and install

./waf # build binaries
./build/sdpb --help # run SDPB binary
./test/run_all_tests.sh # run tests to check correctness
./waf install # install sdpb to --prefix=$HOME/install/sdpb-master

If waf fails to find some package, e.g. `boost`, check the installation directory by calling, e.g. `brew info boost` and
update `--boost-dir` argument above.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0"?>
<!--Two 2x2 matrices, generated by mathematica/Tests.m/testSDPMatrix-->
<sdp>
<objective>
<elt>0</elt>
Expand Down
7 changes: 7 additions & 0 deletions test/data/spectrum/matrix/solution/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
terminateReason = "found primal-dual optimal solution";
primalObjective = 0.6012421506913844846540859655147697554285334896813495334936294574176056371903459588831856774634560843444107605150815727292631115893066950304558334746042092132489421489156314264603193078537481156934251701492897832674289405158147967481152744311283343454291848702513963522398;
dualObjective = 0.6012421506913844846540859655141182098411604268159238514655621530575912555464601071614665289397314538666289135991872221745174554797462589958935884515145681144913724032340358267339908340154216980380815708829242456700319963805037811501536563693522764089795881806522790091923;
dualityGap = 5.418329259050060852643029705556072127572858592307093415113938756983287620195844418775303020842420808233626435546739290798788750220357580840921665774950307442052932312947836761796077871239708030250253569494653150978778249244463473231606902580036891892077156404966841349987e-31;
primalError = 2.396757611526323875533403900091670287853628762587889553653211000467514848479911427424266732315419817144797370343462326090776798428449295719559000397189773408905887286041232226125142246301522933867088262557180473985454781536817792720153995024838827335235352418278455757453e-274;
dualError = 1.015350529545233472880909391014192227051481508117206628827694088158980051398167764332486345494452204634819204236287703629056335540324442191635501744662796370454426283578414835242978355065929624038987690655987486328147109038116221546764989465574694326974114912964617861293e-246;
Solver runtime = 133;
16 changes: 16 additions & 0 deletions test/data/spectrum/matrix/solution/x_0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
15 1
7.22226316159341686622588502593311878808953847279189437269385048487317465852722591731843918410402719301917936570547584456572577721654856689132610019936469679238976864130764370504218903563825104788240306741605446111905390055741763363603785841774435845157479238892808887331e-32
3.84211586945501515596501252194221119322255886830699000468868498044266929721204398047600247526925881713349011088355880049785011912582061499042521046200357373711084789612251227622267404773041045965098142060412473272867231329578120906771136749752062084583402293502311484536e-32
7.71676642716018986376685648849025972868926080499354148421088820722703690015812820757280405309360823665537836715539033473085553542114558302801716710471647712337939924544592117429498726580042539904789094310523066538432148418447861657786842852811244475953735130805199687313e-31
3.60568733155244440018268079135215122661390296422782503926336580733895138883788827224352159521269528457264681879154579260906007191584572449076131874207733115613277854717561146914828187713967284547018012993703402914373396574475426758037346488389464849850118369110184204961e-32
4.2306126883526006275949275152733041020955621410511945036727291174892945016635806444089184639142949119095692058781376039120669946302920666513195658644834907406614649217220550593293644744831594051039662210781911015268331713730024991197818565105913007780678262180031922257e-33
-1.13653785217895691980779126382090866114817106693363855485117310519080801014714318785959845532319920261602300789272894559703087420998496874525094706142820627529939447819028340745393877176499158459207846885344074128266063867015112617674660671869161263840754600520904319512e-31
1.99546634343343694135491741301047505362541558884292329165361638205762103846027322040246047749438518122979051446056353879403468119517111229822572002523978001341293408564673720153257498506811906436509148798552213255101708881959840521266789647504027942328594833090933019475e-31
-7.513823684477472323614052926095507016950813041057276795827600998719079385473336753786415428842157765537073297795595055511616409888214642393316484012913621952081601790956238756906001329401743662213277813050020965654915503252520807261320615540816825815460779938906570482e-31
-1.03906916364696779212781317025464500527750138783522748125723517256006839929948360016680796511930055821359392961106052981753280456904372698293800284899430402330415380364594815789634265635140463045519575884339076432636539068081292436079476385409250471900084165738524849283e-31
2.52224971122639760617084012360724313095809653700782286541573119703734185586569085411512511128449795577085014803448535014314555599756899971882042567982923689905545220854374663024219476363251445607556976224464226393119214054547427356895556062183519788653868946995407438418e-32
8.5622663525882761194624739046319569495685167695418944453106169381305754750391785919915729976257022090484457867535189260561365540937124901273615408940828364593943347484831336449276169753002746111179876332872086677899956220220866694389860688098910220780053955361989962184e-32
-1.20157481592158843149253339170952713540369160147956122110661434890409261299474108685047850919833216810181570530135408383821043452285913467570606342351725253643863557016487719270533109069857567932565673275354364964554681604131122801640580792960971251964443058836719565575e-31
3.37626060403662124260872633003988265787145777653594379568483239212790918649817373869141288459224889902743658384061270974084103004590059535421131294296410630384151581162698426263009940893208528558319742969819455031415751232640626687346900773186434954881668088090408373369e-31
4.56999946663845978834704245364173713289657670579176975879223524565649217809632749474010684083149387429073596695945820534518583726859152385006024454914932811918082523954960362332242406694819303799061741999006577695970098753025009465246302377834156564003061865130545106607e-32
8.27316619509510644612111936554905490953207761496640138578876352549421861530576701181433005328371783355201413811494806545410806535308546816539514957040615795031845952560336361634707694918764035376876288152506324842633690203466227806634787728620962547633894974745894785539e-33
16 changes: 16 additions & 0 deletions test/data/spectrum/matrix/solution/x_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
15 1
0.154318085216177847841135557655695203269409266552838948258670050273117789758569095695902125944045647401872852356962822714330005965344644871574469767673156985832057101930327577866724886508537692970912947251279331676204437045421470916622454298578750201105340915709747452985
-0.264582470393169558013130618774332295040536240696132317162691217067656541258494945720466500549330808945229231336024329415964051515761640631175746127593881915235707673625689551756208705268397827765207379215410904331553637620533064014584541978941805369771099306484690244154
0.413087332746493275297801475169374358225559153534750720238234315159959196546287939855003720270580277820461143480428391014088119807708089377865089157974208715358200647056025013865442465051569021338916204683179886327628651137448406666081645001955257034477002959977093243161
0.221856412074050759569277216783921774046951904826437247446193547853287984966778874106181776980295465271822452734647804347501035406194512768247931085517450138861564819041575970241513511167228615811833325304813004979476749698262172510482401230524664937730207920505305883642
-0.0463648660433789658891128520098930251702871931254095240400301233664242189502685869546976031028981970519093036397954382885427013812691204377827025275515694253677275072597173266656940522648603772924654664320671037224865666451147218120058389010995738501581698283546094858678
-0.366751782552700285242327501612007125387789025006873138542963092803887297814148013659371725275237685988083853301783780858801774835185239567814839165207473777897710236399529757055850715497423312267979686313512264627572070199647916958658486777171066478352020688527634950326
0.628805706816269256297000888545575113733907844340217057722086657811423629072898426556022870308299139533579618643681093347280792652329527237972477714789597624756303265395125029486156469040662670008083045912829131315010397430119596008510316078749840489582837585269332609114
-0.981741805715681469933858390398735178715571691356116493204212871621546722422862658619347709456608239286176260887971977041371803872844951701718508416826352257326031238313180819322820882103499512332128501768647690299133678929279470174733172352193156926844335664777699092336
-0.527263116859711733838010873369961667291191110199549080170336005608594323623161507120396242020710695201034169725692984415452236679901422823565238938215268489825332920505249213926016079427696974476905838029145596828186189367382530169508386228745543304449923936504496179491
0.11019056674663659905359967077668207360370104608431992500023123347977331093425477411266076560479236538018156956264912073827442639523357847343362994799338131614205791432843938916789092627756994912614091747078064576749365821183136192183479877324045174732038021479600396116
0.217905227726805352563324235804023800675144944631554510162921751344603599385161299053369977285630381030269478798689623608589098862833026206266331723212430740936294541390483079851052023855622186054567136346636781902343562440469993375912538671792861423754839671611429692876
-0.373604321118807101454839619256766723866092033137018772226445961594205550340457429219865289978206491160545923957250547021644840539436292511040844447564373655722688894181362939052864224116945450912599169922396977321099601219096457913998478797705233572647214925289210480952
0.583300973356988495937115055857713367093513091438541180032378649074867498389027948033340668586613914594183475071296092640558667083337750557999653182895374780991835926473761900172785658015917783046969616860442364863626363605958569769712893305350730413443847972082232583996
0.313272886505333065646046346903144937458610583099302617556169291163687762946589987179230974893824301257751488611520456211221443372011729375331678551264335393815587322734816132754469382205639311747523300051568336092503536264974305032335045380243638200024516664041705179556
-0.0654696219147110091199399709555868348253840287887996258874567065371417984246580809086060171757732517853914584413894982026442055045549330649503963380566933801584293192634169665848219564904985861920533985997861739026689517752417431497223250285186858972737110244390955693669
2 changes: 2 additions & 0 deletions test/data/spectrum/matrix/solution/y.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 1
-0.601242150691384484654085965514118209841160426815923851465562153057591255546460107161466528939731453866628913599187222174517455479746258995893588451514568114491372403234035826733990834015421698038081570882924245670031996380503781150153656369352276408979588180652279009192
22 changes: 22 additions & 0 deletions test/data/spectrum/matrix/spectrum.orig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"zeros":
[
],
"error": "5.429771596769312184535668038468911539759940662901028162749495519013509037247620960768141321327882432805452272879980489718253827609253386051253288046180277373127257180078401955697263585532647568639824447988688492466336485053375681892993114530873804445879448324419581326089371655314254986752860257182521168499296e-31"
},
{
"zeros":
[
{
"zero": "1.344386196155997494649115541556055680779288071443475472658297186359057835165095752578565899117525650315582818302022506817287388344444495185930471309274477211608561831573348526026012247487431161798482826542828707167515732449524468157043917696557720551156378398246706363426750115300061228240534453019807402628912",
"lambda":
[
"-0.3559184903564825058880080430651484728773534402055623418111493954738237968330942679483672624227710803343181043089677314088630363780538243012805308586583878323185576389297608278031796287652332797309891956140099169830705502765883745239440114220174206083500796947263763821895044734809117530057953027490216952969409",
"0.4229372746520496473797877248830593349110374988636914636540851411628556827814030398913949809091012112986363672037669076407276396951757496137173963235720053945008178020087908994931063752019636206183453627322858073988658025335122961607407936659872800542120124152580465834943202526362014922162994798565661901716801"
]
}
],
"error": "2.106341529054153493822615203762740915252698509836743151085700344932498499775784575219216154565981214469609051205877899311066284177077079288235775383183588788802297257627895669117791050910283709418273131529034572615330843471944050739804017779982180774619544925919578248471888246304789464530575701354050007739832e-27"
}
]
4 changes: 2 additions & 2 deletions test/src/integration_tests/cases/end-to-end.test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ namespace
{"--sdpDir", sdp_zip},
{"--outDir", (output_dir / "out").string()},
{"--checkpointDir", (output_dir / "ck").string()}};
runner.create_nested("sdpb/run")
.mpi_run({"build/sdpb", default_sdpb_args}, args, num_procs);
runner.create_nested("sdpb").mpi_run({"build/sdpb", default_sdpb_args},
args, num_procs);

// SDPB runs with --precision=<precision>
// We check test output up to lower precision=<sdpb_output_diff_precision>
Expand Down
33 changes: 19 additions & 14 deletions test/src/integration_tests/cases/spectrum.test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ namespace fs = std::filesystem;
TEST_CASE("spectrum")
{
INFO("Simple spectrum test");
Test_Util::Test_Case_Runner runner("spectrum");

fs::path data_dir = runner.data_dir;
fs::path output_dir = runner.output_dir;
for(std::string name : {"1d", "matrix"})
DYNAMIC_SECTION(name)
{
Test_Util::Test_Case_Runner runner("spectrum/" + name);

Test_Util::Test_Case_Runner::Named_Args_Map args{
{"--input", (data_dir / "pvm.xml").string()},
{"--solution", (data_dir / "solution").string()},
{"--output", (output_dir / "spectrum.json").string()},
{"--precision", "1024"},
{"--threshold", "1e-10"},
{"--format", "PVM"}};
fs::path data_dir = runner.data_dir;
fs::path output_dir = runner.output_dir;

runner.create_nested("run").mpi_run({"build/spectrum"}, args);
Test_Util::Test_Case_Runner::Named_Args_Map args{
{"--input", (data_dir / "pvm.xml").string()},
{"--solution", (data_dir / "solution").string()},
{"--output", (output_dir / "spectrum.json").string()},
{"--precision", "1024"},
{"--threshold", "1e-10"},
{"--format", "PVM"}};

auto out = output_dir / "spectrum.json";
auto out_orig = data_dir / "spectrum_orig.json";
Test_Util::REQUIRE_Equal::diff_spectrum(out, out_orig, 1024, 1024);
runner.mpi_run({"build/spectrum"}, args, 2);

auto out = output_dir / "spectrum.json";
auto out_orig = data_dir / "spectrum.orig.json";
Test_Util::REQUIRE_Equal::diff_spectrum(out, out_orig, 1024, 1024 / 2);
}
}

0 comments on commit de39a62

Please sign in to comment.