Implement OpSelectBinary and v/m_assign_bslct_masked operations - #244
Open
b08lsoai wants to merge 47 commits into
Open
Implement OpSelectBinary and v/m_assign_bslct_masked operations#244b08lsoai wants to merge 47 commits into
OpSelectBinary and v/m_assign_bslct_masked operations#244b08lsoai wants to merge 47 commits into
Conversation
…n with spla primitives
fix clang tidy code style2 fix algorithm.cpp cland tidy 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Short description
This PR introduces a new core operation to the library: the binary selector (
OpSelectBinary). Based on this, vector and matrix assignment operations (v_assign_bslct_masked,m_assign_bslct_masked) have been implemented on both the CPU and OpenCL backends.Additionally, Boruvka’s MST algorithm has been optimized by offloading heavy host-side loops to the new OpenCL kernels, and critical bugs have been resolved.
List of changes
New operation type
OpSelectBinaryinterface (op.hpp) andTOpSelectBinary<T>implementation (top.hpp) supportingbool(T, T)signatures.CLProgramBuilder::add_opto handleOpSelectBinarycode generation.New primitives: v_assign_bslct_masked / m_assign_bslct_masked
exec_v/m_assign_bslct_maskedpublic API (exec.hpp) and integratedScheduleTask_v/m_assign_bslct_masked.vector_assign_bslct.cl(for dense/sparse masks) andm_assign_bslct.cl(for CSR matrix).v_assign_bslct_masked: Updates vector elementsr[i] = op_assign(r[i], value)only ifop_select_bin(mask[i], mask_value)is true.m_assign_bslct_masked: For each matrix element at position[row, col], it updates the element's value asr[row, col] = op_assign(r[ow, col], value)only ifop_select_bin(mask[row], mask[col])is true.Bug fixes
overridekeywords toget_pair/set_pairand removed an invalidconstspecifier inTScalar<Pair>. Fixedas_pair()to correctly returnm_valueinstead of throwing an error, restoring host<->device scalar readback.T_PAIRtype support.needs_pair_overridehack that hardcoded macro definitions forPair, which previously caused macro redefinition conflicts and broke any new operations.CLPrograminitialization on cache miss.IDENTITY_PAIR,MUL_PAIR,MIN_PAIR,SECOND_PAIR, andALWAYS_PAIRinop.cpp.m_extract_row: Added initialization of row and moved the calculation of range bounds directly into the OpenCL kernel code.Boruvka's MST optimization
get_pair/set_pairhost<->device round-trips per iteration. Replaced withexec_v_assign_bslct_masked+ existingexec_v_reduce, andexec_m_assign_bslct_masked, respectively.Type of changes
Changes aspect
.githubscripts addedTesting strategy
Unit Tests
tests/test_v_assign_bslct.cppandtests/test_m_assign_bslct.cpp: these test the corresponding operations for thePairandInttypes.Background
This PR is based on two PRs:
m_extract_rowandv_emultfor OpenCL backend #238: implementextract_rowon CSR matrices for the OpenCL backend.