{"action":"created","comment":{"url":"https://api.github.com/repos/openucx/ucx/pulls/comments/44224857","id":44224857,"diff_hunk":"@@ -0,0 +1,122 @@\n+/**\n+* Copyright (C) Mellanox Technologies Ltd. 2001-2014.  ALL RIGHTS RESERVED.\n+* Copyright (C) UT-Battelle, LLC. 2014. ALL RIGHTS RESERVED.\n+* See file LICENSE for terms.\n+*/\n+\n+extern \"C\" {\n+#include <uct/api/uct.h>\n+#include <ucs/time/time.h>\n+}\n+#include <ucs/gtest/test.h>\n+#include \"uct_test.h\"\n+\n+class test_uct_pending : public uct_test {\n+public:\n+    void initialize() {\n+        uct_test::init();\n+\n+        m_e1 = uct_test::create_entity(0);\n+        m_e2 = uct_test::create_entity(0);\n+\n+        m_e1->connect(0, *m_e2, 0);\n+        m_e2->connect(0, *m_e1, 0);\n+\n+        m_entities.push_back(m_e1);\n+        m_entities.push_back(m_e2);\n+    }\n+\n+    typedef struct pending_send_request {\n+        uct_ep_h          ep;\n+        uint64_t          hdr;\n+        unsigned          buffer;     /* Send buffer */\n+        size_t            length;     /* Total length, in bytes */\n+        uct_pending_req_t uct;\n+    } pending_send_request_t;\n+\n+    static ucs_status_t pending_am_handler(void *arg, void *data, size_t length,\n+                                           void *desc) {\n+\n+        unsigned *counter = (unsigned *) arg;\n+        uint64_t test_hdr = *(uint64_t *) data;\n+        uint64_t actual_data = *(unsigned*)((char*)data + sizeof(test_hdr));\n+\n+        if ((test_hdr == 0xabcd) && (actual_data == (0xdeadbeef + *counter))) {\n+            (*counter)++;\n+        } else {\n+            UCS_TEST_ABORT(\"Error in comparison in pending_am_handler. Counter: \" << counter);\n+        }\n+\n+        return UCS_OK;\n+    }\n+\n+    static ucs_status_t pending_send_op(uct_pending_req_t *self) {\n+\n+        pending_send_request_t *req = ucs_container_of(self, pending_send_request_t, uct);\n+        ucs_status_t status;\n+\n+        status = uct_ep_am_short(req->ep, 0, req->hdr, &req->buffer, req->length);\n+        if (status == UCS_OK) {\n+            free(req);\n+        }\n+        return status;\n+    }\n+\n+    void cleanup() {\n+        uct_test::cleanup();\n+    }\n+\n+protected:\n+    entity *m_e1, *m_e2;\n+};\n+\n+UCS_TEST_P(test_uct_pending, pending_op)\n+{\n+    uint64_t send_data = 0xdeadbeef;\n+    uint64_t test_pending_hdr = 0xabcd;\n+    ucs_status_t status;\n+    pending_send_request_t *req;\n+    int i, counter = 0;\n+\n+    initialize();\n+    check_caps(UCT_IFACE_FLAG_AM_SHORT | UCT_IFACE_FLAG_PENDING);\n+\n+    /* set a callback for the uct to invoke for receiving the data */\n+    uct_iface_set_am_handler(m_e2->iface(), 0, pending_am_handler , &counter);\n+\n+    /* send the data until the resources run out */\n+    for (i = 0; i < 100000; i++) {\n+        status = uct_ep_am_short(m_e1->ep(0), 0, test_pending_hdr, &send_data,\n+                                 sizeof(send_data));\n+        if (status != UCS_OK) {\n+            if (status == UCS_ERR_NO_RESOURCE) {\n+\n+                req = (pending_send_request_t *) malloc(sizeof(*req));\n+                req->buffer   = send_data;\n+                req->hdr      = test_pending_hdr;\n+                req->length   = sizeof(send_data);\n+                req->ep       = m_e1->ep(0);\n+                req->uct.func = pending_send_op;\n+\n+                status = uct_ep_pending_add(m_e1->ep(0), &req->uct);\n+                if (status != UCS_OK) {","path":"test/gtest/uct/test_pending.cc","position":102,"original_position":102,"commit_id":"f19923ab000d9f565abf6c175efb34f8404e3f33","original_commit_id":"f19923ab000d9f565abf6c175efb34f8404e3f33","user":{"login":"yosefe","id":2255631,"avatar_url":"https://avatars.githubusercontent.com/u/2255631?v=3","gravatar_id":"","url":"https://api.github.com/users/yosefe","html_url":"https://github.com/yosefe","followers_url":"https://api.github.com/users/yosefe/followers","following_url":"https://api.github.com/users/yosefe/following{/other_user}","gists_url":"https://api.github.com/users/yosefe/gists{/gist_id}","starred_url":"https://api.github.com/users/yosefe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yosefe/subscriptions","organizations_url":"https://api.github.com/users/yosefe/orgs","repos_url":"https://api.github.com/users/yosefe/repos","events_url":"https://api.github.com/users/yosefe/events{/privacy}","received_events_url":"https://api.github.com/users/yosefe/received_events","type":"User","site_admin":false},"body":"this doesn't meant it was sent, if add returns busy need to retry sending.","created_at":"2015-11-08T13:47:56Z","updated_at":"2015-11-08T13:47:56Z","html_url":"https://github.com/openucx/ucx/pull/450#discussion_r44224857","pull_request_url":"https://api.github.com/repos/openucx/ucx/pulls/450","_links":{"self":{"href":"https://api.github.com/repos/openucx/ucx/pulls/comments/44224857"},"html":{"href":"https://github.com/openucx/ucx/pull/450#discussion_r44224857"},"pull_request":{"href":"https://api.github.com/repos/openucx/ucx/pulls/450"}}},"pull_request":{"url":"https://api.github.com/repos/openucx/ucx/pulls/450","id":48295135,"html_url":"https://github.com/openucx/ucx/pull/450","diff_url":"https://github.com/openucx/ucx/pull/450.diff","patch_url":"https://github.com/openucx/ucx/pull/450.patch","issue_url":"https://api.github.com/repos/openucx/ucx/issues/450","number":450,"state":"open","locked":false,"title":"SM/MM: added support for pending operations.","user":{"login":"alinask","id":2405183,"avatar_url":"https://avatars.githubusercontent.com/u/2405183?v=3","gravatar_id":"","url":"https://api.github.com/users/alinask","html_url":"https://github.com/alinask","followers_url":"https://api.github.com/users/alinask/followers","following_url":"https://api.github.com/users/alinask/following{/other_user}","gists_url":"https://api.github.com/users/alinask/gists{/gist_id}","starred_url":"https://api.github.com/users/alinask/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alinask/subscriptions","organizations_url":"https://api.github.com/users/alinask/orgs","repos_url":"https://api.github.com/users/alinask/repos","events_url":"https://api.github.com/users/alinask/events{/privacy}","received_events_url":"https://api.github.com/users/alinask/received_events","type":"User","site_admin":false},"body":null,"created_at":"2015-10-21T07:10:04Z","updated_at":"2015-11-08T13:47:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e212cadb3d1fb64f33fadbfd92a30af5ae78fa2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openucx/ucx/pulls/450/commits","review_comments_url":"https://api.github.com/repos/openucx/ucx/pulls/450/comments","review_comment_url":"https://api.github.com/repos/openucx/ucx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openucx/ucx/issues/450/comments","statuses_url":"https://api.github.com/repos/openucx/ucx/statuses/f19923ab000d9f565abf6c175efb34f8404e3f33","head":{"label":"alinask:topic/mm-pending-ops","ref":"topic/mm-pending-ops","sha":"f19923ab000d9f565abf6c175efb34f8404e3f33","user":{"login":"alinask","id":2405183,"avatar_url":"https://avatars.githubusercontent.com/u/2405183?v=3","gravatar_id":"","url":"https://api.github.com/users/alinask","html_url":"https://github.com/alinask","followers_url":"https://api.github.com/users/alinask/followers","following_url":"https://api.github.com/users/alinask/following{/other_user}","gists_url":"https://api.github.com/users/alinask/gists{/gist_id}","starred_url":"https://api.github.com/users/alinask/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alinask/subscriptions","organizations_url":"https://api.github.com/users/alinask/orgs","repos_url":"https://api.github.com/users/alinask/repos","events_url":"https://api.github.com/users/alinask/events{/privacy}","received_events_url":"https://api.github.com/users/alinask/received_events","type":"User","site_admin":false},"repo":{"id":39071172,"name":"ucx","full_name":"alinask/ucx","owner":{"login":"alinask","id":2405183,"avatar_url":"https://avatars.githubusercontent.com/u/2405183?v=3","gravatar_id":"","url":"https://api.github.com/users/alinask","html_url":"https://github.com/alinask","followers_url":"https://api.github.com/users/alinask/followers","following_url":"https://api.github.com/users/alinask/following{/other_user}","gists_url":"https://api.github.com/users/alinask/gists{/gist_id}","starred_url":"https://api.github.com/users/alinask/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alinask/subscriptions","organizations_url":"https://api.github.com/users/alinask/orgs","repos_url":"https://api.github.com/users/alinask/repos","events_url":"https://api.github.com/users/alinask/events{/privacy}","received_events_url":"https://api.github.com/users/alinask/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alinask/ucx","description":"Unified Communication X : ","fork":true,"url":"https://api.github.com/repos/alinask/ucx","forks_url":"https://api.github.com/repos/alinask/ucx/forks","keys_url":"https://api.github.com/repos/alinask/ucx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alinask/ucx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alinask/ucx/teams","hooks_url":"https://api.github.com/repos/alinask/ucx/hooks","issue_events_url":"https://api.github.com/repos/alinask/ucx/issues/events{/number}","events_url":"https://api.github.com/repos/alinask/ucx/events","assignees_url":"https://api.github.com/repos/alinask/ucx/assignees{/user}","branches_url":"https://api.github.com/repos/alinask/ucx/branches{/branch}","tags_url":"https://api.github.com/repos/alinask/ucx/tags","blobs_url":"https://api.github.com/repos/alinask/ucx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alinask/ucx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alinask/ucx/git/refs{/sha}","trees_url":"https://api.github.com/repos/alinask/ucx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alinask/ucx/statuses/{sha}","languages_url":"https://api.github.com/repos/alinask/ucx/languages","stargazers_url":"https://api.github.com/repos/alinask/ucx/stargazers","contributors_url":"https://api.github.com/repos/alinask/ucx/contributors","subscribers_url":"https://api.github.com/repos/alinask/ucx/subscribers","subscription_url":"https://api.github.com/repos/alinask/ucx/subscription","commits_url":"https://api.github.com/repos/alinask/ucx/commits{/sha}","git_commits_url":"https://api.github.com/repos/alinask/ucx/git/commits{/sha}","comments_url":"https://api.github.com/repos/alinask/ucx/comments{/number}","issue_comment_url":"https://api.github.com/repos/alinask/ucx/issues/comments{/number}","contents_url":"https://api.github.com/repos/alinask/ucx/contents/{+path}","compare_url":"https://api.github.com/repos/alinask/ucx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alinask/ucx/merges","archive_url":"https://api.github.com/repos/alinask/ucx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alinask/ucx/downloads","issues_url":"https://api.github.com/repos/alinask/ucx/issues{/number}","pulls_url":"https://api.github.com/repos/alinask/ucx/pulls{/number}","milestones_url":"https://api.github.com/repos/alinask/ucx/milestones{/number}","notifications_url":"https://api.github.com/repos/alinask/ucx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alinask/ucx/labels{/name}","releases_url":"https://api.github.com/repos/alinask/ucx/releases{/id}","created_at":"2015-07-14T11:34:14Z","updated_at":"2015-07-14T11:34:16Z","pushed_at":"2015-11-08T13:00:54Z","git_url":"git://github.com/alinask/ucx.git","ssh_url":"git@github.com:alinask/ucx.git","clone_url":"https://github.com/alinask/ucx.git","svn_url":"https://github.com/alinask/ucx","homepage":" http://www.openucx.org","size":2960,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openucx:master","ref":"master","sha":"c37172678706a85730a4ce19e8ee4507b00dacbc","user":{"login":"openucx","id":13118737,"avatar_url":"https://avatars.githubusercontent.com/u/13118737?v=3","gravatar_id":"","url":"https://api.github.com/users/openucx","html_url":"https://github.com/openucx","followers_url":"https://api.github.com/users/openucx/followers","following_url":"https://api.github.com/users/openucx/following{/other_user}","gists_url":"https://api.github.com/users/openucx/gists{/gist_id}","starred_url":"https://api.github.com/users/openucx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openucx/subscriptions","organizations_url":"https://api.github.com/users/openucx/orgs","repos_url":"https://api.github.com/users/openucx/repos","events_url":"https://api.github.com/users/openucx/events{/privacy}","received_events_url":"https://api.github.com/users/openucx/received_events","type":"Organization","site_admin":false},"repo":{"id":25379390,"name":"ucx","full_name":"openucx/ucx","owner":{"login":"openucx","id":13118737,"avatar_url":"https://avatars.githubusercontent.com/u/13118737?v=3","gravatar_id":"","url":"https://api.github.com/users/openucx","html_url":"https://github.com/openucx","followers_url":"https://api.github.com/users/openucx/followers","following_url":"https://api.github.com/users/openucx/following{/other_user}","gists_url":"https://api.github.com/users/openucx/gists{/gist_id}","starred_url":"https://api.github.com/users/openucx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openucx/subscriptions","organizations_url":"https://api.github.com/users/openucx/orgs","repos_url":"https://api.github.com/users/openucx/repos","events_url":"https://api.github.com/users/openucx/events{/privacy}","received_events_url":"https://api.github.com/users/openucx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openucx/ucx","description":"Unified Communication X  (https://elist.ornl.gov/mailman/listinfo/ucx-group): ","fork":false,"url":"https://api.github.com/repos/openucx/ucx","forks_url":"https://api.github.com/repos/openucx/ucx/forks","keys_url":"https://api.github.com/repos/openucx/ucx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openucx/ucx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openucx/ucx/teams","hooks_url":"https://api.github.com/repos/openucx/ucx/hooks","issue_events_url":"https://api.github.com/repos/openucx/ucx/issues/events{/number}","events_url":"https://api.github.com/repos/openucx/ucx/events","assignees_url":"https://api.github.com/repos/openucx/ucx/assignees{/user}","branches_url":"https://api.github.com/repos/openucx/ucx/branches{/branch}","tags_url":"https://api.github.com/repos/openucx/ucx/tags","blobs_url":"https://api.github.com/repos/openucx/ucx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openucx/ucx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openucx/ucx/git/refs{/sha}","trees_url":"https://api.github.com/repos/openucx/ucx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openucx/ucx/statuses/{sha}","languages_url":"https://api.github.com/repos/openucx/ucx/languages","stargazers_url":"https://api.github.com/repos/openucx/ucx/stargazers","contributors_url":"https://api.github.com/repos/openucx/ucx/contributors","subscribers_url":"https://api.github.com/repos/openucx/ucx/subscribers","subscription_url":"https://api.github.com/repos/openucx/ucx/subscription","commits_url":"https://api.github.com/repos/openucx/ucx/commits{/sha}","git_commits_url":"https://api.github.com/repos/openucx/ucx/git/commits{/sha}","comments_url":"https://api.github.com/repos/openucx/ucx/comments{/number}","issue_comment_url":"https://api.github.com/repos/openucx/ucx/issues/comments{/number}","contents_url":"https://api.github.com/repos/openucx/ucx/contents/{+path}","compare_url":"https://api.github.com/repos/openucx/ucx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openucx/ucx/merges","archive_url":"https://api.github.com/repos/openucx/ucx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openucx/ucx/downloads","issues_url":"https://api.github.com/repos/openucx/ucx/issues{/number}","pulls_url":"https://api.github.com/repos/openucx/ucx/pulls{/number}","milestones_url":"https://api.github.com/repos/openucx/ucx/milestones{/number}","notifications_url":"https://api.github.com/repos/openucx/ucx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openucx/ucx/labels{/name}","releases_url":"https://api.github.com/repos/openucx/ucx/releases{/id}","created_at":"2014-10-17T22:17:24Z","updated_at":"2015-11-06T02:45:56Z","pushed_at":"2015-11-08T13:00:54Z","git_url":"git://github.com/openucx/ucx.git","ssh_url":"git@github.com:openucx/ucx.git","clone_url":"https://github.com/openucx/ucx.git","svn_url":"https://github.com/openucx/ucx","homepage":" http://www.openucx.org","size":7760,"stargazers_count":21,"watchers_count":21,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":45,"forks":14,"open_issues":45,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openucx/ucx/pulls/450"},"html":{"href":"https://github.com/openucx/ucx/pull/450"},"issue":{"href":"https://api.github.com/repos/openucx/ucx/issues/450"},"comments":{"href":"https://api.github.com/repos/openucx/ucx/issues/450/comments"},"review_comments":{"href":"https://api.github.com/repos/openucx/ucx/pulls/450/comments"},"review_comment":{"href":"https://api.github.com/repos/openucx/ucx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openucx/ucx/pulls/450/commits"},"statuses":{"href":"https://api.github.com/repos/openucx/ucx/statuses/f19923ab000d9f565abf6c175efb34f8404e3f33"}}}}