Skip to content

Conversation

@jieli-matrix
Copy link

Currently, dngvd_op in module_hsolver/kernels/rocm/dngvd_op.hip.cu uses the ROCm implementation for all input sizes (nstart). Performance analysis shows that the CPU implementation (dngvd_op.cpp) is faster for smaller nstart values.
This PR proposes adding a conditional branch within the dngvd_op<double, base_device::DEVICE_GPU>::operator() function to select the optimal implementation based on nstart:

If nstart > 234, use the existing ROCm implementation.
If nstart <= 234, call the CPU implementation (dngvd_op<double, base_device::DEVICE_CPU>).
This change requires:
Adding an if (nstart > 234) { ... } else { ... } block within the GPU operator().
Inside the else block, calling the CPU implementation with appropriate type casts.

This optimization is expected to improve performance, especially for bigger matrix sizes.

@dyzheng
Copy link
Collaborator

dyzheng commented Feb 25, 2025

please fix the compiling error

// copied from ../cuda/dngvd_op.cu, "dngvd_op"
assert(nstart == ldh);

if (nstart > N_DCU){
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add notes for this kernel has intersection point of the performance curves between CPU and DCU.

// copied from ../cuda/dngvd_op.cu, "dngvd_op"
assert(nstart == ldh);

if (nstart > N_DCU){
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add notes for this kernel has intersection point of the performance curves between CPU and DCU.

Copy link
Collaborator

Choose a reason for hiding this comment

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

to be honest, N_DCU is tested only for "complex" kernel, but maybe not good intersection point for "double" and "complex" kernel.

@mohanchen mohanchen added Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes labels Mar 11, 2025
@dyzheng dyzheng deleted the branch deepmodeling:stable March 31, 2025 09:48
@dyzheng dyzheng closed this Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants