<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/slang-ir-string-hash.cpp, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2024-10-29T06:49:26+00:00</updated>
<entry>
<title>format</title>
<updated>2024-10-29T06:49:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T06:49:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21'/>
<id>urn:sha1:f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21</id>
<content type='text'>
* format

* Minor test fixes

* enable checking cpp format in ci</content>
</entry>
<entry>
<title>Refactor compiler option representations. (#3598)</title>
<updated>2024-02-20T20:24:00+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-02-20T20:24:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=4d20fd329956ac89408b1628a8291fea01bc9a6d'/>
<id>urn:sha1:4d20fd329956ac89408b1628a8291fea01bc9a6d</id>
<content type='text'>
* Refactor compiler option representation.

* Fix binary compatibility.

* Add a test for specifying compiler options at link time.

* Fix binary compatibility.

* Fix binary compatibility.

* Fix backward compatibility on matrix layout.

* Fix.

* Fix.

* Fix.

* Fix gfx.

* Fix gfx.

* Fix dynamic dispatch.

* Polish.</content>
</entry>
<entry>
<title>Remove `SharedIRBuilder`. (#2657)</title>
<updated>2023-02-17T00:44:04+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-02-17T00:44:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=245466d89cfe54b78da486f06d470bc6daaf4625'/>
<id>urn:sha1:245466d89cfe54b78da486f06d470bc6daaf4625</id>
<content type='text'>
Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Inline functions with string param/return for GPU targets (#2544)</title>
<updated>2022-12-02T14:29:38+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-12-02T14:29:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=92ae4949fe1af28ef31331fd4116c8111c057420'/>
<id>urn:sha1:92ae4949fe1af28ef31331fd4116c8111c057420</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* WIP inlining of functions that take or return string related types on GPU targets.

* Small fixes.

* Added a test.

* Add checking for any getStringHash insts are valid.

* Support getStringHash on CUDA.

* Tweak diagnostic.</content>
</entry>
<entry>
<title>Cleanup refactoring work around the IR builder (#2061)</title>
<updated>2021-12-17T17:35:23+00:00</updated>
<author>
<name>Theresa Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-12-17T17:35:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=cc709e6532e2dc5da3dd19595bc635856d5fd33b'/>
<id>urn:sha1:cc709e6532e2dc5da3dd19595bc635856d5fd33b</id>
<content type='text'>
* Cleanup refactoring work around the IR builder

We have some long-term goals for the IR that require a more centralized and disciplined set of rules for how IR instructions get created/emitted. I had been working on trying to set things up so that all IR instruction creation goes through a single bottleneck point, but the non-trivial work in that branch was getting drowned out by the sheer volume of cleanup and refactoring changes. This change tries to pull together several of the more important cleanups.

The big pieces are:

* `IRBuilder` and `SharedIRBuilder` now protect their data members and rely on users to initialize them more directly via constructor of an `init()` method. This change affects a *bunch* of sites where `IRBuilder`s were created. I changed use sites to use the constructors whenever possible, and to use `init()` in cases where we had longer-lived builders that needed to be initialized multiple times.

* The insertion location for the `IRBuilder` now uses an encapsulated type called `IRInsertLoc`. This new type can replace what used to be just two `IRInst*` fields in the builder, and also covers some new functionality (if we ever want to take advantage of it). Very little client code cares about this change, but it is still a nice cleanup in terms of making things more explicit.

* The creation of an `IRModule` has been moded *out* of `IRBuilder`, because in practice we `IRBuilder` always wants to be associated with a pre-existing `IRModule` at creation time (via its `SharedIRBuilder`). There is now an `IRModule::create()` operation instead. This required changing the sequencing at many `IRModule` creation sites, since most had been contriving to make an `IRBuilder` first. There were also several cleanups because code had been carelessly using non-reference-counted pointers for `IRModule`s in ways that broke now that `IRModule::create()` always returns a `RefPtr`.

* The core operations to actually allocate memory for IR instructions were moved into `IRModule` (since they interact with the memory pool that the module owns). These *were* called `createEmptyInst()` but have been renamed into `_allocateInst()`. In principle these seem like they should only be needed to be called by the `IRBuilder`, but in practice they are also needed by the IR deserialization logic.

* A few core operations for emitting IR instructions that were associted with `IRBuilder` were moved to actually be methods on `IRBuilder`. First is `_findOrEmitConstant` which is the primary bottleneck for creating simple scalar constant values. Another is `_createInst` (formerly part of the templated `createInstImpl` along with `createInstWithSizeImpl`) which is the main bottleneck for allocation and initialization of any instruction other than a constant (well, the `IRModuleInst` is the other exception...). Finally, there is also `_maybeSetSourceLoc()`, which is obvious to scope inside the `IRBuilder` once it is protecting the source-location info.

Notes:

* The `minSizeInBytes` parameter to `_createInst()` might not actually be needed at all. At this point any `IRInst` subtypes that need data allocated for things other than their operands already get created manually via `_allocateInst` or `_findOrEmitConstant`, so I *think* we could remove that part. I will handle that in a subsequent cleanup if it turns out to be the case.

* There is one IR pass (`slang-ir-string-hash.cpp`) that is using manual `_allocateInst()` instead of going through an `IRBuilder`. It could be easily cleaned up to not do so (and I will probably make that change down the line), but for now I wanted to avoid doing anything that wasn't close to pure refactoring if I could.

* At this point in our design an `IRBuilder` is a very lightweight thing - it basically just owns the insertion location plus a source location to write into instructions. A lot of our code currently treats `IRBuilder`s like they are expensive and/or need to be re-used (which leads to them being used in more mutable/stateful ways). It is quite likely that as we clean up other aspects of the implementation of IR creation/emission we can make `IRBuilder` use feel more lightweight in ways that can streamline and simplify code.

* The next step for this work is to identify the different paths that eventually lead to `_createInst()` being called, and unify them at a single bottleneck operation that can own the decisions around when to create an instruction vs. when to re-use an existing one (rather than those decisions being baked into the various `IRBuilder` subroutines that create instructions of the various subtypes).

* fixup: gcc/clang C++ spec details</content>
</entry>
<entry>
<title>Change handling of strings for HLSL/GLSL targets (#1204)</title>
<updated>2020-02-07T16:45:32+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2020-02-07T16:45:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=af84d85799758234110fc42f0ba5c771dacb5fe3'/>
<id>urn:sha1:af84d85799758234110fc42f0ba5c771dacb5fe3</id>
<content type='text'>
* Change handling of strings for HLSL/GLSL targets

This change switches our handling of string literals and `getStringHash` to something that is more streamlined at the cost of potentially being less general/flexible.

* `String` is now allowed as a parameter type in user-defined functions

* `getStringHash` is now allowed to apply to `String`-type values that aren't literals

* The list of strings in an IR module is now generated during IR lowering as part of lowering a string literal expression, rather than being defined by recursively walking the IR of the module looking for `getStringHash` calls. The public API still refers to these as "hashed" strings, but they are realistically now "static strings."

* When emitting code for HLSL/GLSL, the `String` type emits as `int`, and `getStringHash(x)` emits as `x`.

In terms of implementation, the choice was whether to translate `String` over to `int` in an explicit IR pass, or to lump it into the emit pass. While adding the logic to emit clutters up an already complicated step, it is ultimately much easier to make the change there than to write a clean IR pass to eliminate all `String` use.

Note that other targets that can handle a more full-featured `String` type are *not* addressed by this change and thus do not support `String` at all. It may be woth emitting `String` as `const char*` on those targets, and emitting string literals directly, but the `getStringHash` function would need to be implemented in the "prelude" then, and we probably want to pick a well-known/-documented hash algorithm before we go that far.

This change also brings along some some clean-ups to the `gpu-printing` example, since it can now take advantage of the new functionality of `String`.

* Fix up tests for new string handling

* Add global string literal list to string-literal test (since we now list *all* static string literals and not just those passed to `getStringHash`)

* Disable `getStringHash` test on CPU, since we don't have a working `String` on that platform right now (only HLSL/GLSL)

Co-authored-by: Tim Foley &lt;tim.foley.is@gmail.com&gt;
</content>
</entry>
<entry>
<title>Feature/string hash review (#1142)</title>
<updated>2019-12-04T17:38:38+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2019-12-04T17:38:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=5df582dd3229789364ae3fa75575fd978ca3282d'/>
<id>urn:sha1:5df582dd3229789364ae3fa75575fd978ca3282d</id>
<content type='text'>
* * Added ConstArrayView
* Made StringSlicePool have styles
* Remove point about strings not having terminating 0 (they do), and restriction around ""

* spCalcStringHash -&gt; spComputeStringHash

* Small code improvements.
Closer to coding conventions.

* Fix small bug with Empty adding c string.

* Fix typo in assert.

* Fix ArrayView compiling issue on gcc/clang.

* Remove tabs.

* Improve comments around StringSlicePool.
Simplify getting the added slices.
</content>
</entry>
<entry>
<title>getStringHash on string literals (#1140)</title>
<updated>2019-12-03T14:58:59+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2019-12-03T14:58:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=9653dcc2c9d5d20d3d0e8918aaf1d5b09e963060'/>
<id>urn:sha1:9653dcc2c9d5d20d3d0e8918aaf1d5b09e963060</id>
<content type='text'>
* WIP getStringHash

* Have a use.

* Add slang-string-hash.h/.cpp

* Use StringSlicePool for holding strings for StringHash.
Add outputBuffer to string-literal-hash.slang so value can be tested.
Ignore the GlobalHashedStringLiterals instruction on emit.

* Add all the hashed string literals to ProgramLayout.

* Add reflection support for hashed string literals to reflection test.

* Fix string literal hash test.

* Small fixes to pass test suite.

* Fix issue in serialization where IRUse is not correctly initialized.

* Fix problem initializing IRUse for string hash pass.
Remove hack from slang-ir-specialize - specially handling if user is not null.

* * Use shared builder when replacing getStringHash
* Comments for functions in slang-ir-string-hash
* Do not allow zero length string literals. Could be allowed, but doing so would require StringSlicePool to have a special case (or some other mechanism)
</content>
</entry>
</feed>
