Skip to content

Conversation

@IvanKobzarev
Copy link
Contributor

@IvanKobzarev IvanKobzarev commented Jun 2, 2020

Stack from ghstack:

Introducing ComputeUnitFactory which is responsible for providing ComputeUnits (Shaders),
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just std::map<string, std::shared_ptr>

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use ComputeUnitFactory

Ownership model:
ComputeUnitFactory also owns vkPipelineCache that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

VContext (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before vkDestryDevice in ~VContext => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before vkDestroyDevice, doing unique_ptr<ComputeUnitFactory>.reset()

Differential Revision: D21962430

[ghstack-poisoned]
@dr-ci
Copy link

dr-ci bot commented Jun 2, 2020

💊 CI failures summary and remediations

As of commit 8df4055 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 112 times.

Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

[ghstack-poisoned]
IvanKobzarev added a commit that referenced this pull request Jun 2, 2020
ghstack-source-id: b66f11a
Pull Request resolved: #39384
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
return constBuffer;
}

ComputeUnitFactory::ComputeUnitFactory(const VkDevice& device)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically opaque handles in Vulkan like VkDevice etc. are just a typedef to an integer or a pointer so there's no need to pass them by reference.


class ComputeUnitFactory {
public:
ComputeUnitFactory(const VkDevice& device);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's generally considered good practice in C++ to mark single argument constructors as explicit to avoid implicit type conversions unless such behavior (i.e. in this case implicit conversion of VkDevice to ComputeUnitFactory) is desired.

WorkGroupSize& workGroupSize) {
std::stringstream ss;
ss << key << ':' << workGroupSize.x << ':' << workGroupSize.y << ':'
<< workGroupSize.z;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of looks like an expensive operation to construct a key for lookups if those lookups are frequent but on the other hand it may never end up mattering so I think it's fine to roll with it for now.


VkDevice device_;
VkPipelineCache pipelineCache_;
std::map<std::string, std::shared_ptr<ComputeUnit>> computeUnits_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a std::unordered_map (aka hash map) instead of a std::map. std::map is a poor data structure in general for performance: O(log(n)) look up and poor cache performance due to scattered memory accesses which is even more detrimental to performance when dealing with few (say hundreds) of elements like we are here. In those scenarios the best data structure is typically a vector with a good old boring linear search or for slightly bigger arrays (1000s of elements) sorted vector plus a binary search. A hash map is perfectly fine for now, but just as an FYI if you wanted to go down the route of vector you would store [uint64_t, std::shared_ptr] in the vector where uint64_t is the hash key, and you would do the lookup by using hash(string) as key. Collisions should be very rare and could be handled by storing identical keys inline and doing a linear search over them.

Chances are high this never ends up mattering in our usage here so unordered_map is perfectly fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I did not know the difference between std::map and std::unordered_map, looks like map works as HashTree (balanced binary tree) while unordered_map juts as a hash map without preserving ordering. I will change it to unordered_map.

return *(computeUnit.get());
}

#ifdef USE_VULKAN_SHADERC_RUNTIME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One alternate design could have been to encapsulate the difference between source code (null-terminated const char* shader_source) and binary representation ([const uint32_t* code, const uint32_t size] pair) such that the need for multiple code paths could have been avoided. Haven't put much thought into it but I think it should be possible to cheaply abstract that away.

Introducing `ComputeUnitFactory` which is responsible for providing `ComputeUnit`s (Shaders), 
it caches it, using shader name (glsl file name)+workGroupSize as a cacheKey, just `std::map<string, std::shared_ptr>`

Macro GLSL_SPV changed to have literal name for cache key as a first argument.

All constructors of ComputeUnit are changed to use `ComputeUnitFactory`


Ownership model:
ComputeUnitFactory also owns `vkPipelineCache` that is internal vulkan cache object ( https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPipelineCache.html )

`VContext` (global object) owns ComputeUnitFactory, that owns ComputeUnits, vkPipelineCache, for destruction of them we need valid VkDevice, so it should be destructed before `vkDestryDevice` in `~VContext` => As members of the class will be destructed only after destructor - forcing destruction of ComputeUnitFactory before `vkDestroyDevice`, doing `unique_ptr<ComputeUnitFactory>.reset()`

Differential Revision: [D21962430](https://our.internmc.facebook.com/intern/diff/D21962430)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

@IvanKobzarev merged this pull request in 6367a9d.

@facebook-github-bot facebook-github-bot deleted the gh/IvanKobzarev/28/head branch July 31, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants