Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ on:

jobs:
cxx-build-workflow:
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.5
uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.6
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ if(NOT ITK_SOURCE_DIR)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
endif()

option(ITK_USES_NUMBEROFTHREADS "If ITKv5 uses NumberOfThreads (not NumberOfWorkUnits)" OFF)

include_directories(${CMAKE_BINARY_DIR})
if(NOT ITK_SOURCE_DIR)
include(ITKModuleExternal)
else()
set(ITK_DIR ${CMAKE_BINARY_DIR})
Expand Down
44 changes: 40 additions & 4 deletions evaluate-itk-performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import socket
import json

import glob


def get_shell_output_as_string(commandlist):
"""
Expand Down Expand Up @@ -40,8 +42,8 @@ def __call__(self, parser, namespace, values, option_string=None):
run_parser.add_argument('benchmark_bin',
help='ITK performance benchmarks build directory', action = FullPaths)
run_parser.add_argument('-r', '--rev-list',
help='Arguments for "git rev-list" to select the range of commits to benchmark, for example: "--no-merges v4.10.0..v5.0rc1"',
default='--no-merges HEAD~1..')
help='Arguments for "git rev-list" to select the range of commits to benchmark, for example: "--first-parent v4.10.0..v5.0rc1"',
default='--first-parent HEAD~1..')

upload_parser = subparsers.add_parser('upload',
help='upload the benchmarks to data.kitware.com')
Expand Down Expand Up @@ -152,20 +154,41 @@ def check_for_build_information(itk_src):
has_itkbuildinformation = True
return has_itkbuildinformation

# 2075084be6f9988b1ae2231bca607830fe6d772b is sha1 that rename NumberOfThreads into NumberOfWorkUnits in filters
# Author: Dzenan Zukic <dzenan.zukic@kitware.com>
# Date: Tue Jul 17 19:30:02 2018
# so all ancestors need to prevent the benchmarking from using
def check_for_NumberOfThreads(itk_src):
os.chdir(itk_src)
try:
cmd = ['git', 'merge-base',
'--is-ancestor', 'HEAD',
'2075084be6f9988b1ae2231bca607830fe6d772b']
has_itkNumberOfThreads = not bool(subprocess.check_call( cmd ) )
except subprocess.CalledProcessError:
has_itkNumberOfThreads = False
return has_itkNumberOfThreads

def build_benchmarks(benchmark_src, benchmark_bin,
itk_bin,
itk_has_buildinformation):
itk_has_buildinformation,
itk_has_NumberOfThreads):
os.chdir(benchmark_bin)
if itk_has_buildinformation:
build_information_arg = '-DITK_HAS_INFORMATION_H:BOOL=ON'
else:
build_information_arg = '-DITK_HAS_INFORMATION_H:BOOL=OFF'
if itk_has_NumberOfThreads:
NumberOfThreads_arg = '-DITK_USES_NUMBEROFTHREADS:BOOL=ON'
else:
NumberOfThreads_arg = '-DITK_USES_NUMBEROFTHREADS:BOOL=OFF'
subprocess.check_call(['cmake',
'-G', 'Ninja',
'-DCMAKE_BUILD_TYPE:STRING=Release',
'-DCMAKE_CXX_STANDARD:STRING=17',
'-DITK_DIR:PATH=' + itk_bin,
build_information_arg,
NumberOfThreads_arg,
benchmark_src])
subprocess.check_call(['ninja'])

Expand Down Expand Up @@ -309,15 +332,28 @@ def has_sha(filepath):
os.environ['ITKPERFORMANCEBENCHMARK_AUX_JSON'] = \
json.dumps(itk_information)

## Remove vcl_compiler.h in build dir that takes precidence over older non-generated
## vcl_compiler.h in the source tree (older source code).
if not os.path.exists( os.path.join( args.src, 'Modules','ThirdParty','VNL','src','vxl','vcl','vcl_compiler.h.in') ):
generated_vcl_headers = glob.glob(os.path.join( args.bin, 'Modules','ThirdParty','VNL','src','vxl','vcl',"*.h"))
for vcl_header_file in generated_vcl_headers:
os.remove( vcl_header_file )

## HDF generates and tries to build .c files from other builds, clean these out
hdf5_generated_files = os.path.join( args.bin, 'Modules','ThirdParty','HDF5','src','itkhdf5',"*.c")
hdf5_bld_src_files = glob.glob( hdf5_generated_files )
for hdf5_file in hdf5_bld_src_files:
os.remove( hdf5_file )

print('\nBuilding ITK...')
build_itk(args.src, args.bin)

itk_has_buildinformation = check_for_build_information(args.src)
itk_has_NumberOfThreads = check_for_NumberOfThreads(args.src)

print('\nBuilding benchmarks...')
build_benchmarks(benchmark_src, args.benchmark_bin, args.bin,
itk_has_buildinformation)
itk_has_buildinformation, itk_has_NumberOfThreads)

print('\nRunning benchmarks...')
run_benchmarks(args.benchmark_bin, itk_information)
Expand Down
12 changes: 6 additions & 6 deletions include/PerformanceBenchmarkingUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
#ifndef PerformanceBenchmarkingUtilities_h
#define PerformanceBenchmarkingUtilities_h

#include "PerformanceBenchmarkingExport.h"
#include "PerformanceBenchmarkingInformation.h"

#include "jsonxx.h"
#include <ctime> //TODO: Move to utiliites
#include "itkHighPriorityRealTimeProbesCollector.h"

#if ITK_VERSION_MAJOR >= 5
# include "itkMultiThreaderBase.h"
using MultiThreaderName = itk::MultiThreaderBase;
# define SET_PARALLEL_UNITS(x) SetNumberOfWorkUnits(x)
#else
#if ITK_VERSION_MAJOR < 5 || defined(ITK_USES_NUMBEROFTHREADS)
# include "itkMultiThreader.h"
using MultiThreaderName = itk::MultiThreader;
# define SET_PARALLEL_UNITS(x) SetNumberOfThreads(x)
#else
# include "itkMultiThreaderBase.h"
using MultiThreaderName = itk::MultiThreaderBase;
# define SET_PARALLEL_UNITS(x) SetNumberOfWorkUnits(x)
#endif

PerformanceBenchmarking_EXPORT std::string
Expand Down
36 changes: 22 additions & 14 deletions src/PerformanceBenchmarkingInformation.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "PerformanceBenchmarkingExport.h"

#cmakedefine ITK_USES_NUMBEROFTHREADS


namespace itk
{
Expand All @@ -49,13 +51,13 @@ namespace itk
* \ingroup PerformanceBenchmarking
*
*/
class PerformanceBenchmarking_EXPORT PerformanceBenchmarkingInformation final: public itk::Object
class PerformanceBenchmarking_EXPORT PerformanceBenchmarkingInformation final : public itk::Object
{
public:
/** Standard class type aliases. */
using Self = PerformanceBenchmarkingInformation;
using Pointer = itk::SmartPointer< Self >;
using ConstPointer = itk::SmartPointer< const Self >;
using Pointer = itk::SmartPointer<Self>;
using ConstPointer = itk::SmartPointer<const Self>;
using MapKeyType = std::string;
using MapValueType = std::string;
using MapValueDescriptionType = MapValueType;
Expand All @@ -70,29 +72,35 @@ private:
{
public:
InformationValueType() = default;
InformationValueType( const InformationValueType & ) = default;
InformationValueType( InformationValueType && ) = default;
InformationValueType(const InformationValueType &) = default;
InformationValueType(InformationValueType &&) = default;

const MapValueType m_Value;
const MapValueDescriptionType m_Description;
};
public:

public:
using MapStorageType = InformationValueType;
using MapType = std::map<MapKeyType, MapStorageType >;
using MapType = std::map<MapKeyType, MapStorageType>;

/** Run-time type information (and related methods). */
itkOverrideGetNameOfClassMacro(PerformanceBenchmarkingInformation);

/** Returns the global instance */
static Pointer New();
static Pointer
New();

/** Returns the global singleton instance of the PerformanceBenchmarkingInformation */
static Pointer GetInstance();
static const MapType & GetMap();
static const MapValueType GetValue(const MapKeyType &&);
static const MapValueDescriptionType GetDescription(const MapKeyType &&);
static const std::vector< MapKeyType > GetAllKeys();
static Pointer
GetInstance();
static const MapType &
GetMap();
static const MapValueType
GetValue(const MapKeyType &&);
static const MapValueDescriptionType
GetDescription(const MapKeyType &&);
static const std::vector<MapKeyType>
GetAllKeys();

private:
ITK_DISALLOW_COPY_AND_MOVE(PerformanceBenchmarkingInformation);
Expand All @@ -103,7 +111,7 @@ private:
static std::mutex m_Mutex;
static Pointer m_InformationInstance;
static MapType m_Map;
}; // end of class
}; // end of class

} // end namespace itk
#endif
Loading