Skip to content

Kronecker #73

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

Closed
wants to merge 35 commits into from
Closed

Conversation

artemiipatov
Copy link
Contributor

Proposed Changes

  • kronecker

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

let newColumnIndices =
mapWithValueClArray queue allocationMode columnOffset m.Columns

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

Choose a reason for hiding this comment

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

Why don't you use the Free extension method?

let leftMatrixCols = matrixLeft.Columns.ToHost queue
let leftMatrixVals = matrixLeft.Values.ToHost queue

for row in 0 .. (matrixLeft.RowCount - 1) do
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be worth dividing the logical parts of this function into separate functions

queue.Post(Msg.CreateFreeMsg<_>(rows))
queue.Post(Msg.CreateFreeMsg<_>(columns))

match result with
Copy link
Contributor

Choose a reason for hiding this comment

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

Why Option.bind cannot be used here

@@ -8,7 +8,7 @@ open GraphBLAS.FSharp.Backend.Objects.ClCell
module Common =
///<param name="clContext">.</param>
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
let setPositions<'a when 'a: struct> (clContext: ClContext) workGroupSize =
let setPositionsUnsafe<'a when 'a: struct> (clContext: ClContext) workGroupSize =
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename both functions? Why safe? Wouldn't it be more appropriate to use option here

HostPrimitives.array2DMultiplication zero opMul opAdd leftArray rightArray
|> fun array -> Utils.createMatrixFromArray2D COO array (isEqual zero)

if matrixExpected.NNZ > 0 then
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 check the conditions in one place in order to avoid nesting?

leftMatrixCols.[firstElementIndex + offset]

let numberOfZeroElements =
match offset with
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it is better to use if here?

| _ ->
currentColumn
- leftMatrixCols.[firstElementIndex + offset - 1]
- 1
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 we count the number of zero elements using Array.pairwise or something like that? Then use Array.map...

RowCount = matrixLeft.RowCount * matrixRight.RowCount
ColumnCount = matrixLeft.ColumnCount * matrixRight.ColumnCount }

let run<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality>
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 it necessary to explicitly pair the conversion function? It seems that at the same time we lose in modularity


let kernel = clContext.Compile <| preparePositions op

fun (processor: MailboxProcessor<_>) (operand: ClCell<'a option>) rowCount columnCount (values: ClArray<'b>) (rowPointers: ClArray<int>) (columns: ClArray<int>) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to pass all the fields of the matrix one by one? Is it possible to pass the entire matrix at once?

let result =
runCSR queue allocationFlag matrix1 matrix2

match result with
Copy link
Contributor

Choose a reason for hiding this comment

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

It is assumed that the result cannot be a null matrix?

let queue = testContext.Queue
queue.Error.Add(fun e -> failwithf "%A" e)

createGeneralTest context queue false (=) (&&) ArithmeticOperations.boolMulOption "bool mul"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth passing the type of test data if it is already present in the name of the test?

let localID = ndRange.LocalID0

if localID < 2 then
let x = localID * (workGroupSize - 1) + i - 1
Copy link
Contributor

Choose a reason for hiding this comment

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

In case of first element x = -1. Is it normal?

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.

2 participants