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
e3a01e02
Commit
e3a01e02
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Fixed the atomic min/max/add for floats that were incorrectly pushed earlier.
parent
ff8cb4a0
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/atomic.h
+30
-21
30 additions, 21 deletions
src/atomic.h
with
30 additions
and
21 deletions
src/atomic.h
+
30
−
21
View file @
e3a01e02
...
@@ -35,39 +35,48 @@
...
@@ -35,39 +35,48 @@
#define atomic_swap(v, n) __sync_lock_test_and_set(v, n)
#define atomic_swap(v, n) __sync_lock_test_and_set(v, n)
/**
/**
* @
param
Atomic min operation on floats.
* @
brief
Atomic min operation on floats.
*/
*/
__attribute__
((
always_inline
))
INLINE
void
atomic_min_f
(
float
cons
t
*
x
,
__attribute__
((
always_inline
))
INLINE
void
atomic_min_f
(
volatile
floa
t
*
x
,
float
y
)
{
float
y
)
{
int
done
=
0
;
float
test
,
new
;
while
(
!
done
)
{
float
old
=
*
x
;
const
float
val
=
*
x
;
do
{
done
=
__sync_bool_compare_and_swap
((
int
*
)
x
,
val
,
min
(
val
,
y
));
test
=
old
;
}
new
=
min
(
old
,
y
);
if
(
new
==
old
)
return
;
old
=
atomic_cas
((
int
*
)
x
,
test
,
new
);
}
while
(
test
!=
old
);
}
}
/**
/**
* @
param
Atomic max operation on floats.
* @
brief
Atomic max operation on floats.
*/
*/
__attribute__
((
always_inline
))
INLINE
void
atomic_max_f
(
float
cons
t
*
x
,
__attribute__
((
always_inline
))
INLINE
void
atomic_max_f
(
volatile
floa
t
*
x
,
float
y
)
{
float
y
)
{
int
done
=
0
;
float
test
,
new
;
while
(
!
done
)
{
float
old
=
*
x
;
const
float
val
=
*
x
;
do
{
done
=
__sync_bool_compare_and_swap
((
int
*
)
x
,
val
,
max
(
val
,
y
));
test
=
old
;
}
new
=
max
(
old
,
y
);
if
(
new
==
old
)
return
;
old
=
atomic_cas
((
int
*
)
x
,
test
,
new
);
}
while
(
test
!=
old
);
}
}
/**
/**
* @
param
Atomic add operation on floats.
* @
brief
Atomic add operation on floats.
*/
*/
__attribute__
((
always_inline
))
INLINE
void
atomic_add_f
(
float
cons
t
*
x
,
__attribute__
((
always_inline
))
INLINE
void
atomic_add_f
(
volatile
floa
t
*
x
,
float
y
)
{
float
y
)
{
int
done
=
0
;
float
test
,
new
;
while
(
!
done
)
{
float
old
=
*
x
;
const
float
val
=
*
x
;
do
{
done
=
__sync_bool_compare_and_swap
((
int
*
)
x
,
val
,
val
+
y
);
test
=
old
;
}
new
=
old
+
y
;
if
(
new
==
old
)
return
;
old
=
atomic_cas
((
int
*
)
x
,
test
,
new
);
}
while
(
test
!=
old
);
}
}
#endif
/* SWIFT_ATOMIC_H */
#endif
/* SWIFT_ATOMIC_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