To submit your Homeworks, please follow the instructions below:
- Fork the
exercises
repository. By default, it is set to be a private fork. Go to the Members tab on the left and giveDeveloper
permissions to:hartwig.anzt
fritz.goebel
pratik.nayak
Unfortunately, this is needed to allow us to pull from your private fork and create a branch
from that to run the CI pipelines on the nla4hpc_winter20-21/exercises
repository.
-
Keep your
master
branch tracking in tow with the main repository's (nla4hpc_winter20-21/exercises
) correspondingmaster
branch. -
Create a new branch for every Homework with the following scheme:
pr_hw<number>_build
and substitute the number with the homework that you are working on.- Do not work or push anything to the master branch, even on your own fork. This makes it difficult for you to
pull from the
origin/master
branch when that gets updated as you might have to resolve merge conflicts.
- Do not work or push anything to the master branch, even on your own fork. This makes it difficult for you to
pull from the
-
Follow the coding and build instructions provided in the
hwX/README.md
to complete the homework and you can run and test on your local systems. -
At a certain point, at the deadline, mentioned in
hwX/README.md
, we will- Run all your HW's on the CI,
- Create merge requests for your homeworks on the main repository,
- Open the merge requests for review and
- Assign you to a merge request that you need to review.
Git is a distributed version control system to track code changes and coordinate work among its developers. A general guide to git can be found in its extensive documentation.
With software sustainability and maintainability in mind, it is important to write commit messages that are short, clear and informative. Ideally, this would be the format to prefer:
Summary of the changes in a sentence, max 50 chars.
More detailed comments:
+ Changes that have been added.
- Changes that been removed.
You can refer to this informative guide for more details.
Git has a nice feature where it allows you to add a co-author for your commit, if you would like to attribute credits for the changes made in the commit. This can be done by:
Commit message.
Co-authored-by: Name <email@domain>
This is most commonly associated with suggested improvements from code reviews.
We use the GTest framework for the unit test framework. Writing good tests are extremely important to verify the functionality of the new code and to make sure that none of the existing code has been broken.
- GTest provides a comprehensive documentation of the functionality available within Gtest.
- Reduce code duplication with Testing Fixtures,
TEST_F
- Write templated tests using
TYPED_TEST
.
- Unit tests must follow the KISS principle.
- Unit tests must follow the AAA pattern, and a single blank line must appear between consecutive "A" sections.
- Reference kernels, kernels on the
ReferenceExecutor
, are meant to be single threaded reference implementations. Therefore, tests for reference kernels need to be performed with data that can be as small as possible. For example, matrices lesser than 5x5 are acceptable. This allows the reviewers to verify the results for exactness with tools such as MATLAB. - OpenMP, CUDA and HIP kernels have to be tested against the reference kernels. Hence data for the tests of these kernels can be generated in the test files using helper functions or by using external files to be read through the standard input. In particular for CUDA and HIP, the data size should be at least bigger than the architecture's warp size to ensure there is no corner case in the kernels.
Reviewing code effectively is an important skill. Following are some general guidelines for reviewing code:
-
Make sure the CI pipeline has passed. If not, then see which file compilation or tests have failed and maybe you can give some quick input to the coder.
-
Try to see if you can reason out any dimensional out of bounds checks that the tests have not covered and see if the code accounts for these.
-
Check if the implementation holds for different types and if there are any inadvertent type conversions that may break the code.
-
Check if the function parameters have been correctly qualified (constness, reference/pointer) and may differ for different situations reference:const-correctness.
-
You can fetch the branch you are reviewing and on your local system run
valgrind
and other memory check tools(cuda-memcheck
) to make sure no memory is being leaked.
-
Compare the implementation with the actual algorithm being implemented. What is the minimum amount of reads and writes the algorithm can get away with ? Does the implementation achieve this ? Do you see a better way ?
-
Many times a direct conversion from the a mathematical representation (mathematical pseudo-code) to a coding implementation is not efficient as it does not account for the data locality, data arrangement and parallelism. Check if there is a better way to reorganize the implementation so that better data locality and coalescing of memory is achievable.
-
Most compilers do a great job of optimizing the code, but can do an even better job when proper compiler hints can be provided to them. In general it is a good idea to:
- Check for unnecessary allocations and deallocations.
- Unnecessary copies and data movement.
- Appropriate hints to compilers such as
__restrict__
qualifications etc.
Here is a nice article explaining some of the compiler optimizations.
-
Verify that the style the code has been written in conforms to the project style.
-
Verify that the variable, function, class names make sense and are in a sense self-documenting. This increases readability and is essential for sustainable code.
-
Check the include files are appropriate and there are no unnecessary files included.
-
Be respectful and give constructive feedback. Provide a reason for your comments.
-
Feel free to ask questions as to why the author implemented it in the way they did if there is some confusion and clarity is needed.
For a very comprehensive guide, you can refer to the Google Code review guide.