# Finding a cycle in trimmed edges (help)

**URL:** <https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282>\
**Category:** Development and Technical Discussion\
**Created:** [March 18, 2018, 10:19am UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282 "2018-03-18T10:19:06Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 5, 2018, 2:41pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/21 "2018-04-05T14:41:13Z")

</div>

My output now matches your output. Also compiles on linux, but I still need to make some changes for linux.

On the image below, I often miss 314 cycle in iteration two. So that leads me to a question. When you follow a path from currently inserted edge to its root, what happens when that path runs into itself in a loop. We just terminate path method and if that happened to be shorter path, it gets reversed, but this is destructive, because there is no free root node for the clean reversal. Maybe the implementation differs here.

[![](https://canada1.discourse-cdn.com/flex036/uploads/grin/original/1X/3fe62e5f707d408c20158bb861baa9ac507d1edd.png) ](https://dl.dropboxusercontent.com/s/h12aglkkbebug0r/theta3.png?dl=0)

---

<div class="post-metadata">

**Author:** ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)\
**Post date:** [April 5, 2018, 3:55pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/22 "2018-04-05T15:55:45Z")

</div>

> When you follow a path from currently inserted edge to its root, what happens when that path runs into itself in a loop

That’s a bug, since findcycles() maintains a directed forest, i.e. a loop free graph.  
It does need to run single threaded to maintain this invariant though…

---

<div class="post-metadata">

**Author:** ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)\
**Post date:** [April 5, 2018, 4:01pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/23 "2018-04-05T16:01:56Z")

</div>

Looking very good! 2.2x faster than my CUDA solver.  
Is this also running on a 1080Ti?

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 5, 2018, 4:11pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/24 "2018-04-05T16:11:40Z")

</div>

1070, I don’t have any other GPU. I expect final speedup to be 4x and with the complex variant that will come later 5x, absolute maximum 6x. I do wonder how 1080 will take it.

---

<div class="post-metadata">

**Author:** ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)\
**Post date:** [April 5, 2018, 5:31pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/25 "2018-04-05T17:31:53Z")

</div>

For reference, how fast is my solver on your 1070?

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 5, 2018, 9:01pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/26 "2018-04-05T21:01:40Z")

</div>

For the same nonce as my example above. Looks faster compared to results posted in the other thread so not quite 4x speedup, but close. But 1080 might go slightly over 4x speedup. Compiled with cuda 9.1.

[![](https://canada1.discourse-cdn.com/flex036/uploads/grin/original/1X/6b0be6752b06c8ce5aca54155df1f3d9442019ad.png) ](https://dl.dropboxusercontent.com/s/ccqtno64ggoehad/john_cuda30.png?dl=0)

---

<div class="post-metadata">

**Author:** ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)\
**Post date:** [April 5, 2018, 9:57pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/27 "2018-04-05T21:57:31Z")

</div>

So if your speedup is preserved from 1070 to 1080Ti, then we’re looking at solve times of only 0.270ms. Very impressive indeed. You’re very close to collecting a double bounty, just like xenoncat did.

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 5, 2018, 11:52pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/28 "2018-04-05T23:52:00Z")

</div>

Running on same system in linux now. Still losing some cycles, likely a memory access bug hidden in cuda code. In 10 runs I have not lost that 42 cycle solution once so it is not critical. It is bugging me though.

[![](https://canada1.discourse-cdn.com/flex036/uploads/grin/original/1X/280ddac12e0481cb90293d37f2e77faf7c0c2555.png) ](https://dl.dropboxusercontent.com/s/czm7a6qxerbblrr/theta5.png?dl=0)

The cuda (later opencl) executable is as simple as possible, accepts header hash on the input and spits out around 80k edges. The rest is done in dotnet process(es). The idea is to have this program sitting on a windows/linux/nvidia/amd PC and connect over local network with either grin node or pool.

I will check the code again to see if I spot anything fishy that would explain missed cycles.

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 7, 2018, 9:49am UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/29 "2018-04-07T09:49:32Z")

</div>

Hi John, the miner has been published at [https://github.com/mozkomor/GrinGoldMiner](https://github.com/mozkomor/GrinGoldMiner)

Tested on 10k iterations on both win and linux for stability, passed.

It may still be slightly buggy and lose some cycles, but we need to focus on something else for at least a week so publishing now. I hope you’ll manage to get it running. At the end I just made a small ramdisk in “edges” subfolder and use normal files to get edges out, crude but effective until better solution is made for linux.

---

<div class="post-metadata">

**Author:** ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)\
**Post date:** [April 7, 2018, 5:27pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/30 "2018-04-07T17:27:19Z")

</div>

Thanks for making your solver publicly available. I will start testing it tonight or tomorrow and let you know if I have trouble getting it to run. I just noticed it requires 8 GB. What would remain of your performance improvement if you had to target 4 GB or 6 GB cards?

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 7, 2018, 5:30pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/31 "2018-04-07T17:30:57Z")

</div>

Windows steals over 1GB on every GPU so in reality it can work on something around 7GB. I never bothered to target less memory, because with 6GB GPU and widnows stealing portion of it, might as well go all in on 8GB cards only.

Compare my screens above the linux one and windows one. Look at the initial free memory. Windows is retarded, it does this even on headless GPUs.

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 7, 2018, 5:34pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/32 "2018-04-07T17:34:28Z")

</div>

You’d have to copy a lot more around and with 4GB cards having less compute processors as well, wouldn’t be that great. Might still be fast, but I’m not gonna even try.

6GB cards on linux might work without any performance impact later on as the more advanced optimizations also save quite a lot of memory.

If your solver can fit in 4GB card on windows and it uses that matrixy stuff to save maximum space, I image you could apply some of the individual optimizations, but you would not see anywhere near 4x speedup. More like little bit, not sure, I don’t actually fully understand how the mean miner works.

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 8, 2018, 10:41pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/35 "2018-04-08T22:41:16Z")

</div>

Anybody reading this thread who has GTX 1070 **Ti** or TITAN V and is willing to test the solver in above mentioned repository, please come forward and share your results.

---

<div class="post-metadata">

**Author:** ![Chronos](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/chronos/32/153_2.png) [@Chronos](https://forum.grin.mw/u/Chronos)\
**Post date:** [April 9, 2018, 2:33am UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/36 "2018-04-09T02:33:24Z")

</div>

> [@photon](#):
>
> Anybody reading this thread who has GTX 1070 Ti or TITAN V and is willing to test the solver in above

Unfortunately, I only fit two of those three criteria. I lack only the possession. 🙂

---

<div class="post-metadata">

**Author:** ![v05](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/v05/32/154_2.png) [@v05](https://forum.grin.mw/u/v05)\
**Post date:** [April 9, 2018, 8:25pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/37 "2018-04-09T20:25:09Z")

</div>

GTX 1070 Ti on Ubuntu 16.04 has error:

```
$ ./Theta -r 100 -n 0
Starting CUDA solver process...
Currently available amount of device memory: 7086145536 bytes
Total amount of device memory: 8513585152 bytes
Allociating buffer 1
Allociating buffer 2
status: out of memory
cudaMalloc failed buffer B 3GB!
CUDA terminating...
CUDA launch error
Finished in 2042ms

```

Do I need to adjust some parameters for memory?

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 9, 2018, 8:43pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/38 "2018-04-09T20:43:14Z")

</div>

Some windows software stole memory from the GPU, you can just find it and kill, reboot or make the buffers smaller by lowering DUCK\_SIZE\_A and B compile time constants one by one until it fits (if you compiled from source).

Edit: Sorry I missed the ubuntu… definitely some process took over 1.4GB of your memory.

---

<div class="post-metadata">

**Author:** ![v05](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/v05/32/154_2.png) [@v05](https://forum.grin.mw/u/v05)\
**Post date:** [April 9, 2018, 9:13pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/39 "2018-04-09T21:13:48Z")

</div>

Thanks, sorted it out. Using Ubuntu 16.04, GTX 1070 Ti + ramdisk.

=======================================================  
$ ./Theta -r 1000 -n 0  
…  
Trimming iteration 61 of 1000  
Trimming: 4178123b6607deb3 596e493a0fe04022 685fbcfc1d315fe 7cf66796fc0083c1  
2-cycle found  
16-cycle found  
12-cycle found  
6-cycle found  
26-cycle found  
8-cycle found  
Trimmed to: 78176 edges  
Trimmed in 400ms  
Trimming iteration 62 of 1000  
Trimming: 544f44b2b17afc97 4ba38ecebc2fa72c 21e2c32bba7f6196 4d8886ccba77435b  
4-cycle found  
32-cycle found  
56-cycle found  
302-cycle found  
314-cycle found  
Trimmed to: 77508 edges  
Trimmed in 404ms  
Trimming iteration 63 of 1000  
Trimming: 7d4f06d5f68dc772 331017080ac63322 e62926ee68af70ed cf2efe7e2f4dbc16  
Trimmed to: 76856 edges  
Trimmed in 395ms  
Trimming iteration 64 of 1000  
Trimming: 89f81d7da5e674df 7586b93105a5fd13 6fbe212dd4e8c001 8800c93a8431f938  
42-cycle found!  
84-cycle found  
320-cycle found  
192-cycle found  
Trimmed to: 69937 edges  
Trimmed in 400ms  
Trimming iteration 65 of 1000  
Solution: nonce:3F k0:7D4F06D5F68DC772 k1:331017080AC63322 k2:E62926EE68AF70ED k3:CF2EFE7E2F4DBC16  
16-cycle found  
288-cycle found  
554-cycle found  
226-cycle found  
23ECE, 27E0856, 2AD8C27, 2CBB0B5, 3694CDD, 477A095, 64DE6FC, 64E1C92, 68E624D, 6AA4C6F, 6B1D0C2, 76F07D2, C273122, C2E38ED, C655CDE, C97BA17, E708130, EC8890D, ECB9932, F28D66D, F577AFF, 104D8441, 116DE91F, 116E61CB, 1178EA28, 11840F8A, 11CE10B0, 12792630, 12AE2388, 140AE893, 1439B9FD, 146A3047, 1538D93C, 176CB068, 17E01C9B, 1876EE0A, 1C871774, 1D37D976, 1D6FA785, 1D9C1669, 1D9D015E, 1DB85F7E  
Trimming: aad9475236944448 af6b3569368015a e032c834e65b9b87 f168dfa67498e7c8  
Trimmed to: 73503 edges  
Trimmed in 495ms  
Trimming iteration 66 of 1000  
Trimming: bb8e0d9c86092685 5cc27ab9541d15f 745df9f37b43b2ce 9ebdebee66aa3f74  
20-cycle found  
324-cycle found  
118-cycle found  
Trimmed to: 84426 edges  
Trimmed in 400ms  
…  
CUDA terminating…  
Finished in 405892ms

=======================================================

**So 2.46 h/s on 1070 Ti.** 🔥

---

<div class="post-metadata">

**Author:** ![photon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/photon/32/27_2.png) [@photon](https://forum.grin.mw/u/photon)\
**Post date:** [April 9, 2018, 9:21pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/40 "2018-04-09T21:21:13Z")

</div>

So you get 10% boost over regular 1070 with the only difference being 4 extra multiprocessors. I guess memory becomes fully saturated on 1070 Ti. Thank you for testing this.

You can also have fun with overclocking, both core and memory, for my 1070 overclocking core had larger impact compared to overclocked memory. But on 1070 Ti core overclock alone may not be that effective anymore.

---

<div class="post-metadata">

**Author:** ![monkyyy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/monkyyy/32/1590_2.png) [@monkyyy](https://forum.grin.mw/u/monkyyy)\
**Post date:** [April 10, 2018, 2:22pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/41 "2018-04-10T14:22:21Z")

</div>

There are processes that would eat up that much without user intention?

Is it the wm?

Why isn’t turning off whatever it is common knowledge in any gaming community?

---

<div class="post-metadata">

**Author:** ![v05](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/v05/32/154_2.png) [@v05](https://forum.grin.mw/u/v05)\
**Post date:** [April 10, 2018, 4:36pm UTC](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282/42 "2018-04-10T16:36:05Z")

</div>

For me, it was chrome. Not sure why it was holding GPU memory but I did have some youtube links open so maybe it was cached video content. After closing chrome I had almost 100% GPU memory available and was able to run the test.

[Previous page](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282.md?page=1)

[Next page](https://forum.grin.mw/t/finding-a-cycle-in-trimmed-edges-help/282.md?page=3)
