{"action":"created","issue":{"url":"https://api.github.com/repos/imageworks/OpenShadingLanguage/issues/902","repository_url":"https://api.github.com/repos/imageworks/OpenShadingLanguage","labels_url":"https://api.github.com/repos/imageworks/OpenShadingLanguage/issues/902/labels{/name}","comments_url":"https://api.github.com/repos/imageworks/OpenShadingLanguage/issues/902/comments","events_url":"https://api.github.com/repos/imageworks/OpenShadingLanguage/issues/902/events","html_url":"https://github.com/imageworks/OpenShadingLanguage/pull/902","id":343167114,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyODk1MTk4","number":902,"title":"Device Strings","user":{"login":"timgrant","id":8603285,"node_id":"MDQ6VXNlcjg2MDMyODU=","avatar_url":"https://avatars2.githubusercontent.com/u/8603285?v=4","gravatar_id":"","url":"https://api.github.com/users/timgrant","html_url":"https://github.com/timgrant","followers_url":"https://api.github.com/users/timgrant/followers","following_url":"https://api.github.com/users/timgrant/following{/other_user}","gists_url":"https://api.github.com/users/timgrant/gists{/gist_id}","starred_url":"https://api.github.com/users/timgrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timgrant/subscriptions","organizations_url":"https://api.github.com/users/timgrant/orgs","repos_url":"https://api.github.com/users/timgrant/repos","events_url":"https://api.github.com/users/timgrant/events{/privacy}","received_events_url":"https://api.github.com/users/timgrant/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-07-20T16:15:40Z","updated_at":"2018-07-26T01:07:46Z","closed_at":"2018-07-26T01:07:36Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/imageworks/OpenShadingLanguage/pulls/902","html_url":"https://github.com/imageworks/OpenShadingLanguage/pull/902","diff_url":"https://github.com/imageworks/OpenShadingLanguage/pull/902.diff","patch_url":"https://github.com/imageworks/OpenShadingLanguage/pull/902.patch"},"body":"## Description\r\n\r\nThis is our second take on a GPU-friendly alternative to ``OIIO::ustring``. The main premise is that string constants reside in a block of CUDA device memory, with one entry for each canonical string. As with ``ustring``, two strings can be tested for equality by comparing their pointer values.\r\n\r\nAs a convenience, the length of the string and its hash value are stored in the 16 bytes preceding the characters in device memory, resulting in the following layout:\r\n\r\n```\r\nstruct TableReb {\r\n    size_t hash;\r\n    size_t len;\r\n    char  str[len+1];\r\n};\r\n```\r\n\r\nThe ``testoptix`` project has been updated to include a ``StringTable`` class that manages the device memory and creates OptiX variables for each of the strings.\r\n\r\nAs in take one, only static string operations are currently supported.\r\n\r\n### Variables & STRDECLs\r\nCreating variables is especially important for the set of \"standard\" strings (generally, members of the ``Strings`` namespace), to prevent raw pointer values from appearing in the compiled shaders, which helps make the generated PTX more friendly to OptiX's caching mechanisms.\r\n\r\nThe standard strings are enumerated in ``<OSL/strdecls.h>``. The STRDECLs are used to create the global variables for the strings in ``<OSL/device_string.h>``(which declares the variables) and ``StringTable::init`` (which creates the entries in the string table).\r\n\r\n<!-- Please provide a description of what this PR is meant to fix, and  -->\r\n<!-- how it works (if it's not going to be very clear from the code).   -->\r\n\r\n## Tests\r\nThe testsuite has been updated with some simple tests to test basic string operations (assignment, comparison, strlen, etc.).\r\n<!-- Did you / should you add a testsuite case (new test, or add to an  -->\r\n<!-- existing test) to verify that this works?                          -->\r\n\r\n\r\n## Checklist:\r\n\r\n<!-- Put an 'x' in the boxes as you complete the checklist items -->\r\n\r\n- [x] I have read the [contribution guidelines](../CONTRIBUTING.md).\r\n- [x] I have previously submitted a [Contributor License Agreement](http://opensource.imageworks.com/cla/).\r\n- [x] I have updated the documentation, if applicable.\r\n- [x] I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).\r\n- [x] My code follows the prevailing code style of this project.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/imageworks/OpenShadingLanguage/issues/comments/407943764","html_url":"https://github.com/imageworks/OpenShadingLanguage/pull/902#issuecomment-407943764","issue_url":"https://api.github.com/repos/imageworks/OpenShadingLanguage/issues/902","id":407943764,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNzk0Mzc2NA==","user":{"login":"lgritz","id":504179,"node_id":"MDQ6VXNlcjUwNDE3OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/504179?v=4","gravatar_id":"","url":"https://api.github.com/users/lgritz","html_url":"https://github.com/lgritz","followers_url":"https://api.github.com/users/lgritz/followers","following_url":"https://api.github.com/users/lgritz/following{/other_user}","gists_url":"https://api.github.com/users/lgritz/gists{/gist_id}","starred_url":"https://api.github.com/users/lgritz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lgritz/subscriptions","organizations_url":"https://api.github.com/users/lgritz/orgs","repos_url":"https://api.github.com/users/lgritz/repos","events_url":"https://api.github.com/users/lgritz/events{/privacy}","received_events_url":"https://api.github.com/users/lgritz/received_events","type":"User","site_admin":false},"created_at":"2018-07-26T01:07:46Z","updated_at":"2018-07-26T01:07:46Z","author_association":"MEMBER","body":"merged, thanks\r\n"}}
{"actor":{"display_login":"lgritz"}}