Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
5a2a6074
Commit
5a2a6074
authored
6 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Patches
Plain Diff
Add function to give a different seed for randoms
parent
67bd6d88
No related branches found
No related tags found
1 merge request
!506
Add ParMETIS support
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/clocks.c
+21
-0
21 additions, 0 deletions
src/clocks.c
src/clocks.h
+1
-0
1 addition, 0 deletions
src/clocks.h
with
22 additions
and
0 deletions
src/clocks.c
+
21
−
0
View file @
5a2a6074
...
...
@@ -30,6 +30,7 @@
/* Standard headers. */
#include
<stdio.h>
#include
<limits.h>
#include
<unistd.h>
/* Local headers. */
...
...
@@ -280,3 +281,23 @@ double clocks_get_cputime_used(void) {
times
(
&
tmstic
);
return
(
double
)(
tmstic
.
tms_utime
+
tmstic
.
tms_cutime
);
}
/**
* @brief Return an integer based on the current time.
*
* Normally this will be the remainder of the current number of nanoseconds
* so not very dissimilar in the most significant figures unless the time
* between calls is greater than INT_MAX nanoseconds. For faster calls use
* fewer figures, if that matters.
*
* @result an integer.
*/
int
clocks_random_seed
(
void
)
{
struct
timespec
timespec
;
#ifdef HAVE_CLOCK_GETTIME
clock_gettime
(
CLOCK_REALTIME
,
&
timespec
);
return
(
timespec
.
tv_nsec
%
INT_MAX
);
#else
return
(
getticks
()
%
INT_MAX
);
#endif
}
This diff is collapsed.
Click to expand it.
src/clocks.h
+
1
−
0
View file @
5a2a6074
...
...
@@ -44,5 +44,6 @@ double clocks_diff_ticks(ticks tic, ticks toc);
const
char
*
clocks_get_timesincestart
(
void
);
double
clocks_get_cputime_used
(
void
);
int
clocks_random_seed
(
void
);
#endif
/* SWIFT_CLOCKS_H */
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