A set of benchmarks to compare a new prototype MiniZinc implementation
at develop 3.0 kB view raw
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2 3/* 4 * Main authors: 5 * Jip J. Dekker <jip.dekker@monash.edu> 6 * Guido Tack <guido.tack@monash.edu> 7 */ 8 9/* This Source Code Form is subject to the terms of the Mozilla Public 10 * License, v. 2.0. If a copy of the MPL was not distributed with this 11 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 12 13namespace MiniZinc { 14inline std::pair<Val, bool> Interpreter::cse_find(int proc, const CSEKey& key, 15 BytecodeProc::Mode& mode) { 16 std::pair<Val, bool> result; 17 DTRACE2(CSE_FIND_START, (uintptr_t)this, _procs[proc].nargs); 18 switch (_procs[proc].nargs) { 19 case 1: { 20 auto fkey = static_cast<const FixedKey<1>&>(key); 21 auto table = static_cast<CSETable<FixedKey<1>>*>(cse[proc]); 22 result = table->find(*this, fkey, mode); 23 break; 24 } 25 case 2: { 26 auto fkey = static_cast<const FixedKey<2>&>(key); 27 auto table = static_cast<CSETable<FixedKey<2>>*>(cse[proc]); 28 result = table->find(*this, fkey, mode); 29 break; 30 } 31 case 3: { 32 auto fkey = static_cast<const FixedKey<3>&>(key); 33 auto table = static_cast<CSETable<FixedKey<3>>*>(cse[proc]); 34 result = table->find(*this, fkey, mode); 35 break; 36 } 37 case 4: { 38 auto fkey = static_cast<const FixedKey<4>&>(key); 39 auto table = static_cast<CSETable<FixedKey<4>>*>(cse[proc]); 40 result = table->find(*this, fkey, mode); 41 break; 42 } 43 default: { 44 auto vkey = static_cast<const VariadicKey&>(key); 45 auto table = static_cast<CSETable<VariadicKey>*>(cse[proc]); 46 result = table->find(*this, vkey, mode); 47 break; 48 } 49 } 50 DTRACE2(CSE_FIND_END, (uintptr_t)this, result.second); 51 return result; 52} 53inline void Interpreter::cse_insert(int proc, CSEKey& key, BytecodeProc::Mode& mode, Val& val) { 54 DTRACE2(CSE_INSERT_START, (uintptr_t)this, _procs[proc].nargs); 55 switch (_procs[proc].nargs) { 56 case 1: { 57 auto fkey = static_cast<FixedKey<1>&>(key); 58 auto table = static_cast<CSETable<FixedKey<1>>*>(cse[proc]); 59 table->insert(*this, fkey, mode, val); 60 break; 61 } 62 case 2: { 63 auto fkey = static_cast<FixedKey<2>&>(key); 64 auto table = static_cast<CSETable<FixedKey<2>>*>(cse[proc]); 65 table->insert(*this, fkey, mode, val); 66 break; 67 } 68 case 3: { 69 auto fkey = static_cast<FixedKey<3>&>(key); 70 auto table = static_cast<CSETable<FixedKey<3>>*>(cse[proc]); 71 table->insert(*this, fkey, mode, val); 72 break; 73 } 74 case 4: { 75 auto fkey = static_cast<FixedKey<4>&>(key); 76 auto table = static_cast<CSETable<FixedKey<4>>*>(cse[proc]); 77 table->insert(*this, fkey, mode, val); 78 break; 79 } 80 default: { 81 auto vkey = static_cast<VariadicKey&>(key); 82 auto table = static_cast<CSETable<VariadicKey>*>(cse[proc]); 83 table->insert(*this, vkey, mode, val); 84 break; 85 } 86 } 87 DTRACE1(CSE_INSERT_END, (uintptr_t)this); 88} 89} // namespace MiniZinc