Skip to content
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

Bugfix/exception handling method #87

Closed

Conversation

Kaybangz
Copy link

Which issue are you addressing?

#51

How have you addressed the issue?

This PR introduces a new ValidateParameters method and implements an additional error check in the Parallel.Ordered method to prevent unexpected behavior and improve the reliability of the codebase.

  • Added a new ValidateParameters method to validate input parameters, ensuring the correctness of start and end indices, number of threads, chunk size, number of tasks, and grainsize.
  • Implemented validation checks in the Parallel.Ordered method to ensure proper usage. If conditions like not being used inside the Parallel.For or Parallel.ForReduction methods are not met, the NotInForException is thrown to provide a clear error message.
  • Added Barrier call at the end of Parallel.Ordered

Copy link
Owner

@computablee computablee left a comment

Choose a reason for hiding this comment

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

Couple of things.

  1. Ordered should not be a barrier. This will cause a deadlock.
  2. In the if statements in ValidateParameters, please have the body of the loop indented on a new line.
  3. I recently closed Features #86 which adds several ForCollapse and ForReductionCollapse overloads for collapsed parallel-for loops. Please add the ValidateParameters check to those methods as well. You may need to open a PR to your fork to get the updates.

@computablee
Copy link
Owner

Oooohhhh... merge conflict. I suspected that when I did the refactoring in #86. Let me see what I can do on my end.

@computablee
Copy link
Owner

Okay, updated list of changes after the tests ran:

  1. Ordered should not be a barrier. This will cause a deadlock. I had to cancel the integrations tests check because that happened.
  2. In the if statements in ValidateParameters, please have the body of the loop indented on a new line. This doesn't cause a linter error, but I should probably configure the linter such that it does.
  3. In Exceptions.cs, please add a space before the : tokens. This causes a linter error.
  4. In Parallel.cs, please remove the spaces on line 250. This causes a linter error.

I went ahead and resolved the merge conflict and pushed the results to your fork. Under the new refactoring of For/ForReduction/ForCollapse/ForReductionCollapse, the only place that the parameters validation needs to happen is at the top of the internal For handler, because all of the methods in the public-facing API call this method.

@Kaybangz Kaybangz closed this Oct 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.

2 participants