Skip to content

Commit

Permalink
add fenv cache to task struct
Browse files Browse the repository at this point in the history
Fixes #51277
  • Loading branch information
simonbyrne committed Sep 13, 2023
1 parent 5d82d80 commit 64aa1de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "libsupport.h"
#include <stdint.h>
#include <string.h>
#include <fenv.h>

#include "htable.h"
#include "arraylist.h"
Expand Down Expand Up @@ -2050,6 +2051,9 @@ typedef struct _jl_task_t {
uint16_t priority;

// hidden state:
// cached floating point environment
// only updated at task switch
fenv_t fenv;

#ifdef USE_TRACY
const char *name;
Expand Down
3 changes: 3 additions & 0 deletions src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,8 @@ JL_NO_ASAN static void ctx_switch(jl_task_t *lastt)
jl_set_pgcstack(&t->gcstack);
jl_signal_fence();
lastt->ptls = NULL;
fegetenv(&lastt->fenv);
fesetenv(&t->fenv);
#ifdef MIGRATE_TASKS
ptls->previous_task = lastt;
#endif
Expand Down Expand Up @@ -1079,6 +1081,7 @@ JL_DLLEXPORT jl_task_t *jl_new_task(jl_function_t *start, jl_value_t *completion
t->excstack = NULL;
t->started = 0;
t->priority = 0;
fegetenv(&t->fenv);
jl_atomic_store_relaxed(&t->tid, t->copy_stack ? jl_atomic_load_relaxed(&ct->tid) : -1); // copy_stacks are always pinned since they can't be moved
t->threadpoolid = ct->threadpoolid;
t->ptls = NULL;
Expand Down

0 comments on commit 64aa1de

Please sign in to comment.