llvm icon indicating copy to clipboard operation
llvm copied to clipboard

[SYCL][COMPAT] Add default ctor to dim3 and update tests/docs

Open joeatodd opened this issue 1 year ago • 1 comments

This PR adds a default constructor for syclcompat::dim3, and makes the members non-const. This means patterns like this are now possible:

syclcompat::dim3 myDim3;
myDim3.x = 32;

@Alcpz this doesn't quite match your previous suggestion that members x,y,z should be initialized to zero, forcing the developer to take care of it before inadvertently launching a kernel of size 1. Unfortunately it's tricky to implement that in a way that works with the pattern above. In that case, myDim3 would have dims (32, 0, 0) which isn't allowed. I toyed with the idea of initializing them to (0, 1, 1) to combine the ideas, but it seems... messy.

@aacostadiaz does this do what you need?

joeatodd avatar Jun 28 '24 13:06 joeatodd

@Alcpz the request from the DPCT team also suggested changing from size_t to unsigned int. I was hesitant since size_t matches sycl::range members, but realistically I'm not sure how much of a problem this is.

I have made the change here (in rather a hurry). I suppose I ought to static_cast<unsigned int> in the dim3 constructors taking a sycl::range argument?

joeatodd avatar Jun 28 '24 13:06 joeatodd

@intel/llvm-gatekeepers this is ready to merge - failures appear unrelated.

joeatodd avatar Jul 02 '24 09:07 joeatodd

@joeatodd - The description reads a little like a conversation, so I am a little reluctant to put it as a commit message. Would you mind rewording it and include the information about the change in parameters?

steffenlarsen avatar Jul 02 '24 11:07 steffenlarsen

@steffenlarsen thanks for the suggestion - done :+1:

joeatodd avatar Jul 02 '24 13:07 joeatodd