Skip to content
Steven Wu edited this page Jan 12, 2017 · 6 revisions

Profiling Code

gperftools

  1. Install gperftools and libunwind.
  2. Enable gperfools support in CMake: e.g. cd build/debug && cmake -DDNG_DEVEL_ENABLE_GPERFTOOLS=1 ../..
  3. Run dng the CPUPROFILE env variable set: e.g. env CPUPROFILE=dng-loglike.prof src/dng-loglike ....
  4. Run pprof to analyze output

Note: gperftools can produce false output if the program links against libraries that have had their symbols stripped. This is because it cannot accurately find the name of non-exported functions without the symbols.

Valgrind/Callgrind

Callgrind is slower than gperftools, but can provide more detailed information including information about cache misses.

  • valgrind --tool=callgrind [callgrind options] your-program [program options]

Callgrind Manual

Squashing a branch before issuing a pull request

  1. Review log and write comprehensive commit message

  2. Squash branch and add commit message to beginning of log:

     git checkout -b feature/xyz-squashed feature/xyz
     git rebase -i develop
    
  3. If needed issue git mergetool -t meld to resolve issues. And git rebase --continue to continue.

Building a Linux binary on CentOS 5

In order to build a Linux binary that will work on most systems, use an old version of Linux. We have chosen CentOS 5, which first came out in 2007.

  1. Download ISO from http://isoredirect.centos.org/centos/5/isos/x86_64/ and install it on a virtual machine.

  2. Install Developer Toolset 2.1 from http://linux.web.cern.ch/linux/devtoolset/#dts21

  3. Extract CMake binary from http://www.cmake.org/download/

  4. Enable the toolset from the command line: scl enable devtoolset-2 bash

  5. Configure and build DeNovoGear:

    cd ~/denovogear*/build
    ~/cmake*/bin/cmake .. -DBUILD_EXTERNAL_PROJECTS=1 -DUSE_STATIC_LIBS=1 -DCMAKE_BUILD_TYPE=Release
    make
    make package
    

Counting The Number of Downloads

curl https://api.github.com/repos/denovogear/denovogear/releases | jq -r '.[].assets[] | [.["name"], .["download_count"]] | @csv'

Verbose Output of Failed Tests

env CTEST_OUTPUT_ON_FAILURE=1 ninja test

or

ctest -V

Updating Test data

If you add or edit files in the test data repository you will need to edit the Tests/CMakeLists.txt file of the denovogear repo to ensure the new data is downloaded when tests are run. Specifically you need to include the sha-1 hash for the commit that includes your changes and an SHA256 checksum for the contents of the repo.

SET(TESTDATA_COMMIT c4ff355)
SET(TESTDATA_SHA256 b8c2f82f6b6662d1826e99722e378b2e6af25499eed553c4ec451633ce45935d)

The sha can be found on the repo's github page, or by typing git log on your local machine.

The SHA256 checksum can be generated by editing TESTDATA_COMMIT and calling

make make_testdata_sum

See #113.

The sum can also be generated with a one-liner

wget -q -O -  https://api.github.com/repos/denovogear/testdata/tarball/${commit-sha}  | sha256sum

Run make testdata to verify that it works.

How many digits?

17

http://en.cppreference.com/w/cpp/types/climits

http://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10

Setting up Eclipse development environment for Denovogear

  1. Install Eclipse CDT
  2. Checkout denovogear (assuming into directory $WORKSPACE/denovogear)
  3. Open Eclipse and go to File -> New -> C++ Project, create project with properties:
  • Empty Project
  • (Default) Location should be set to $WORKSPACE
  • Project Name: denovogear (Should say 'Directory with that name already exists')
  • Linux GCC Toolchains
  1. Create a Make Target to execute cmake command
  2. Window -> Show View -> Other -> Make -> Make Target
  3. In "Make Target" window go to build directory and click on "New Make Target" button. * Target name: CMake Debug * Make target: [leave blank] * Build command: cmake -DCMAKE_BUILD_TYPE=Debug ..
  4. Once created, click on the hammer to build target. Open Window -> Other -> General -> Console to see the progress of the cmake command.
  5. Ninja: Create a target for running the ninja. In the build directory Create a target with; * Target name: CMake Debug Ninja * Make target: [leave blank] * Build command: cmake -DCMAKE_BUILD_TYPE=Debug -D"Ninja" ..
  6. Optional: Create a target for running the unit-tests. In the build directory Create another target with name "Make Test", Make Target = "test", and Build command = "make".
  7. Get the make command to run properly.
  8. Right click on the project in the Project Explorer and go to Properties -> C/C++ Build -> Builder Settings tab
  • Build command: make -j4
  • Build directory: $WORKSPACE/denovogear/build
  1. Open the Behavior tab and: * Tick "Enable parallel build" * Build (Incremental build): [blank value]

  2. Click on the Project and go to Project -> Build Project. Output of make will be displayed in the console.

  3. Nanja: Make sure target "CMake Debug Ninja" exist and set Build command: PATH_NINJA_COMMAND

  4. Get the C++ Indexer working

  5. Right click on the Project in the Project Explorer window and go to Project -> Properties -> C/C++ General -> Paths and Symbols -> Source Location Tab: * Set the source folder to only be /denovogear/src * Click Edit Filter and add exclusion rules for **/*.in, **/*.txt and **/*.xmh.

  6. Go to C/C++ General -> Preprocessor Include Paths -> Providers tab and select "CDT GCC Build-in Compiler Settings" * To the command line arguments add -std=C++11

  7. Click on Project -> C/C++ Index -> Rebuild

  8. Note: If Eclipse is still showing unresolved classes in boost/std/htslib, right click on the project and select Index -> Freshen all files and let the index rebuild completely. Otherwise unresolved links should only occur if headers are missing or not properly included.

  9. Note: If Eclipse is still showing unresolved classes Eigen, then you need to manually add Eigen to include path. * Right click on the project in the Project Explorer and go to Properties -> C/C++ General -> Paths and Symbols.
    * Go to "Includes" tab and select "GNC C++". Click "Add..." and select the location of ${INCLUDE_DIR}/eigen3/ and ${INCLUDE_DIR}/eigen3/unsupported/ folder.

  10. Set up Run/Debug environment.

  11. Right click on Project and go to Run As -> Run Configuration

  12. Create New C/C++ Application * In Main tab set the C/C++ Application: build/src/dng-call * In the Arguments tab use the add any Program arguments as a single line.

  13. Click on the Project, then choose Run -> Run or Run -> Debug. Output will be displayed in console window.

  14. Set up Code Style.

  15. Go to Window -> Preferences -> C/C++ -> Code Style -> Name Style * Go to Code and select the following (based on Naming and Class_Format ):

    • Constant: Upper Case, Word Delimiter=_
    • Variable: Lower Case, Word Delimiter=_
    • Class Field: Lower Case, Word Delimiter=_, Suffix='_'
    • Class Method: Camel Case
    • Getter Method: Original
    • Setter Method: Original, prefix=set_ * Go to Files and select the following:
    • C++ Header File: Lower Case, Word Delimiter=_, Suffix=.h
    • C++ Source File: Lower Case, Word Delimiter=_, Suffix=.cc
  16. Go to Window -> Preferences -> C/C++ -> Code Style -> Formatter * Create a new profile based on K&R * Click Edit and change the following

    • Indentation - tick Statements with 'switch' body
    • New Lines - tick before colon in constructor initializer list
  • TODO: Go to Formatter and Import the denovogear code format configuration file (which does not exist yet)
  1. Troubleshooting
  • If nothing happen after using build target, try resetting the build location in Properties -> C/C++ Build -> Builder Settings

TODO: Get Eclipse to run ninja, git, and use proper code formatting.