Blame CONTRIBUTING

Packit Service 724aca
CONTRIBUTING
Packit Service 724aca
============
Packit Service 724aca
Packit Service 724aca
This file is intended to help those interested in contributing to the
Packit Service 724aca
memkind library.
Packit Service 724aca
Packit Service 724aca
Packit Service 724aca
COMMUNICATION
Packit Service 724aca
=============
Packit Service 724aca
Packit Service 724aca
Please participate in the memkind mailing list:
Packit Service 724aca
Packit Service 724aca
    https://lists.01.org/mailman/listinfo/memkind
Packit Service 724aca
Packit Service 724aca
There is also the option of opening an issue through github:
Packit Service 724aca
Packit Service 724aca
    https://github.com/memkind/memkind/issues
Packit Service 724aca
Packit Service 724aca
The mailing list is intended for discussion and the issues are useful
Packit Service 724aca
for tracking progress on tasks.  The TODO file lists out a number of
Packit Service 724aca
topics, and in order to prioritize one of them please open a github
Packit Service 724aca
issue with a related subject.
Packit Service 724aca
Packit Service 724aca
Packit Service 724aca
TESTING
Packit Service 724aca
=======
Packit Service 724aca
Packit Service 724aca
The tests require a Linux kernel newer than 3.11 (the details are
Packit Service 724aca
documented in the memkind README), and the reservation of 3000 huge
Packit Service 724aca
pages.  The huge pages can be reserved with the following command:
Packit Service 724aca
Packit Service 724aca
    $ sudo echo 3000 > /proc/sys/vm/nr_hugepages
Packit Service 724aca
Packit Service 724aca
Only in the case where gigabyte pages have been reserved will the
Packit Service 724aca
tests associated with gigabyte pages be executed.  Reserving gigabyte
Packit Service 724aca
pages may require a modification to the kernel command line unless the
Packit Service 724aca
kernel is quite recent.
Packit Service 724aca
Packit Service 724aca
To test memkind simply execute the "make check" target after building.
Packit Service 724aca
This target calls memkind/test/test.sh with parameters
Packit Service 724aca
depending on the environment.
Packit Service 724aca
Packit Service 724aca
Most of the tests are written within the gtest framework, however, as
Packit Service 724aca
part of testing the example programs are also executed and the return
Packit Service 724aca
code of the executable determines pass or fail.  The autotools test
Packit Service 724aca
infrastructure is used as a high level executor, but it does not track
Packit Service 724aca
individual tests.  The consequence of this is that the autotools
Packit Service 724aca
output records only one high level test which passes in the case where
Packit Service 724aca
every underlying test was successful and fails if any underlying test
Packit Service 724aca
fails.  The individual test results are recorded in the directory
Packit Service 724aca
called "gtest_output." Here you will find the log of the tests in
Packit Service 724aca
gtest_output/test.out and a set of junit style xml results: one for
Packit Service 724aca
each test.  Note that a side effect of having only one autotools test
Packit Service 724aca
is that autotools parallel testing is disabled.  We have
Packit Service 724aca
multi-threaded tests that use the OpenMP run-time which enables more
Packit Service 724aca
purposeful and deterministic testing of threading issues.  Note that
Packit Service 724aca
the OpenMP run-time is only required for testing, it is not used by
Packit Service 724aca
the memkind library internally.
Packit Service 724aca
Packit Service 724aca
Packit Service 724aca
CODING STYLE
Packit Service 724aca
============
Packit Service 724aca
Packit Service 724aca
Before submitting a patch for inclusion, please run the modified
Packit Service 724aca
source code files through astyle with the following options
Packit Service 724aca
Packit Service 724aca
    $ astyle --style=linux --indent=spaces=4 -S --max-continuation-indent=80 \
Packit Service 724aca
             --max-code-length=80 --break-after-logical --indent-namespaces -z2 \
Packit Service 724aca
             --align-pointer=name
Packit Service 724aca
Packit Service 724aca
More information about astyle can be found here:
Packit Service 724aca
Packit Service 724aca
    http://astyle.sourceforge.net/
Packit Service 724aca
Packit Service 724aca
In C, source code constants are in all caps and everything else is in
Packit Service 724aca
all lower case.  Underscores are used to separate words within a
Packit Service 724aca
symbol name. No camel case shall be used in C code.  The test code is
Packit Service 724aca
largely written in C++.  Here camel-case should be used for class
Packit Service 724aca
names and should always have a capitalized first letter.  Other
Packit Service 724aca
symbols in C++ should generally follow the C style.
Packit Service 724aca
Packit Service 724aca
Most symbols with global scope shall be prefixed with "memkind_" or
Packit Service 724aca
"hbw_" depending on which interface they are a part of.
Packit Service 724aca
Packit Service 724aca
Any global variable shall have _g appended to the variable name and in
Packit Service 724aca
most cases shall be statically scoped within a single compilation
Packit Service 724aca
unit.  The exception to that rule are static memory kinds that are
Packit Service 724aca
declared as extern within the associated interface header and are
Packit Service 724aca
constant after initialization.  Global variables should be used in a
Packit Service 724aca
very narrow set of circumstances and in most cases modifications
Packit Service 724aca
should be guarded with pthread_once(3).
Packit Service 724aca
Packit Service 724aca
Functions not used outside of the compilation unit shall be declared
Packit Service 724aca
as static.  All functions which are not declared as static shall be
Packit Service 724aca
documented in a man page and have an associated interface header file.
Packit Service 724aca
Packit Service 724aca
Preprocessor mark-up is discouraged when other options are possible.
Packit Service 724aca
Please use enum in place of #define when value control at configure or
Packit Service 724aca
build time is not required.
Packit Service 724aca
Packit Service 724aca
Packit Service 724aca
TESTS
Packit Service 724aca
=====
Packit Service 724aca
Packit Service 724aca
The current state of the tests is not nearly as well organized as it
Packit Service 724aca
could be.  That being said, it is quite simple to add a new test.
Packit Service 724aca
Most C++ files in the test directory are associated with a single
Packit Service 724aca
gtest testing::Test class.  These classes usually have several
Packit Service 724aca
associated test fixtures in the same file.  If a new test can be added
Packit Service 724aca
as a fixture to an existing class, simply add the fixture to the file
Packit Service 724aca
and the test will be incorporated into the test infrastructure.
Packit Service 724aca
If a new class is required, create a new file and add it to the list
Packit Service 724aca
of "test_all_tests_SOURCES" in memkind/test/Makfile.mk and it will
Packit Service 724aca
be incorporated into the test infrastructure.
Packit Service 724aca
Packit Service 724aca
There are a few files which define classes which are not google test
Packit Service 724aca
classes.  These are check.cpp, trial_generator.cpp and main.cpp.  The
Packit Service 724aca
check.cpp file defines a class Check that can be used to validate
Packit Service 724aca
fundamental memkind features like NUMA node location, and page size.
Packit Service 724aca
The trial_generator.cpp file is used to abstract a sequence of
Packit Service 724aca
allocation and deallocation calls while performing checks on the
Packit Service 724aca
results of each call; this can be used to apply similar tests to all
Packit Service 724aca
of the different allocation APIs.  The main.cpp file is a simple
Packit Service 724aca
wrapper around testing::InitGoogleTest and RUN_ALL_TESTS().
Packit Service 724aca
Packit Service 724aca
Packit Service 724aca
SUBMITTING A PATCH
Packit Service 724aca
==================
Packit Service 724aca
Packit Service 724aca
Please be sure that all tests pass before submission and that the
Packit Service 724aca
style conforms to the specifications given here.  If a new feature is
Packit Service 724aca
implemented in the patch, please also include unit tests and an
Packit Service 724aca
example which exercises this feature.  Once these requirements have
Packit Service 724aca
been met, please submit a pull request through github.