{"action":"created","comment":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/182689202","pull_request_review_id":113533664,"id":182689202,"diff_hunk":"@@ -24,21 +24,11 @@ namespace paddle {\n namespace operators {\n \n template <typename T>\n-__global__ void RandomGenerator(const size_t n, const int seed,\n-                                const float dropout_prob, const T* src,\n-                                T* mask_data, T* dst) {\n-  thrust::minstd_rand rng;\n-  rng.seed(seed);\n-  thrust::uniform_real_distribution<float> dist(0, 1);\n-\n+__global__ void RandomGenerator(const size_t n, const T* src,\n+                                const T* cpu_mask_data, T* mask_data, T* dst) {\n   int idx = blockDim.x * blockIdx.x + threadIdx.x;\n   for (; idx < n; idx += blockDim.x * gridDim.x) {\n-    rng.discard(idx);","path":"paddle/fluid/operators/dropout_op.cu","position":15,"original_position":15,"commit_id":"c72f39d63027b3c8bebcc5f512f06fc477995a01","original_commit_id":"c72f39d63027b3c8bebcc5f512f06fc477995a01","user":{"login":"dzhwinter","id":6687176,"avatar_url":"https://avatars2.githubusercontent.com/u/6687176?v=4","gravatar_id":"","url":"https://api.github.com/users/dzhwinter","html_url":"https://github.com/dzhwinter","followers_url":"https://api.github.com/users/dzhwinter/followers","following_url":"https://api.github.com/users/dzhwinter/following{/other_user}","gists_url":"https://api.github.com/users/dzhwinter/gists{/gist_id}","starred_url":"https://api.github.com/users/dzhwinter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzhwinter/subscriptions","organizations_url":"https://api.github.com/users/dzhwinter/orgs","repos_url":"https://api.github.com/users/dzhwinter/repos","events_url":"https://api.github.com/users/dzhwinter/events{/privacy}","received_events_url":"https://api.github.com/users/dzhwinter/received_events","type":"User","site_admin":false},"body":"If we don't do the discard, then every thread will get the same random value. Now our random array are generated in CPU vector, so every thread will get the correct value without discarding any preceding numbers.","created_at":"2018-04-19T09:38:29Z","updated_at":"2018-04-19T09:38:29Z","html_url":"https://github.com/PaddlePaddle/Paddle/pull/9902#discussion_r182689202","pull_request_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9902","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/182689202"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/9902#discussion_r182689202"},"pull_request":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9902"}},"in_reply_to_id":182657014},"pull_request":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9902","id":181442755,"html_url":"https://github.com/PaddlePaddle/Paddle/pull/9902","diff_url":"https://github.com/PaddlePaddle/Paddle/pull/9902.diff","patch_url":"https://github.com/PaddlePaddle/Paddle/pull/9902.patch","issue_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/9902","number":9902,"state":"open","locked":false,"title":"accelerate dropout","user":{"login":"dzhwinter","id":6687176,"avatar_url":"https://avatars2.githubusercontent.com/u/6687176?v=4","gravatar_id":"","url":"https://api.github.com/users/dzhwinter","html_url":"https://github.com/dzhwinter","followers_url":"https://api.github.com/users/dzhwinter/followers","following_url":"https://api.github.com/users/dzhwinter/following{/other_user}","gists_url":"https://api.github.com/users/dzhwinter/gists{/gist_id}","starred_url":"https://api.github.com/users/dzhwinter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzhwinter/subscriptions","organizations_url":"https://api.github.com/users/dzhwinter/orgs","repos_url":"https://api.github.com/users/dzhwinter/repos","events_url":"https://api.github.com/users/dzhwinter/events{/privacy}","received_events_url":"https://api.github.com/users/dzhwinter/received_events","type":"User","site_admin":false},"body":"fix https://github.com/PaddlePaddle/Paddle/issues/9507\r\nfix https://github.com/guoshengCS/transformer-nist/issues/4\r\nthe same data in size of 56*80*512, I got a **1.20 ms -> 100us**, 10x acceleration.\r\n\r\nbefore optimize (ms)\r\n```txt\r\n------------------------->     Profiling Report     <-------------------------\r\n\r\nPlace: All\r\nTime unit: ms\r\nSorted by total time in descending order in the same thread\r\n\r\nEvent                                       Calls       Total       Min.        Max.        Ave.\r\nthread0::mul_grad                           4850        6198.66     0.397312    42.3485     1.27807\r\nthread0::dropout                            2500        3016.29     0.559968    2.28013     1.20652\r\nthread0::mul                                4850        3000.64     0.200704    21.7682     0.618688\r\nthread0::softmax_with_cross_entropy         50          2130.97     36.8415     46.8009     42.6194\r\nthread0::layer_norm_grad                    1500        1916.48     0.832512    1.61075     1.27765\r\nthread0::elementwise_add_grad               3700        1513.65     0.043008    3.03923     0.409095\r\nthread0::softmax_grad                       900         1202.94     0.405504    2.22618     1.3366\r\nthread0::layer_norm                         1500        895.745     0.385024    0.750592    0.597163\r\nthread0::matmul_grad                        1800        786.354     0.280576    0.560128    0.436863\r\nthread0::softmax                            900         777.398     0.256256    1.44301     0.863775\r\n```\r\nafter optimize \r\n```txt\r\n==34607== Profiling application: /paddle/Paddle/build/paddle/fluid/operators/dropout_op_test\r\n==34607== Profiling result:\r\nTime(%)      Time     Calls       Avg       Min       Max  Name\r\n 95.25%  2.0010ms         6  333.49us     928ns  1.0640ms  [CUDA memcpy HtoD]\r\n  4.75%  99.713us         1  99.713us  99.713us  99.713us  void paddle::operators::RandomGenerator<float>(unsigned long, float const *, float const , paddle::operators::RandomGenerator<float>*, float const *)\r\n\r\n```","created_at":"2018-04-13T10:07:03Z","updated_at":"2018-04-19T09:38:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b14d270161d856b5333ddb2a6aa3a371e22a8b62","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9902/commits","review_comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9902/comments","review_comment_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/9902/comments","statuses_url":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/c72f39d63027b3c8bebcc5f512f06fc477995a01","head":{"label":"dzhwinter:speed/dropout_speed","ref":"speed/dropout_speed","sha":"c72f39d63027b3c8bebcc5f512f06fc477995a01","user":{"login":"dzhwinter","id":6687176,"avatar_url":"https://avatars2.githubusercontent.com/u/6687176?v=4","gravatar_id":"","url":"https://api.github.com/users/dzhwinter","html_url":"https://github.com/dzhwinter","followers_url":"https://api.github.com/users/dzhwinter/followers","following_url":"https://api.github.com/users/dzhwinter/following{/other_user}","gists_url":"https://api.github.com/users/dzhwinter/gists{/gist_id}","starred_url":"https://api.github.com/users/dzhwinter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzhwinter/subscriptions","organizations_url":"https://api.github.com/users/dzhwinter/orgs","repos_url":"https://api.github.com/users/dzhwinter/repos","events_url":"https://api.github.com/users/dzhwinter/events{/privacy}","received_events_url":"https://api.github.com/users/dzhwinter/received_events","type":"User","site_admin":false},"repo":{"id":88926226,"name":"Paddle","full_name":"dzhwinter/Paddle","owner":{"login":"dzhwinter","id":6687176,"avatar_url":"https://avatars2.githubusercontent.com/u/6687176?v=4","gravatar_id":"","url":"https://api.github.com/users/dzhwinter","html_url":"https://github.com/dzhwinter","followers_url":"https://api.github.com/users/dzhwinter/followers","following_url":"https://api.github.com/users/dzhwinter/following{/other_user}","gists_url":"https://api.github.com/users/dzhwinter/gists{/gist_id}","starred_url":"https://api.github.com/users/dzhwinter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzhwinter/subscriptions","organizations_url":"https://api.github.com/users/dzhwinter/orgs","repos_url":"https://api.github.com/users/dzhwinter/repos","events_url":"https://api.github.com/users/dzhwinter/events{/privacy}","received_events_url":"https://api.github.com/users/dzhwinter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dzhwinter/Paddle","description":"PArallel Distributed Deep LEarning","fork":true,"url":"https://api.github.com/repos/dzhwinter/Paddle","forks_url":"https://api.github.com/repos/dzhwinter/Paddle/forks","keys_url":"https://api.github.com/repos/dzhwinter/Paddle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dzhwinter/Paddle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dzhwinter/Paddle/teams","hooks_url":"https://api.github.com/repos/dzhwinter/Paddle/hooks","issue_events_url":"https://api.github.com/repos/dzhwinter/Paddle/issues/events{/number}","events_url":"https://api.github.com/repos/dzhwinter/Paddle/events","assignees_url":"https://api.github.com/repos/dzhwinter/Paddle/assignees{/user}","branches_url":"https://api.github.com/repos/dzhwinter/Paddle/branches{/branch}","tags_url":"https://api.github.com/repos/dzhwinter/Paddle/tags","blobs_url":"https://api.github.com/repos/dzhwinter/Paddle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dzhwinter/Paddle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dzhwinter/Paddle/git/refs{/sha}","trees_url":"https://api.github.com/repos/dzhwinter/Paddle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dzhwinter/Paddle/statuses/{sha}","languages_url":"https://api.github.com/repos/dzhwinter/Paddle/languages","stargazers_url":"https://api.github.com/repos/dzhwinter/Paddle/stargazers","contributors_url":"https://api.github.com/repos/dzhwinter/Paddle/contributors","subscribers_url":"https://api.github.com/repos/dzhwinter/Paddle/subscribers","subscription_url":"https://api.github.com/repos/dzhwinter/Paddle/subscription","commits_url":"https://api.github.com/repos/dzhwinter/Paddle/commits{/sha}","git_commits_url":"https://api.github.com/repos/dzhwinter/Paddle/git/commits{/sha}","comments_url":"https://api.github.com/repos/dzhwinter/Paddle/comments{/number}","issue_comment_url":"https://api.github.com/repos/dzhwinter/Paddle/issues/comments{/number}","contents_url":"https://api.github.com/repos/dzhwinter/Paddle/contents/{+path}","compare_url":"https://api.github.com/repos/dzhwinter/Paddle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dzhwinter/Paddle/merges","archive_url":"https://api.github.com/repos/dzhwinter/Paddle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dzhwinter/Paddle/downloads","issues_url":"https://api.github.com/repos/dzhwinter/Paddle/issues{/number}","pulls_url":"https://api.github.com/repos/dzhwinter/Paddle/pulls{/number}","milestones_url":"https://api.github.com/repos/dzhwinter/Paddle/milestones{/number}","notifications_url":"https://api.github.com/repos/dzhwinter/Paddle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dzhwinter/Paddle/labels{/name}","releases_url":"https://api.github.com/repos/dzhwinter/Paddle/releases{/id}","deployments_url":"https://api.github.com/repos/dzhwinter/Paddle/deployments","created_at":"2017-04-21T01:29:56Z","updated_at":"2017-04-21T01:30:00Z","pushed_at":"2018-04-19T02:13:06Z","git_url":"git://github.com/dzhwinter/Paddle.git","ssh_url":"git@github.com:dzhwinter/Paddle.git","clone_url":"https://github.com/dzhwinter/Paddle.git","svn_url":"https://github.com/dzhwinter/Paddle","homepage":"http://www.paddlepaddle.org/","size":63068,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"PaddlePaddle:develop","ref":"develop","sha":"f7fbef17815634b659e7b457357307f14c2a1bdc","user":{"login":"PaddlePaddle","id":23534030,"avatar_url":"https://avatars3.githubusercontent.com/u/23534030?v=4","gravatar_id":"","url":"https://api.github.com/users/PaddlePaddle","html_url":"https://github.com/PaddlePaddle","followers_url":"https://api.github.com/users/PaddlePaddle/followers","following_url":"https://api.github.com/users/PaddlePaddle/following{/other_user}","gists_url":"https://api.github.com/users/PaddlePaddle/gists{/gist_id}","starred_url":"https://api.github.com/users/PaddlePaddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaddlePaddle/subscriptions","organizations_url":"https://api.github.com/users/PaddlePaddle/orgs","repos_url":"https://api.github.com/users/PaddlePaddle/repos","events_url":"https://api.github.com/users/PaddlePaddle/events{/privacy}","received_events_url":"https://api.github.com/users/PaddlePaddle/received_events","type":"Organization","site_admin":false},"repo":{"id":65711522,"name":"Paddle","full_name":"PaddlePaddle/Paddle","owner":{"login":"PaddlePaddle","id":23534030,"avatar_url":"https://avatars3.githubusercontent.com/u/23534030?v=4","gravatar_id":"","url":"https://api.github.com/users/PaddlePaddle","html_url":"https://github.com/PaddlePaddle","followers_url":"https://api.github.com/users/PaddlePaddle/followers","following_url":"https://api.github.com/users/PaddlePaddle/following{/other_user}","gists_url":"https://api.github.com/users/PaddlePaddle/gists{/gist_id}","starred_url":"https://api.github.com/users/PaddlePaddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaddlePaddle/subscriptions","organizations_url":"https://api.github.com/users/PaddlePaddle/orgs","repos_url":"https://api.github.com/users/PaddlePaddle/repos","events_url":"https://api.github.com/users/PaddlePaddle/events{/privacy}","received_events_url":"https://api.github.com/users/PaddlePaddle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PaddlePaddle/Paddle","description":"PArallel Distributed Deep LEarning","fork":false,"url":"https://api.github.com/repos/PaddlePaddle/Paddle","forks_url":"https://api.github.com/repos/PaddlePaddle/Paddle/forks","keys_url":"https://api.github.com/repos/PaddlePaddle/Paddle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PaddlePaddle/Paddle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PaddlePaddle/Paddle/teams","hooks_url":"https://api.github.com/repos/PaddlePaddle/Paddle/hooks","issue_events_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/events{/number}","events_url":"https://api.github.com/repos/PaddlePaddle/Paddle/events","assignees_url":"https://api.github.com/repos/PaddlePaddle/Paddle/assignees{/user}","branches_url":"https://api.github.com/repos/PaddlePaddle/Paddle/branches{/branch}","tags_url":"https://api.github.com/repos/PaddlePaddle/Paddle/tags","blobs_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/refs{/sha}","trees_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/{sha}","languages_url":"https://api.github.com/repos/PaddlePaddle/Paddle/languages","stargazers_url":"https://api.github.com/repos/PaddlePaddle/Paddle/stargazers","contributors_url":"https://api.github.com/repos/PaddlePaddle/Paddle/contributors","subscribers_url":"https://api.github.com/repos/PaddlePaddle/Paddle/subscribers","subscription_url":"https://api.github.com/repos/PaddlePaddle/Paddle/subscription","commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/commits{/sha}","git_commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/commits{/sha}","comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/comments{/number}","issue_comment_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/comments{/number}","contents_url":"https://api.github.com/repos/PaddlePaddle/Paddle/contents/{+path}","compare_url":"https://api.github.com/repos/PaddlePaddle/Paddle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PaddlePaddle/Paddle/merges","archive_url":"https://api.github.com/repos/PaddlePaddle/Paddle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PaddlePaddle/Paddle/downloads","issues_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues{/number}","pulls_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls{/number}","milestones_url":"https://api.github.com/repos/PaddlePaddle/Paddle/milestones{/number}","notifications_url":"https://api.github.com/repos/PaddlePaddle/Paddle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PaddlePaddle/Paddle/labels{/name}","releases_url":"https://api.github.com/repos/PaddlePaddle/Paddle/releases{/id}","deployments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/deployments","created_at":"2016-08-15T06:59:08Z","updated_at":"2018-04-19T09:09:16Z","pushed_at":"2018-04-19T09:21:52Z","git_url":"git://github.com/PaddlePaddle/Paddle.git","ssh_url":"git@github.com:PaddlePaddle/Paddle.git","clone_url":"https://github.com/PaddlePaddle/Paddle.git","svn_url":"https://github.com/PaddlePaddle/Paddle","homepage":"http://www.paddlepaddle.org/","size":101208,"stargazers_count":6737,"watchers_count":6737,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1818,"mirror_url":null,"archived":false,"open_issues_count":1266,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1818,"open_issues":1266,"watchers":6737,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9902"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/9902"},"issue":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/9902"},"comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/9902/comments"},"review_comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9902/comments"},"review_comment":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9902/commits"},"statuses":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/c72f39d63027b3c8bebcc5f512f06fc477995a01"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dzhwinter"}}