Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceAPI::isAgent() DeviceAPI::isState() #1116

Merged
merged 8 commits into from
Sep 29, 2023
Merged

Conversation

Robadob
Copy link
Member

@Robadob Robadob commented Sep 26, 2023

With new C/Python tests

Closes #1108

Todo

  • C/non-RTC
    • Implementation
    • Tests
  • Python/RTC
    • Implementation
    • Tests
  • Agent Python
    • Implementation?
    • Tests

Note

  • strcmp() is not defined in device code, so ripped a small correct looking implementation off stack overflow (found in util/dstring.h).

Branch should be squashed

With new C/Python tests

Closes #1108

Currently only RTC implemented with Python test.
@@ -132,7 +132,7 @@ void CUDAAgent::setPopulationData(const AgentVector& population, const std::stri
if (state_name == ModelData::DEFAULT_STATE) {
THROW exception::InvalidAgentState("Agent '%s' does not use the default state, so the state must be passed explicitly, "
"in CUDAAgent::setPopulationData()",
state_name.c_str(), population.getAgentName().c_str());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had this exception thrown whilst writing test, noticed it was wrong.

@Robadob Robadob marked this pull request as ready for review September 27, 2023 12:14
*
* @note Implementation based on https://stackoverflow.com/a/34873763/1646387
*/
__device__ __forceinline__ int dstrcmp(const char *s1, const char *s2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not be resolved at compile time for RTC due to the use of the while loop. If we really wanted to have this resolve at compile time we would have to find a way for this to work with constexpr or a through template recursion. I don't think this is necessary though and we should flag that string comparisons are not particularly fast in the docs.

@mondus mondus merged commit 7a7944d into master Sep 29, 2023
18 checks passed
@mondus mondus deleted the check_agent_name_state branch September 29, 2023 10:19
Robadob added a commit that referenced this pull request Oct 27, 2023
This bug was introduced by #1116

Closes #1137
Robadob added a commit that referenced this pull request Oct 28, 2023
This bug was introduced by #1116

Closes #1137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Access/Check agent state inside an agent function
2 participants