// Copyright 2002 - 2008, 2010, 2011 National Technology Engineering // Solutions of Sandia, LLC (NTESS). Under the terms of Contract // DE-NA0003525 with NTESS, the U.S. Government retains certain rights // in this software. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // * Neither the name of NTESS nor the names of its contributors // may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "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 // OWNER OR CONTRIBUTORS 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 #include "stk_unit_test_utils/stk_mesh_fixtures/SelectorFixture.hpp" #include #include #include #include #include #include #include #include #include namespace { using stk::mesh::fixtures::VariableSelectorFixture; } TEST(selector_timings, selector_timings) { // A scaling test for selector and bucket operations // If we are running with STL in debug mode we shrink the problem // down in order to keep things running in a reasonable amount of // time. #ifdef _GLIBCXX_DEBUG size_t N = 500; #else size_t N = 50000; #endif const unsigned NUM_RUNS = 5; stk::unit_test_util::BatchTimer batchTimer(MPI_COMM_WORLD); batchTimer.initialize_batch_timer(); for (unsigned j = 0; j < NUM_RUNS; j++) { VariableSelectorFixture fix(N); size_t total_buckets_grabbed = 0; batchTimer.start_batch_timer(); for (size_t n = 1 ; n= elems.size()) { break; } bulk.change_entity_parts(elems[elemCounter++], addParts, rmParts); } } if (blockCounter >= blocks.size()) { break; } addParts[0] = blocks[blockCounter++]; } bulk.modification_end(); } TEST(selector_timings, get_buckets) { MPI_Comm comm = stk::parallel_machine_world(); if (stk::parallel_machine_size(comm) > 1) { GTEST_SKIP(); } std::shared_ptr bulkPtr = stk::mesh::MeshBuilder(comm).set_spatial_dimension(3).create(); stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); const int numParts = 5000; create_elem_block_parts(numParts, meta); stk::io::fill_mesh("generated:100x100x100", *bulkPtr); const int numElems = 100*100*100; const int elemsPerPart = numElems/numParts; move_elems_to_each_part(*bulkPtr, elemsPerPart); stk::unit_test_util::BatchTimer batchTimer(MPI_COMM_WORLD); batchTimer.initialize_batch_timer(); batchTimer.start_batch_timer(); stk::mesh::PartVector blocks = stk::mesh::ExodusTranslator(*bulkPtr).get_element_block_parts(); for(stk::mesh::Part* partPtr : blocks) { stk::mesh::Selector selector(*partPtr); selector.get_buckets(stk::topology::NODE_RANK); } batchTimer.stop_batch_timer(); const int numIterations = 1; batchTimer.print_batch_timing(numIterations); } TEST(Verify, selectorAlgorithmicComplexity) { // // Verify expected algorithmic complexity is obtained by selector classes. // Only test serial, in parallel this gets a bit ill posed as some procs have empty bucket selections // and the complexity is not meaningful. // stk::mesh::fixtures::SelectorFixture fix; fix.m_meta_data.commit(); fix.m_bulk_data.modification_begin(); fix.generate_mesh(); if (fix.get_BulkData().parallel_size() > 1) return; stk::mesh::Part & partA = fix.m_partA; stk::mesh::Part & partB = fix.m_partB; stk::mesh::Part & partC = fix.m_partC; stk::mesh::Part & partD = fix.m_partD; stk::mesh::Selector selectABC = partA & partB & partC; stk::mesh::Selector selectA = partA; stk::mesh::Selector selectB = partB; stk::mesh::Selector selectC = partC; stk::mesh::Selector selectD = partD; unsigned numCopiesBase = 1000000; std::vector trialLen; trialLen.push_back(128); trialLen.push_back(256); trialLen.push_back(512); trialLen.push_back(1024); trialLen.push_back(2048); trialLen.push_back(4096); std::vector elapsedTime(trialLen.size()); // // Test complexity of construction of large binary selector as would be made of selectUnion of a large number of parts // for(unsigned j=0; j