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
HPX counters crashing the application #3224
Comments
Could you provide us with a small reproducing test case for this. The way you describe it does not allow for any diagnostics or even fixing. Thanks. |
Could you give any kind of test case. I am not understand even where it will crash so don't know how to fix it. Thanks |
@RANJEET16520 I didn't ask you to fix it. I asked you to give us some code that allows us to reproduce the problem you're seeing. |
Hi all, I'm sorry that I wasn't clear enough when I opened the issue. Please find below a simplified example where this error occurs. #include <hpx/hpx_init.hpp>
#include <hpx/include/performance_counters.hpp>
#include <iostream>
#include <thread>
#include <boost/format.hpp>
hpx::id_type idle_rate_counter_;
void my_sampling_funct(void)
{
// Create one counter per locality
static const char* idle_counter_name =
"/threads{locality#%d/total}/idle-rate";
const std::uint32_t prefix = hpx::get_locality_id();
std::cerr << "Registering counter "
<< boost::str(boost::format(idle_counter_name) % prefix)
<< std::endl;
idle_rate_counter_ = hpx::performance_counters::get_counter(
boost::str(boost::format(idle_counter_name) % prefix));
// Start the counter
hpx::performance_counters::stubs::performance_counter::start(
hpx::launch::sync, idle_rate_counter_);
// Get the value
hpx::performance_counters::counter_value idle_value =
hpx::performance_counters::stubs::performance_counter::get_value(
hpx::launch::sync, idle_rate_counter_);
double idle_rate_ = idle_value.get_value<double>() * 0.01;
std::cout << "Idle rate: " << idle_rate_ << std::endl;
// Stop the counter
hpx::performance_counters::stubs::performance_counter::stop(
hpx::launch::sync, idle_rate_counter_);
}
int hpx_main(int argc, char** argv)
{
// Create one additional OS-thread
std::thread sampler_thread = std::thread(&my_sampling_funct);
sampler_thread.join();
hpx::finalize();
//std::terminate();
return 0;
}
int main(int argc, char** argv)
{
return hpx::init();
} Please don't hesitate to ask me again if you need further assistance. Thanks! |
Thanks sir
|
@RANJEET16520 Thanks for the code snippet. I'm not sure why you decided to create a new (kernel-) thread for your test function. I would advise not to do that. You should create an HPX thread instead. Either simply switch Generally, it is not possible to directly invoke (most of) HPX's functionality from arbitrary kernel-threads. For this to be possible those threads have to be registered with the runtime. I however admit that the generated error message could be more descriptive. I'll make a note to work on this. |
Hi, thanks a lot for your explanation. I wasn't aware that blending kernel threads with HPX wasn't a good idea. I needed to sample the counters every certain period and as I already had a thread doing some work at a certain frequency, I just added the code in there. In any case, knowing now that doing this is not good, I'll move all that code to a function used together with hpx::util::interval_time (I wasn't aware either of such HPX utility actually) and I'll remove the additional thread creation. Thanks again! |
Hello Sir,
This program shows an error related to it's header file.
May be I am not able to compile this program,.
I am trying to compile this program from many days but it continuously
showing errors.
Thanks.
|
Which header file? What errors do you have? I could compile this small example in my environment without any problems. |
@RANJEET16520 you'll have to be a bit more specific about what errors you're seeing. Also, in order to help we'd need to see the code that causes errors for you (or better, a minimal self-contained example that demonstrates the issue you're seeing). |
Sir this error is shown by header files.
I am compiling this code from a week and it still not able to give any
output, except this error.
|
@RANJEET16520 You're saying "...except this error". What error specifically? Can you paste it somewhere? |
Using HPX counters in a std::thread makes the program crash.
I create an additional thread to sample some HPX counters with a certain frequency using:
sampler_thread = std::thread(&my_sampling_funct, this);
Then if I create/use a counter in my_sampling_funct, the program crashes.
The text was updated successfully, but these errors were encountered: