Skip to content

Kronecker #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 16, 2023
Merged

Conversation

artemiipatov
Copy link
Contributor

Proposed Changes

  • Kronecker with size precalculation

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

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...

@IgorErin IgorErin requested review from gsvgit and IgorErin May 10, 2023 20:03
| Some _ -> resultBitmap.[0] <- newItem
| _ -> ()

else if (gid - 1) < valuesLength then
Copy link
Member

Choose a reason for hiding this comment

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

elif

| ClMatrix.CSR m1, ClMatrix.CSR m2 ->
let result = run queue allocationFlag m1 m2
Option.map ClMatrix.COO result
| _ -> failwith "Matrix formats are not matching"
Copy link
Member

Choose a reason for hiding this comment

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

Can you provide more information in the message to make it more useful?

let mutable res = 0

let xInt =
match x with
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment to clarify why these conversions are needed?
Should it be reported as a quotation evaluator bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -73,7 +125,7 @@ module ArithmeticOperations =
mkUnaryOp zero <@ fun x -> x + constant @>

let intSumOption = mkNumericSum 0
let byteSumOption = mkNumericSum 0uy
Copy link
Member

Choose a reason for hiding this comment

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

So... Finally, what about bytes?

let create = create clContext workGroupSize

let init =
init <@ fun x -> x @> clContext workGroupSize
Copy link
Member

Choose a reason for hiding this comment

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

Can it be replaced with <@ id @> ?

@@ -53,6 +53,7 @@
<Compile Include="Backend/Matrix/Merge.fs" />
<Compile Include="Backend/Matrix/ExpandRows.fs" />
<Compile Include="Backend/Matrix/SubRows.fs" />
<Compile Include="Backend\Matrix\Kronecker.fs" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Path style


let createGeneralTest (context: ClContext) (processor: MailboxProcessor<Msg>) (zero: 'a) isEqual op opQ testName =

let kronecker =
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the pipeline not used here?

createGeneralTest context queue false (=) (&&) ArithmeticOperations.boolMulOption "mul"
createGeneralTest context queue false (=) (||) ArithmeticOperations.boolSumOption "sum"

createGeneralTest context queue 0 (=) (*) ArithmeticOperations.intMulOption "mul"
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 pass the testContext as a single parameter in order to reduce their number?

kroneckerFun processor ClContext.HostInterop m1 m2

let actual =
Option.bind (fun (m: ClMatrix<'a>) -> m.ToHost processor |> Some) result
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't Option.map be used here?

|> Some)
| None ->
opOnHost value None
|> Option.bind
Copy link
Contributor

Choose a reason for hiding this comment

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

Option.map?

let result =
setPositions queue allocationMode values indices bitmap

queue.Post(Msg.CreateFreeMsg<_>(indices))
Copy link
Contributor

Choose a reason for hiding this comment

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

ClArray.Free

let result =
setPositions queue allocationMode rows columns values bitmap

queue.Post(Msg.CreateFreeMsg<_>(bitmap))
Copy link
Contributor

Choose a reason for hiding this comment

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

ClArray.Free

let result =
mapAll queue allocationMode size matrixZero matrixLeft matrixRight

match matrixZero with
Copy link
Contributor

Choose a reason for hiding this comment

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

Release only in one case

Copy link
Contributor

Choose a reason for hiding this comment

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

And mb Option.iter?

let startIndex =
insertNonZero queue rowsEdges matrixRight matrixLeft.Values leftColumns resultMatrix

match matrixZero with
Copy link
Contributor

Choose a reason for hiding this comment

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

Option.iter?

@artemiipatov artemiipatov requested review from gsvgit and IgorErin May 12, 2023 18:29
@gsvgit gsvgit merged commit b494dab into SparseLinearAlgebra:dev May 16, 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