{"action":"created","comment":{"url":"https://api.github.com/repos/torch/cutorch/pulls/comments/86619198","pull_request_review_id":7271726,"id":86619198,"diff_hunk":"@@ -48,11 +46,81 @@ function cutorch.createCudaHostTensor(...)\n    else\n       size = torch.LongTensor{...}\n    end\n+   return size\n+end\n \n+-- Creates a FloatTensor using the CudaHostAllocator.\n+-- Accepts either a LongStorage or a sequence of numbers.\n+function cutorch.createCudaHostTensor(...)\n+   local size = longTensorSize(...)\n    local storage = torch.FloatStorage(cutorch.CudaHostAllocator, size:prod())\n    return torch.FloatTensor(storage, 1, size:storage())\n end\n \n+-- Creates a CudaTensor using the CudaUVAAllocator.\n+-- Accepts either a LongStorage or a sequence of numbers.\n+function _createUVATensor(...)\n+   local size = longTensorSize(...)\n+   local storage = torch.FloatStorage(cutorch.CudaUVAAllocator, size:prod())\n+   return torch.FloatTensor(storage)\n+end\n+\n+function cutorch.createFloatUVATensor(...)\n+   return _createUVATensor(...)\n+end\n+\n+-- Creates a CudaTensor using the CudaUVAAllocator.\n+-- Accepts either a LongStorage or a sequence of numbers.\n+-- First creates a UVA backed FloatTensor and takes its pointer.\n+function cutorch.createCudaUVATensor(...)\n+   local ft = _createUVATensor(...)\n+   local storage = torch.CudaStorage(\n+      ft:storage():size(),\n+      tonumber(torch.data(ft:storage(), true))\n+   )\n+   return torch.CudaTensor(storage)\n+end\n+\n+-- UVA storage is a single memory location backed by virtual addressing.\n+-- Converting between CPU / GPU tensor types is done by raw pointer passing.\n+-- We only support FloatTensor, CudaTensor, Cuda -> float and float -> Cuda atm\n+function cutorch.toFloatUVATensor(t)\n+   if not torch.type(t):find('Tensor') then\n+      error('Must use a tensor, got ' .. torch.type(t))\n+   end\n+   -- See THCAllocator.c for explanation about synchronization\n+   cutorch.streamSynchronize(0)\n+   local storage = torch.FloatStorage(\n+      t:storage():size(),\n+      tonumber(torch.data(t:storage(), true))\n+   )\n+   cutorch.streamSynchronize(0)\n+   assert(cutorch.isManaged(storage))\n+   return torch.FloatTensor(storage)\n+end\n+\n+function cutorch.toCudaUVATensor(t)\n+   if not torch.type(t):find('Tensor') then\n+      error('Must use a tensor, got ' .. torch.type(t))\n+   end\n+   -- See THCAllocator.c for explanation about synchronization\n+   cutorch.streamSynchronize(0)\n+   local storage = torch.CudaStorage(\n+      t:storage():size(),\n+      tonumber(torch.data(t:storage(), true))\n+   )\n+   cutorch.streamSynchronize(0)\n+   assert(cutorch.isManaged(storage))\n+   return torch.CudaTensor(storage)\n+end\n+\n+function cutorch.isManaged(t)\n+   if not torch.type(t):find('Tensor') and not torch.type(t):find('Storage') then","path":"init.lua","position":84,"original_position":84,"commit_id":"a05fea73351bfddea74c59c628d3426366e5959e","original_commit_id":"a05fea73351bfddea74c59c628d3426366e5959e","user":{"login":"colesbury","id":655866,"avatar_url":"https://avatars.githubusercontent.com/u/655866?v=3","gravatar_id":"","url":"https://api.github.com/users/colesbury","html_url":"https://github.com/colesbury","followers_url":"https://api.github.com/users/colesbury/followers","following_url":"https://api.github.com/users/colesbury/following{/other_user}","gists_url":"https://api.github.com/users/colesbury/gists{/gist_id}","starred_url":"https://api.github.com/users/colesbury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colesbury/subscriptions","organizations_url":"https://api.github.com/users/colesbury/orgs","repos_url":"https://api.github.com/users/colesbury/repos","events_url":"https://api.github.com/users/colesbury/events{/privacy}","received_events_url":"https://api.github.com/users/colesbury/received_events","type":"User","site_admin":false},"body":"I think `torch.isTensor` and `torch.isStorage` should work","created_at":"2016-11-04T19:44:34Z","updated_at":"2016-11-04T19:51:58Z","html_url":"https://github.com/torch/cutorch/pull/583#discussion_r86619198","pull_request_url":"https://api.github.com/repos/torch/cutorch/pulls/583","_links":{"self":{"href":"https://api.github.com/repos/torch/cutorch/pulls/comments/86619198"},"html":{"href":"https://github.com/torch/cutorch/pull/583#discussion_r86619198"},"pull_request":{"href":"https://api.github.com/repos/torch/cutorch/pulls/583"}}},"pull_request":{"url":"https://api.github.com/repos/torch/cutorch/pulls/583","id":92220938,"html_url":"https://github.com/torch/cutorch/pull/583","diff_url":"https://github.com/torch/cutorch/pull/583.diff","patch_url":"https://github.com/torch/cutorch/pull/583.patch","issue_url":"https://api.github.com/repos/torch/cutorch/issues/583","number":583,"state":"open","locked":false,"title":"THC UVA Allocator","user":{"login":"nicolasvasilache","id":10148468,"avatar_url":"https://avatars.githubusercontent.com/u/10148468?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolasvasilache","html_url":"https://github.com/nicolasvasilache","followers_url":"https://api.github.com/users/nicolasvasilache/followers","following_url":"https://api.github.com/users/nicolasvasilache/following{/other_user}","gists_url":"https://api.github.com/users/nicolasvasilache/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolasvasilache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolasvasilache/subscriptions","organizations_url":"https://api.github.com/users/nicolasvasilache/orgs","repos_url":"https://api.github.com/users/nicolasvasilache/repos","events_url":"https://api.github.com/users/nicolasvasilache/events{/privacy}","received_events_url":"https://api.github.com/users/nicolasvasilache/received_events","type":"User","site_admin":false},"body":"This PR adds support for UVA allocation (backed by virtual memory).\r\n\r\nDepending on compute capabilities, perf and coherence vary so I am just adding the possibility to use UVA.\r\n\r\nSince a single allocation results in a pointer that can be used directly both on CPU and GPU, the conversion function only reference the same pointer and never allocate.\r\n\r\nSimilarly to the current cudaHostAllocator, only Cuda/Float tensors are supported atm.\r\n\r\nI have not propagated the pointer passing to the tensor:cuda() and tensor:float() functions, future work.\r\n","created_at":"2016-11-03T19:11:40Z","updated_at":"2016-11-04T19:51:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3915d9e120c1ff988d763f899dcd3332d683233f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/torch/cutorch/pulls/583/commits","review_comments_url":"https://api.github.com/repos/torch/cutorch/pulls/583/comments","review_comment_url":"https://api.github.com/repos/torch/cutorch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/torch/cutorch/issues/583/comments","statuses_url":"https://api.github.com/repos/torch/cutorch/statuses/a05fea73351bfddea74c59c628d3426366e5959e","head":{"label":"nicolasvasilache:master","ref":"master","sha":"a05fea73351bfddea74c59c628d3426366e5959e","user":{"login":"nicolasvasilache","id":10148468,"avatar_url":"https://avatars.githubusercontent.com/u/10148468?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolasvasilache","html_url":"https://github.com/nicolasvasilache","followers_url":"https://api.github.com/users/nicolasvasilache/followers","following_url":"https://api.github.com/users/nicolasvasilache/following{/other_user}","gists_url":"https://api.github.com/users/nicolasvasilache/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolasvasilache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolasvasilache/subscriptions","organizations_url":"https://api.github.com/users/nicolasvasilache/orgs","repos_url":"https://api.github.com/users/nicolasvasilache/repos","events_url":"https://api.github.com/users/nicolasvasilache/events{/privacy}","received_events_url":"https://api.github.com/users/nicolasvasilache/received_events","type":"User","site_admin":false},"repo":{"id":72777077,"name":"cutorch","full_name":"nicolasvasilache/cutorch","owner":{"login":"nicolasvasilache","id":10148468,"avatar_url":"https://avatars.githubusercontent.com/u/10148468?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolasvasilache","html_url":"https://github.com/nicolasvasilache","followers_url":"https://api.github.com/users/nicolasvasilache/followers","following_url":"https://api.github.com/users/nicolasvasilache/following{/other_user}","gists_url":"https://api.github.com/users/nicolasvasilache/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolasvasilache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolasvasilache/subscriptions","organizations_url":"https://api.github.com/users/nicolasvasilache/orgs","repos_url":"https://api.github.com/users/nicolasvasilache/repos","events_url":"https://api.github.com/users/nicolasvasilache/events{/privacy}","received_events_url":"https://api.github.com/users/nicolasvasilache/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nicolasvasilache/cutorch","description":"A CUDA backend for Torch7","fork":true,"url":"https://api.github.com/repos/nicolasvasilache/cutorch","forks_url":"https://api.github.com/repos/nicolasvasilache/cutorch/forks","keys_url":"https://api.github.com/repos/nicolasvasilache/cutorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nicolasvasilache/cutorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nicolasvasilache/cutorch/teams","hooks_url":"https://api.github.com/repos/nicolasvasilache/cutorch/hooks","issue_events_url":"https://api.github.com/repos/nicolasvasilache/cutorch/issues/events{/number}","events_url":"https://api.github.com/repos/nicolasvasilache/cutorch/events","assignees_url":"https://api.github.com/repos/nicolasvasilache/cutorch/assignees{/user}","branches_url":"https://api.github.com/repos/nicolasvasilache/cutorch/branches{/branch}","tags_url":"https://api.github.com/repos/nicolasvasilache/cutorch/tags","blobs_url":"https://api.github.com/repos/nicolasvasilache/cutorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nicolasvasilache/cutorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nicolasvasilache/cutorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/nicolasvasilache/cutorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nicolasvasilache/cutorch/statuses/{sha}","languages_url":"https://api.github.com/repos/nicolasvasilache/cutorch/languages","stargazers_url":"https://api.github.com/repos/nicolasvasilache/cutorch/stargazers","contributors_url":"https://api.github.com/repos/nicolasvasilache/cutorch/contributors","subscribers_url":"https://api.github.com/repos/nicolasvasilache/cutorch/subscribers","subscription_url":"https://api.github.com/repos/nicolasvasilache/cutorch/subscription","commits_url":"https://api.github.com/repos/nicolasvasilache/cutorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/nicolasvasilache/cutorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/nicolasvasilache/cutorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/nicolasvasilache/cutorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/nicolasvasilache/cutorch/contents/{+path}","compare_url":"https://api.github.com/repos/nicolasvasilache/cutorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nicolasvasilache/cutorch/merges","archive_url":"https://api.github.com/repos/nicolasvasilache/cutorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nicolasvasilache/cutorch/downloads","issues_url":"https://api.github.com/repos/nicolasvasilache/cutorch/issues{/number}","pulls_url":"https://api.github.com/repos/nicolasvasilache/cutorch/pulls{/number}","milestones_url":"https://api.github.com/repos/nicolasvasilache/cutorch/milestones{/number}","notifications_url":"https://api.github.com/repos/nicolasvasilache/cutorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nicolasvasilache/cutorch/labels{/name}","releases_url":"https://api.github.com/repos/nicolasvasilache/cutorch/releases{/id}","deployments_url":"https://api.github.com/repos/nicolasvasilache/cutorch/deployments","created_at":"2016-11-03T18:56:58Z","updated_at":"2016-11-03T18:56:59Z","pushed_at":"2016-11-03T19:08:57Z","git_url":"git://github.com/nicolasvasilache/cutorch.git","ssh_url":"git@github.com:nicolasvasilache/cutorch.git","clone_url":"https://github.com/nicolasvasilache/cutorch.git","svn_url":"https://github.com/nicolasvasilache/cutorch","homepage":"","size":1639,"stargazers_count":0,"watchers_count":0,"language":"Cuda","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"torch:master","ref":"master","sha":"d165fa2eb5b020196923f1336d93e13e26a52b29","user":{"login":"torch","id":4978924,"avatar_url":"https://avatars.githubusercontent.com/u/4978924?v=3","gravatar_id":"","url":"https://api.github.com/users/torch","html_url":"https://github.com/torch","followers_url":"https://api.github.com/users/torch/followers","following_url":"https://api.github.com/users/torch/following{/other_user}","gists_url":"https://api.github.com/users/torch/gists{/gist_id}","starred_url":"https://api.github.com/users/torch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/torch/subscriptions","organizations_url":"https://api.github.com/users/torch/orgs","repos_url":"https://api.github.com/users/torch/repos","events_url":"https://api.github.com/users/torch/events{/privacy}","received_events_url":"https://api.github.com/users/torch/received_events","type":"Organization","site_admin":false},"repo":{"id":13677478,"name":"cutorch","full_name":"torch/cutorch","owner":{"login":"torch","id":4978924,"avatar_url":"https://avatars.githubusercontent.com/u/4978924?v=3","gravatar_id":"","url":"https://api.github.com/users/torch","html_url":"https://github.com/torch","followers_url":"https://api.github.com/users/torch/followers","following_url":"https://api.github.com/users/torch/following{/other_user}","gists_url":"https://api.github.com/users/torch/gists{/gist_id}","starred_url":"https://api.github.com/users/torch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/torch/subscriptions","organizations_url":"https://api.github.com/users/torch/orgs","repos_url":"https://api.github.com/users/torch/repos","events_url":"https://api.github.com/users/torch/events{/privacy}","received_events_url":"https://api.github.com/users/torch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/torch/cutorch","description":"A CUDA backend for Torch7","fork":false,"url":"https://api.github.com/repos/torch/cutorch","forks_url":"https://api.github.com/repos/torch/cutorch/forks","keys_url":"https://api.github.com/repos/torch/cutorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/torch/cutorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/torch/cutorch/teams","hooks_url":"https://api.github.com/repos/torch/cutorch/hooks","issue_events_url":"https://api.github.com/repos/torch/cutorch/issues/events{/number}","events_url":"https://api.github.com/repos/torch/cutorch/events","assignees_url":"https://api.github.com/repos/torch/cutorch/assignees{/user}","branches_url":"https://api.github.com/repos/torch/cutorch/branches{/branch}","tags_url":"https://api.github.com/repos/torch/cutorch/tags","blobs_url":"https://api.github.com/repos/torch/cutorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/torch/cutorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/torch/cutorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/torch/cutorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/torch/cutorch/statuses/{sha}","languages_url":"https://api.github.com/repos/torch/cutorch/languages","stargazers_url":"https://api.github.com/repos/torch/cutorch/stargazers","contributors_url":"https://api.github.com/repos/torch/cutorch/contributors","subscribers_url":"https://api.github.com/repos/torch/cutorch/subscribers","subscription_url":"https://api.github.com/repos/torch/cutorch/subscription","commits_url":"https://api.github.com/repos/torch/cutorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/torch/cutorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/torch/cutorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/torch/cutorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/torch/cutorch/contents/{+path}","compare_url":"https://api.github.com/repos/torch/cutorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/torch/cutorch/merges","archive_url":"https://api.github.com/repos/torch/cutorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/torch/cutorch/downloads","issues_url":"https://api.github.com/repos/torch/cutorch/issues{/number}","pulls_url":"https://api.github.com/repos/torch/cutorch/pulls{/number}","milestones_url":"https://api.github.com/repos/torch/cutorch/milestones{/number}","notifications_url":"https://api.github.com/repos/torch/cutorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/torch/cutorch/labels{/name}","releases_url":"https://api.github.com/repos/torch/cutorch/releases{/id}","deployments_url":"https://api.github.com/repos/torch/cutorch/deployments","created_at":"2013-10-18T12:29:23Z","updated_at":"2016-11-01T15:04:48Z","pushed_at":"2016-11-03T21:10:56Z","git_url":"git://github.com/torch/cutorch.git","ssh_url":"git@github.com:torch/cutorch.git","clone_url":"https://github.com/torch/cutorch.git","svn_url":"https://github.com/torch/cutorch","homepage":"","size":11749,"stargazers_count":182,"watchers_count":182,"language":"Cuda","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":139,"mirror_url":null,"open_issues_count":62,"forks":139,"open_issues":62,"watchers":182,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/torch/cutorch/pulls/583"},"html":{"href":"https://github.com/torch/cutorch/pull/583"},"issue":{"href":"https://api.github.com/repos/torch/cutorch/issues/583"},"comments":{"href":"https://api.github.com/repos/torch/cutorch/issues/583/comments"},"review_comments":{"href":"https://api.github.com/repos/torch/cutorch/pulls/583/comments"},"review_comment":{"href":"https://api.github.com/repos/torch/cutorch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/torch/cutorch/pulls/583/commits"},"statuses":{"href":"https://api.github.com/repos/torch/cutorch/statuses/a05fea73351bfddea74c59c628d3426366e5959e"}}}}
{"actor":{"display_login":"colesbury"}}