Skip to content

Commit

Permalink
supernova: ensure that daz/ftz are set in all audio threads
Browse files Browse the repository at this point in the history
  • Loading branch information
timblechmann committed Jun 11, 2014
1 parent 10b7027 commit e2a4962
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions server/supernova/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ void nova_server::prepare_backend(void)

audio_backend::output_mapping(outputs.begin(), outputs.end());

#ifdef __SSE__
/* denormal handling */
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_mm_setcsr(_mm_getcsr() | 0x40);
#endif

time_per_tick = time_tag::from_samples(blocksize, get_samplerate());
}

Expand Down Expand Up @@ -228,6 +222,14 @@ static void name_current_thread(int thread_index)
name_thread(buf);
}

static void set_daz_ftz(void)
{
#ifdef __SSE__
/* denormal handling */
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_mm_setcsr(_mm_getcsr() | 0x40);
#endif
}

static bool set_realtime_priority(int thread_index)
{
Expand Down Expand Up @@ -289,6 +291,7 @@ static bool set_realtime_priority(int thread_index)

void thread_init_functor::operator()(int thread_index)
{
set_daz_ftz();
name_current_thread(thread_index);

if (rt)
Expand Down Expand Up @@ -321,6 +324,8 @@ void synth_definition_deleter::dispose(synth_definition * ptr)

void realtime_engine_functor::init_thread(void)
{
set_daz_ftz();

if (!thread_set_affinity(0))
std::cerr << "Warning: cannot set thread affinity of main audio thread" << std::endl;

Expand Down

5 comments on commit e2a4962

@sonoro1234
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi tim,
Now CheckBadValues does not post that there are denormals but there are CPU spikes in the same places.
Thats weird!!! it seems that SSE kills demormals but with a CPU cost as great as before.
victor

@timblechmann
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, now it is definitely called in the correct places. but can you perform some profiling to see if actually sse code is involved in the slowdown? otherwise, have you tried to kill denormals by adding/substracting a small offset (say 1e-20) to the feedback paths to kill denormals?

@sonoro1234
Copy link
Contributor

@sonoro1234 sonoro1234 commented on e2a4962 Jun 11, 2014 via email

Choose a reason for hiding this comment

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

@timblechmann
Copy link
Contributor Author

Choose a reason for hiding this comment

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

you did compile for sse/sse2 instruction sets, right?

@sonoro1234
Copy link
Contributor

@sonoro1234 sonoro1234 commented on e2a4962 Jun 11, 2014 via email

Choose a reason for hiding this comment

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

Please sign in to comment.