| 124 | } |
| 125 | |
| 126 | void BaseMachine::load_schedule(const string& progname, bool load_bytecode) |
| 127 | { |
| 128 | this->progname = progname; |
| 129 | string fname = "Programs/Schedules/" + progname + ".sch"; |
| 130 | #ifdef DEBUG_FILES |
| 131 | cerr << "Opening file " << fname << endl; |
| 132 | #endif |
| 133 | ifstream inpf; |
| 134 | inpf.open(fname); |
| 135 | if (inpf.fail()) { throw file_error("Missing '" + fname + "'. Did you compile '" + progname + "'?"); } |
| 136 | |
| 137 | int nprogs; |
| 138 | inpf >> nthreads; |
| 139 | inpf >> nprogs; |
| 140 | |
| 141 | if (inpf.fail()) |
| 142 | throw file_error("Error reading " + fname); |
| 143 | |
| 144 | #ifdef DEBUG_FILES |
| 145 | cerr << "Number of threads I will run in parallel = " << nthreads << endl; |
| 146 | cerr << "Number of program sequences I need to load = " << nprogs << endl; |
| 147 | #endif |
| 148 | |
| 149 | bc_filenames.clear(); |
| 150 | |
| 151 | // Load in the programs |
| 152 | string threadname; |
| 153 | for (int i=0; i<nprogs; i++) |
| 154 | { inpf >> threadname; |
| 155 | size_t split = threadname.find_last_of(":"); |
| 156 | long expected = -1; |
| 157 | if (split != string::npos) |
| 158 | { |
| 159 | expected = atoi(threadname.substr(split + 1).c_str()); |
| 160 | threadname = threadname.substr(0, split); |
| 161 | } |
| 162 | |
| 163 | string filename = "Programs/Bytecode/" + threadname + ".bc"; |
| 164 | bc_filenames.push_back(filename); |
| 165 | if (load_bytecode) |
| 166 | { |
| 167 | #ifdef DEBUG_FILES |
| 168 | cerr << "Loading program " << i << " from " << filename << endl; |
| 169 | #endif |
| 170 | long size = load_program(threadname, filename); |
| 171 | if (expected >= 0 and expected != size) |
| 172 | { |
| 173 | stringstream os; |
| 174 | os << "broken bytecode file, found " << size |
| 175 | << " instructions, expected " << expected; |
| 176 | throw runtime_error(os.str()); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | } |
| 181 | |
| 182 | for (auto i : {1, 0, 0}) |
| 183 | { |
no test coverage detected