Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
28fe68e0
Commit
28fe68e0
authored
Aug 10, 2015
by
peastman
Browse files
Attempt at fixing a race condition in CPU PME
parent
300566f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
plugins/cpupme/src/CpuPmeKernels.cpp
plugins/cpupme/src/CpuPmeKernels.cpp
+11
-0
No files found.
plugins/cpupme/src/CpuPmeKernels.cpp
View file @
28fe68e0
...
@@ -372,6 +372,7 @@ void CpuCalcPmeReciprocalForceKernel::initialize(int xsize, int ysize, int zsize
...
@@ -372,6 +372,7 @@ void CpuCalcPmeReciprocalForceKernel::initialize(int xsize, int ysize, int zsize
// Initialize threads.
// Initialize threads.
isFinished
=
false
;
pthread_cond_init
(
&
startCondition
,
NULL
);
pthread_cond_init
(
&
startCondition
,
NULL
);
pthread_cond_init
(
&
endCondition
,
NULL
);
pthread_cond_init
(
&
endCondition
,
NULL
);
pthread_cond_init
(
&
mainThreadStartCondition
,
NULL
);
pthread_cond_init
(
&
mainThreadStartCondition
,
NULL
);
...
@@ -386,6 +387,14 @@ void CpuCalcPmeReciprocalForceKernel::initialize(int xsize, int ysize, int zsize
...
@@ -386,6 +387,14 @@ void CpuCalcPmeReciprocalForceKernel::initialize(int xsize, int ysize, int zsize
}
}
pthread_create
(
&
mainThread
,
NULL
,
threadBody
,
new
ThreadData
(
*
this
,
-
1
));
pthread_create
(
&
mainThread
,
NULL
,
threadBody
,
new
ThreadData
(
*
this
,
-
1
));
// Wait until the main thread is up and running.
pthread_mutex_lock
(
&
lock
);
while
(
!
isFinished
)
{
pthread_cond_wait
(
&
mainThreadEndCondition
,
&
lock
);
}
pthread_mutex_unlock
(
&
lock
);
// Initialize FFTW.
// Initialize FFTW.
realGrid
=
threadData
[
0
]
->
tempGrid
;
realGrid
=
threadData
[
0
]
->
tempGrid
;
...
@@ -478,6 +487,8 @@ void CpuCalcPmeReciprocalForceKernel::runThread(int index) {
...
@@ -478,6 +487,8 @@ void CpuCalcPmeReciprocalForceKernel::runThread(int index) {
// This is the main thread that coordinates all the other ones.
// This is the main thread that coordinates all the other ones.
pthread_mutex_lock
(
&
lock
);
pthread_mutex_lock
(
&
lock
);
isFinished
=
true
;
pthread_cond_signal
(
&
mainThreadEndCondition
);
while
(
true
)
{
while
(
true
)
{
// Wait for the signal to start.
// Wait for the signal to start.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment