/* * Copyright (C) 2015 - 2018 Intel Corporation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice(s), * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice(s), * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include "Configuration.hpp" #include "AllocatorFactory.hpp" #include "TaskFactory.hpp" #include "Task.hpp" #include "ConsoleLog.hpp" #include "Stats.hpp" #include "Thread.hpp" #include "Tests.hpp" #include "CommandLine.hpp" #include "FunctionCallsPerformanceTask.h" #include "StressIncreaseToMax.h" /* Command line description. Syntax: key=value Options: - 'test' - specify the test case. This option can be used with the following values: 'calls', 'all' or 'self', where: 'calls' - function calls performance test, 'all' - execute both above ('footprint' and 'calls') tests, 'self' - execute self tests 's1' - stress tests (perform allocations until the maximum amount of allocated memory has been reached, than frees allocated memory. If the time interval has not been exceed, than repeat the test), - 'operations' - the number of memory operations per thread - 'size_from' - lower bound for the random sizes of allocation - 'size_to' - upper bound for the random sizes of allocation - 'seed' - random seed - 'threads_num' - the number of threads per test case - 'time' - minimum execution time interval - 'kind' - the kind to test - 'csv_log' - if 'true' then log to csv file memory operations and statistics - 'call' specify the allocation function call. This option can be used with the following values: 'malloc' (default), 'calloc', 'realloc', - 'requested_memory_limit' test stops when the requested memory limit has been reached * - maximum of available memory in OS, or maximum memory based 'operations' parameter Example: 1. Performance test: ./perf_tool test=all operations=1000 size_from=32 size_to=20480 seed=11 threads_num=200 2. Stress test ./perf_tool test=s1 time=120 kind=MEMKIND_HBW size_from=1048576 csv_log=true requested_memory_limit=1048576 */ int main(int argc, char *argv[]) { unsigned mem_operations_num = 1000; size_t size_from = 32, size_to = 2048*1024; unsigned seed = 11; //should be at least one size_t threads_number = 10; CommandLine cmd_line(argc, argv); if((argc >= 1) && cmd_line.is_option_set("test", "self")) { execute_self_tests(); getchar(); } cmd_line.parse_with_strtol("operations", mem_operations_num); cmd_line.parse_with_strtol("size_from", size_from); cmd_line.parse_with_strtol("size_to", size_to); cmd_line.parse_with_strtol("seed", seed); cmd_line.parse_with_strtol("threads_num", threads_number); bool is_csv_log_enabled = cmd_line.is_option_set("csv_log", "true"); //Heap Manager initialization std::vector stats = AllocatorFactory().initialization_test(); if(!cmd_line.is_option_set("print_init_stats", "false")) { printf("\nInitialization overhead:\n"); for (int i=0; i threads; std::vector tasks; for (int i=0; i( task_factory.create(conf) ); tasks.push_back(task); threads.push_back(new Thread(task)); conf.seed += 1; } ThreadsManager threads_manager(threads); threads_manager.start(); threads_manager.barrier(); TimeStats stats; for (int i=0; iget_results(); } ConsoleLog::print_table(stats); ConsoleLog::print_requested_memory(stats, "func. calls test"); threads_manager.release(); } return 0; }