Skip to content

Commit

Permalink
Cleanup debugging printfs
Browse files Browse the repository at this point in the history
  • Loading branch information
ptheywood committed Oct 7, 2021
1 parent cdda03e commit 93e414d
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions src/flamegpu/model/AgentDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ namespace flamegpu {
*/
AgentDescription::AgentDescription(std::shared_ptr<const ModelData> _model, AgentData *const data)
: model(_model)
, agent(data) {

printf("%s::%d agent=%p\n", __FILE__, __LINE__, data);
printf("%s::%d agent=%p\n", __FILE__, __LINE__, this->agent);
printf("%s::%d agent->functions=%p\n", __FILE__, __LINE__, &this->agent->functions);
}
, agent(data) { }


bool AgentDescription::operator==(const AgentDescription& rhs) const {
Expand Down Expand Up @@ -159,20 +154,13 @@ bool AgentDescription::isOutputOnDevice() const {
return agent->isOutputOnDevice();
}


AgentFunctionDescription& AgentDescription::newRTCFunction(const std::string& function_name, const std::string& func_src) {
printf("%s::%d agent=%p\n", __FILE__, __LINE__, this->agent);
printf("%s::%d agent->functions=%p\n", __FILE__, __LINE__, &this->agent->functions);
if (agent->functions.find(function_name) == agent->functions.end()) {
printf("%s::%d\n", __FILE__, __LINE__);
// Use Regex to get agent function name, and input/output message type
std::regex rgx(R"###(.*FLAMEGPU_AGENT_FUNCTION\([ \t]*(\w+),[ \t]*([:\w]+),[ \t]*([:\w]+)[ \t]*\))###");
printf("%s::%d\n", __FILE__, __LINE__);
std::smatch match;
if (std::regex_search(func_src, match, rgx)) {
printf("%s::%d\n", __FILE__, __LINE__);
if (match.size() == 4) {
printf("%s::%d\n", __FILE__, __LINE__);
std::string code_func_name = match[1]; // not yet clear if this is required
std::string in_type_name = match[2];
std::string out_type_name = match[3];
Expand All @@ -187,11 +175,9 @@ AgentFunctionDescription& AgentDescription::newRTCFunction(const std::string& fu
func_src_str = func_src_str.append("#include \"flamegpu/runtime/messaging/"+ in_type_include_name + "/" + in_type_include_name + "Device.cuh\"\n");
// If the message input and output types do not match, also include the input type
if (in_type_name != out_type_name) {
printf("%s::%d\n", __FILE__, __LINE__);
std::string out_type_include_name = out_type_name.substr(out_type_name.find_last_of("::") + 1);
func_src_str = func_src_str.append("#include \"flamegpu/runtime/messaging/"+ out_type_include_name + "/" + out_type_include_name + "Device.cuh\"\n");
}
printf("%s::%d\n", __FILE__, __LINE__);

// Append line pragma to correct file/line number in same format as OUTPUT_RTC_DYNAMIC_FILES
#ifndef OUTPUT_RTC_DYNAMIC_FILES
Expand All @@ -204,16 +190,8 @@ AgentFunctionDescription& AgentDescription::newRTCFunction(const std::string& fu
} else {
func_src_str.append(func_src);
}
printf("%s::%d\n", __FILE__, __LINE__);
auto rtn = std::shared_ptr<AgentFunctionData>(new AgentFunctionData(this->agent->shared_from_this(), function_name, func_src_str, in_type_name, out_type_name, code_func_name));
printf("%s::%d\n", __FILE__, __LINE__);
printf("function_name %s\n", function_name.c_str());
printf("rtn %p\n", rtn.get());
printf("rtn->rtc_func_name %s\n", rtn->rtc_func_name.c_str());
printf("agent->functions.size() %zu\n", agent->functions.size());
// agent->functions.emplace(function_name, rtn);
agent->functions.insert({function_name, rtn}); // emplace caused nvhpc 21.7 with gcc 9 to segfault
printf("%s::%d\n", __FILE__, __LINE__);
agent->functions.insert({function_name, rtn}); // Switched to insert from emplace to fix NVHPC with GCC 9. AgentDescription::newFunction must use the opposite (emplace)
return *rtn->description;
} else {
THROW exception::InvalidAgentFunc("Runtime agent function('%s') is missing FLAMEGPU_AGENT_FUNCTION arguments e.g. (func_name, message_input_type, message_output_type), "
Expand Down

0 comments on commit 93e414d

Please sign in to comment.