Conversation
| RaisePropertyChanged(nameof(MaximumX)); | ||
| if (!_projectOptions.VisualizerOptions.NDRange3D) | ||
| { | ||
| RaisePropertyChanged(nameof(MaximumX)); |
There was a problem hiding this comment.
- I don't remember why this line (
RaisePropertyChanged(...)) was in the original code. It's not clear what it does and why it is needed, could you check what happens when you remove it? - If there's a reason for having this call before setting
X,Y,Zwith NDRange disabled and after settingX,Y,Zwith NDRange enabled, then this should be reflected in code comments, otherwise the calling order should be identical (and this line can be moved outside ofif-else).
Slimakanzer
left a comment
There was a problem hiding this comment.
I suspect the problem is much more complicated than we thought. We need to carefully review all lines of code that use VisualizerOptions.NDRange3D. In the following example, it's not clear why 1D groupIdx is used even with 3D Range.
|
|
||
| // OneWay bindings in XAML do not work on these properties for some reason, hence the empty setters | ||
| public uint MaximumX { get => _projectOptions.VisualizerOptions.NDRange3D ? DimX - 1 : uint.MaxValue; set { } } | ||
| public uint MaximumX { get => _projectOptions.VisualizerOptions.NDRange3D ? DimX - 1 : DimX * DimY * DimZ - 1; set { } } |
There was a problem hiding this comment.
Why would we need this ternary operator? DimY == DimZ == 1 in 1D dispatch
| X = X + Y * DimX + Z * DimX * DimY; | ||
| Y = 1; | ||
| Z = 1; | ||
| } | ||
| else | ||
| { | ||
| var x = X; | ||
| X = X % DimX; | ||
| Y = x % (DimX * DimY) / DimZ; | ||
| Z = x / DimX / DimY; | ||
| RaisePropertyChanged(nameof(MaximumX)); | ||
| } |
There was a problem hiding this comment.
It's not clear why we need different code paths for 1D and 3D. I assume the logic should be the same for both 1D and 3D.
There was a problem hiding this comment.
This chunk of code is actually responsible for conversion 1D group index to 3D, and vice versa. So naturally, if we turned on 1D indexation, we need to do 3D->1D conversion, in other case - 1D->3D
| DimY = gridY / GroupSizeY; | ||
| DimZ = gridZ / GroupSizeZ; |
There was a problem hiding this comment.
- I don't remember why
Math.Maxis needed, but I would changeDimX = gridX / GroupSizeXtoDimX = GridSizeX / GroupSizeX. Same forDimY,DimZ. - Is there any reason for having
Math.Max(1, ...)?
There was a problem hiding this comment.
Regarding Math.Max, I suspect it's used in the constructor to enforce the invariant that SizeX/Y/Z >= 1. Which is not that bad of an idea, considering that we assume it holds true in other parts of the code. I wonder, though, if it would be better to throw an exception instead of silently swallowing invalid values.
This PR provides refactoring for
NDRange3Dfeature.Changes:
NDRange3Dfrom dispatch parametersLooks like we did not had a good reason for it to be there, as the only real use of that was caused by setting
DimYandDimZto 0 inBreakStateDispatchParametersinstead of 1, which is incorrect in the first place and also refactored.GroupSizeandNGroupsno longer depends on the state ofNDRange3Das 1-dimentional indexing is equivalent to 3-dimentional whenDimYandDimZare set to 1's.3D NDRange(see attached gif).