Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDC
cats
Commits
4f16e375
Commit
4f16e375
authored
May 9, 2023
by
Andreas Gattringer
Browse files
Options
Downloads
Patches
Plain Diff
threading: add temporary variables and more random number generators
parent
7a31d237
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cats/threading/threading-helpers.c
+17
-0
17 additions, 0 deletions
src/cats/threading/threading-helpers.c
src/cats/threading/threading.c
+2
-0
2 additions, 0 deletions
src/cats/threading/threading.c
src/cats/threading/threading.h
+5
-0
5 additions, 0 deletions
src/cats/threading/threading.h
with
24 additions
and
0 deletions
src/cats/threading/threading-helpers.c
+
17
−
0
View file @
4f16e375
...
...
@@ -50,10 +50,21 @@ initialize_thread(struct cats_thread_info *thread, struct cats_grid *grid, struc
zero_statistics_stats
(
&
thread
->
stats
[
i
]);
}
thread
->
temp
=
0
;
thread
->
temp1
=
0
;
thread
->
temp2
=
0
;
thread
->
seed
=
get_random_seed
(
false
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
thread
->
seed4
[
i
]
=
get_random_seed64
(
false
);
}
thread
->
id
=
id
;
thread
->
grid
=
grid
;
thread
->
conf
=
conf
;
thread
->
rng_buf_size
=
32
;
thread
->
rng_state_buffer
=
calloc_or_die
(
1
,
thread
->
rng_buf_size
);
thread
->
rng_state
=
calloc_or_die
(
1
,
sizeof
(
struct
random_data
));
initstate_r
(
get_random_seed
(
false
),
thread
->
rng_state_buffer
,
thread
->
rng_buf_size
,
thread
->
rng_state
);
}
...
...
@@ -65,8 +76,12 @@ int32_t get_dispersal_radius(const struct cats_configuration *conf, int32_t id)
void
cleanup_threads
(
struct
cats_thread_info
*
threads
,
int32_t
num_threads
)
{
for
(
int32_t
i
=
0
;
i
<
num_threads
;
i
++
)
{
gsl_rng_free
(
threads
[
i
].
rng
);
free
(
threads
[
i
].
rng_state
);
free
(
threads
[
i
].
rng_state_buffer
);
}
for
(
int32_t
i
=
0
;
i
<
num_threads
;
i
++
)
{
...
...
@@ -75,6 +90,8 @@ void cleanup_threads(struct cats_thread_info *threads, int32_t num_threads)
}
}
free
(
threads
);
}
...
...
This diff is collapsed.
Click to expand it.
src/cats/threading/threading.c
+
2
−
0
View file @
4f16e375
...
...
@@ -94,6 +94,8 @@ setup_threads(struct cats_configuration *conf, struct cats_grid *grid, int32_t m
}
switch
(
t
->
strategy
)
{
case
TS_UNKNOWN
:
log_message
(
LOG_ERROR
,
"undefined threading strategy"
);
...
...
This diff is collapsed.
Click to expand it.
src/cats/threading/threading.h
+
5
−
0
View file @
4f16e375
...
...
@@ -53,6 +53,11 @@ struct cats_thread_info {
int64_t
temp
;
int64_t
temp1
;
int64_t
temp2
;
char
*
rng_state_buffer
;
int32_t
rng_buf_size
;
struct
random_data
*
rng_state
;
unsigned
int
seed
;
uint64_t
seed4
[
4
];
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment