feat: add Kernighan-Lee graph partitioning #9

Open
chipuni wants to merge 5 commits from Brent-Edwards-job-app into master
chipuni commented 2024-03-13 03:46:10 +00:00 (Migrated from git.qoto.org)

As part of my job application for CleverThis, this is code using the Aparapi API.

It implements the Kernighan-Lee algorithm (see https://en.wikipedia.org/wiki/Kernighan%E2%80%93Lin_algorithm ) but uses Aparapi to parallelize two operations.

As part of my job application for CleverThis, this is code using the Aparapi API. It implements the Kernighan-Lee algorithm (see https://en.wikipedia.org/wiki/Kernighan%E2%80%93Lin_algorithm ) but uses Aparapi to parallelize two operations.
chipuni commented 2024-03-13 03:46:10 +00:00 (Migrated from git.qoto.org)

assigned to @chipuni

assigned to @chipuni
freemo commented 2024-03-13 19:15:16 +00:00 (Migrated from git.qoto.org)

Why did you make this class package-private rather than public?

Why did you make this class package-private rather than public?
freemo commented 2024-03-13 19:15:16 +00:00 (Migrated from git.qoto.org)

You have been using final on your classes, any particularl reason your test classes arent final?

You have been using final on your classes, any particularl reason your test classes arent final?
freemo commented 2024-03-13 19:15:19 +00:00 (Migrated from git.qoto.org)

Any particular reason for the modified hungarian notation as opposed to the java style standard?

Any particular reason for the modified hungarian notation as opposed to the java style standard?
freemo commented 2024-03-13 19:15:19 +00:00 (Migrated from git.qoto.org)

The class level javadocs could be a bit more elaborate, but being internal to examples not super critical here, just a comment.

The class level javadocs could be a bit more elaborate, but being internal to examples not super critical here, just a comment.
freemo commented 2024-03-13 19:15:19 +00:00 (Migrated from git.qoto.org)

Could use more information (as many of the javadocs could). Namely 1) Can null be returned? 2) Can this (or other methods) throw exceptions, if so that should be listed. Many other javadoc elements are left out that are less critical but may have been helpful, such as @since

Could use more information (as many of the javadocs could). Namely 1) Can null be returned? 2) Can this (or other methods) throw exceptions, if so that should be listed. Many other javadoc elements are left out that are less critical but may have been helpful, such as @since
freemo commented 2024-03-13 19:15:27 +00:00 (Migrated from git.qoto.org)

Any particular reason you choose to make this a getter (and some other methods not).. how did you pick when to make something a getter (get*) vs not?

Any particular reason you choose to make this a getter (and some other methods not).. how did you pick when to make something a getter (get*) vs not?
freemo commented 2024-03-13 19:15:31 +00:00 (Migrated from git.qoto.org)

Why are these two varibles package-private and not public?

Why are these two varibles package-private and not public?
freemo commented 2024-03-13 19:15:31 +00:00 (Migrated from git.qoto.org)

Is this just segmented out for readability.

Is this just segmented out for readability.
freemo commented 2024-03-13 19:15:31 +00:00 (Migrated from git.qoto.org)

any reason these variables are package-private

any reason these variables are package-private
freemo commented 2024-03-13 19:15:39 +00:00 (Migrated from git.qoto.org)

This isnt thread safe and documentation doesnt state as such. We can make it safe by instantiating it in a static block.

This isnt thread safe and documentation doesnt state as such. We can make it safe by instantiating it in a static block.
freemo commented 2024-03-13 19:15:44 +00:00 (Migrated from git.qoto.org)

Why are we using an assert here rather than throwing an exception? What would be the proper type of exception, and would it be checked or runtime, and why?

Why are we using an assert here rather than throwing an exception? What would be the proper type of exception, and would it be checked or runtime, and why?
freemo commented 2024-03-13 19:15:44 +00:00 (Migrated from git.qoto.org)

Methods arent checked for validity. Are nulls allowed for example?

Methods arent checked for validity. Are nulls allowed for example?
freemo commented 2024-03-13 19:15:45 +00:00 (Migrated from git.qoto.org)

No indication in comments about validity of arguments (what is the range allowed, when is null allowed, etc).

No indication in comments about validity of arguments (what is the range allowed, when is null allowed, etc).
freemo commented 2024-03-13 19:15:45 +00:00 (Migrated from git.qoto.org)

Name is confusing as is javadocs.

Name is confusing as is javadocs.
freemo commented 2024-03-13 19:15:45 +00:00 (Migrated from git.qoto.org)

why are you using an array here as opposed to an ArrayList?

why are you using an array here as opposed to an ArrayList?
freemo commented 2024-03-13 19:15:57 +00:00 (Migrated from git.qoto.org)

Some of my initial concerns, i may add more.

Some of my initial concerns, i may add more.
chipuni commented 2024-03-15 04:25:04 +00:00 (Migrated from git.qoto.org)

This class is only used within these tests. I don't anticipate other tests needing it. It should have the lowest permission that allows everything to run.

This class is only used within these tests. I don't anticipate other tests needing it. It should have the lowest permission that allows everything to run.
chipuni commented 2024-03-15 04:25:04 +00:00 (Migrated from git.qoto.org)

No. These tests probably should be final as well -- I don't anticipate needing to extend them.

No. These tests probably should be final as well -- I don't anticipate needing to extend them.
chipuni commented 2024-03-15 04:25:10 +00:00 (Migrated from git.qoto.org)

We talked about this; it has been several years since I have read the Java Style standard, so I switched to my default (based on Hungarian notation.)

I will rename my variables and classes based on https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html

We talked about this; it has been several years since I have read the Java Style standard, so I switched to my default (based on Hungarian notation.) I will rename my variables and classes based on https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
chipuni commented 2024-03-15 04:25:18 +00:00 (Migrated from git.qoto.org)

Roger.

Roger.
chipuni commented 2024-03-15 04:25:18 +00:00 (Migrated from git.qoto.org)

I have vastly updated the JavaDocs.

I have vastly updated the JavaDocs.
chipuni commented 2024-03-15 04:25:26 +00:00 (Migrated from git.qoto.org)

For me, a getter is a very simple property.

A method that does not start with get represents something that is computed.

For me, a getter is a very simple property. A method that does not start with get represents something that is computed.
chipuni commented 2024-03-15 04:25:43 +00:00 (Migrated from git.qoto.org)

These constants should only be used by KRKernelHelper. The way to run the methods is through KrKernelHelper.executeCostDifference and KrKernelHelper.executeMaximalDifference.

These constants should only be used by KRKernelHelper. The way to run the methods is through KrKernelHelper.executeCostDifference and KrKernelHelper.executeMaximalDifference.
chipuni commented 2024-03-15 04:25:51 +00:00 (Migrated from git.qoto.org)

Yes.

Yes.
chipuni commented 2024-03-15 04:25:51 +00:00 (Migrated from git.qoto.org)

Yes. I had problems with setting variables within the kernel (especially setting variables that were not in an array), so I had all setting done by KrKernelHelper.

Yes. I had problems with setting variables within the kernel (especially setting variables that were not in an array), so I had all setting done by KrKernelHelper.
chipuni commented 2024-03-15 04:55:56 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#102223f435764d06c37089a0b6109b58420545b7_21_0)
chipuni commented 2024-03-15 04:56:10 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#102223f435764d06c37089a0b6109b58420545b7_19_0)
chipuni commented 2024-03-15 04:56:36 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#102223f435764d06c37089a0b6109b58420545b7_26_0)
chipuni commented 2024-03-15 04:57:02 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#71a4c1dc16dc8fd52571be450a121911212e9150_113_0)
chipuni commented 2024-03-15 04:57:25 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#be45dcc6d1c7d62fea8aceede914adae42ce6a8c_26_0)
chipuni commented 2024-03-15 04:57:31 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#be45dcc6d1c7d62fea8aceede914adae42ce6a8c_87_0)
chipuni commented 2024-03-15 04:57:58 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#be45dcc6d1c7d62fea8aceede914adae42ce6a8c_91_0)
chipuni commented 2024-03-15 04:58:33 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#d4895bc9d7e4ad0108c3631a4c09627e7b46ae99_26_0)
chipuni commented 2024-03-15 04:58:42 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#7134b78486839cabbcafcf5480a0ad7064698d20_35_0)
chipuni commented 2024-03-15 04:58:51 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#7134b78486839cabbcafcf5480a0ad7064698d20_34_0)
chipuni commented 2024-03-15 04:59:05 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#7134b78486839cabbcafcf5480a0ad7064698d20_32_0)
chipuni commented 2024-03-15 04:59:14 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#be45dcc6d1c7d62fea8aceede914adae42ce6a8c_51_0)
chipuni commented 2024-03-15 04:59:18 +00:00 (Migrated from git.qoto.org)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c#be45dcc6d1c7d62fea8aceede914adae42ce6a8c_35_0)
chipuni commented 2024-03-15 04:59:21 +00:00 (Migrated from git.qoto.org)

added 2 commits

  • d8a2678b - style: update code to match Oracle's Cava style
  • 03ae0e43 - style: update even more code.

Compare with previous version

added 2 commits <ul><li>d8a2678b - style: update code to match Oracle&#39;s Cava style</li><li>03ae0e43 - style: update even more code.</li></ul> [Compare with previous version](/aparapi/aparapi-examples/-/merge_requests/9/diffs?diff_id=272&start_sha=baf59e19294056e1ec1f723344d0e9e749e9333c)
chipuni commented 2024-03-15 04:59:43 +00:00 (Migrated from git.qoto.org)

Thank you. I have done so.

Thank you. I have done so.
chipuni commented 2024-03-15 04:59:52 +00:00 (Migrated from git.qoto.org)

I have fixed this. Thank you very much.

I have fixed this. Thank you very much.
chipuni commented 2024-03-15 05:00:01 +00:00 (Migrated from git.qoto.org)

I have added checking for validity throughout the code.

I have added checking for validity throughout the code.
chipuni commented 2024-03-15 05:00:09 +00:00 (Migrated from git.qoto.org)

I have added checks within the code for the validity of these
values (and many others). I have also updated the documentation.

I have added checks within the code for the validity of these values (and many others). I have also updated the documentation.
chipuni commented 2024-03-15 05:00:17 +00:00 (Migrated from git.qoto.org)

I have updated the name and the javadocs.

I have updated the name and the javadocs.
chipuni commented 2024-03-15 05:00:24 +00:00 (Migrated from git.qoto.org)

I am using an array here because the only way that I found to send data from the GPU was through the GPU writing arrays and the CPU reading it.

I would love to learn other ways to communicate between the GPU and the CPU, but I didn't have time to find them.

I am using an array here because the only way that I found to send data from the GPU was through the GPU writing arrays and the CPU reading it. I would love to learn other ways to communicate between the GPU and the CPU, but I didn't have time to find them.
chipuni commented 2024-03-15 05:00:24 +00:00 (Migrated from git.qoto.org)

Thank you very much for your comments.

Thank you very much for your comments.
chipuni commented 2024-03-15 05:00:24 +00:00 (Migrated from git.qoto.org)

I have made extensive documentation to the code, updated many names, and cleaned up the code extensively.

We have a difference of opinion in the code review. As far as I can tell, the code does run on the GPU. When I run KrKernelHelper lines 157 and 170, it reports:

The kernel for executeCostDifference was run under: Intel <GPU>

The kernel for executeMaximalDifferences was run under: Intel<GPU>

This might be because I am using an Intel GPU and I am using OpenCL 3.0.

Thank you so much for your extensive examination of the code.

I have made extensive documentation to the code, updated many names, and cleaned up the code extensively. We have a difference of opinion in the code review. As far as I can tell, the code does run on the GPU. When I run KrKernelHelper lines 157 and 170, it reports: The kernel for executeCostDifference was run under: Intel &lt;GPU&gt; The kernel for executeMaximalDifferences was run under: Intel&lt;GPU&gt; This might be because I am using an Intel GPU and I am using OpenCL 3.0. Thank you so much for your extensive examination of the code.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin Brent-Edwards-job-app:Brent-Edwards-job-app
git switch Brent-Edwards-job-app

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff Brent-Edwards-job-app
git switch Brent-Edwards-job-app
git rebase master
git switch master
git merge --ff-only Brent-Edwards-job-app
git switch Brent-Edwards-job-app
git rebase master
git switch master
git merge --no-ff Brent-Edwards-job-app
git switch master
git merge --squash Brent-Edwards-job-app
git switch master
git merge --ff-only Brent-Edwards-job-app
git switch master
git merge Brent-Edwards-job-app
git push origin master
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: aparapi/aparapi-examples#9
No description provided.