MCPcopy Create free account
hub / github.com/devosoft/avida / loadInstSet

Method loadInstSet

avida-core/source/cpu/cHardwareManager.cc:124–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124bool cHardwareManager::loadInstSet(int hw_type, const Apto::String& name, int stack_size, int uops_per_cycle, cStringList& sl, cUserFeedback* feedback)
125{
126 // Current list in progress, create actual cInstSet instance and process it
127 cInstSet* inst_set = NULL;
128 switch (hw_type)
129 {
130 case HARDWARE_TYPE_CPU_ORIGINAL:
131 inst_set = new cInstSet(m_world, (const char*)name, hw_type, cHardwareCPU::GetInstLib(), stack_size, uops_per_cycle);
132 break;
133 case HARDWARE_TYPE_CPU_TRANSSMT:
134 inst_set = new cInstSet(m_world, (const char*)name, hw_type, cHardwareTransSMT::GetInstLib(), stack_size, uops_per_cycle);
135 break;
136 case HARDWARE_TYPE_CPU_EXPERIMENTAL:
137 inst_set = new cInstSet(m_world, (const char*)name, hw_type, cHardwareExperimental::GetInstLib(), stack_size, uops_per_cycle);
138 break;
139 case HARDWARE_TYPE_CPU_GP8:
140 inst_set = new cInstSet(m_world, (const char*)name, hw_type, cHardwareGP8::GetInstLib(), stack_size, uops_per_cycle);
141 break;
142 case HARDWARE_TYPE_CPU_BCR:
143 inst_set = new cInstSet(m_world, (const char*)name, hw_type, cHardwareBCR::GetInstLib(), stack_size, uops_per_cycle);
144 break;
145 default:
146 if (feedback) feedback->Error("unknown/unsupported hw_type specified for instset '%s'", (const char*)name);
147 return false;
148 }
149 if (!inst_set->LoadWithStringList(sl, feedback)) return false;
150
151 int inst_set_id = m_inst_sets.GetSize();
152 m_inst_sets.Push(inst_set);
153 m_is_name_map.Set(name, inst_set_id);
154
155 Apto::Array<cString> names(inst_set->GetSize());
156 for (int i = 0; i < inst_set->GetSize(); i++) names[i] = inst_set->GetName(i);
157 m_world->GetStats().SetInstNames(inst_set->GetInstSetName(), names);
158 Apto::String is((const char*)inst_set->GetInstSetName());
159 m_world->GetStats().SetGroupAttackInstNames(inst_set->GetInstSetName());
160
161 m_world->GetStats().InstPreyExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
162 m_world->GetStats().InstPredExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
163 m_world->GetStats().InstTopPredExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
164 m_world->GetStats().InstPreyFromSensorExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
165 m_world->GetStats().InstPredFromSensorExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
166 m_world->GetStats().InstTopPredFromSensorExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
167 m_world->GetStats().InstFromMessageExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
168
169 m_world->GetStats().ExecCountsForGroupAttackInstSet(inst_set->GetInstSetName()).Clear();
170 Apto::Array<cString> att_inst = m_world->GetStats().GetGroupAttackInsts(inst_set->GetInstSetName());
171 for (int i = 0; i < att_inst.GetSize(); i++) {
172 m_world->GetStats().ExecCountsForGroupAttackInst(inst_set->GetInstSetName(), att_inst[i]).Resize(20);
173 for (int j = 0; j < 20; j++) {
174 m_world->GetStats().ExecCountsForGroupAttackInst(inst_set->GetInstSetName(), att_inst[i])[j].Clear();
175 }
176 }
177
178 m_world->GetStats().InstMaleExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
179 m_world->GetStats().InstFemaleExeCountsForInstSet(inst_set->GetInstSetName()).Resize(inst_set->GetSize());
180
181 return true;

Callers

nothing calls this directly

Calls 11

LoadWithStringListMethod · 0.80
SetInstNamesMethod · 0.80
ErrorMethod · 0.45
GetSizeMethod · 0.45
PushMethod · 0.45
SetMethod · 0.45
GetNameMethod · 0.45
GetStatsMethod · 0.45
ResizeMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected