{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1773","labels_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1773/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1773/comments","events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1773/events","html_url":"https://github.com/ethereum/cpp-ethereum/issues/1773","id":72168837,"number":1773,"title":"opencl RAM usage optimization","user":{"login":"Genoil","id":7251705,"avatar_url":"https://avatars.githubusercontent.com/u/7251705?v=3","gravatar_id":"","url":"https://api.github.com/users/Genoil","html_url":"https://github.com/Genoil","followers_url":"https://api.github.com/users/Genoil/followers","following_url":"https://api.github.com/users/Genoil/following{/other_user}","gists_url":"https://api.github.com/users/Genoil/gists{/gist_id}","starred_url":"https://api.github.com/users/Genoil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Genoil/subscriptions","organizations_url":"https://api.github.com/users/Genoil/orgs","repos_url":"https://api.github.com/users/Genoil/repos","events_url":"https://api.github.com/users/Genoil/events{/privacy}","received_events_url":"https://api.github.com/users/Genoil/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-30T13:54:07Z","updated_at":"2015-05-01T15:47:22Z","closed_at":null,"body":"With a single GPU, double the RAM required to store a DAG is used. I think that could be done better. \r\n\r\nThe source mentions this:\r\n```\r\n// memcpying 1GB: horrible... really. horrible. but necessary since we can't mmap *and* gpumap.\r\n```\r\nBut I wonder if we can't. If we would first:\r\n\r\n```\r\nvoid* dag_ptr = m_queue.enqueueMapBuffer(m_dag, true, m_opencl_1_1 ? CL_MAP_WRITE : CL_MAP_WRITE_INVALIDATE_REGION, 0, params.full_size);\r\n```\r\n\r\nand then pass that dag_ptr as a BytesRef to\r\n```\r\nEthashAux::FullType EthashAux::full(h256 const& _seedHash, bytesRef _dest, bool _createIfMissing)\r\n```\r\n\r\nI did this is in a similar manner in a fork of the ethash repo, but never got to commit that. \r\n```\r\nvoid* dag_ptr = m_queue.enqueueMapBuffer(m_dag, true, m_opencl_1_1 ? CL_MAP_WRITE : CL_MAP_WRITE_INVALIDATE_REGION, 0, params.full_size);\r\nstd::string memoFile = getDataDir(\"ethash\") + \"/full\";\r\nlength = contentsToBuffer(memoFile, dag_ptr);\r\n```\r\n(@gavofyork: now you know where my not-so--size-safe contentsToBuffer came from that I accidentaly commited the other day)\r\n \r\nAnyway I'l see if I can make this work, but if you see anything that I might overlook, please comment.\r\n\r\n\r\nIt gets worse when multiple GPUs are involved, as the (host!) RAM requirements multiply by the amount of GPUs. This can also be resolved, by creating a shared context between devices. Then the devices will automatically share any mapped cl_mem. The catch is in how to deal with the non-DAG memory (hash and search buffers). I guess I will just multiply the allocated memory for each device and use a device index, so that each GPU uses their own hash and search part of the shared memory. \r\n\r\nAny suggestions as to how to implement this? Make cl_miner::init static adn add a deviceId member?"},"comment":{"url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/comments/98162374","html_url":"https://github.com/ethereum/cpp-ethereum/issues/1773#issuecomment-98162374","issue_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/1773","id":98162374,"user":{"login":"Genoil","id":7251705,"avatar_url":"https://avatars.githubusercontent.com/u/7251705?v=3","gravatar_id":"","url":"https://api.github.com/users/Genoil","html_url":"https://github.com/Genoil","followers_url":"https://api.github.com/users/Genoil/followers","following_url":"https://api.github.com/users/Genoil/following{/other_user}","gists_url":"https://api.github.com/users/Genoil/gists{/gist_id}","starred_url":"https://api.github.com/users/Genoil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Genoil/subscriptions","organizations_url":"https://api.github.com/users/Genoil/orgs","repos_url":"https://api.github.com/users/Genoil/repos","events_url":"https://api.github.com/users/Genoil/events{/privacy}","received_events_url":"https://api.github.com/users/Genoil/received_events","type":"User","site_admin":false},"created_at":"2015-05-01T15:47:22Z","updated_at":"2015-05-01T15:47:22Z","body":"fixed with #1777 "}}