Make applyshuffle instruction mergeable, execution is still sequential

This commit is contained in:
Vincent Ehrmanntraut
2024-12-06 15:55:01 +01:00
parent b0dc2b36f8
commit b91a01adc3
6 changed files with 89 additions and 17 deletions

View File

@@ -285,7 +285,8 @@ void BaseInstruction::parse_operands(istream& s, int pos, int file_pos)
case PRINTFLOATPLAIN:
case PRINTFLOATPLAINB:
case APPLYSHUFFLE:
get_vector(5, start, s);
num_var_args = get_int(s);
get_vector(num_var_args, start, s);
break;
case INCINT:
r[0]=get_int(s);
@@ -1136,8 +1137,7 @@ inline void Instruction::execute(Processor<sint, sgf2n>& Proc) const
Proc.machine.shuffle_store));
return;
case APPLYSHUFFLE:
Proc.Procp.apply_shuffle(*this, Proc.read_Ci(start.at(3)),
Proc.machine.shuffle_store);
Proc.Procp.apply_shuffle(*this, Proc.machine.shuffle_store);
return;
case DELSHUFFLE:
Proc.machine.shuffle_store.del(Proc.read_Ci(r[0]));

View File

@@ -88,8 +88,7 @@ public:
void secure_shuffle(const Instruction& instruction);
size_t generate_secure_shuffle(const Instruction& instruction,
ShuffleStore& shuffle_store);
void apply_shuffle(const Instruction& instruction, int handle,
ShuffleStore& shuffle_store);
void apply_shuffle(const Instruction& instruction, ShuffleStore& shuffle_store);
void inverse_permutation(const Instruction& instruction);
void input_personal(const vector<int>& args);

View File

@@ -890,13 +890,23 @@ size_t SubProcessor<T>::generate_secure_shuffle(const Instruction& instruction,
}
template<class T>
void SubProcessor<T>::apply_shuffle(const Instruction& instruction, int handle,
ShuffleStore& shuffle_store)
void SubProcessor<T>::apply_shuffle(const Instruction& instruction,
ShuffleStore& shuffle_store)
{
shuffler.apply(S, instruction.get_size(), instruction.get_start()[2],
instruction.get_start()[0], instruction.get_start()[1],
shuffle_store.get(handle),
instruction.get_start()[4]);
auto& start = instruction.get_start();
for (auto shuffleArgs = start.begin(); shuffleArgs < start.end(); shuffleArgs += 6) {
// shuffleArgs[0] size
// shuffleArgs[1] dest
// shuffleArgs[2] source
// shuffleArgs[3] unit size
// shuffleArgs[4] handle
// shuffleArgs[5] reverse
shuffler.apply(S, shuffleArgs[0], shuffleArgs[3],
shuffleArgs[1], shuffleArgs[2],
shuffle_store.get(Proc->read_Ci(shuffleArgs[4])),
shuffleArgs[5]);
}
}
template<class T>