Aatch / ramp

RAMP - Rust Arithmetic in Multiple Precision
Apache License 2.0
261 stars 38 forks source link

Infinite loop on ARM #69

Closed MagaTailor closed 7 years ago

MagaTailor commented 8 years ago

Trying to run the multiply example from zcdziura/pumpkin on ARM Linux, never fnishes, not even getting to the first println. (the example takes just 12s on x86)

Letting it run for a while produces the following profile:

--------------------------------------------------------------------------------
           Ir 
--------------------------------------------------------------------------------
5,158,779,308  PROGRAM TOTALS

--------------------------------------------------------------------------------
           Ir  file:function
--------------------------------------------------------------------------------
1,097,181,200  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::limb::mul::h42f9717ba7a0c591 [/pumpkin/target/release/examples/multiply]
  822,885,900  /src/libcore/num/mod.rs:ramp::ll::limb::mul::h42f9717ba7a0c591
  680,088,987  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::mul::submul_1_generic::hbeb09a870749cc21
  440,138,242  /ramp-0.2.4/src/ll/mul.rs:ramp::ll::mul::submul_1_generic::hbeb09a870749cc21 [/pumpkin/target/release/examples/multiply]
  370,224,000  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::mul::addmul_1_generic::hfa83cc681e5292db
  274,295,300  /src/libcore/ops.rs:ramp::ll::limb::mul::h42f9717ba7a0c591
  263,206,125  /ramp-0.2.4/src/ll/mul.rs:ramp::ll::mul::addmul_1_generic::hfa83cc681e5292db [/pumpkin/target/release/examples/multiply]
  250,919,928  /src/libcore/ptr.rs:ramp::ll::mul::submul_1_generic::hbeb09a870749cc21
  170,022,246  /src/libcore/num/mod.rs:ramp::ll::mul::submul_1_generic::hbeb09a870749cc21
  130,156,875  /src/libcore/ptr.rs:ramp::ll::mul::addmul_1_generic::hfa83cc681e5292db
   92,556,000  /src/libcore/num/mod.rs:ramp::ll::mul::addmul_1_generic::hfa83cc681e5292db
   61,571,727  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::addsub::add_n_generic::h8017fb3f696c3827
   49,425,624  /ramp-0.2.4/src/ll/div.rs:ramp::ll::div::invert_pi::h37e4002131b72562 [/pumpkin/target/release/examples/multiply]
   35,384,665  /ramp-0.2.4/src/ll/addsub.rs:ramp::ll::addsub::add_n_generic::h8017fb3f696c3827 [/pumpkin/target/release/examples/multiply]
   32,008,950  /ramp-0.2.4/src/ll/mul.rs:ramp::ll::mul::mul_basecase::h24ea3d00965ade9a [/pumpkin/target/release/examples/multiply]
   30,008,121  /build/eglibc-euxZvP/eglibc-2.19/malloc/malloc.c:_int_malloc [/lib/arm-linux-gnueabihf/libc-2.19.so]
   24,692,260  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::div::divrem_3by2::h3ad1011bead13922
   23,355,848  /src/libcore/num/mod.rs:ramp::ll::div::divrem_3by2::h3ad1011bead13922
   19,817,019  /src/libcore/ptr.rs:ramp::ll::addsub::add_n_generic::h8017fb3f696c3827
   19,476,292  /build/eglibc-euxZvP/eglibc-2.19/malloc/malloc.c:_int_free [/lib/arm-linux-gnueabihf/libc-2.19.so]
   19,211,688  /build/eglibc-euxZvP/eglibc-2.19/string/../ports/sysdeps/arm/memset.S:memset [/lib/arm-linux-gnueabihf/libc-2.19.so]
   18,511,200  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::mul::mul_1_generic::hb74fcfb822b9692a
   17,819,126  /ramp-0.2.4/src/ll/div.rs:ramp::ll::div::divrem_3by2::h3ad1011bead13922 [/pumpkin/target/release/examples/multiply]
   17,020,241  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::addsub::sub_n_generic::h8a9a928dc6dc2db7
   15,130,058  /ramp-0.2.4/src/ll/addsub.rs:ramp::ll::addsub::sub_n_generic::h8a9a928dc6dc2db7 [/pumpkin/target/release/examples/multiply]
   14,461,875  /ramp-0.2.4/src/ll/mul.rs:ramp::ll::mul::mul_1_generic::hb74fcfb822b9692a [/pumpkin/target/release/examples/multiply]
   13,819,125  /ramp-0.2.4/src/ll/mod.rs:ramp::mem::TmpAllocator::allocate::h6d2af0ca83521b26
   10,969,176  /src/libcore/num/mod.rs:ramp::ll::div::invert_pi::h37e4002131b72562
    9,068,068  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::div::divrem_1::h00ea568e6ff59101
    9,042,938  /build/eglibc-euxZvP/eglibc-2.19/malloc/malloc.c:malloc'2 [/lib/arm-linux-gnueabihf/libc-2.19.so]
    8,677,125  /src/libcore/ptr.rs:ramp::ll::mul::mul_1_generic::hb74fcfb822b9692a
    6,969,621  /src/libcore/ptr.rs:ramp::ll::addsub::sub_n_generic::h8a9a928dc6dc2db7
    6,919,952  /ramp-0.2.4/src/ll/mod.rs:ramp::ll::div::invert_pi::h37e4002131b72562
    6,916,488  /ramp-0.2.4/src/int.rs:ramp::int::Int::with_capacity::hbad52ef439589d1c'2 [/pumpkin/target/release/examples/multiply]
    6,855,740  /ramp-0.2.4/src/ll/mul.rs:ramp::ll::div::invert_pi::h37e4002131b72562
    5,944,943  ???:__udivsi3 [/lib/arm-linux-gnueabihf/libgcc_s.so.1]
    5,811,630  /ramp-0.2.4/src/ll/div.rs:ramp::ll::div::divrem_1::h00ea568e6ff59101 [/pumpkin/target/release/examples/multiply]
    4,841,424  /ramp-0.2.4/src/ll/limb.rs:ramp::ll::limb::mul::h42f9717ba7a0c591'2 [/pumpkin/target/release/examples/multiply]
    4,723,641  /ramp-0.2.4/src/ll/mod.rs:ramp::int::Int::with_capacity::hbad52ef439589d1c'2
    3,631,068  /src/libcore/num/mod.rs:ramp::ll::limb::mul::h42f9717ba7a0c591'2
    3,123,600  /build/eglibc-euxZvP/eglibc-2.19/malloc/malloc.c:free [/lib/arm-linux-gnueabihf/libc-2.19.so]
    3,085,200  /src/libcore/num/mod.rs:ramp::ll::mul::mul_1_generic::hb74fcfb822b9692a
    2,742,296  /ramp-0.2.4/src/ll/limb_ptr.rs:ramp::ll::div::invert_pi::h37e4002131b72562
    2,552,655  /src/libcore/num/mod.rs:_$LT$alloc..raw_vec..RawVec$LT$T$GT$$GT$::reserve_exact::hb7fda2cd8a63e7ac
    2,487,954  /src/libcore/num/mod.rs:ramp::ll::div::divrem_1::h00ea568e6ff59101

Probably a rustc bug, both 1.9 and 1.10 produce broken code. Any suggestions?

MagaTailor commented 8 years ago

Not surprisingly some tests fail:

test div::assign_baseint ... FAILED
test count_ones ... ok
test div::assign_i32 ... FAILED
test div::assign_usize ... FAILED
test div::assign_limb ... FAILED
test div::baseint_int ... ok
test div::i32_int ... ok
test div::int_baseint ... FAILED
test div::int_i32 ... FAILED
test div::assign_intref ... FAILED
test div::int_limb ... FAILED
test div::int_usize ... FAILED
test div::int_int ... FAILED
test div::intref_int ... FAILED
test div::assign_int ... FAILED
test div::int_intref ... FAILED
test div::usize_int ... ok
test dsquare ... FAILED
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"8849803919073"`, right: `"8597451702272"`)', tests/quickcheck.rs:762
test format::debug ... FAILED
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"9029714407493269026017417734137839691007213564442062089896904729616809044024142790379484059617269584959837407582902363009113429674987305841500896332882143717103751709451516746827689130546499776908068799372322622534992258334284425859971"`, right: `"3490060671491993686214905888792446194871103440964562448490091323288508271396753595134714873778185535371292782690510811579720506174632528388926877180137531000296377700657826113854424337781216261876299677067551323714090195986427259387908"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"5713886196822985594106667841465769528176853953767844242824527910650530279415437531154089102105674883623051073154253182377862855489000142063496472236639819549329944103905099929312095761827444327784356635858"`, right: `"2753172420589426449564691924584874498873256307070177196185577168310139217156823622641882942253473415554542748706619381585092138275232145260247057630738890719526975532118328407785058629601288899817220603904"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"5871970368832091240885816628360906039656033280063516190180346613585375822439507569820436759955028105664801901417825338693225803397007659824133896887424000466256578694412673794"`, right: `"2171870087935699189718787761912670127725060173613950751922295045558204937459105416211047829349130593816884876374970539055793888526740600647961557330427742461096334202809352191"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"3934972798989292307331229006723822505854692627010346685509766049208278419000946355495357831723854845458295821730135456671610812430789644580210009"`, right: `"1713303403591394173863728166508504406757816963544563655840537955839295703252039954393104918962948139711322359057473768684154478105621737412493312"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"2688633295290066818105497824615555387719288059024241312783168019897650855849048171695532459463252669860170763452529"`, right: `"1351558073875347736651661409192795041963000307892155599736925167383214994891230805767277700895903965127891654541312"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"1772936324527772151357447733725496001813962702045777118351861859374958772220766093176494833447291489619434931"`, right: `"1288946222186420189525281342690272371256828601734309768425870101340498919383269124762799931426910367133990912"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"378945777648903906789695716026380594533179877282076491959881732589000490694509622968631330970291135"`, right: `"1229234907328052701497346251192352648979977227911290901590223409023760718711156010401534968783293120512"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"2330353817500888298291790719247231558935961406937025231209265420380711281930210075307191381740230"`, right: `"1172289759948780728814455271904328011493661144171992208090041550658951491080432901765379875930112"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"1449966612869523721353952613849716863241933252155559712169035137895401304975805790218969715"`, right: `"1117982635449200371565299293426826488011990684673301895227471876772834292488510991826419712"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"1818420132404134103684359450194274417090216860519831155519331982033368490196463061720"`, right: `"1066191325616073962750720303942514884960165676759054084041091801426729481209288589312"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"1319809570512615485910127877749274102287901999540778440094618525735834859172828"`, right: `"1016799283615182841063232711737170109710851361044935306588260461260537606438912"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"1186990385049000993431805962821334327600196421581392849115004854769250102"`, right: `"969695361724074212134583198296709165297366486592231089199314557323968512"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"1592100713752950986124072184402880617464374600080755553330926496033"`, right: `"924773561214517795691092680260380902573935019104224290084185178112"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"1049961164700998186739596529046369044849782671450896059989941"`, right: `"881932793821828647318928413639431860517439860443329134067712"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"971753689315263468711456704001656404898493675547214804"`, right: `"841076654264286658591202176703864918248596058314637312"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"1379952715086360674366063258038855809629286828356"`, right: `"802113203300749453154756714538445394753070886912"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"858693220763714433808174470436897667102988"`, right: `"764954760838269665865666117227979082825728"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"795551270212833032574810782500809594"`, right: `"729517708624143281808534733989695628"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"781510631392534438342335907468"`, right: `"695722302078383714493307813634"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"702954579302276211512605"`, right: `"663492490843185152524287"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"651298696660445870"`, right: `"632755747645554687"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"621716927544"`, right: `"603442905087"`)', tests/quickcheck.rs:755
thread 'safe' panicked at 'assertion failed: `(left == right)` (left: `"39887945675"`, right: `"37715181567"`)', tests/quickcheck.rs:755
test format::display ... FAILED
test divmod ... FAILED
test div::intref_intref ... FAILED
test format::lowerhex ... ok
test from::i16 ... ok
test from::i32 ... ok
test from::i64 ... ok
test format::binary ... ok
test from::isize ... ok
test from::i8 ... ok
test format::upperhex ... ok
test from::u16 ... ok
test format::octal ... ok
test from::u32 ... ok
test from::usize ... ok
test from::u8 ... ok
error: Process didn't exit successfully: `/ramp/target/debug/quickcheck-a52d6e57e32cbbcf` (signal: 11, SIGSEGV: invalid memory reference)
anfractuosity commented 8 years ago

Have you seen this issue - https://github.com/Aatch/ramp/issues/55

MagaTailor commented 8 years ago

Yeah, if memory serves a few months ago I ran the bench suite just fine (and probably the tests too)

anfractuosity commented 8 years ago

It looks to me it hasn't been fixed as far as I can see, comparing some of the code from https://github.com/Aatch/ramp/blob/a7228cbb5c7aea34705b4ca6b1a37f4e34d6029a/src/ll/limb.rs#L476 (from November last year) to the latest version, being the same.

MagaTailor commented 8 years ago

Ok, must have been the benchmarks then.

anfractuosity commented 8 years ago

The patches on that issue got the tests to pass for me on a 32 bit ARM device (Raspberry Pi)

MagaTailor commented 8 years ago

I saw that issue, from a quick perusal definitely thought the fix must have been merged.

Aatch commented 8 years ago

I'll try to remember to apply those fixes, even better if somebody else can submit a PR with them.