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
cc823dbd
Commit
cc823dbd
authored
4 years ago
by
Mladen Ivkovic
Committed by
Matthieu Schaller
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added task lock RTD documentation
parent
7b50a927
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/RTD/source/Task/index.rst
+1
-0
1 addition, 0 deletions
doc/RTD/source/Task/index.rst
doc/RTD/source/Task/locks.rst
+65
-0
65 additions, 0 deletions
doc/RTD/source/Task/locks.rst
with
66 additions
and
0 deletions
doc/RTD/source/Task/index.rst
+
1
−
0
View file @
cc823dbd
...
...
@@ -21,3 +21,4 @@ Everything is described in :ref:`Analysis_Tools`.
adding_your_own
adding_your_own_neighbour_loop
adding_to_dependency_plotting_tool
locks
This diff is collapsed.
Click to expand it.
doc/RTD/source/Task/locks.rst
0 → 100644
+
65
−
0
View file @
cc823dbd
.. locks
Mladen Ivkovic Feb 2021
.. _task_locks:
.. highlight:: c
Task Locks
=============
Swift doesn't only deal with dependencies, but with data conflicts as
well. We can't have two independent tasks working on the same data
concurrently, even if the tasks have no dependencies between them.
For this reason, each task locks the data it works on when it begins,
and unlocks the data again once it's finished. Data here refers to the
particle (gas, gravity, stars,...) content of a cell as well as of the
hierarchy of cells in the tree at levels closer to the root that. By
default, it is assumed that the task is doing work on hydro
particles. If your task requires other particle types, you will need
to specify that in ``src/task.c``. Suppose you have implemented a task
with type ``task_type_new`` that requires both stars and hydro
particles: ::
/**
* @brief Try to lock the cells associated with this task.
*
* @param t the #task.
*/
int task_lock(struct task *t) {
const enum task_types type = t->type;
const enum task_subtypes subtype = t->subtype;
struct cell *ci = t->ci, *cj = t->cj;
switch (type) {
/* lots of stuff */
case task_type_new:
/* is the data locked already? */
if (ci->hydro.hold || ci->stars.hold) return 0;
/* if it's not locked already, lock first particle type (hydro)
* if something locked it in the meantime, exit with failure. */
if (cell_locktree(ci) != 0) return 0;
/* if it's not locked already, lock first particle type (stars)
* if something locked it in the meantime, first unlock what you
* locked, and then exit with failure. */
if (cell_slocktree(ci) != 0) {
cell_unlocktree(ci);
return 0;
}
/* lots of other stuff */
}
/* lots of other stuff */
}
Similarly, don't forget to write your unlocking routines in ``task_unlock()`` !
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