Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Optimise work updates on CUDA, was Branch#359 #361

Merged
merged 47 commits into from
Dec 28, 2017

Conversation

MariusVanDerWijden
Copy link
Collaborator

@MariusVanDerWijden MariusVanDerWijden commented Oct 28, 2017

Working on issue #359
The newest commit should work, Please test it!

@smurfy
Copy link
Collaborator

smurfy commented Oct 29, 2017

Just a note, @chfast mentioned before. If possible please make this similiar to the OpenCL variant #217
And also if there are duplicate code move them to the base class. Thanks

@chfast
Copy link
Contributor

chfast commented Nov 3, 2017

How is it going?

@MariusVanDerWijden
Copy link
Collaborator Author

I am working on it, but i don't have a suitable gpu to test my changes

@ZiDanRO
Copy link

ZiDanRO commented Nov 22, 2017

If you need a tester, i'm availoable. I have gtx 1060 3gb and 6 gb and also gtx 1070 to test it.
Here is my email if i can help you with this part.
[email protected]

LE: I'm using windows 10 64bit 1073 version if this has any relevance for you

@kkkrackpot
Copy link

I could test it too with 1060 and CUDA 9 on Linux -- if someone can tell me how to patch ethminer from git with these changes.

@MariusVanDerWijden
Copy link
Collaborator Author

MariusVanDerWijden commented Nov 23, 2017

Travis ci:
"The command "pip install requests" failed and exited with 127 during ."
Maybe the script is wrong

@chfast
Copy link
Contributor

chfast commented Nov 23, 2017

Yes, something changed in Travis/macOS, but it is not related. I will try to fix it soon.

@chfast
Copy link
Contributor

chfast commented Nov 24, 2017

travis fixed in master branch

@smurfy smurfy changed the title Branch #359 Optimise work updates on CUDA, was Branch#359 Nov 24, 2017
@chfast
Copy link
Contributor

chfast commented Nov 24, 2017

Can you rebase this? Is this ready?

@MariusVanDerWijden
Copy link
Collaborator Author

This is not ready!

@ZiDanRO
Copy link

ZiDanRO commented Nov 25, 2017

Yes this is not ready, it gets stuck at generating DAG

C:\ethminer>ethminer.exe --farm-recheck 5000 -U -S eu1.ethermine.org:4444 -FS eu1.ethermine.org:14444 -O 0x.................. --cuda-parallel-hash 4 --api-port 3333
cu 16:48:04|main Using grid size 8192 , block size 128
i 16:48:04|main Connecting to stratum server eu1.ethermine.org:4444
i 16:48:04|stratum Connected to stratum server eu1.ethermine.org : 4444
i 16:48:04|stratum Starting farm
i 16:48:04|CUDA0 No work. Pause for 3 s.
i 16:48:04|CUDA1 No work. Pause for 3 s.
i 16:48:04|CUDA2 No work. Pause for 3 s.
i 16:48:04|CUDA3 No work. Pause for 3 s.
i 16:48:04|CUDA4 No work. Pause for 3 s.
i 16:48:04|CUDA5 No work. Pause for 3 s.
i 16:48:04|CUDA6 No work. Pause for 3 s.
i 16:48:04|stratum Subscribed to stratum server
i 16:48:04|stratum Authorized worker 0x7.........................
i 16:48:04|stratum Received new job #da64956c
i 16:48:07|CUDA0 set work; seed: #89c875b9, target: #0000000112e0
i 16:48:07|CUDA0 Initialising miner...
i 16:48:07|CUDA2 No work. Pause for 3 s.
i 16:48:07|CUDA1 No work. Pause for 3 s.
i 16:48:07|CUDA3 No work. Pause for 3 s. i 16:48:07|CUDA4 No work. Pause for 3 s.
i 16:48:07|CUDA6 No work. Pause for 3 s.
i 16:48:07|CUDA5 No work. Pause for 3 s.

@MariusVanDerWijden
Copy link
Collaborator Author

Thats propably because of a previous bug, I'm going to rebase it later, but thanks for testing 👍

@ZiDanRO
Copy link

ZiDanRO commented Nov 26, 2017

No problem, i will test everything because i can't use 12 final version. It seams it is worst than 12.rc1 on nvidia miners. To much hash drops like other reported already. Now everything seems it is on your shoulders to find out were is the problem and if i can help, i do it gladly.
Im sad i can't help more with the programming, its to much for my understanding and no time to research.

@MariusVanDerWijden MariusVanDerWijden force-pushed the branch_#359 branch 2 times, most recently from 1e282d2 to a816f1c Compare November 26, 2017 22:35
@MariusVanDerWijden
Copy link
Collaborator Author

I rebased it now, can you retest it?

@ZiDanRO
Copy link

ZiDanRO commented Nov 26, 2017

Sorry the same, it can't pass the generation of DAG. It generat's it until 97% and it starst again.
And i don't know why the error of no work...

ethminer -U -S eu1.ethermine.org:4444 -O 0xY.............. --cuda-parallel-hash 4
cu 00:57:42|main Using grid size 8192 , block size 128
i 00:57:42|main Connecting to stratum server eu1.ethermine.org:4444
i 00:57:42|stratum Connected to stratum server eu1.ethermine.org : 4444
i 00:57:42|stratum Starting farm
i 00:57:42|CUDA0 No work. Pause for 3 s.
i 00:57:42|CUDA1 No work. Pause for 3 s.
i 00:57:42|CUDA2 No work. Pause for 3 s.
i 00:57:42|CUDA3 No work. Pause for 3 s.
i 00:57:42|CUDA4 No work. Pause for 3 s.
i 00:57:42|CUDA5 No work. Pause for 3 s.
i 00:57:42|CUDA6 No work. Pause for 3 s.
i 00:57:42|stratum Subscribed to stratum server
i 00:57:42|stratum Authorized worker 0x74B9aad.................
i 00:57:42|stratum Received new job #0dcd693a
i 00:57:45|CUDA2 No work. Pause for 3 s.
i 00:57:45|CUDA1 No work. Pause for 3 s.
i 00:57:45|CUDA0 set work; seed: #4be89018, target: #0000000112e0
i 00:57:45|CUDA0 Initialising miner...
i 00:57:45|CUDA4 No work. Pause for 3 s. i 00:57:45|CUDA3 No work. Pause for 3 s.

i 00:57:45|CUDA5 No work. Pause for 3 s. i 00:57:45|CUDA6 No work. Pause for 3 s.

cu 00:57:47|CUDA0 Using device: GeForce GTX 1070 (Compute 6.1)
cu 00:57:47|CUDA0 Generating DAG for GPU # 0
CUDA#0: 0%
CUDA#0: 3%
CUDA#0: 6%
CUDA#0: 8%
i 00:57:48|CUDA1 No work. Pause for 3 s.
i 00:57:48|CUDA2 No work. Pause for 3 s.
i 00:57:48|CUDA4 No work. Pause for 3 s.
i 00:57:48|CUDA3 No work. Pause for 3 s.
i 00:57:48|CUDA5 No work. Pause for 3 s.
i 00:57:48|CUDA6 No work. Pause for 3 s.
CUDA#0: 11%

@MariusVanDerWijden
Copy link
Collaborator Author

No work. Pause for 3 s. this is no real problem, the new code polls if there is new work, but i't can't receive new Work if the miner/stratum/dag is not initialized. It's purely semantical, but I'm going to change it in the evening

@ZiDanRO
Copy link

ZiDanRO commented Nov 27, 2017

it looks like it is working, but i don't know how and the rate, no other info than this

LE: it's not submitting anything. On Ethermine.org the miner apears offline!

13:43:15|CUDA2 No work. Pause for 3 s.
i 13:43:15|CUDA5 No work. Pause for 3 s.
i 13:43:15|CUDA6 No work. Pause for 3 s.
i 13:43:15|CUDA4 No work. Pause for 3 s.
i 13:43:16|CUDA0 Solution found; Submitting to eu1.ethermine.org ...
i 13:43:16|CUDA0 Nonce: 0x61d988404c3bdf5d
i 13:43:18|CUDA1 No work. Pause for 3 s.
i 13:43:18|CUDA3 No work. Pause for 3 s.
i 13:43:18|CUDA2 No work. Pause for 3 s.
i 13:43:18|CUDA5 No work. Pause for 3 s.

@chfast
Copy link
Contributor

chfast commented Nov 29, 2017

@ZiDanRO from you logs it looks like something is broken in the logic in the miner and it does not see the work updates.

@ZiDanRO
Copy link

ZiDanRO commented Dec 3, 2017

I see that Appveyor can't build so that i could test the new kernel. When is ready i will try it.

@MariusVanDerWijden
Copy link
Collaborator Author

MariusVanDerWijden commented Dec 27, 2017

Oh man, I really hate it... I'm going to invest my Christmas money into buying a GPU to test that stuff myself. I'm really sorry. Can you run valgrind/gdb or something over it?
Did you test it before the latest commits?

@ZiDanRO
Copy link

ZiDanRO commented Dec 27, 2017

in windows is ok. no errors until now

@jean-m-cyr
Copy link
Contributor

jean-m-cyr commented Dec 27, 2017

Under Ubuntu 16.04 LTS problem is with hwmon. Runs fine without -HWMON option.

Code crashes trying to display per card temp and fan speed data.

Not seeing performance improvement, perhaps even slight performance loss. Will monitor for an hour for stale rate.

@smurfy
Copy link
Collaborator

smurfy commented Dec 27, 2017

I will test the hwmon stuff. soon

@jean-m-cyr
Copy link
Contributor

This continues to work well when the hardware monitor is disabled.

I'd get rid of the per card "Set work;" logs. They present identical information for all GPUs, information already provided by the single stratum log.

@jean-m-cyr
Copy link
Contributor

jean-m-cyr commented Dec 28, 2017

Also now works with hwmon enabled (-HWMON) ??? Where'd that get fixed?

NOTE: I deleted the cnote << "set work;"... log in my local build, but that shouldn't have anything to do with it.

@@ -17,6 +17,8 @@ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
/** @file CUDAMiner.cpp
* @author Gav Wood <[email protected]>
* @date 2014
* @author MariusVanDerWijden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to remove entire comment. Git should be enough to find contributors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -113,75 +115,87 @@ void CUDAMiner::report(uint64_t _nonce)
void CUDAMiner::kickOff()
{
m_hook->reset();
startWorking();
//startWorking();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the commented out part

delete m_miner;
//delete m_miner;
//m_miner = new ethash_cuda_miner;
if(!m_miner)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just embed ethash_cuda_miner in CUDAMiner. I will remove it anyway later on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what you mean

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I will fix it later.

bytesConstRef lightData = light->data();
EthashAux::LightType light;
light = EthashAux::light(seed);
//bytesConstRef dagData = dag->data();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what you mean

current.seed = h256{1u};
try
{
while(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this loop ends?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed it

@@ -194,7 +208,7 @@ void CUDAMiner::workLoop()
void CUDAMiner::pause()
{
m_hook->abort();
stopWorking();
//stopWorking();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

@@ -17,6 +17,8 @@
/** @file ethash_cuda_miner.cpp
* @author Genoil <[email protected]>
* @date 2015
* @author MariusVanDerWijden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove entire comment.

@@ -63,6 +65,11 @@ ethash_cuda_miner::search_hook::~search_hook() {}

ethash_cuda_miner::ethash_cuda_miner()
{
int devicesCount = getNumDevices();
m_light = new hash64_t*[devicesCount];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF? Use std::vector<hash64_t*>(deviceCount).

Copy link
Collaborator Author

@MariusVanDerWijden MariusVanDerWijden Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only have a fixed no. of devices, i use this as a lookup whether a device has a light-struct already allocated. Since the number of devices during an execution doesn't change its save to use an array and index it by device_num

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::vector will do the same (single allocation once) and you will not have to fill it with nullptrs manually and delete in the end.

m_light = new hash64_t*[devicesCount];
for(int i = 0; i < devicesCount; i++)
m_light[i] = nullptr;
m_dag = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Init m_dag in declaration.

@@ -58,7 +58,14 @@ class ethash_cuda_miner
uint64_t m_starting_nonce;
uint64_t m_current_index;
uint32_t m_sharedBytes;

///Constants on GPU
hash128_t* m_dag;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Init all the fields.

@jean-m-cyr
Copy link
Contributor

Left running overnight on 3 cards.

Still has problem in HWMON. All three cards report exactly the same temp and fan speed percentage.

@smurfy
Copy link
Collaborator

smurfy commented Dec 28, 2017

@jean-m-cyr
Just to make sure, you mean nvidia cards, i know this is a cuda fix branch but still, nvidia should work, but i know i had a bug on amd (adl) on windows. I currently only can test amd_sysfs (3 cards) and nvidia on (8 cards) linux and nvidia on windows (one card)

edit: update, i can reproduce the problem on windows, testing on linux soon


if (device_count == 0)
return false;

// use selected device
m_device_num = std::min<int>((int)_deviceId, device_count - 1);

unsigned device_num = _deviceId < device_count -1 ? _deviceId : device_count - 1;
Copy link
Collaborator

@smurfy smurfy Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to use class variable m_device_num (or set it to same value), happy to change it to unsigned, but hwmon needs the device_num later to fetch stats for the correct device. See line 404 in this file.

Copy link
Contributor

@jean-m-cyr jean-m-cyr Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep...
Changing m_device_num type to uint32, and all references to device_num in ethash_cuda_miner::init to m_device_num does the trick.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah I'm sorry... fixed it now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@subtly is this fine now?

Copy link
Contributor

@chfast chfast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this vector instead of raw dynamic array left. I'm fine with the rest.

delete m_miner;
//delete m_miner;
//m_miner = new ethash_cuda_miner;
if(!m_miner)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I will fix it later.


ethash_cuda_miner::~ethash_cuda_miner()
{
delete[] m_light;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not be needed at at all if std::vector used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for(int i = 0; i < devicesCount; i++)
int deviceCount = getNumDevices();
m_light = std::vector<hash64_t*>(deviceCount);
for(int i = 0; i < deviceCount; i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. vector's constructor will init all elements with default values, in this case with nullptr.

m_light = new hash64_t*[devicesCount];
for(int i = 0; i < devicesCount; i++)
int deviceCount = getNumDevices();
m_light = std::vector<hash64_t*>(deviceCount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but because m_light is a vector already, you can alternatively write it like m_light.resize(deviceCount). Still it will init new elements with nullptr.

@ddobreff
Copy link
Collaborator

Confirmed working with -HWMON enabled.

@chfast
Copy link
Contributor

chfast commented Dec 28, 2017

Ready to merge?

@MariusVanDerWijden
Copy link
Collaborator Author

MariusVanDerWijden commented Dec 28, 2017

Yes, Thank you all for bearing with me and for your continuous support

@chfast chfast merged commit 627859d into ethereum-mining:master Dec 28, 2017
@chfast
Copy link
Contributor

chfast commented Dec 28, 2017

Great work! Welcome to the group of the ethminer contributors.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants