Skip to content

Conversation

@artemiipatov
Copy link
Contributor

Proposed Changes

Matrix.map

Types of changes

What types of changes does your code introduce to GraphBLAS-sharp?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Build and tests pass locally
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@gsvgit gsvgit requested a review from IgorErin March 21, 2023 20:11
Copy link
Contributor

@IgorErin IgorErin left a comment

Choose a reason for hiding this comment

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

Could we generalize some functions and logically separate them?

(uint64 rowIndex <<< 32) ||| (uint64 columnIndex)

let value =
(%Map2.binSearch) valuesLength index rowPointers columns values
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the popularity of this function, could you separate it into a separate module.

open GraphBLAS.FSharp.Backend.Objects.ClContext

module Map =
let binSearch<'a> =
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like an optimization of the original function. Could we use it in Map2 too? Could we move this function to a separate module as well?

let q = case.TestContext.Queue
q.Error.Add(fun e -> failwithf "%A" e)

let addFloat64Q =
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we separate these functions into a separate module and make them more generalized in order to reduce duplication?

Copy link
Member

Choose a reason for hiding this comment

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

I guess, these functions can be generalized and placed here

open GraphBLAS.FSharp.Backend.Objects.ClMatrix
open GraphBLAS.FSharp.Backend.Objects.ClContext

module Map =
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make these module internal according to Map2

workGroupSize
=

let elementwiseToCOO = runToCOO clContext opAdd workGroupSize
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know, functions of this kind should be called map*. This name can be confusing

<Compile Include="Quotes/PreparePositions.fs" />
<Compile Include="Quotes/Predicates.fs" />
<Compile Include="Quotes/Map.fs" />
<Compile Include="Quotes\BinSearch.fs" />
Copy link
Member

Choose a reason for hiding this comment

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

Path style.

open GraphBLAS.FSharp.Backend.Objects

module ArithmeticOperations =
let inline mkOpWithConst zero op constant =
Copy link
Member

Choose a reason for hiding this comment

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

I think we should have two versions because non-commutative operations exist.

open Brahma.FSharp

module BinSearch =
let searchInRange<'a> =
Copy link
Member

Choose a reason for hiding this comment

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

Doc comments required.

let q = case.TestContext.Queue
q.Error.Add(fun e -> failwithf "%A" e)

let mulFloat64Q =
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we predefine these functions?

if Utils.isFloat64Available context.ClDevice then
createTestMap case 0.0 ((*) 10.0) Utils.floatIsEqual (ArithmeticOperations.mulLeftConst 0.0 10.0) Matrix.map

createTestMap case 0.0f ((*) 10.0f) Utils.float32IsEqual (ArithmeticOperations.mulLeftConst 0.0f 10.0f) Matrix.map
Copy link
Contributor

Choose a reason for hiding this comment

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

We can pass zero, constant and both functions once to the createTestMap. So as not to write them twice

@gsvgit gsvgit requested a review from IgorErin March 25, 2023 08:39
/// <remarks>
/// Position is uint64 and it should be written in such format: first 32 bits is row, second 32 bits is column.
/// </remarks>
let searchCOO<'a> =
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we'll call this function byKey2D, since the word search is present in the module name.

[ let context = case.TestContext.ClContext
let q = case.TestContext.Queue
q.Error.Add(fun e -> failwithf "%A" e)

Copy link
Contributor

Choose a reason for hiding this comment

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

Integers must be supported by the operation. Could you add tests to this

@gsvgit
Copy link
Member

gsvgit commented Mar 25, 2023

Can you resolve conflicts caused by merging of previous request?

@gsvgit gsvgit requested a review from IgorErin March 25, 2023 16:23
@IgorErin IgorErin requested a review from gsvgit March 25, 2023 17:25
@gsvgit gsvgit merged commit 7885e8a into SparseLinearAlgebra:dev Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants