Implement OpSelectBinary and v/m_assign_bslct_masked operations - #244
Open
b08lsoai wants to merge 56 commits into
Open
Implement OpSelectBinary and v/m_assign_bslct_masked operations#244b08lsoai wants to merge 56 commits into
OpSelectBinary and v/m_assign_bslct_masked operations#244b08lsoai wants to merge 56 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 and implementation supportingbool(T, T)signatures.OpSelectBinarycode generation.New primitives: v_assign_bslct_masked / m_assign_bslct_masked
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[row, col], value)only ifop_select_bin(mask[row], mask[col])is true.Bug fixes
TScalar<Pair>: added missingoverridekeywords, removed invalidconstspecifier, and correctedas_pair()to returnm_valueproperly (restoring host<->device scalar readback).T_PAIRtype support.needs_pair_overridehack that caused macro redefinition conflicts.CLPrograminitialization on cache miss.n_sortinMtxLoaderfor weighted matrices (previously caused out-of-bounds access).Pairoperations (IDENTITY_PAIR,MUL_PAIR,MIN_PAIR,SECOND_PAIR,ALWAYS_PAIR).m_extract_row: fixed row vector initialization and moved range bounds calculation directly into the OpenCL kernel.--run-cpumode tomstutilityMtxLoader::saveto preserve matrix weights when writing to file.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.