writing a cross-platform C++17 application

The code of this application can be found on GitHub.

Rationale

Wrote another memory test application as it's a simple enough project, with decent focus on user space operations and modern C++ concepts.

The application is very much work in progress right now, just demonstrating its core functionality.

Memory Testing

During memory operation, especially overclocked beyond specs, there's a chance of getting transient errors. Regular errors such as bits flipping or updates not applying correctly are covered here.

Given a memory byte containing a pattern such as 10101010, a common occurrence might be bits flipping.

We define a pattern structure that encodes a bit "animation". Assigning specific values to a byte, in succession, creates such an "animation", with each value being a "frame" in that animation. Consider:

0x01:  0000 0001
0x02:  0000 0010
0x04:  0000 0100
0x08:  0000 1000
0x10:  0001 0000
0x20:  0010 0000
0x40:  0100 0000
0x80:  1000 0000

This is a typical "advancing ones" pattern, where the idea is to check for correct bit flips throughout.

Structure

The loader application spawns a family of threads, each running the execution_plan on its independent slice of the apparent total available physical memory.

To increase the amount of available physical memory, some pressure is applied beforehand, in the hope that the operating system triggers a defragmentation and consolidation step.

The execution_plan consists of a series of passes, each with a pattern and a given amount of repetitions.

Patterns included so far:

  • count_pattern
  • advancing_ones
  • advancing_zeroes
  • inversions
  • checkerboard

The pass applies during execute each "frame" defined inside each pattern to a buffer of size initially default_size (1 megabyte), then pads the whole memory under test with this buffer and checks that the values are the right ones.

Build Process

vcpkg

Available from its GitHub repository, clone it into a folder which will be referred from now on as VCPKGDIR and then build it according to the readme.

Make sure the resulting executable from VCPKGDIR/vcpkg is accessible through the system PATH environment variable (add the VCPKGDIR directory to PATH).

A necessary script is VCPKGDIR/scripts/buildsystems/vcpkg.cmake which contains definitions that help CMake locate vcpkg-managed libraries.

Google Test

Just install it through vcpkg:

vcpkg install gtest

CMake

Popular build system for C++ projects. Grab it from the official site or through whichever software distribution mechanisms available on your system.

To build everything:

cd MemoryLoader
cmake -DCMAKE_TOOLCHAIN_FILE=$VCPKGDIR/scripts/buildsystems/vcpkg.cmake -DBUILD_EXPERIMENTS=True
make

and a whole series of executables will be generated, including the Google Test executable.