Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Revisit parallelization in HARK #1245

Closed
sbenthall opened this issue Mar 22, 2023 · 1 comment
Closed

Revisit parallelization in HARK #1245

sbenthall opened this issue Mar 22, 2023 · 1 comment

Comments

@sbenthall
Copy link
Contributor

We have some support for parallelization using multi-threading:

https://github.com/econ-ark/HARK/blob/876ede3a8de0ba2606a27f6b9b6d2ae42076f580/HARK/parallel.py

The only place this is used is in the Market solve_agents method:

HARK/HARK/core.py

Lines 1274 to 1301 in 876ede3

def solve_agents(self):
"""
Solves the microeconomic problem for all AgentTypes in this market.
Parameters
----------
None
Returns
-------
None
"""
try:
multi_thread_commands(self.agents, ["solve()"])
except Exception as err:
if self.print_parallel_error_once:
# Set flag to False so this is only printed once.
self.print_parallel_error_once = False
print(
"**** WARNING: could not execute multi_thread_commands in HARK.core.Market.solve_agents() ",
"so using the serial version instead. This will likely be slower. "
"The multiTreadCommands() functions failed with the following error:",
"\n",
sys.exc_info()[0],
":",
err,
) # sys.exc_info()[0])
multi_thread_commands_fake(self.agents, ["solve()"])

This is a bit brittle; it causes this failure when there's some reasonable refactoring:

#1240 (comment)

In general, there are many ways to parallelize and it would be better to have options for how to parallelize, rather than hard-coding one method in the model definition code.

@mnwhite
Copy link
Contributor

mnwhite commented Mar 22, 2023 via email

@econ-ark econ-ark locked and limited conversation to collaborators Dec 5, 2024
@akshayshanker akshayshanker converted this issue into discussion #1517 Dec 5, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants