ROCm / rocBLAS

Next generation BLAS implementation for ROCm platform
https://rocm.docs.amd.com/projects/rocBLAS/en/latest/
Other
336 stars 157 forks source link

[Feature]: allow data to be nullptr when querying for workspace buffer size #1390

Closed jakub-homola closed 5 months ago

jakub-homola commented 6 months ago

Is your feature request related to a problem? Please describe.

I am querying the required workspace buffer size for manual workspace management using rocblas_start_device_memory_size_query and rocblas_stop_device_memory_size_query. When calling the rocblas functions inside the query, they require the matrix/vector pointers to be non-null. IMO, they should be allowed to be null, since they should not be used. Currently, the rocblas routine returns with rocblas_status_invalid_pointer. I am mainly using the trsm function, but this issue probably applies to all functions.

Describe the solution you'd like

Check matrix and vector pointers only if handle->is_device_memory_size_query() is false.

Describe alternatives you've considered

Passing e.g. (double*)(sizeof(double)) as the pointer argument works, but is clunky and weird.

Additional context

I need to do all allocations at one place, therefore cannot first allocate the matrix, then query workspace size, and then do another allocation of the workspace buffer.

Library context

I am using rocblas that comes with rocm-5.4.3, but I see the same code handling the errors in the newest rocm-6.0.2 too.

xiaobo1025 commented 6 months ago

Dear friends, how to assign 1 to alpha and beta in rocblas_half alpha,beta?

rkamd commented 5 months ago

@xiaobo1025 , could you refer to https://github.com/ROCm/rocBLAS-Examples. if you still have questions, please open a new issues, as this is unrelated to the current one. Thanks

rkamd commented 5 months ago

@jakub-homola , Thanks for requesting the feature, we are working on improving the workspace query. I will update the ticket with additional information once the requested feature is implemented.

rkamd commented 5 months ago

@jakub-homola ,

All the rocblas functions will now skip pointer checks during device memory size query. Changes are merged to develop, commits https://github.com/ROCm/rocBLAS/commit/70c6c5f665a975cb9a633187aed581934d79cee7 and https://github.com/ROCm/rocBLAS/commit/2614a2134a768cad6a69025e3bd939eb58a3a352

If this resolves the issue, please close the ticket.

jakub-homola commented 5 months ago

Seems ok at first sight, thanks :)