Skip to content

Commit

Permalink
Quick attempt at resolving high env hash collision rate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robadob committed Nov 13, 2020
1 parent e7d7aad commit 4e55957
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/flamegpu/gpu/CUDASimulation.cu
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ bool CUDASimulation::step() {
std::string message_name;
Curve::NamespaceHash message_name_inp_hash = 0;
Curve::NamespaceHash message_name_outp_hash = 0;
// hash model name
const Curve::NamespaceHash instance_id_hash = Curve::variableRuntimeHash(instance_id);

// TODO: simulation.getMaxFunctionsPerLayer()
for (auto lyr = model->layers.begin(); lyr != model->layers.end(); ++lyr) {
Expand Down Expand Up @@ -313,7 +311,7 @@ bool CUDASimulation::step() {
#ifndef NO_SEATBELTS
error_buffer,
#endif
instance_id_hash,
instance_id,
agent_func_name_hash,
state_list_size,
t_rng,
Expand All @@ -333,7 +331,7 @@ bool CUDASimulation::step() {
#ifndef NO_SEATBELTS
reinterpret_cast<void*>(&error_buffer),
#endif
const_cast<void*>(reinterpret_cast<const void*>(&instance_id_hash)),
const_cast<void*>(reinterpret_cast<const void*>(&instance_id)),
reinterpret_cast<void*>(&agent_func_name_hash),
const_cast<void *>(reinterpret_cast<const void*>(&state_list_size)),
reinterpret_cast<void*>(&t_rng),
Expand Down Expand Up @@ -533,7 +531,7 @@ bool CUDASimulation::step() {
#ifndef NO_SEATBELTS
error_buffer,
#endif
instance_id_hash,
instance_id,
agent_func_name_hash,
message_name_inp_hash,
message_name_outp_hash,
Expand All @@ -559,7 +557,7 @@ bool CUDASimulation::step() {
#ifndef NO_SEATBELTS
reinterpret_cast<void*>(&error_buffer),
#endif
const_cast<void*>(reinterpret_cast<const void*>(&instance_id_hash)),
const_cast<void*>(reinterpret_cast<const void*>(&instance_id)),
reinterpret_cast<void*>(&agent_func_name_hash),
reinterpret_cast<void*>(&message_name_inp_hash),
reinterpret_cast<void*>(&message_name_outp_hash),
Expand Down
3 changes: 1 addition & 2 deletions src/flamegpu/runtime/utility/EnvironmentManager.cu
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ EnvironmentManager::NamePair EnvironmentManager::toName(const unsigned int &inst
* @note Not static, because eventually we might need to use curve singleton
*/
Curve::VariableHash EnvironmentManager::toHash(const NamePair &name) const {
Curve::VariableHash model_cvh = Curve::variableRuntimeHash(name.first);
Curve::VariableHash var_cvh = Curve::variableRuntimeHash(name.second.c_str());
return CURVE_NAMESPACE_HASH + model_cvh + var_cvh;
return CURVE_NAMESPACE_HASH + name.first + var_cvh;
}

void EnvironmentManager::newProperty(const NamePair &name, const char *ptr, const size_t &length, const bool &isConst, const size_type &elements, const std::type_index &type) {
Expand Down

0 comments on commit 4e55957

Please sign in to comment.