// Copyright (c) 2017-2026 Advanced Micro Devices, Inc. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #include "benchmark_host_api.hpp" #include template void queue_host_bench(primbench::executor& executor, EngineType engine, OrderingType ordering, size_t dimensions, size_t offset, bool benchmark_host, Args... args) { executor.queue>(engine, ordering, dimensions, offset, benchmark_host, args...); } template void queue_host_permutations(primbench::executor& executor, size_t dimensions, size_t offset, bool benchmark_host, const std::vector& poisson_lambdas) { #ifdef __HIP__ queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench<__half, DISTRIBUTION_UNIFORM>(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench<__half, DISTRIBUTION_NORMAL>(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench<__half, DISTRIBUTION_LOG_NORMAL>(executor, Engine, Ordering, dimensions, offset, benchmark_host); #elif defined(__CUDACC__) if constexpr(Engine == CURAND_RNG_QUASI_SOBOL64 || Engine == CURAND_RNG_QUASI_SCRAMBLED_SOBOL64) { queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); } else { queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); } #endif queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host); for(double lambda : poisson_lambdas) { queue_host_bench(executor, Engine, Ordering, dimensions, offset, benchmark_host, lambda); } } template void queue_host_pseudo_permutations(primbench::executor& executor, size_t dimensions, size_t offset, bool benchmark_host, const std::vector& poisson_lambdas) { queue_host_permutations(executor, dimensions, offset, benchmark_host, poisson_lambdas); if(!benchmark_host) { queue_host_permutations(executor, dimensions, offset, benchmark_host, poisson_lambdas); } } template struct engine_ordering { static constexpr auto Engine = EngineVal; static constexpr auto Ordering = OrderingVal; }; template void queue_all_pseudo_permutations(primbench::executor& executor, size_t dimensions, size_t offset, bool benchmark_host, const std::vector& poisson_lambdas) { (queue_host_pseudo_permutations(executor, dimensions, offset, benchmark_host, poisson_lambdas), ...); } template void queue_all_permutations(primbench::executor& executor, size_t dimensions, size_t offset, bool benchmark_host, const std::vector& poisson_lambdas) { (queue_host_permutations(executor, dimensions, offset, benchmark_host, poisson_lambdas), ...); } int main(int argc, char* argv[]) { primbench::settings settings; settings.size = 128 * primbench::MiB; // In items settings.min_gpu_ms_per_batch = 1000; settings.batch_window_size = 3; settings.noise_tolerance_percent = 3; settings.hot = true; primbench::executor executor(argc, argv, settings, primbench::flags::sync); auto dimensions = executor.get("dimensions", 1, "Number of dimensions of quasi-random values"); auto offset = executor.get("offset", 0, "Offset of generated pseudo-random values"); auto benchmark_host = executor.get("host", false, "Run benchmarks on the host instead of on the device"); auto poisson_lambdas = executor.get>( "lambda", {10.0}, "Space-separated list of lambdas of Poisson distribution"); #ifdef __HIP__ queue_all_pseudo_permutations(executor, dimensions, offset, benchmark_host, poisson_lambdas); queue_all_permutations< engine_ordering, engine_ordering, engine_ordering, engine_ordering, engine_ordering>( executor, dimensions, offset, benchmark_host, poisson_lambdas); #elif defined(__CUDACC__) queue_all_pseudo_permutations(executor, dimensions, offset, benchmark_host, poisson_lambdas); queue_all_permutations< engine_ordering, engine_ordering, engine_ordering, engine_ordering, engine_ordering>( executor, dimensions, offset, benchmark_host, poisson_lambdas); #endif executor.run(); }