image: simgrid/build-deps
-stages:
- - build
- - test
+#stages:
+# - build
+# - test
pages:
- stage: test
+# stage: test
script:
- cmake -Denable_model-checking=OFF -Denable_documentation=ON -Denable_compile_optimizations=OFF -Denable_smpi=OFF -Dpython=ON .
- make -j4
- pip3 install --requirement docs/requirements.txt
- cd docs
- - LC_ALL=C.UTF-8 ./Build.sh
+ - LC_ALL=C.UTF-8 SPHINXOPTS=-vv ./Build.sh
- mv build/html ../public
# - The CSS contains a reference to a font or something, not something we gonna fix on our side
# - The javasphinx output does not exist in the git, so the "edit on FramaGit" link is broken.
- master
ctest:
- stage: build
+# stage: build
except:
- stable
script:
pip:
image: debian:testing
- stage: build
+# stage: build
except:
- stable
script:
- cd dist && tar xfz simgrid*.tar.gz && cd simgrid-*/ && python3 setup.py build
release:
- stage: build
+# stage: build
only:
- stable
script:
SimGrid (3.24.1) NOT RELEASED YET (v3.25 expected December 22. 2029, 04:19 UTC)
+S4U:
+- Actor: Merge signals on_migration_start/end into on_host_change
+- Actor: Rename migrate() into set_host()
+
+XML:
+- Parse errors now raise a simgrid::ParseError that you may want to catch.
+
+Kernel:
+- In simgrid::kernel::resource::Model, the methods next_occuring_event*() have
+ been renamed to fix a spelling error. As usual, the previous definitions are
+ kept with a deprecation warning. However, to avoid runtime errors, it is now
+ forbidden to override these deprecated methods in a derived class. Please use
+ the new names immediately if you need to override them.
+
+XBT:
+- Remove unused parameter 'free_ctn' for xbt_dict_set() and xbt_dict_set_ext().
+
Fixed bugs (FG#.. -> framagit bugs; FG!.. -> framagit merge requests):
- GH#31: [MC] please provide an option to make MPI_Send asynchronous
- - GH#305: Unscheduled tasks are still excuted
+ - GH#305: Unscheduled tasks are still excuted
+ - GH#323: Crash when an actor turn off his physical host
- FG!19: Removing RngStream
----------------------------------------------------------------------------
include examples/python/exec-dvfs/exec-dvfs.tesh
include examples/python/exec-remote/exec-remote.py
include examples/python/exec-remote/exec-remote.tesh
-include examples/s4u/README.rst
include examples/s4u/actor-create/s4u-actor-create.cpp
include examples/s4u/actor-create/s4u-actor-create.tesh
include examples/s4u/actor-create/s4u-actor-create_d.xml
include teshsuite/s4u/activity-lifecycle/testing_platform.xml
include teshsuite/s4u/actor-autorestart/actor-autorestart.cpp
include teshsuite/s4u/actor-autorestart/actor-autorestart.tesh
-include teshsuite/s4u/actor-migration/actor-migration.cpp
-include teshsuite/s4u/actor-migration/actor-migration.tesh
include teshsuite/s4u/actor/actor.cpp
include teshsuite/s4u/actor/actor.tesh
include teshsuite/s4u/cloud-interrupt-migration/cloud-interrupt-migration.cpp
include teshsuite/smpi/coll-scatter/coll-scatter.tesh
include teshsuite/smpi/fort_args/fort_args.f90
include teshsuite/smpi/fort_args/fort_args.tesh
+include teshsuite/smpi/gh-139/gh-139.c
+include teshsuite/smpi/gh-139/gh-139.tesh
include teshsuite/smpi/hostfile
include teshsuite/smpi/hostfile_cluster
include teshsuite/smpi/hostfile_coll
include doc/doxygen/uhood_arch.doc
include doc/doxygen/uhood_switch.doc
include docs/Build.sh
+include docs/find-missing.py
include docs/ignored_symbols
include docs/manpages/smpicc.1
include docs/manpages/smpicxx.1
include docs/source/Tutorial_Algorithms.rst
include docs/source/Tutorial_MPI_Applications.rst
include docs/source/XML_Reference.rst
-include docs/source/_ext/hidden_code_block.py
+include docs/source/_ext/autodoxy.py
+include docs/source/_ext/showfile.css
+include docs/source/_ext/showfile.js
+include docs/source/_ext/showfile.py
include docs/source/_templates/breadcrumbs.html
include docs/source/app_msg.rst
include docs/source/app_s4u.rst
include docs/source/img/extlink.png
include docs/source/img/extlink.svg
include docs/source/img/graphical-toc.svg
-include docs/source/img/lang_cpp.png
-include docs/source/img/lang_python.png
include docs/source/img/smpi_simgrid_alltoall_pair_16.png
include docs/source/img/smpi_simgrid_alltoall_ring_16.png
include docs/source/img/zone_hierarchy.png
include docs/source/tuto_smpi/img/big-picture.svg
include docs/source/tuto_smpi/img/lu.S.4.png
include docs/source/tuto_smpi/roundtrip.c
+include examples/README.rst
include examples/deprecated/java/.classpath
include examples/deprecated/java/.project
include examples/deprecated/java/CMakeLists.txt
for (int i = 0; i < (data->n - 1); i++)
data->percentage[i] = atof(strtok_r(NULL, "\t", &saveptr));
- xbt_dict_set(mydict, key, data, NULL);
+ xbt_dict_set(mydict, key, data);
}
fclose(fpInput);
}
data->percentage[i] = atof(strtok_r(NULL, "\t", &saveptr));
}
- xbt_dict_set(mydict, key, data, NULL);
+ xbt_dict_set(mydict, key, data);
}
fclose(fpInput);
}
~~~~
s_surf_model_description_t surf_cpu_model_description[] = {
{"Cas01",
- "Simplistic CPU model (time=size/power).",
+ "Simplistic CPU model (time=size/speed).",
surf_cpu_model_init_Cas01},
{"Plop",
"The new plop CPU model.",
perl -pe 's/(xlink:href="(?:http|.*\.html))/target="_top" $1/' \
source/img/graphical-toc.svg > build/html/graphical-toc.svg
-echo "List of missing references:"
-for f in $( (grep '<name>' build/xml/msg_8h.xml; \
- grep '<name>' build/xml/namespacesimgrid_1_1s4u.xml; \
- grep '<innerclass refid=' build/xml/namespacesimgrid_1_1s4u.xml ; \
- ) | sed 's/<[^>]*>//g' | sort )
+echo
+echo "Undocumented examples:"
+for ex in $( (cd .. ; \
+ find examples/s4u/ -name '*.cpp'; \
+ find examples/python -name '*.py'; \
+ ) | sort )
do
-
- if grep $f source/*rst | grep -q '.. doxygen[^::]*:: '"$f"'$' ||
- grep $f source/*rst | grep -q '.. doxygen[^::]*:: simgrid::[^:]*::[^:]*::'"$f"'$' ; then :
-# echo "$f documented"
- else
- if grep -q $f ignored_symbols ; then :
-# echo "$f ignored" # not documented
+ if grep -q "example-tab:: $ex" ../examples/README.rst ; then :
+# echo "found example-tab:: $ex"
+ elif grep -q "showfile:: $ex" ../examples/README.rst ; then :
else
- echo "$f"
+ echo $ex
fi
- fi
done
-if [ -e /opt/simgrid ]Â ; then chmod -x /opt/simgrid; fi
-
-set +e #Â Don't fail
+set +e # Don't fail
if [ -e /usr/bin/linkchecker ]Â ; then
- linkchecker --no-status -o csv --ignore-url='.*\.css$' --ignore-url=public/java/org build/html \
+ linkchecker --no-status -o csv --ignore-url='.*\.css$' --ignore-url=build/html/_modules --ignore-url=public/java/org build/html \
| grep -v '^#' \
| grep -v 'urlname;parentname;baseref;result;warningstring'
echo "done."
--- /dev/null
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2019. The SimGrid Team.
+# All rights reserved.
+
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the license (GNU LGPL) which comes with this package.
+
+"""
+Search for symbols documented in both the XML files produced by Doxygen and the python modules,
+but not documented with autodoxy in the RST files.
+
+This script is tailored to SimGrid own needs and should be made more generic for autodoxy.
+"""
+
+import fnmatch
+import os
+import re
+import sys
+import xml.etree.ElementTree as ET
+import inspect
+
+xml_files = [
+ 'build/xml/classsimgrid_1_1s4u_1_1Activity.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Actor.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Barrier.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Comm.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1ConditionVariable.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Disk.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Engine.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1ExecPar.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1ExecSeq.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Exec.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Host.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Io.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Link.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Mailbox.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Mutex.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1NetZone.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1Semaphore.xml',
+ 'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml'
+]
+
+python_modules = [
+ 'simgrid'
+]
+python_ignore = [
+ 'simgrid.ActorKilled'
+]
+
+
+############ Search the python elements in the source, and report undocumented ones
+############
+
+# data structure in which we store the declaration we find
+python_decl = {}
+
+def handle_python_module(fullname, englobing, elm):
+ """Recursive function exploring the python modules."""
+
+ def found_decl(kind, obj):
+ """Helper function that add an object in the python_decl data structure"""
+ if kind not in python_decl: python_decl[kind] = []
+ python_decl[kind].append(obj)
+
+
+ if fullname in python_ignore:
+ print ("Ignore Python symbol '{}' as requested.".format(fullname))
+ return
+
+ if inspect.isroutine(elm) and inspect.isclass(englobing):
+ found_decl("method", fullname)
+# print('.. automethod:: {}'.format(fullname))
+ elif inspect.isroutine(elm) and (not inspect.isclass(englobing)):
+ found_decl("function", fullname)
+# print('.. autofunction:: {}'.format(fullname))
+ elif inspect.isdatadescriptor(elm):
+ found_decl("attribute", fullname)
+# print('.. autoattribute:: {}'.format(fullname))
+ elif isinstance(elm, str) or isinstance(elm, int): # We do have such a data, directly in the SimGrid top module
+ found_decl("data", fullname)
+# print('.. autodata:: {}'.format(fullname))
+ elif inspect.ismodule(elm) or inspect.isclass(elm):
+ for name, data in inspect.getmembers(elm):
+ if name.startswith('__'):
+ continue
+# print("Recurse on {}.{}".format(fullname, name))
+ handle_python_module("{}.{}".format(fullname, name), elm, data)
+ else:
+ print('UNHANDLED TYPE {} : {!r} Type: {}'.format(fullname, elm, type(elm)))
+
+# Start the recursion on the provided Python modules
+for name in python_modules:
+ try:
+ module = __import__(name)
+ except Exception:
+ print("Cannot import {}. Did you set PYTHONPATH=../lib accordingly?".format(name))
+ sys.exit(1)
+ for sub in dir(module):
+ if sub[0] == '_':
+ continue
+ handle_python_module("{}.{}".format(name, sub), module, getattr(module, sub))
+
+# Forget about the python declarations that were actually done in the RST
+for kind in python_decl:
+ with os.popen('grep \'[[:blank:]]*auto{}::\' source/*rst|sed \'s/^.*auto{}:: //\''.format(kind, kind)) as pse:
+ for fullname in (l.strip() for l in pse):
+ if fullname not in python_decl[kind]:
+ print("Warning: {} documented but declaration not found in python.".format(fullname))
+ else:
+ python_decl[kind].remove(fullname)
+# Dump the missing ones
+for kind in python_decl:
+ for fullname in python_decl[kind]:
+ print(" .. auto{}:: {}".format(kind, fullname))
+
+################ And now deal with Doxygen declarations
+################
+
+doxy_funs = {} # {classname: {func_name: [args]} }
+doxy_vars = {} # {classname: [names]}
+
+# find the declarations in the XML files
+for arg in xml_files[:3]:
+ if arg[-4:] != '.xml':
+ print ("Argument '{}' does not end with '.xml'".format(arg))
+ continue
+ print("Parse file {}".format(arg))
+ tree = ET.parse(arg)
+ for elem in tree.findall(".//compounddef"):
+ if elem.attrib["prot"] != "public":
+ continue
+ if "compoundname" in elem:
+ raise Exception("Compound {} has no 'compoundname' child tag.".format(elem))
+ compoundname = elem.find("compoundname").text
+ #print ("compoundname {}".format(compoundname))
+ for member in elem.findall('.//memberdef'):
+ if member.attrib["prot"] != "public":
+ continue
+ kind = member.attrib["kind"]
+ name = member.find("name").text
+ if kind == "variable":
+ if compoundname not in doxy_vars: doxy_vars[compoundname] = []
+ doxy_vars[compoundname].append(name)
+ elif kind == "function":
+ args = member.find('argsstring').text
+ args = re.sub('\)[^)]*$', ')', args) # ignore what's after the parameters (eg, '=0' or ' const')
+
+ if compoundname not in doxy_funs: doxy_funs[compoundname] = {}
+ if name not in doxy_funs[compoundname]: doxy_funs[compoundname][name] = []
+ doxy_funs[compoundname][name].append(args)
+ else:
+ print ("member {}::{} is of kind {}".format(compoundname, name, kind))
+
+# Forget about the declarations that are done in the RST
+with os.popen('grep autodoxymethod:: source/*rst|sed \'s/^.*autodoxymethod:: //\'') as pse:
+ for line in (l.strip() for l in pse):
+ (klass, obj, args) = (None, None, None)
+ if "(" in line:
+ (line, args) = line.split('(', 1)
+ args = "({}".format(args)
+ (klass, obj) = line.rsplit('::', 1)
+
+ if klass not in doxy_funs:
+ print("Warning: {} documented, but class {} not found in doxygen.".format(line, klass))
+ continue
+ if obj not in doxy_funs[klass]:
+ print("Warning: Object {} documented but not found in {}".format(line, klass))
+ elif len(doxy_funs[klass][obj])==1:
+ del doxy_funs[klass][obj]
+ elif args not in doxy_funs[klass][obj]:
+ print("Warning: Function {}{} not found in {}".format(obj, args, klass))
+ else:
+# print("Found {} in {}".format(line, klass))
+ doxy_funs[klass][obj].remove(args)
+ if len(doxy_funs[klass][obj]) == 0:
+ del doxy_funs[klass][obj]
+with os.popen('grep autodoxyvar:: source/*rst|sed \'s/^.*autodoxyvar:: //\'') as pse:
+ for line in (l.strip() for l in pse):
+ (klass, var) = line.rsplit('::', 1)
+
+ if klass not in doxy_vars:
+ print("Warning: {} documented, but class {} not found in doxygen.".format(line, klass))
+ continue
+ if var not in doxy_vars[klass]:
+ print("Warning: Object {} documented but not found in {}".format(line, klass))
+ else:
+# print("Found {} in {}".format(line, klass))
+ doxy_vars[klass].remove(var)
+ if len(doxy_vars[klass]) == 0:
+ del doxy_vars[klass]
+
+# Dump the undocumented Doxygen declarations
+for obj in sorted(doxy_funs):
+ for meth in sorted(doxy_funs[obj]):
+ for args in sorted(doxy_funs[obj][meth]):
+ print(".. autodoxymethod:: {}::{}{}".format(obj, meth, args))
+
+for obj in doxy_vars:
+ for meth in sorted(doxy_vars[obj]):
+ print(".. autodoxyvar:: {}::{}".format(obj, meth))
+
intrusive_ptr_release
intrusive_ptr_add_ref
get_filtered_netzones_recursive
-simgrid::s4u::Storage
\ No newline at end of file
+simgrid::s4u::Storage
+simgrid::s4u::Activity_T
breathe
sphinx>=1.8.0
sphinx_rtd_theme
+sphinx_tabs
javasphinx
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("ConfigBox")
- ``cpu/model``: specify the used CPU model. We have only one model
for now:
- - **Cas01:** Simplistic CPU model (time=size/power)
+ - **Cas01:** Simplistic CPU model (time=size/speed)
- ``host/model``: The host concept is the aggregation of a CPU with a
network card. Three models exists, but actually, only 2 of them are
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("DeployBox")
INPUT = ../../include/simgrid/forward.h
INPUT += ../../include/simgrid/s4u
INPUT += ../../include/simgrid/msg.h
+INPUT += ../../include/simgrid/actor.h
+INPUT += ../../include/simgrid/barrier.h
+INPUT += ../../include/simgrid/cond.h
+INPUT += ../../include/simgrid/engine.h
+INPUT += ../../include/simgrid/host.h
+#INPUT += ../../include/simgrid/instr.h
+INPUT += ../../include/simgrid/link.h
+INPUT += ../../include/simgrid/mailbox.h
+INPUT += ../../include/simgrid/mutex.h
+INPUT += ../../include/simgrid/semaphore.h
+INPUT += ../../include/simgrid/vm.h
+INPUT += ../../include/simgrid/zone.h
INPUT += ../../src/msg/
INPUT += ../../src/plugins/
RECURSIVE = YES
CREATE_SUBDIRS = NO # Mandatory for exhale
# Allow for rst directives and advanced functions e.g. grid tables
-ALIASES = "rst=\verbatim embed:rst:leading-asterisk"
+ALIASES = "beginrst=\verbatim "
ALIASES += "endrst=\endverbatim"
# Enable preprocessing and related preprocessor necessities
PREDEFINED += \
__cplusplus \
DOXYGEN \
+ SG_BEGIN_DECL= \
+ SG_END_DECL= \
XBT_PUBLIC= \
XBT_EXPORT_NO_IMPORT= \
XBT_IMPORT_NO_EXPORT= \
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("XPSetupBox")
.. raw:: html
- <object data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object data="graphical-toc.svg" type="image/svg+xml"></object>
<br/>
<br/>
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("ExamplesBox")
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("PluginsBox")
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("ReferenceBox")
--- /dev/null
+"""
+This is autodoxy, a sphinx extension providing autodoc-like directives
+that are feed with Doxygen files.
+
+It is highly inspired from the autodoc_doxygen sphinx extension, but
+adapted to my own needs in SimGrid.
+https://github.com/rmcgibbo/sphinxcontrib-autodoc_doxygen
+
+Licence: MIT
+Copyright (c) 2015 Robert T. McGibbon
+Copyright (c) 2019 Martin Quinson
+"""
+from __future__ import print_function, absolute_import, division
+
+import os.path
+import re
+import sys
+
+from six import itervalues
+from lxml import etree as ET
+from sphinx.ext.autodoc import Documenter, AutoDirective, members_option, ALL
+from sphinx.errors import ExtensionError
+from sphinx.util import logging
+
+
+##########################################################################
+# XML utils
+##########################################################################
+def format_xml_paragraph(xmlnode):
+ """Format an Doxygen XML segment (principally a detaileddescription)
+ as a paragraph for inclusion in the rst document
+
+ Parameters
+ ----------
+ xmlnode
+
+ Returns
+ -------
+ lines
+ A list of lines.
+ """
+ return [l.rstrip() for l in _DoxygenXmlParagraphFormatter().generic_visit(xmlnode).lines]
+
+
+class _DoxygenXmlParagraphFormatter(object):
+ # This class follows the model of the stdlib's ast.NodeVisitor for tree traversal
+ # where you dispatch on the element type to a different method for each node
+ # during the traverse.
+
+ # It's supposed to handle paragraphs, references, preformatted text (code blocks), and lists.
+
+ def __init__(self):
+ self.lines = ['']
+ self.continue_line = False
+
+ def visit(self, node):
+ method = 'visit_' + node.tag
+ visitor = getattr(self, method, self.generic_visit)
+ return visitor(node)
+
+ def generic_visit(self, node):
+ for child in node.getchildren():
+ self.visit(child)
+ return self
+
+ def visit_ref(self, node):
+ ref = get_doxygen_root().findall('.//*[@id="%s"]' % node.get('refid'))
+ if ref:
+ ref = ref[0]
+ if ref.tag == 'memberdef':
+ parent = ref.xpath('./ancestor::compounddef/compoundname')[0].text
+ name = ref.find('./name').text
+ real_name = parent + '::' + name
+ elif ref.tag in ('compounddef', 'enumvalue'):
+ name_node = ref.find('./name')
+ real_name = name_node.text if name_node is not None else ''
+ else:
+ raise NotImplementedError(ref.tag)
+ else:
+ real_name = None
+
+ val = [':cpp:any:`', node.text]
+ if real_name:
+ val.extend((' <', real_name, '>`'))
+ else:
+ val.append('`')
+ if node.tail is not None:
+ val.append(node.tail)
+
+ self.lines[-1] += ''.join(val)
+
+ def visit_para(self, node):
+ if node.text is not None:
+ if self.continue_line:
+ self.lines[-1] += node.text
+ else:
+ self.lines.append(node.text)
+ self.generic_visit(node)
+ self.lines.append('')
+ self.continue_line = False
+
+ def visit_verbatim(self, node):
+ if node.text is not None:
+ # remove the leading ' *' of any lines
+ lines = [re.sub('^\s*\*','', l) for l in node.text.split('\n')]
+ # Merge each paragraph together
+ text = re.sub("\n\n", "PaRaGrraphSplit", '\n'.join(lines))
+ text = re.sub('\n', '', text)
+ lines = text.split('PaRaGrraphSplit')
+
+ # merge content to the built doc
+ if self.continue_line:
+ self.lines[-1] += lines[0]
+ lines = lines[1:]
+ for l in lines:
+ self.lines.append('')
+ self.lines.append(l)
+ self.generic_visit(node)
+ self.lines.append('')
+ self.continue_line = False
+
+ def visit_parametername(self, node):
+ if 'direction' in node.attrib:
+ direction = '[%s] ' % node.get('direction')
+ else:
+ direction = ''
+
+ self.lines.append('**%s** -- %s' % (
+ node.text, direction))
+ self.continue_line = True
+
+ def visit_parameterlist(self, node):
+ lines = [l for l in type(self)().generic_visit(node).lines if l is not '']
+ self.lines.extend([':parameters:', ''] + ['* %s' % l for l in lines] + [''])
+
+ def visit_simplesect(self, node):
+ if node.get('kind') == 'return':
+ self.lines.append(':returns: ')
+ self.continue_line = True
+ self.generic_visit(node)
+
+ def visit_listitem(self, node):
+ self.lines.append(' - ')
+ self.continue_line = True
+ self.generic_visit(node)
+
+ def visit_preformatted(self, node):
+ segment = [node.text if node.text is not None else '']
+ for n in node.getchildren():
+ segment.append(n.text)
+ if n.tail is not None:
+ segment.append(n.tail)
+
+ lines = ''.join(segment).split('\n')
+ self.lines.extend(('.. code-block:: C++', ''))
+ self.lines.extend([' ' + l for l in lines])
+
+ def visit_computeroutput(self, node):
+ c = node.find('preformatted')
+ if c is not None:
+ return self.visit_preformatted(c)
+ return self.visit_preformatted(node)
+
+ def visit_xrefsect(self, node):
+ if node.find('xreftitle').text == 'Deprecated':
+ sublines = type(self)().generic_visit(node).lines
+ self.lines.extend(['.. admonition:: Deprecated'] + [' ' + s for s in sublines])
+ else:
+ raise ValueError(node)
+
+ def visit_subscript(self, node):
+ self.lines[-1] += '\ :sub:`%s` %s' % (node.text, node.tail)
+
+
+##########################################################################
+# Directives
+##########################################################################
+
+
+class DoxygenDocumenter(Documenter):
+ # Variables to store the names of the object being documented. modname and fullname are redundant,
+ # and objpath is always the empty list. This is inelegant, but we need to work with the superclass.
+
+ fullname = None # example: "OpenMM::NonbondedForce" or "OpenMM::NonbondedForce::methodName""
+ modname = None # example: "OpenMM::NonbondedForce" or "OpenMM::NonbondedForce::methodName""
+ objname = None # example: "NonbondedForce" or "methodName"
+ objpath = [] # always the empty list
+ object = None # the xml node for the object
+
+ option_spec = {
+ 'members': members_option,
+ }
+
+ def __init__(self, directive, name, indent=u'', id=None):
+ super(DoxygenDocumenter, self).__init__(directive, name, indent)
+ if id is not None:
+ self.parse_id(id)
+
+ def parse_id(self, id):
+ return False
+
+ def parse_name(self):
+ """Determine what module to import and what attribute to document.
+ Returns True and sets *self.modname*, *self.objname*, *self.fullname*,
+ if parsing and resolving was successful.
+ """
+ # To view the context and order in which all of these methods get called,
+ # See, Documenter.generate(). That's the main "entry point" that first
+ # calls parse_name(), follwed by import_object(), format_signature(),
+ # add_directive_header(), and then add_content() (which calls get_doc())
+
+ # If we were provided a prototype, that must be an overloaded function. Save it.
+ self.argsstring = None
+ if "(" in self.name:
+ (self.name, self.argsstring) = self.name.split('(', 1)
+ self.argsstring = "({}".format(self.argsstring)
+
+ # methods in the superclass sometimes use '.' to join namespace/class
+ # names with method names, and we don't want that.
+ self.name = self.name.replace('.', '::')
+ self.fullname = self.name
+ self.modname = self.fullname
+ self.objpath = []
+
+ if '::' in self.name:
+ parts = self.name.split('::')
+ self.klassname = parts[-2]
+ self.objname = parts[-1]
+ else:
+ self.objname = self.name
+ self.klassname = ""
+
+ return True
+
+ def add_directive_header(self, sig):
+ """Add the directive header and options to the generated content."""
+ domain = getattr(self, 'domain', 'cpp')
+ directive = getattr(self, 'directivetype', self.objtype)
+ name = self.format_name()
+ sourcename = self.get_sourcename()
+ self.add_line(u'.. %s:%s:: %s%s' % (domain, directive, name, sig),
+ sourcename)
+
+ def document_members(self, all_members=False):
+ """Generate reST for member documentation.
+ If *all_members* is True, do all members, else those given by
+ *self.options.members*.
+ """
+ want_all = all_members or self.options.inherited_members or \
+ self.options.members is ALL
+ # find out which members are documentable
+ members_check_module, members = self.get_object_members(want_all)
+
+ # remove members given by exclude-members
+ if self.options.exclude_members:
+ members = [(membername, member) for (membername, member) in members
+ if membername not in self.options.exclude_members]
+
+ # document non-skipped members
+ memberdocumenters = []
+ for (mname, member, isattr) in self.filter_members(members, want_all):
+ classes = [cls for cls in itervalues(AutoDirective._registry)
+ if cls.can_document_member(member, mname, isattr, self)]
+ if not classes:
+ # don't know how to document this member
+ continue
+
+ # prefer the documenter with the highest priority
+ classes.sort(key=lambda cls: cls.priority)
+
+ documenter = classes[-1](self.directive, mname, indent=self.indent, id=member.get('id'))
+ memberdocumenters.append((documenter, isattr))
+
+ for documenter, isattr in memberdocumenters:
+ documenter.generate(
+ all_members=True, real_modname=self.real_modname,
+ check_module=members_check_module and not isattr)
+
+ # reset current objects
+ self.env.temp_data['autodoc:module'] = None
+ self.env.temp_data['autodoc:class'] = None
+
+
+class DoxygenClassDocumenter(DoxygenDocumenter):
+ objtype = 'doxyclass'
+ directivetype = 'class'
+ domain = 'cpp'
+ priority = 100
+
+ option_spec = {
+ 'members': members_option,
+ }
+
+ @classmethod
+ def can_document_member(cls, member, membername, isattr, parent):
+ # this method is only called from Documenter.document_members
+ # when a higher level documenter (module or namespace) is trying
+ # to choose the appropriate documenter for each of its lower-level
+ # members. Currently not implemented since we don't have a higher-level
+ # doumenter like a DoxygenNamespaceDocumenter.
+ return False
+
+ def import_object(self):
+ """Import the object and set it as *self.object*. In the call sequence, this
+ is executed right after parse_name(), so it can use *self.fullname*, *self.objname*,
+ and *self.modname*.
+
+ Returns True if successful, False if an error occurred.
+ """
+ xpath_query = './/compoundname[text()="%s"]/..' % self.fullname
+ match = get_doxygen_root().xpath(xpath_query)
+ if len(match) != 1:
+ raise ExtensionError('[autodoxy] could not find class (fullname="%s"). I tried'
+ 'the following xpath: "%s"' % (self.fullname, xpath_query))
+
+ self.object = match[0]
+ return True
+
+ def format_signature(self):
+ return ''
+
+ def format_name(self):
+ return self.fullname
+
+ def get_doc(self, encoding):
+ detaileddescription = self.object.find('detaileddescription')
+ doc = [format_xml_paragraph(detaileddescription)]
+ return doc
+
+ def get_object_members(self, want_all):
+ all_members = self.object.xpath('.//sectiondef[@kind="public-func" '
+ 'or @kind="public-static-func"]/memberdef[@kind="function"]')
+
+ if want_all:
+ return False, ((m.find('name').text, m) for m in all_members)
+ else:
+ if not self.options.members:
+ return False, []
+ else:
+ return False, ((m.find('name').text, m) for m in all_members
+ if m.find('name').text in self.options.members)
+
+ def filter_members(self, members, want_all):
+ ret = []
+ for (membername, member) in members:
+ ret.append((membername, member, False))
+ return ret
+
+ def document_members(self, all_members=False):
+ super(DoxygenClassDocumenter, self).document_members(all_members=all_members)
+ # Uncomment to view the generated rst for the class.
+ # print('\n'.join(self.directive.result))
+
+class DoxygenMethodDocumenter(DoxygenDocumenter):
+ objtype = 'doxymethod'
+ directivetype = 'function'
+ domain = 'cpp'
+ priority = 100
+
+ @classmethod
+ def can_document_member(cls, member, membername, isattr, parent):
+ if ET.iselement(member) and member.tag == 'memberdef' and member.get('kind') == 'function':
+ return True
+ return False
+
+ def parse_id(self, id):
+ xp = './/*[@id="%s"]' % id
+ match = get_doxygen_root().xpath(xp)
+ if len(match) > 0:
+ match = match[0]
+ self.fullname = match.find('./definition').text.split()[-1]
+ self.modname = self.fullname
+ self.objname = match.find('./name').text
+ self.object = match
+ return False
+
+ def import_object(self):
+ if ET.iselement(self.object):
+ # self.object already set from DoxygenDocumenter.parse_name(),
+ # caused by passing in the `id` of the node instead of just a
+ # classname or method name
+ return True
+
+ (obj, meth) = self.fullname.rsplit('::', 1)
+
+ xpath_query_noparam = ('.//compoundname[text()="{:s}"]/../sectiondef[@kind="public-func" or @kind="public-static-func"]'
+ '/memberdef[@kind="function"]/name[text()="{:s}"]/..').format(obj, meth)
+ xpath_query = ""
+# print("fullname {}".format(self.fullname))
+ if self.argsstring != None:
+ xpath_query = ('.//compoundname[text()="{:s}"]/../sectiondef[@kind="public-func" or @kind="public-static-func"]'
+ '/memberdef[@kind="function" and argsstring/text()="{:s}"]/name[text()="{:s}"]/..').format(obj,self.argsstring,meth)
+ else:
+ xpath_query = xpath_query_noparam
+ match = get_doxygen_root().xpath(xpath_query)
+ if len(match) == 0:
+ logger = logging.getLogger(__name__)
+
+ if self.argsstring != None:
+ candidates = get_doxygen_root().xpath(xpath_query_noparam)
+ if len(candidates) == 1:
+ logger.warning("[autodoxy] Using method '{}::{}{}' instead of '{}::{}{}'. You may want to drop your specification of the signature, or to fix it."
+ .format(obj, meth, candidates[0].find('argsstring').text, obj, meth, self.argsstring))
+ self.object = candidates[0]
+ return True
+ logger.warning("[autodoxy] WARNING: Could not find method {}::{}{}".format(obj, meth, self.argsstring))
+ for cand in candidates:
+ logger.warning("[autodoxy] WARNING: Existing candidate: {}::{}{}".format(obj, meth, cand.find('argsstring').text))
+ else:
+ logger.warning("[autodoxy] WARNING: could not find method {}::{} in Doxygen files".format(obj, meth))
+ return False
+ self.object = match[0]
+ return True
+
+ def get_doc(self, encoding):
+ detaileddescription = self.object.find('detaileddescription')
+ doc = [format_xml_paragraph(detaileddescription)]
+ return doc
+
+ def format_name(self):
+ def text(el):
+ if el.text is not None:
+ return el.text
+ return ''
+
+ def tail(el):
+ if el.tail is not None:
+ return el.tail
+ return ''
+
+ rtype_el = self.object.find('type')
+ rtype_el_ref = rtype_el.find('ref')
+ if rtype_el_ref is not None:
+ rtype = text(rtype_el) + text(rtype_el_ref) + tail(rtype_el_ref)
+ else:
+ rtype = rtype_el.text
+
+ # print("rtype: {}".format(rtype))
+ signame = (rtype and (rtype + ' ') or '') + self.klassname + "::"+ self.objname
+ return self.format_template_name() + signame
+
+ def format_template_name(self):
+ types = [e.text for e in self.object.findall('templateparamlist/param/type')]
+ if len(types) == 0:
+ return ''
+ ret = 'template <%s>' % ','.join(types)
+# print ("template: {}".format(ret))
+ return ret
+
+ def format_signature(self):
+ args = self.object.find('argsstring').text
+ return args
+
+ def document_members(self, all_members=False):
+ pass
+
+class DoxygenVariableDocumenter(DoxygenDocumenter):
+ objtype = 'doxyvar'
+ directivetype = 'var'
+ domain = 'cpp'
+ priority = 100
+
+ @classmethod
+ def can_document_member(cls, member, membername, isattr, parent):
+ if ET.iselement(member) and member.tag == 'memberdef' and member.get('kind') == 'variable':
+ return True
+ return False
+
+ def import_object(self):
+ if ET.iselement(self.object):
+ # self.object already set from DoxygenDocumenter.parse_name(),
+ # caused by passing in the `id` of the node instead of just a
+ # classname or method name
+ return True
+
+ (obj, var) = self.fullname.rsplit('::', 1)
+
+ xpath_query = ('.//compoundname[text()="{:s}"]/../sectiondef[@kind="public-attrib" or @kind="public-static-attrib"]'
+ '/memberdef[@kind="variable"]/name[text()="{:s}"]/..').format(obj, var)
+# print("fullname {}".format(self.fullname))
+ match = get_doxygen_root().xpath(xpath_query)
+ if len(match) == 0:
+ logger = logging.getLogger(__name__)
+
+ logger.warning("[autodoxy] WARNING: could not find variable {}::{} in Doxygen files".format(obj, var))
+ return False
+ self.object = match[0]
+ return True
+
+ def parse_id(self, id):
+ xp = './/*[@id="%s"]' % id
+ match = get_doxygen_root().xpath(xp)
+ if len(match) > 0:
+ match = match[0]
+ self.fullname = match.find('./definition').text.split()[-1]
+ self.modname = self.fullname
+ self.objname = match.find('./name').text
+ self.object = match
+ return False
+
+ def format_name(self):
+ def text(el):
+ if el.text is not None:
+ return el.text
+ return ''
+
+ def tail(el):
+ if el.tail is not None:
+ return el.tail
+ return ''
+
+ rtype_el = self.object.find('type')
+ rtype_el_ref = rtype_el.find('ref')
+ if rtype_el_ref is not None:
+ rtype = text(rtype_el) + text(rtype_el_ref) + tail(rtype_el_ref)
+ else:
+ rtype = rtype_el.text
+
+ # print("rtype: {}".format(rtype))
+ signame = (rtype and (rtype + ' ') or '') + self.klassname + "::" + self.objname
+ return self.format_template_name() + signame
+
+ def get_doc(self, encoding):
+ detaileddescription = self.object.find('detaileddescription')
+ doc = [format_xml_paragraph(detaileddescription)]
+ return doc
+
+ def format_template_name(self):
+ types = [e.text for e in self.object.findall('templateparamlist/param/type')]
+ if len(types) == 0:
+ return ''
+ ret = 'template <%s>' % ','.join(types)
+# print ("template: {}".format(ret))
+ return ret
+
+ def document_members(self, all_members=False):
+ pass
+
+
+##########################################################################
+# Setup the extension
+##########################################################################
+def set_doxygen_xml(app):
+ """Load all doxygen XML files from the app config variable
+ `app.config.doxygen_xml` which should be a path to a directory
+ containing doxygen xml output
+ """
+ err = ExtensionError(
+ '[autodoxy] No doxygen xml output found in doxygen_xml="%s"' % app.config.doxygen_xml)
+
+ if not os.path.isdir(app.config.doxygen_xml):
+ raise err
+
+ files = [os.path.join(app.config.doxygen_xml, f)
+ for f in os.listdir(app.config.doxygen_xml)
+ if f.lower().endswith('.xml') and not f.startswith('._')]
+ if len(files) == 0:
+ raise err
+
+ setup.DOXYGEN_ROOT = ET.ElementTree(ET.Element('root')).getroot()
+ for file in files:
+ root = ET.parse(file).getroot()
+ for node in root:
+ setup.DOXYGEN_ROOT.append(node)
+
+
+def get_doxygen_root():
+ """Get the root element of the doxygen XML document.
+ """
+ if not hasattr(setup, 'DOXYGEN_ROOT'):
+ setup.DOXYGEN_ROOT = ET.Element("root") # dummy
+ return setup.DOXYGEN_ROOT
+
+
+def setup(app):
+ import sphinx.ext.autosummary
+
+ app.connect("builder-inited", set_doxygen_xml)
+# app.connect("builder-inited", process_generate_options)
+
+ app.setup_extension('sphinx.ext.autodoc')
+# app.setup_extension('sphinx.ext.autosummary')
+
+ app.add_autodocumenter(DoxygenClassDocumenter)
+ app.add_autodocumenter(DoxygenMethodDocumenter)
+ app.add_autodocumenter(DoxygenVariableDocumenter)
+ app.add_config_value("doxygen_xml", "", True)
+
+# app.add_directive('autodoxysummary', DoxygenAutosummary)
+# app.add_directive('autodoxyenum', DoxygenAutoEnum)
+
+ return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
+++ /dev/null
-"""Simple, inelegant Sphinx extension which adds a directive for a
-highlighted code-block that may be toggled hidden and shown in HTML.
-This is possibly useful for teaching courses.
-
-The directive, like the standard code-block directive, takes
-a language argument and an optional linenos parameter. The
-hidden-code-block adds starthidden and label as optional
-parameters.
-
-Examples:
-
-.. hidden-code-block:: python
- :starthidden: False
-
- a = 10
- b = a + 5
-
-.. hidden-code-block:: python
- :label: --- SHOW/HIDE ---
-
- x = 10
- y = x + 5
-
-Thanks to http://www.javascriptkit.com/javatutors/dom3.shtml for
-inspiration on the javascript.
-
-Thanks to Milad 'animal' Fatenejad for suggesting this extension
-in the first place.
-
-Written by Anthony 'el Scopz' Scopatz, January 2012.
-https://github.com/scopatz/hiddencode
-
-Released under the WTFPL (http://sam.zoy.org/wtfpl/).
-"""
-
-from docutils import nodes
-from docutils.parsers.rst import directives
-from sphinx.directives.code import CodeBlock
-
-HCB_COUNTER = 0
-
-js_showhide = """\
-<script type="text/javascript">
- function showhide(element){
- if (!document.getElementById)
- return
-
- if (element.style.display == "block")
- element.style.display = "none"
- else
- element.style.display = "block"
- };
-</script>
-"""
-
-def nice_bool(arg):
- tvalues = ('true', 't', 'yes', 'y')
- fvalues = ('false', 'f', 'no', 'n')
- arg = directives.choice(arg, tvalues + fvalues)
- return arg in tvalues
-
-
-class hidden_code_block(nodes.General, nodes.FixedTextElement):
- pass
-
-
-class HiddenCodeBlock(CodeBlock):
- """Hidden code block is Hidden"""
-
- option_spec = dict(starthidden=nice_bool,
- label=str,
- **CodeBlock.option_spec)
-
- def run(self):
- # Body of the method is more or less copied from CodeBlock
- code = u'\n'.join(self.content)
- hcb = hidden_code_block(code, code)
- hcb['language'] = self.arguments[0]
- hcb['linenos'] = 'linenos' in self.options
- hcb['starthidden'] = self.options.get('starthidden', True)
- hcb['label'] = self.options.get('label', '+ show/hide code')
- hcb.line = self.lineno
- return [hcb]
-
-
-def visit_hcb_html(self, node):
- """Visit hidden code block"""
- global HCB_COUNTER
- HCB_COUNTER += 1
-
- # We want to use the original highlighter so that we don't
- # have to reimplement it. However it raises a SkipNode
- # error at the end of the function call. Thus we intercept
- # it and raise it again later.
- try:
- self.visit_literal_block(node)
- except nodes.SkipNode:
- pass
-
- # The last element of the body should be the literal code
- # block that was just made.
- code_block = self.body[-1]
-
- fill_header = {'divname': 'hiddencodeblock{0}'.format(HCB_COUNTER),
- 'startdisplay': 'none' if node['starthidden'] else 'block',
- 'label': node.get('label'),
- }
-
- divheader = ("""<a href="javascript:showhide(document.getElementById('{divname}'))">"""
- """{label}</a><br />"""
- '''<div id="{divname}" style="display: {startdisplay}">'''
- ).format(**fill_header)
-
- code_block = js_showhide + divheader + code_block + "</div>"
-
- # reassign and exit
- self.body[-1] = code_block
- raise nodes.SkipNode
-
-
-def depart_hcb_html(self, node):
- """Depart hidden code block"""
- # Stub because of SkipNode in visit
-
-
-def setup(app):
- app.add_directive('hidden-code-block', HiddenCodeBlock)
- app.add_node(hidden_code_block, html=(visit_hcb_html, depart_hcb_html))
--- /dev/null
+
+/**
+ *
+ */
+.toggle-tab {
+ margin-bottom: 40px;
+}
+
+.toggle-header {
+ display: block;
+ clear: both;
+ cursor: pointer;
+}
+.toggle-header p {display: inline; }
+.toggle-header strong {color: #2980b9 }
+
+.toggle-header:after {
+ content: " â–¼";
+}
+
+.toggle-header.open:after {
+ content: " ⯇";
+}
+
+.toggle-content {
+ display: none;
+ margin-bottom: 20px;
+}
--- /dev/null
+
+$(function() {
+ /**
+ * Toggle logic
+ */
+ $('.hidden-content').hide()
+ $('.toggle-header').click(function () {
+ $(this).toggleClass("open");
+ $(this).next('.toggle-content').toggle('400');
+ })
+});
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+# Useful doc: https://www.sphinx-doc.org/en/master/extdev/markupapi.html
+# Example: https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html
+
+import os
+from docutils.parsers.rst import Directive, directives
+from docutils import nodes
+from docutils.statemachine import StringList
+from sphinx.util.osutil import copyfile
+from sphinx.util import logging
+
+CSS_FILE = 'showfile.css'
+JS_FILE = 'showfile.js'
+
+class ShowFileDirective(Directive):
+ """
+ Show a file or propose it to download.
+ """
+
+ has_content = False
+ optional_arguments = 1
+ option_spec = {
+ 'language': directives.unchanged
+ }
+
+ def run(self):
+
+ filename = self.arguments[0]
+ language = "python"
+ if 'language' in self.options:
+ language = self.options['language']
+
+ logger = logging.getLogger(__name__)
+# logger.info('showfile {} in {}'.format(filename, language))
+
+ new_content = [
+ '.. toggle-header::',
+ ' :header: View {}'.format(filename),
+ '',
+ ' `Download {} <https://framagit.org/simgrid/simgrid/tree/{}>`_'.format(os.path.basename(filename), filename),
+ '',
+ ' .. literalinclude:: ../../{}'.format(filename),
+ ' :language: {}'.format(language),
+ ''
+ ]
+
+ for idx, line in enumerate(new_content):
+# logger.info('{} {}'.format(idx,line))
+ self.content.data.insert(idx, line)
+ self.content.items.insert(idx, (None, idx))
+
+ node = nodes.container()
+ self.state.nested_parse(self.content, self.content_offset, node)
+ return node.children
+
+class ExampleTabDirective(Directive):
+ """
+ A group-tab for a given language, in the presentation of the examples.
+ """
+ has_content = True
+ optional_arguments = 0
+ mandatory_argument = 0
+
+ def run(self):
+ self.assert_has_content()
+
+ filename = self.content[0].strip()
+ self.content.trim_start(1)
+
+ (language, langcode) = (None, None)
+ if filename[-3:] == '.py':
+ language = 'Python'
+ langcode = 'py'
+ elif filename[-4:] == '.cpp':
+ language = 'C++'
+ langcode = 'cpp'
+ elif filename[-4:] == '.xml':
+ language = 'XML'
+ langcode = 'xml'
+ else:
+ raise Exception("Unknown language '{}'. Please choose '.cpp', '.py' or '.xml'".format(language))
+
+ for idx, line in enumerate(self.content.data):
+ self.content.data[idx] = ' ' + line
+
+ for idx, line in enumerate([
+ '.. group-tab:: {}'.format(language),
+ ' ']):
+ self.content.data.insert(idx, line)
+ self.content.items.insert(idx, (None, idx))
+
+ for line in [
+ '',
+ ' .. showfile:: {}'.format(filename),
+ ' :language: {}'.format(langcode),
+ '']:
+ idx = len(self.content.data)
+ self.content.data.insert(idx, line)
+ self.content.items.insert(idx, (None, idx))
+
+# logger = logging.getLogger(__name__)
+# logger.info('------------------')
+# for line in self.content.data:
+# logger.info('{}'.format(line))
+
+ node = nodes.container()
+ self.state.nested_parse(self.content, self.content_offset, node)
+ return node.children
+
+class ToggleDirective(Directive):
+ has_content = True
+ option_spec = {
+ 'header': directives.unchanged,
+ 'show': directives.flag
+ }
+ optional_arguments = 1
+
+ def run(self):
+ node = nodes.container()
+ node['classes'].append('toggle-content')
+ if "show" not in self.options:
+ # This :show: thing is not working, and I fail to see why.
+ # Only the hidden-content class gets a call to hide() in the Javascript,
+ # and :show:n block# still get hidden when I load the page.
+ # No idea what's going on (Mt)
+ node['classes'].append('hidden-content')
+
+ par = nodes.container()
+ par['classes'].append('toggle-header')
+ if self.arguments and self.arguments[0]:
+ par['classes'].append(self.arguments[0])
+
+ self.state.nested_parse(StringList([self.options["header"]]), self.content_offset, par)
+ self.state.nested_parse(self.content, self.content_offset, node)
+
+ return [par, node]
+
+def add_assets(app):
+ app.add_stylesheet(CSS_FILE)
+ app.add_javascript(JS_FILE)
+
+
+def copy_assets(app, exception):
+ if app.builder.name not in ['html', 'readthedocs'] or exception:
+ return
+ logger = logging.getLogger(__name__)
+ logger.info('Copying showfile stylesheet/javascript... ', nonl=True)
+ dest = os.path.join(app.builder.outdir, '_static', CSS_FILE)
+ source = os.path.join(os.path.abspath(os.path.dirname(__file__)), CSS_FILE)
+ copyfile(source, dest)
+ dest = os.path.join(app.builder.outdir, '_static', JS_FILE)
+ source = os.path.join(os.path.abspath(os.path.dirname(__file__)), JS_FILE)
+ copyfile(source, dest)
+ logger.info('done')
+
+def setup(app):
+ app.add_directive('toggle-header', ToggleDirective)
+ app.add_directive('showfile', ShowFileDirective)
+ app.add_directive('example-tab', ExampleTabDirective)
+
+ app.connect('builder-inited', add_assets)
+ app.connect('build-finished', copy_assets)
+
.. doxygendefine:: MSG_init
.. doxygenfunction:: MSG_launch_application
.. doxygenfunction:: MSG_main
-.. doxygenfunction:: MSG_set_function
Process Management
==================
.. doxygenfunction:: MSG_process_sleep
.. doxygenfunction:: MSG_process_suspend
.. doxygenfunction:: MSG_process_unref
-.. doxygenfunction:: MSG_process_userdata_init
.. doxygenfunction:: MSG_process_yield
Host Management
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("ActorBox")
deprecation warnings for 4 releases (one year) before the removal of
the old symbols.
If you want an API that will never ever evolve in the future, you
-should use the deprecated MSG API instead.
+should use the :ref:`deprecated MSG API <MSG_doc>` instead.
Main Concepts
*************
The :ref:`simgrid::s4u::this_actor <API_s4u_this_actor>` namespace
provides many helper functions to simplify the code of actors.
-- **Global Classes**
+- **Simulation Elements**
- - :ref:`class s4u::Actor <API_s4u_Actor>`:
+ - :ref:`class Actor <API_s4u_Actor>`:
Active entities executing your application.
- - :ref:`class s4u::Engine <API_s4u_Engine>`
+ - :ref:`class Engine <API_s4u_Engine>`
Simulation engine (singleton).
- - :ref:`class s4u::Mailbox <API_s4u_Mailbox>`
- Communication rendez-vous.
+ - :ref:`class Mailbox <API_s4u_Mailbox>`
+ Communication rendez-vous, with which actors meet each other.
-- **Platform Elements**
+- **Resources**
- - :ref:`class s4u::Disk <API_s4u_Disk>`
+ - :ref:`class Disk <API_s4u_Disk>`
Resource on which actors can write and read data.
- - :ref:`class s4u::Host <API_s4u_Host>`:
+ - :ref:`class Host <API_s4u_Host>`:
Actor location, providing computational power.
- - :ref:`class s4u::Link <API_s4u_Link>`
+ - :ref:`class Link <API_s4u_Link>`
Interconnecting hosts.
- - :ref:`class s4u::NetZone <API_s4u_NetZone>`:
+ - :ref:`class NetZone <API_s4u_NetZone>`:
Sub-region of the platform, containing resources (Hosts, Links, etc).
- - :ref:`class s4u::VirtualMachine <API_s4u_VirtualMachine>`:
+ - :ref:`class VirtualMachine <API_s4u_VirtualMachine>`:
Execution containers that can be moved between Hosts.
-- **Activities** (:ref:`class s4u::Activity <API_s4u_Activity>`):
+- **Activities** (:ref:`class Activity <API_s4u_Activity>`):
The things that actors can do on resources
- - :ref:`class s4u::Comm <API_s4u_Comm>`
+ - :ref:`class Comm <API_s4u_Comm>`
Communication activity, started on Mailboxes and consuming links.
- - :ref:`class s4u::Exec <API_s4u_Exec>`
+ - :ref:`class Exec <API_s4u_Exec>`
Computation activity, started on Host and consuming CPU resources.
- - :ref:`class s4u::Io <API_s4u_Io>`
+ - :ref:`class Io <API_s4u_Io>`
I/O activity, started on and consumming disks.
-- **Synchronization Mechanisms**: Classical IPC that actors can use
+- **Synchronization Objects**: Classical IPC that actors can use
- - :ref:`class s4u::Barrier <API_s4u_Barrier>`
- - :ref:`class s4u::ConditionVariable <API_s4u_ConditionVariable>`
- - :ref:`class s4u::Mutex <API_s4u_Mutex>`
- - :ref:`class s4u::Semaphore <API_s4u_Semaphore>`
+ - :ref:`class Barrier <API_s4u_Barrier>`
+ - :ref:`class ConditionVariable <API_s4u_ConditionVariable>`
+ - :ref:`class Mutex <API_s4u_Mutex>`
+ - :ref:`class Semaphore <API_s4u_Semaphore>`
.. |API_s4u_Actors| replace:: **Actors**
-.. _API_s4u_Actors: #s4u-actor
+.. _API_s4u_Actors: #api-s4u-actor
.. |API_s4u_Activities| replace:: **Activities**
-.. _API_s4u_Activities: #s4u-activity
+.. _API_s4u_Activities: #api-s4u-activity
.. |API_s4u_Hosts| replace:: **Hosts**
-.. _API_s4u_Hosts: #s4u-host
+.. _API_s4u_Hosts: #api-s4u-host
.. |API_s4u_Links| replace:: **Links**
-.. _API_s4u_Links: #s4u-link
+.. _API_s4u_Links: #api-s4u-link
.. |API_s4u_Disks| replace:: **Disks**
-.. _API_s4u_Disks: #s4u-disk
+.. _API_s4u_Disks: #api-s4u-disk
.. |API_s4u_VirtualMachine| replace:: **VirtualMachines**
.. |API_s4u_Mutex| replace:: **Mutex**
-.. THE EXAMPLES
-
-.. include:: ../../examples/s4u/README.rst
+.. _s4u_Activities:
Activities
**********
Activities represent the actions that consume a resource, such as a
-:ref:`s4u::Comm <API_s4u_Comm>` that consumes the *transmitting power* of
-:ref:`s4u::Link <API_s4u_Link>` resources.
+:ref:`Comm <API_s4u_Comm>` that consumes the *transmitting power* of
+:ref:`Link <API_s4u_Link>` resources, or an :ref:`Exec <API_s4u_Exec>`
+that consumes the *computing power* of :ref:`Host <API_s4u_Host>` resources.
+See also the :ref:`full API <API_s4u_Activity>` below.
=======================
Asynchronous Activities
mailbox or a link. You can still destroy an host (but probably
shouldn't), using :cpp:func:`simgrid::s4u::Host::destroy`.
-C++ API Reference
-*****************
+.. THE EXAMPLES
+
+.. include:: ../../examples/README.rst
+
+API Reference
+*************
.. _API_s4u_this_actor:
-=========================
-namespace s4u::this_actor
-=========================
+==================================
+Interacting with the current actor
+==================================
+
+Static methods working on the current actor (see :ref:`API_s4u_Actor`).
.. doxygennamespace:: simgrid::s4u::this_actor
+
.. _API_s4u_Activity:
-=============
-s4u::Activity
-=============
+==============
+class Activity
+==============
+
+.. autodoxyclass:: simgrid::s4u::Activity
+
+ **Known subclasses:**
+ :ref:`Communications <API_s4u_Comm>` (started on Mailboxes and consuming links),
+ :ref:`Executions <API_s4u_Exec>` (started on Host and consuming CPU resources)
+ :ref:`I/O <API_s4u_Io>` (started on and consumming disks).
+ See also the :ref:`section on activities <s4u_Activities>` above.
+
+Querying info about activities
+------------------------------
+
+ .. autodoxymethod:: simgrid::s4u::Activity::get_remaining()
+ .. autodoxymethod:: simgrid::s4u::Activity::get_state()
+ .. autodoxymethod:: simgrid::s4u::Activity::set_remaining(double remains)
+ .. autodoxymethod:: simgrid::s4u::Activity::get_impl
+
+Activities lifecycle
+--------------------
+
+ .. autodoxymethod:: simgrid::s4u::Activity::start
+ .. autodoxymethod:: simgrid::s4u::Activity::cancel
+ .. autodoxymethod:: simgrid::s4u::Activity::test
+ .. autodoxymethod:: simgrid::s4u::Activity::wait
+ .. autodoxymethod:: simgrid::s4u::Activity::wait_for
+ .. autodoxymethod:: simgrid::s4u::Activity::wait_until(double time_limit)
-.. doxygenclass:: simgrid::s4u::Activity
- :members:
- :protected-members:
- :undoc-members:
.. _API_s4u_Actor:
-==========
-s4u::Actor
-==========
+===========
+class Actor
+===========
.. doxygentypedef:: ActorPtr
.. doxygentypedef:: aid_t
-.. doxygenclass:: simgrid::s4u::Actor
- :members:
- :protected-members:
- :undoc-members:
+.. autodoxyclass:: simgrid::s4u::Actor
+
+Creating actors
+---------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, const std::function< void()> &code)
+ .. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, F code)
+ .. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, F code, Args... args)
+ .. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, const std::string &function, std::vector< std::string > args)
+
+ .. autodoxymethod:: simgrid::s4u::Actor::init(const std::string &name, s4u::Host *host)
+ .. autodoxymethod:: simgrid::s4u::Actor::start(const std::function< void()> &code)
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Actor.create
+
+Searching specific actors
+-------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Actor::by_pid(aid_t pid)
+ .. autodoxymethod:: simgrid::s4u::Actor::self()
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Actor.by_pid
+ .. automethod:: simgrid.Actor.self
+
+Querying info about actors
+--------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Actor::get_cname
+ .. autodoxymethod:: simgrid::s4u::Actor::get_name
+ .. autodoxymethod:: simgrid::s4u::Actor::get_pid
+ .. autodoxymethod:: simgrid::s4u::Actor::get_ppid
+ .. autodoxymethod:: simgrid::s4u::Actor::get_properties() const
+ .. autodoxymethod:: simgrid::s4u::Actor::get_property(const std::string &key) const
+ .. autodoxymethod:: simgrid::s4u::Actor::set_property(const std::string &key, const std::string &value)
+
+ .. autodoxymethod:: simgrid::s4u::Actor::get_host
+ .. autodoxymethod:: simgrid::s4u::Actor::set_host
+
+ .. autodoxymethod:: simgrid::s4u::Actor::get_refcount()
+ .. autodoxymethod:: simgrid::s4u::Actor::get_impl
+
+ .. group-tab:: Python
+
+ .. autoattribute:: simgrid.Actor.name
+ .. autoattribute:: simgrid.Actor.host
+ .. autoattribute:: simgrid.Actor.pid
+ .. autoattribute:: simgrid.Actor.ppid
+
+ .. automethod:: simgrid.Actor.migrate
+
+Suspending and resuming actors
+------------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Actor::suspend()
+ .. autodoxymethod:: simgrid::s4u::Actor::resume()
+ .. autodoxymethod:: simgrid::s4u::Actor::is_suspended()
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Actor.resume
+ .. automethod:: simgrid.Actor.suspend
+ .. automethod:: simgrid.Actor.is_suspended
+
+Specifying when actors should terminate
+---------------------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Actor::kill()
+ .. autodoxymethod:: simgrid::s4u::Actor::kill_all()
+ .. autodoxymethod:: simgrid::s4u::Actor::set_kill_time(double time)
+ .. autodoxymethod:: simgrid::s4u::Actor::get_kill_time()
+
+ .. autodoxymethod:: simgrid::s4u::Actor::restart()
+ .. autodoxymethod:: simgrid::s4u::Actor::daemonize()
+ .. autodoxymethod:: simgrid::s4u::Actor::is_daemon
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Actor.kill
+ .. automethod:: simgrid.Actor.kill_all
+
+ .. automethod:: simgrid.Actor.daemonize
+ .. automethod:: simgrid.Actor.is_daemon
+
+Reacting to the end of actors
+-----------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Actor::on_exit
+ .. autodoxymethod:: simgrid::s4u::Actor::join()
+ .. autodoxymethod:: simgrid::s4u::Actor::join(double timeout)
+ .. autodoxymethod:: simgrid::s4u::Actor::set_auto_restart(bool autorestart)
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Actor.join
+
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxyvar:: simgrid::s4u::Actor::on_creation
+ .. autodoxyvar:: simgrid::s4u::Actor::on_suspend
+ .. autodoxyvar:: simgrid::s4u::Actor::on_resume
+ .. autodoxyvar:: simgrid::s4u::Actor::on_sleep
+ .. autodoxyvar:: simgrid::s4u::Actor::on_wake_up
+ .. autodoxyvar:: simgrid::s4u::Actor::on_migration_start
+ .. autodoxyvar:: simgrid::s4u::Actor::on_migration_end
+ .. autodoxyvar:: simgrid::s4u::Actor::on_termination
+ .. autodoxyvar:: simgrid::s4u::Actor::on_destruction
.. _API_s4u_Barrier:
-============
-s4u::Barrier
-============
+=============
+class Barrier
+=============
.. doxygentypedef:: BarrierPtr
-.. doxygenclass:: simgrid::s4u::Barrier
- :members:
- :protected-members:
- :undoc-members:
+.. autodoxyclass:: simgrid::s4u::Barrier
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Barrier::Barrier(unsigned int count)
+ .. autodoxymethod:: simgrid::s4u::Barrier::create(unsigned int expected_actors)
+ .. autodoxymethod:: simgrid::s4u::Barrier::wait()
+
.. _API_s4u_Comm:
:protected-members:
:undoc-members:
+C API Reference
+***************
+
+==============
+Main functions
+==============
+
+.. doxygenfunction:: simgrid_init
+.. doxygenfunction:: simgrid_get_clock
+.. doxygenfunction:: simgrid_load_deployment
+.. doxygenfunction:: simgrid_load_platform
+.. doxygenfunction:: simgrid_register_default
+.. doxygenfunction:: simgrid_register_function
+.. doxygenfunction:: simgrid_run
+
+==================
+Condition Variable
+==================
+
+See also the :ref:`C++ API <API_s4u_ConditionVariable>`.
+
+.. doxygenfunction:: sg_cond_init
+.. doxygenfunction:: sg_cond_notify_all
+.. doxygenfunction:: sg_cond_notify_one
+.. doxygenfunction:: sg_cond_wait
+.. doxygenfunction:: sg_cond_wait_for
Python API Reference
********************
-The Python API is generated with pybind11. It closely mimicks the C++
+The Python API is automatically generated with pybind11. It closely mimicks the C++
API, to which you should refer for more information.
==========
.. autoclass:: simgrid.Mailbox
:members:
+
+.. |hr| raw:: html
+
+ <hr />
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("SMPIBox")
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("ApplicationBox")
extensions = [
'sphinx.ext.todo',
'breathe',
- # 'exhale',
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
- # 'sphinx.ext.napoleon',
'sphinx.ext.autosummary',
- 'hidden_code_block',
+ 'sphinx_tabs.tabs',
'javasphinx',
+ 'showfile',
+ 'autodoxy',
]
todo_include_todos = True
+# Setup the breath extension
breathe_projects = {'simgrid': '../build/xml'}
breathe_default_project = "simgrid"
-# Setup the exhale extension
-
-exhale_args = {
- # These arguments are required
- "containmentFolder": "./api",
- "rootFileName": "library_root.rst",
- "rootFileTitle": "SimGrid Full API",
- "doxygenStripFromPath": "..",
- # Suggested optional arguments
- "createTreeView": True,
- "exhaleExecutesDoxygen": False,
- # "exhaleUseDoxyfile": True,
-}
-
+# Setup the autodoxy extension
+doxygen_xml = os.path.join(os.path.dirname(__file__), "..", "build", "xml")
# For cross-ref generation
primary_domain = 'cpp'
-
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
   ns-3 as a SimGrid model <ns3.rst>
SimGrid Plugins <Plugins.rst>
Simulation Outcomes <outcomes.rst>
- Use Cases and Howto <howto.rst>
The SimGrid Community <community.rst>
Frequently Asked Questions <faq.rst>
-.. _platform:
-
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("PlatformBox")
<br/>
<br/>
+.. _platform:
+
Describing your Simulated Platform
##################################
.. raw:: html
- <object id="TOC" data="graphical-toc.svg" width="100%" type="image/svg+xml"></object>
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
<script>
window.onload=function() { // Wait for the SVG to be loaded before changing it
var elem=document.querySelector("#TOC").contentDocument.getElementById("PlatformBox")
--- /dev/null
+.. S4U (Simgrid for you) is the modern interface of SimGrid, which new project should use.
+..
+.. This file follows the ReStructured syntax to be included in the
+.. documentation, but it should remain readable directly.
+
+
+Examples
+********
+
+SimGrid comes with an extensive set of examples, documented on this
+page. Most of them only demonstrate one single feature, with some
+larger examplars listed below.
+
+The C++ examples can be found under examples/s4u while python examples
+are in examples/python. Each such directory contains the source code (also listed
+from this page), and the so-called tesh file containing how to call
+the binary obtained by compiling this example and also the expected
+output. Tesh files are used to turn each of our examples into an
+integration test. Some examples also contain other files, on need.
+
+A good way to bootstrap your own project is to copy and combine some
+of the provided examples to constitute the skeleton of what you plan
+to simulate.
+
+.. _s4u_ex_actors:
+
+===========================
+Actors: the Active Entities
+===========================
+
+Starting and Stoping Actors
+---------------------------
+
+ - **Creating actors:**
+ Most actors are started from the deployment XML file, because this
+ is a :ref:`better scientific habbit <howto_science>`, but you can
+ also create them directly from your code.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-create/s4u-actor-create.cpp
+
+ You create actors either:
+
+ - Directly with :cpp:func:`simgrid::s4u::Actor::create`
+ - From XML with :cpp:func:`simgrid::s4u::Engine::register_actor` (if your actor is a class)
+ or :cpp:func:`simgrid::s4u::Engine::register_function` (if your actor is a function)
+ and then :cpp:func:`simgrid::s4u::Engine::load_deployment`
+
+ .. example-tab:: examples/python/actor-create/actor-create.py
+
+ You create actors either:
+
+ - Directly with :py:func:`simgrid.Actor.create()`
+ - From XML with :py:func:`simgrid.Engine.register_actor()` and then :py:func:`simgrid.Engine.load_deployment()`
+
+ .. example-tab:: examples/python/actor-create/actor-create_d.xml
+
+ The following file is used in both C++ and Python.
+
+ - **React to the end of actors:** You can attach callbacks to the end of
+ actors. There is several ways of doing so, depending on whether you want to
+ attach your callback to a given actor and on how you define the end of a
+ given actor. User code probably want to react to the termination of an actor
+ while some plugins want to react to the destruction (memory collection) of
+ actors.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-exiting/s4u-actor-exiting.cpp
+
+ This example shows how to attach a callback to:
+
+ - the end of a specific actor: :cpp:func:`simgrid::s4u::this_actor::on_exit()`
+ - the end of any actor: :cpp:member:`simgrid::s4u::Actor::on_termination()`
+ - the destruction of any actor: :cpp:member:`simgrid::s4u::Actor::on_destruction()`
+
+ - **Kill actors:**
+ Actors can forcefully stop other actors.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-kill/s4u-actor-kill.cpp
+
+ See also :cpp:func:`void simgrid::s4u::Actor::kill(void)`, :cpp:func:`void simgrid::s4u::Actor::kill_all()`,
+ :cpp:func:`simgrid::s4u::this_actor::exit`.
+
+ .. example-tab:: examples/python/actor-kill/actor-kill.py
+
+ See also :py:func:`simgrid.Actor.kill`, :py:func:`simgrid.Actor.kill_all`, :py:func:`simgrid.this_actor.exit`.
+
+ - **Controling the actor life cycle from the XML:**
+ You can specify a start time and a kill time in the deployment file.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp
+
+ This file is not really interesting: the important matter is in the XML file.
+
+ .. example-tab:: examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml
+
+ This demonstrates the ``start_time`` and ``kill_time`` attribute of the :ref:`pf_tag_actor` tag.
+
+ - **Daemonize actors:**
+ Some actors may be intended to simulate daemons that run in background. This example show how to transform a regular
+ actor into a daemon that will be automatically killed once the simulation is over.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-daemon/s4u-actor-daemon.cpp
+
+ See also :cpp:func:`simgrid::s4u::Actor::daemonize()` and :cpp:func:`simgrid::s4u::Actor::is_daemon()`.
+
+ .. example-tab:: examples/python/actor-daemon/actor-daemon.py
+
+ See also :py:func:`simgrid.Actor.daemonize()` and :py:func:`simgrid.Actor.is_daemon()`.
+
+Inter-Actors Interactions
+-------------------------
+
+See also the examples on :ref:`inter-actors communications
+<s4u_ex_communication>` and the ones on :ref:`classical
+synchronization objects <s4u_ex_IPC>`.
+
+ - **Suspend and Resume actors:**
+ Actors can be suspended and resumed during their executions.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-suspend/s4u-actor-suspend.cpp
+
+ See also :cpp:func:`simgrid::s4u::this_actor::suspend()`,
+ :cpp:func:`simgrid::s4u::Actor::suspend()`, :cpp:func:`simgrid::s4u::Actor::resume()` and
+ :cpp:func:`simgrid::s4u::Actor::is_suspended()`.
+
+ .. example-tab:: examples/python/actor-suspend/actor-suspend.py
+
+ See also :py:func:`simgrid.this_actor.suspend()`,
+ :py:func:`simgrid.Actor.suspend()`, :py:func:`simgrid.Actor.resume()` and
+ :py:func:`simgrid.Actor.is_suspended()`.
+
+ - **Migrating Actors:**
+ Actors can move or be moved from a host to another very easily.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-migrate/s4u-actor-migrate.cpp
+
+ See also :cpp:func:`simgrid::s4u::this_actor::migrate()` and :cpp:func:`simgrid::s4u::Actor::migrate()`.
+
+ .. example-tab:: examples/python/actor-migrate/actor-migrate.py
+
+ See also :py:func:`simgrid.this_actor.migrate()` and :py:func:`simgrid.Actor.migrate()`.
+
+ - **Waiting for the termination of an actor:** (joining on it)
+ You can block the current actor until the end of another actor.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-join/s4u-actor-join.cpp
+
+ See also :cpp:func:`simgrid::s4u::Actor::join()`.
+
+ .. example-tab:: examples/python/actor-join/actor-join.py
+
+ See also :py:func:`simgrid.Actor.join()`.
+
+ - **Yielding to other actors**.
+ The ```yield()``` function interrupts the execution of the current
+ actor, leaving a chance to the other actors that are ready to run
+ at this timestamp.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/actor-yield/s4u-actor-yield.cpp
+
+ See also :cpp:func:`simgrid::s4u::this_actor::yield()`.
+
+ .. example-tab:: examples/python/actor-yield/actor-yield.py
+
+ See also :py:func:`simgrid.this_actor.yield_()`.
+
+Traces Replay as a Workload
+---------------------------
+
+This section details how to run trace-driven simulations. It is very
+handy when you want to test an algorithm or protocol that only react
+to external events. For example, many P2P protocols react to user
+requests, but do nothing if there is no such event.
+
+In such situations, you should write your protocol in C++, and separate
+the workload that you want to play onto your protocol in a separate
+text file. Declare a function handling each type of the events in your
+trace, register them using :cpp:func:`xbt_replay_action_register()` in
+your main, and then run the simulation.
+
+Then, you can either have one trace file containing all your events,
+or a file per simulated process: the former may be easier to work
+with, but the second is more efficient on very large traces. Check
+also the tesh files in the example directories for details.
+
+ - **Communication replay:**
+ Presents a set of event handlers reproducing classical communication
+ primitives (asynchronous send/receive at the moment).
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/replay-comm/s4u-replay-comm.cpp
+
+ - **I/O replay:**
+ Presents a set of event handlers reproducing classical I/O
+ primitives (open, read, close).
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/replay-io/s4u-replay-io.cpp
+
+==========================
+Activities: what Actors do
+==========================
+
+.. _s4u_ex_communication:
+
+Communications on the Network
+-----------------------------
+
+ - **Basic asynchronous communications:**
+ Illustrates how to have non-blocking communications, that are
+ communications running in the background leaving the process free
+ to do something else during their completion.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/async-wait/s4u-async-wait.cpp
+
+ See also :cpp:func:`simgrid::s4u::Mailbox::put_async()` and :cpp:func:`simgrid::s4u::Comm::wait()`.
+
+ .. example-tab:: examples/python/async-wait/async-wait.py
+
+ See also :py:func:`simgrid.Mailbox.put_async()` and :py:func:`simgrid.Comm.wait()`.
+
+ - **Waiting for all communications in a set:**
+ The ``wait_all()`` function is useful when you want to block until
+ all activities in a given set have completed.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/async-waitall/s4u-async-waitall.cpp
+
+ See also :cpp:func:`simgrid::s4u::Comm::wait_all()`.
+
+ .. example-tab:: examples/python/async-waitall/async-waitall.py
+
+ See also :py:func:`simgrid.Comm.wait_all()`.
+
+ - **Waiting for the first completed communication in a set:**
+ The ``wait_any()`` function is useful
+ when you want to block until one activity of the set completes, no
+ matter which terminates first.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/async-waitany/s4u-async-waitany.cpp
+
+ See also :cpp:func:`simgrid::s4u::Comm::wait_any()`.
+
+ .. example-tab:: examples/python/async-waitany/async-waitany.py
+
+ See also :py:func:`simgrid.Comm.wait_any()`.
+
+.. _s4u_ex_execution:
+
+Executions on the CPU
+---------------------
+
+ - **Basic execution:**
+ The computations done in your program are not reported to the
+ simulated world, unless you explicitly request the simulator to pause
+ the actor until a given amount of flops gets computed on its simulated
+ host. Some executions can be given an higher priority so that they
+ get more resources.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/exec-basic/s4u-exec-basic.cpp
+
+ See also :cpp:func:`void simgrid::s4u::this_actor::execute(double)`
+ and :cpp:func:`void simgrid::s4u::this_actor::execute(double, double)`.
+
+ .. example-tab:: examples/python/exec-basic/exec-basic.py
+
+ See also :py:func:`simgrid.this_actor.execute()`.
+
+ - **Asynchronous execution:**
+ You can start asynchronous executions, just like you would fire
+ background threads.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/exec-async/s4u-exec-async.cpp
+
+ See also :cpp:func:`simgrid::s4u::this_actor::exec_init()`,
+ :cpp:func:`simgrid::s4u::Activity::start()`,
+ :cpp:func:`simgrid::s4u::Activity::wait()`,
+ :cpp:func:`simgrid::s4u::Activity::get_remaining()`,
+ :cpp:func:`simgrid::s4u::Exec::get_remaining_ratio()`,
+ :cpp:func:`simgrid::s4u::this_actor::exec_async()` and
+ :cpp:func:`simgrid::s4u::Activity::cancel()`.
+
+ .. example-tab:: examples/python/exec-async/exec-async.py
+
+ See also :py:func:`simgrid.this_actor::exec_init()`,
+ :py:func:`simgrid.Activity::start()`,
+ :py:func:`simgrid.Activity.wait()`,
+ :py:func:`simgrid.Activity.get_remaining()`,
+ :py:func:`simgrid.Exec.get_remaining_ratio()`,
+ :py:func:`simgrid.this_actor.exec_async()` and
+ :py:func:`simgrid.Activity.cancel()`.
+
+ - **Remote execution:**
+ You can start executions on remote hosts, or even change the host
+ on which they occur during their execution.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/exec-remote/s4u-exec-remote.cpp
+
+ See also :cpp:func:`simgrid::s4u::Exec::set_host()`.
+
+ .. example-tab:: examples/python/exec-remote/exec-remote.py
+
+ See also :py:func:`simgrid.Exec.set_host()`.
+
+ - **Parallel executions:**
+ These objects are convenient abstractions of parallel
+ computational kernels that span over several machines, such as a
+ PDGEM and the other ScaLAPACK routines. Note that this only works
+ with the "ptask_L07" host model (``--cfg=host/model:ptask_L07``).
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/exec-ptask/s4u-exec-ptask.cpp
+
+ See also :cpp:func:`simgrid::s4u::this_actor::parallel_execute()`.
+
+ - **Using Pstates on a host:**
+ This example shows how define a set of pstates in the XML. The current pstate
+ of an host can then be accessed and changed from the program.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp
+
+ See also :cpp:func:`simgrid::s4u::Host::get_pstate_speed` and :cpp:func:`simgrid::s4u::Host::set_pstate`.
+
+ .. example-tab:: examples/python/exec-dvfs/exec-dvfs.py
+
+ See also :py:func:`Host.get_pstate_speed` and :py:func:`Host.set_pstate`.
+
+ .. example-tab:: examples/platforms/energy_platform.xml
+
+I/O on Disks and Files
+----------------------
+
+SimGrid provides two levels of abstraction to interact with the
+simulated disks. At the simplest level, you simply create read and
+write actions on the disk resources.
+
+ - **Access to raw disk devices:**
+ This example illustrates how to simply read and write data on a
+ simulated disk resource.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
+
+ .. example-tab:: examples/platforms/hosts_with_disks.xml
+
+ This shows how to declare disks in XML.
+
+The FileSystem plugin provides a more detailed view, with the
+classical operations over files: open, move, unlink, and of course
+read and write. The file and disk sizes are also dealt with and can
+result in short reads and short write, as in reality.
+
+ - **File Management:**
+ This example illustrates the use of operations on files
+ (read, write, seek, tell, unlink, etc).
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/io-file-system/s4u-io-file-system.cpp
+
+ - **Remote I/O:**
+ I/O operations on files can also be done in a remote fashion,
+ i.e. when the accessed disk is not mounted on the caller's host.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/io-file-remote/s4u-io-file-remote.cpp
+
+.. _s4u_ex_IPC:
+
+Classical synchronization objects
+---------------------------------
+
+ - **Mutex:**
+ Shows how to use simgrid::s4u::Mutex synchronization objects.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp
+
+ - **Barrier:**
+ Shows how to use simgrid::s4u::Barrier synchronization objects.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp
+
+ - **Semaphore:**
+ Shows how to use simgrid::s4u::Semaphore synchronization objects.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/synchro-semaphore/s4u-synchro-semaphore.cpp
+
+=============================
+Interacting with the Platform
+=============================
+
+ - **User-defined properties:**
+ You can attach arbitrary information to most platform elements from
+ the XML file, and then interact with these values from your
+ program. Note that the changes are not written permanently on disk,
+ in the XML file nor anywhere else. They only last until the end of
+ your simulation.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/platform-properties/s4u-platform-properties.cpp
+
+ - :cpp:func:`simgrid::s4u::Actor::get_property()` and :cpp:func:`simgrid::s4u::Actor::set_property()`
+ - :cpp:func:`simgrid::s4u::Host::get_property()` and :cpp:func:`simgrid::s4u::Host::set_property()`
+ - :cpp:func:`simgrid::s4u::Link::get_property()` and :cpp:func:`simgrid::s4u::Link::set_property()`
+ - :cpp:func:`simgrid::s4u::NetZone::get_property()` and :cpp:func:`simgrid::s4u::NetZone::set_property()`
+
+ .. group-tab:: XML
+
+ **Deployment file:**
+
+ .. showfile:: examples/s4u/platform-properties/s4u-platform-properties_d.xml
+ :language: xml
+
+ |br|
+ **Platform file:**
+
+ .. showfile:: examples/platforms/prop.xml
+ :language: xml
+
+ - **Retrieving the netzones matching a given criteria:**
+ Shows how to filter the cluster netzones.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/routing-get-clusters/s4u-routing-get-clusters.cpp
+
+ - **Retrieving the list of hosts matching a given criteria:**
+ Shows how to filter the actors that match a given criteria.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/engine-filtering/s4u-engine-filtering.cpp
+
+ - **Specifying state profiles:** shows how to specify when the
+ resources must be turned off and on again, and how to react to such
+ failures in your code. See also :ref:`howto_churn`.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/platform-failures/s4u-platform-failures.cpp
+
+ .. group-tab:: XML
+
+ .. showfile:: examples/platforms/small_platform_failures.xml
+ :language: xml
+
+ .. showfile:: examples/platforms/profiles/jupiter_state.profile
+
+ .. showfile:: examples/platforms/profiles/bourassa_state.profile
+
+ .. showfile:: examples/platforms/profiles/fafard_state.profile
+
+ - **Specifying speed profiles:** shows how to specify an external
+ load to resources, variating their peak speed over time.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/platform-profile/s4u-platform-profile.cpp
+
+ .. group-tab:: XML
+
+ .. showfile:: examples/platforms/small_platform_profile.xml
+ :language: xml
+
+ .. showfile:: examples/platforms/profiles/jupiter_speed.profile
+
+ .. showfile:: examples/platforms/profiles/link1_bandwidth.profile
+
+ .. showfile:: examples/platforms/profiles/link1_latency.profile
+
+=================
+Energy Simulation
+=================
+
+ - **Describing the energy profiles in the platform:**
+ This platform file contains the energy profile of each links and
+ hosts, which is necessary to get energy consumption predictions.
+ As usual, you should not trust our example, and you should strive
+ to double-check that your instantiation matches your target platform.
+
+ .. tabs::
+
+ .. example-tab:: examples/platforms/energy_platform.xml
+
+ - **Consumption due to the CPU:**
+ This example shows how to retrieve the amount of energy consumed
+ by the CPU during computations, and the impact of the pstate.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/energy-exec/s4u-energy-exec.cpp
+
+ - **Consumption due to the network:**
+ This example shows how to retrieve and display the energy consumed
+ by the network during communications.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/energy-link/s4u-energy-link.cpp
+
+ - **Modeling the shutdown and boot of hosts:**
+ Simple example of model of model for the energy consumption during
+ the host boot and shutdown periods.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/energy-boot/platform_boot.xml
+
+ .. example-tab:: examples/s4u/energy-boot/s4u-energy-boot.cpp
+
+=======================
+Tracing and Visualizing
+=======================
+
+Tracing can be activated by various configuration options which
+are illustrated in these example. See also the
+:ref:`full list of options related to tracing <tracing_tracing_options>`.
+
+It is interesting to run the process-create example with the following
+options to see the task executions:
+
+ - **Platform Tracing:**
+ This program is a toy example just loading the platform, so that
+ you can play with the platform visualization. Recommanded options:
+ ``--cfg=tracing:yes --cfg=tracing/categorized:yes``
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/trace-platform/s4u-trace-platform.cpp
+
+========================
+Larger SimGrid Examplars
+========================
+
+This section contains application examples that are somewhat larger
+than the previous examples.
+
+ - **Ping Pong:**
+ This simple example just sends one message back and forth.
+ The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to
+ the simulators (as detailed in Section :ref:`options`).
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/app-pingpong/s4u-app-pingpong.cpp
+
+ - **Token ring:**
+ Shows how to implement a classical communication pattern, where a
+ token is exchanged along a ring to reach every participant.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/app-token-ring/s4u-app-token-ring.cpp
+
+ - **Master Workers:**
+ Another good old example, where one Master process has a bunch of task to dispatch to a set of several Worker
+ processes.
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ This example comes in two equivalent variants, one where the actors
+ are specified as simple functions (which is easier to understand for
+ newcomers) and one where the actors are specified as classes (which is
+ more powerful for the users wanting to build their own projects upon
+ the example).
+
+ .. showfile:: examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp
+ :language: cpp
+
+ .. showfile:: examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp
+ :language: cpp
+
+Data diffusion
+--------------
+
+ - **Bit Torrent:**
+ Classical protocol for Peer-to-Peer data diffusion.
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. showfile:: examples/s4u/app-bittorrent/s4u-bittorrent.cpp
+ :language: cpp
+
+ .. showfile:: examples/s4u/app-bittorrent/s4u-peer.cpp
+ :language: cpp
+
+ .. showfile:: examples/s4u/app-bittorrent/s4u-tracker.cpp
+ :language: cpp
+
+ - **Chained Send:**
+ Data broadcast over a ring of processes.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/app-chainsend/s4u-app-chainsend.cpp
+
+Distributed Hash Tables (DHT)
+-----------------------------
+
+ - **Chord Protocol**
+ One of the most famous DHT protocol.
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. showfile:: examples/s4u/dht-chord/s4u-dht-chord.cpp
+ :language: cpp
+
+ .. showfile:: examples/s4u/dht-chord/s4u-dht-chord-node.cpp
+ :language: cpp
+
+ - **Kademlia**
+ Another well-known DHT protocol.
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. showfile:: examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp
+ :language: cpp
+
+ .. showfile:: examples/s4u/dht-kademlia/routing_table.cpp
+ :language: cpp
+
+ .. showfile:: examples/s4u/dht-kademlia/answer.cpp
+ :language: cpp
+
+ .. showfile:: examples/s4u/dht-kademlia/node.cpp
+ :language: cpp
+
+.. _s4u_ex_clouds:
+
+Simulating Clouds
+-----------------
+
+ - **Cloud basics**
+ This example starts some computations both on PMs and VMs, and
+ migrates some VMs around.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/cloud-simple/s4u-cloud-simple.cpp
+
+ - **Migrating VMs**
+ This example shows how to migrate VMs between PMs.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/cloud-migration/s4u-cloud-migration.cpp
+
+=======================
+Model-Checking Examples
+=======================
+
+The model-checker can be used to exhaustively search for issues in the
+tested application. It must be activated at compile time, but this
+mode is rather experimental in SimGrid (as of v3.22). You should not
+enable it unless you really want to formally verify your applications:
+SimGrid is slower and maybe less robust when MC is enabled.
+
+ - **Failing assert**
+ In this example, two actors send some data to a central server,
+ which asserts that the messages are always received in the same order.
+ This is obviously wrong, and the model-checker correctly finds a
+ counter-example to that assertion.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp
+
+.. |br| raw:: html
+
+ <br />
+
+.. |cpp| image:: /img/lang_cpp.png
+ :align: middle
+ :width: 12
+
+.. |py| image:: /img/lang_python.png
+ :align: middle
+ :width: 12
sys.stdout.write("<?xml version='1.0'?>\n"
"<!DOCTYPE platform SYSTEM \"https://simgrid.org/simgrid.dtd\">\n"
"<platform version=\"3\">\n"
- " <process host=\"c-0.me\" function=\"bittorrent.Tracker\"><argument value=\"%d\"/></process>\n" % end_date)
+ " <process host=\"c-0.me\" function=\"bittorrent.Tracker\"><argument value=\"%d\"/></process>\n" %
+ end_date)
for i in range(1, nb_nodes):
ok = False
while not ok:
my_id = random.randint(0, max_id)
- ok = not my_id in all_ids
+ ok = my_id not in all_ids
start_date = i * 10
- line = " <process host=\"c-%d.me\" function=\"bittorrent.Peer\"><argument value=\"%d\" /><argument value=\"%d\" />" % (
- i, my_id, end_date)
+ line = " <process host=\"c-%d.me\" function=\"bittorrent.Peer\"><argument value=\"%d\" />" \
+ "<argument value=\"%d\" />" % (i, my_id, end_date)
if random.randint(0, 100) < seed_percentage:
line += "<argument value=\"1\" />"
line += "</process>\n"
ok = False
while not ok:
my_id = random.randint(0, max_id)
- ok = not my_id in all_ids
+ ok = my_id not in all_ids
known_id = all_ids[random.randint(0, len(all_ids) - 1)]
start_date = i * 10
line = " <process host=\"node-%d.simgrid.org\" function=\"node\">\n <argument value=\"%s\"/>"\
#include "task.h"
#include "answer.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_task, "Messages specific for this msg example");
/** @brief Creates a new "find node" task
* @param sender_id the id of the node who sends the task
sys.stdout.write("<?xml version='1.0'?>\n"
"<!DOCTYPE platform SYSTEM \"https://simgrid.org/simgrid.dtd\">\n"
"<platform version=\"3\">\n"
- " <process host=\"node-0.simgrid.org\" function=\"node\"><argument value=\"42\"/><argument value=\"%d\"/></process>\n" % end_date)
+ " <process host=\"node-0.simgrid.org\" function=\"node\"><argument value=\"42\"/>"
+ "<argument value=\"%d\"/></process>\n" % end_date)
for i in range(1, nb_nodes):
ok = False
while not ok:
my_id = random.randint(0, max_id)
- ok = not my_id in all_ids
+ ok = my_id not in all_ids
known_id = all_ids[random.randint(0, len(all_ids) - 1)]
start_date = i * 10
- line = " <process host=\"node-%d.simgrid.org\" function=\"node\"><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /></process>\n" % (
- i, my_id, known_id, start_date, end_date)
+ line = " <process host=\"node-%d.simgrid.org\" function=\"node\"><argument value=\"%d\" />" \
+ "<argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /></process>\n" % (
+ i, my_id, known_id, start_date, end_date)
sys.stdout.write(line)
all_ids.append(my_id)
static void task_cleanup_handler(void* task)
{
- if (task)
- MSG_task_destroy(task);
+ MSG_task_destroy(task);
}
static int master(int argc, char *argv[])
# application and the settings to test it. This is a better scientific methodology. Actually, starting an actor with
# Actor.create() is mostly useful to start an actor from another actor.
+from simgrid import Actor, Engine, Host, Mailbox, this_actor
import sys
-from simgrid import *
def receiver(mailbox_name):
# This program is free software you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
-from simgrid import *
+from simgrid import Actor, Engine, Host, this_actor
import sys
# This program is free software you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
-from simgrid import *
+from simgrid import Actor, Engine, Host, this_actor
import sys
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
-from simgrid import *
+from simgrid import Actor, Engine, Host, this_actor
import sys
# This Python file acts as the foil to the corresponding XML file, where the
# action takes place: Actors are started and stopped at predefined time
-from simgrid import *
+from simgrid import Engine, this_actor
import sys
# Note that worker() takes an uncommon set of parameters,
# and that this is perfectly accepted by create().
-from simgrid import *
+from simgrid import Actor, Engine, Host, this_actor
import sys
this_actor.info("Let's move to {:s} to execute {:.2f} Mflops (5sec on {:s} and 5sec on {:s})".format(
first_host.name, flop_amount / 1e6, first_host.name, second_host.name))
- this_actor.migrate(first_host)
+ this_actor.set_host(first_host)
this_actor.execute(flop_amount)
this_actor.info("I wake up on {:s}. Let's suspend a bit".format(
this_actor.info(
"After 5 seconds, move the process to {:s}".format(jacquelin.name))
- actor.migrate(jacquelin)
+ actor.host = jacquelin
this_actor.sleep_until(15)
this_actor.info(
"At t=15, move the process to {:s} and resume it.".format(fafard.name))
- actor.migrate(fafard)
+ actor.host = fafard
actor.resume()
# This program is free software you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
-from simgrid import *
+from simgrid import Actor, Engine, this_actor
import sys
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Engine, this_actor
import sys
-from simgrid import *
# This example does not much: It just spans over-polite actor that yield a large amount
# of time before ending.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Engine, Mailbox, this_actor
import sys
-from simgrid import *
# This example shows how to use simgrid::s4u::this_actor::wait() to wait for a given communication.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Comm, Engine, Mailbox, this_actor
import sys
-from simgrid import *
# This example shows how to block on the completion of a set of communications.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Comm, Engine, Mailbox, this_actor
import sys
-from simgrid import *
# This example shows how to block on the completion of a set of communications.
#
# This program is free software you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Actor, Engine, Host, this_actor
import sys
-from simgrid import *
class Waiter:
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Actor, Engine, Host, this_actor
import sys
-from simgrid import *
def executor():
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Actor, Engine, Host, this_actor
import sys
-from simgrid import *
class Dvfs:
# This program is free software you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Actor, Engine, Host, this_actor
import sys
-from simgrid import *
class Wizard:
set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
- ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt
- ${CMAKE_CURRENT_SOURCE_DIR}/README.rst PARENT_SCOPE)
+ ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt PARENT_SCOPE)
+++ /dev/null
-.. S4U (Simgrid for you) is the next interface of SimGrid, expected to be released with SimGrid 4.0.
-..
-.. Even if it is not completely rock stable yet, it may well already fit
-.. your needs. You are welcome to try it and report any interface
-.. glitches that you see. Be however warned that the interface may change
-.. until the final release. You will have to adapt your code on the way.
-..
-.. This file follows the ReStructured syntax to be included in the
-.. documentation, but it should remain readable directly.
-
-
-S4U Examples
-************
-
-SimGrid comes with an extensive set of examples, documented on this
-page. Most of them only demonstrate one single feature, with some
-larger examplars listed below.
-
-The C++ examples can be found under examples/s4u while python examples
-are in examples/python. Each such directory contains the source code (also listed
-from this page), and the so-called tesh file containing how to call
-the binary obtained by compiling this example and also the expected
-output. Tesh files are used to turn each of our examples into an
-integration test. Some examples also contain other files, on need.
-
-A good way to bootstrap your own project is to copy and combine some
-of the provided examples to constitute the skeleton of what you plan
-to simulate.
-
-===========================
-Actors: the Active Entities
-===========================
-
-.. _s4u_ex_actors:
-
-Starting and Stoping Actors
----------------------------
-
- - **Creating actors:**
- Most actors are started from the deployment XML file, but there is other methods.
- This example show them all.
- `examples/python/actor-create/actor-create_d.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/python/actor-create/actor-create_d.xml>`_
-
- - |cpp| `examples/s4u/actor-create/s4u-actor-create.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-create/s4u-actor-create.cpp>`_
- - |py| `examples/python/actor-create/actor-create.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/actor-create/actor-create.py>`_
-
- - **React to the end of actors:**
- You can attach a callback to the end of actors. There is two ways
- of doing so, depending of whether you want your callback to be
- executed when a specific actor ends (with ```this_actor::on_exit()```)
- or whether it should be executed when any actor ends (with
- ```Actor::on_termination()```) or when it gets destroyed (with
- ```Actor::on_destruction()```)
-
- - |cpp| `examples/s4u/actor-exiting/s4u-actor-exiting.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-exiting/s4u-actor-exiting.cpp>`_
-
- - **Kill actors:**
- Actors can forcefully stop other actors.
-
- - |cpp| `examples/s4u/actor-kill/s4u-actor-kill.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-kill/s4u-actor-kill.cpp>`_
- :cpp:func:`void simgrid::s4u::Actor::kill(void)`,
- :cpp:func:`void simgrid::s4u::Actor::kill_all()`,
- :cpp:func:`simgrid::s4u::this_actor::exit`.
- - |py| `examples/python/actor-kill/actor-kill.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/actor-kill/actor-kill.py>`_
- :py:func:`simgrid.Actor.kill`,
- :py:func:`simgrid.Actor.kill_all`,
- :py:func:`simgrid.this_actor.exit`.
-
- - **Controling the actor life cycle from the XML:**
- You can specify a start time and a kill time in the deployment
- file.
- |br| `examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp>`_
- |br| `examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml>`_
-
- - **Daemonize actors:**
- Some actors may be intended to simulate daemons that run in background. This example show how to transform a regular
- actor into a daemon that will be automatically killed once the simulation is over.
-
- - |cpp| `examples/s4u/actor-daemon/s4u-actor-daemon.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-daemon/s4u-actor-daemon.cpp>`_
- - |py| `examples/python/actor-daemon/actor-daemon.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/actor-daemon/actor-daemon.py>`_
-
-Inter-Actors Interactions
--------------------------
-
-See also the examples on :ref:`inter-actors communications
-<s4u_ex_communication>` and the ones on :ref:`classical
-synchronization objects <s4u_ex_IPC>`.
-
- - **Suspend and Resume actors:**
- Actors can be suspended and resumed during their executions.
-
- - |cpp| `examples/s4u/actor-suspend/s4u-actor-suspend.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-suspend/s4u-actor-suspend.cpp>`_
- :cpp:func:`simgrid::s4u::this_actor::suspend()`,
- :cpp:func:`simgrid::s4u::Actor::suspend()`, :cpp:func:`simgrid::s4u::Actor::resume()`, :cpp:func:`simgrid::s4u::Actor::is_suspended()`.
- - |py| `examples/python/actor-suspend/actor-suspend.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/actor-suspend/actor-suspend.py>`_
- :py:func:`simgrid.this_actor.suspend()`,
- :py:func:`simgrid.Actor.suspend()`, :py:func:`simgrid.Actor.resume()`, :py:func:`simgrid.Actor.is_suspended()`.
-
- - **Migrating Actors:**
- Actors can move or be moved from a host to another very easily.
-
- - |cpp| `examples/s4u/actor-migrate/s4u-actor-migrate.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-migrate/s4u-actor-migrate.cpp>`_
- :cpp:func:`simgrid::s4u::this_actor::migrate()`
- - |py| `examples/python/actor-migrate/actor-migrate.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/actor-migrate/actor-migrate.py>`_
- :py:func:`simgrid.this_actor.migrate()`
-
- - **Waiting for the termination of an actor:** (joining on it)
- You can block the current actor until the end of another actor.
-
- - |cpp| `examples/s4u/actor-join/s4u-actor-join.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-join/s4u-actor-join.cpp>`_
- :cpp:func:`simgrid::s4u::Actor::join()`
- - |py| `examples/python/actor-join/actor-join.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/actor-join/actor-join.py>`_
- :py:func:`simgrid.Actor.join()`
-
- - **Yielding to other actors**.
- The ```yield()``` function interrupts the execution of the current
- actor, leaving a chance to the other actors that are ready to run
- at this timestamp.
-
- - |cpp| `examples/s4u/actor-yield/s4u-actor-yield.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/actor-yield/s4u-actor-yield.cpp>`_
- :cpp:func:`simgrid::s4u::this_actor::yield()`
- - |py| `examples/python/actor-yield/actor-yield.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/actor-yield/actor-yield.py>`_
- :py:func:`simgrid.this_actor.yield_()`
-
-Traces Replay as a Workload
----------------------------
-
-This section details how to run trace-driven simulations. It is very
-handy when you want to test an algorithm or protocol that only react
-to external events. For example, many P2P protocols react to user
-requests, but do nothing if there is no such event.
-
-In such situations, you should write your protocol in C++, and separate
-the workload that you want to play onto your protocol in a separate
-text file. Declare a function handling each type of the events in your
-trace, register them using :cpp:func:`xbt_replay_action_register()` in
-your main, and then run the simulation.
-
-Then, you can either have one trace file containing all your events,
-or a file per simulated process: the former may be easier to work
-with, but the second is more efficient on very large traces. Check
-also the tesh files in the example directories for details.
-
- - **Communication replay:**
- Presents a set of event handlers reproducing classical communication
- primitives (asynchronous send/receive at the moment).
- |br| `examples/s4u/replay-comm/s4u-replay-comm.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/replay-comm/s4u-replay-comm.cpp>`_
-
- - **I/O replay:**
- Presents a set of event handlers reproducing classical I/O
- primitives (open, read, close).
- |br| `examples/s4u/replay-io/s4u-replay-io.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/replay-io/s4u-replay-io.cpp>`_
-
-==========================
-Activities: what Actors do
-==========================
-
-.. _s4u_ex_communication:
-
-Communications on the Network
------------------------------
-
- - **Basic asynchronous communications:**
- Illustrates how to have non-blocking communications, that are
- communications running in the background leaving the process free
- to do something else during their completion.
-
- - |cpp| `examples/s4u/async-wait/s4u-async-wait.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/async-wait/s4u-async-wait.cpp>`_
- :cpp:func:`simgrid::s4u::Mailbox::put_async()` and :cpp:func:`simgrid::s4u::Comm::wait()`
- - |py| `examples/python/async-wait/async-wait.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/async-wait/async-wait.py>`_
- :py:func:`simgrid.Mailbox.put_async()` :py:func:`simgrid.Comm.wait()`
-
- - **Waiting for all communications in a set:**
- The `wait_all()` function is useful when you want to block until
- all activities in a given set have completed.
-
- - |cpp| `examples/s4u/async-waitall/s4u-async-waitall.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/async-waitall/s4u-async-waitall.cpp>`_
- :cpp:func:`simgrid::s4u::Comm::wait_all()`
- - |py| `examples/python/async-waitall/async-waitall.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/async-waitall/async-waitall.py>`_
- :py:func:`simgrid.Comm.wait_all()`
-
- - **Waiting for the first completed communication in a set:**
- The `wait_any()` function is useful
- when you want to block until one activity of the set completes, no
- matter which terminates first.
-
- - |cpp| `examples/s4u/async-waitany/s4u-async-waitany.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/async-waitany/s4u-async-waitany.cpp>`_
- :cpp:func:`simgrid::s4u::Comm::wait_any()`
- - |py| `examples/python/async-waitany/async-waitany.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/async-waitany/async-waitany.py>`_
- :py:func:`simgrid.Comm.wait_any()`
-
-.. todo:: review the `ready` and `waituntil` examples and add them here.
-
-.. _s4u_ex_execution:
-
-Executions on the CPU
----------------------
-
- - **Basic execution:**
- The computations done in your program are not reported to the
- simulated world, unless you explicitly request the simulator to pause
- the actor until a given amount of flops gets computed on its simulated
- host. Some executions can be given an higher priority so that they
- get more resources.
-
- - |cpp| `examples/s4u/exec-basic/s4u-exec-basic.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-basic/s4u-exec-basic.cpp>`_
- - |py| `examples/python/exec-basic/exec-basic.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/exec-basic/exec-basic.py>`_
-
- - **Asynchronous execution:**
- You can start asynchronous executions, just like you would fire
- background threads.
-
- - |cpp| `examples/s4u/exec-async/s4u-exec-async.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-async/s4u-exec-async.cpp>`_
- - |py| `examples/python/exec-async/exec-async.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/exec-async/exec-async.py>`_
-
- - **Remote execution:**
- You can start executions on remote hosts, or even change the host
- on which they occur during their execution.
-
- - |cpp| `examples/s4u/exec-remote/s4u-exec-remote.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-remote/s4u-exec-remote.cpp>`_
- - |py| `examples/python/exec-remote/exec-remote.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/exec-remote/exec-remote.py>`_
-
- - **Parallel executions:**
- These objects are convenient abstractions of parallel
- computational kernels that span over several machines, such as a
- PDGEM and the other ScaLAPACK routines. Note that this only works
- with the "ptask_L07" host model (``--cfg=host/model:ptask_L07``).
- |br| `examples/s4u/exec-ptask/s4u-exec-ptask.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-ptask/s4u-exec-ptask.cpp>`_
-
- - **Using Pstates on a host:**
- `examples/platforms/energy_platform.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/energy_platform.xml>`_
- shows how define a set of pstates in the XML. The current pstate
- of an host can then be accessed and changed from the program.
-
- - |cpp| `examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp>`_
- :cpp:func:`simgrid::s4u::Host::get_pstate_speed` and :cpp:func:`simgrid::s4u::Host::set_pstate`.
- - |py| `examples/python/exec-dvfs/exec-dvfs.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/exec-dvfs/exec-dvfs.py>`_
- :py:func:`Host.get_pstate_speed` and :py:func:`Host.set_pstate`.
-
-I/O on Disks and Files
-----------------------
-
-SimGrid provides two levels of abstraction to interact with the
-simulated disks. At the simplest level, you simply create read and
-write actions on the disk resources.
-
- - **Access to raw disk devices:**
- This example illustrates how to simply read and write data on a
- simulated disk resource.
- |br| `examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp>`_
-
-The FileSystem plugin provides a more detailed view, with the
-classical operations over files: open, move, unlink, and of course
-read and write. The file and disk sizes are also dealt with and can
-result in short reads and short write, as in reality.
-
- - **File Management:**
- This example illustrates the use of operations on files
- (read, write, seek, tell, unlink, etc).
- |br| `examples/s4u/io-file-system/s4u-io-file-system.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/io-file-system/s4u-io-file-system.cpp>`_
-
- - **Remote I/O:**
- I/O operations on files can also be done in a remote fashion,
- i.e. when the accessed disk is not mounted on the caller's host.
- |br| `examples/s4u/io-file-remote/s4u-io-file-remote.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/io-file-remote/s4u-io-file-remote.cpp>`_
-
-.. _s4u_ex_IPC:
-
-Classical synchronization objects
----------------------------------
-
- - **Mutex:**
- Shows how to use simgrid::s4u::Mutex synchronization objects.
- |br| `examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp>`_
-
- - **Barrier:**
- Shows how to use simgrid::s4u::Barrier synchronization objects.
- |br| `examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp>`_
-
- - **Semaphore:**
- Shows how to use simgrid::s4u::Semaphore synchronization objects.
- |br| `examples/s4u/synchro-semaphore/s4u-synchro-semaphore.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/synchro-semaphore/s4u-synchro-semaphore.cpp>`_
-
-=============================
-Interacting with the Platform
-=============================
-
- - **Retrieving the list of hosts matching a given criteria:**
- Shows how to filter the actors that match a given criteria.
- |br| `examples/s4u/engine-filtering/s4u-engine-filtering.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/engine-filtering/s4u-engine-filtering.cpp>`_
-
- - **User-defined properties:**
- You can attach arbitrary information to most platform elements from
- the XML file, and then interact with these values from your
- program. Note that the changes are not written permanently on disk,
- in the XML file nor anywhere else. They only last until the end of
- your simulation.
-
- - :cpp:func:`simgrid::s4u::Actor::get_property()` and :cpp:func:`simgrid::s4u::Actor::set_property()`
- - :cpp:func:`simgrid::s4u::Host::get_property()` and :cpp:func:`simgrid::s4u::Host::set_property()`
- - :cpp:func:`simgrid::s4u::Link::get_property()` and :cpp:func:`simgrid::s4u::Link::set_property()`
- - :cpp:func:`simgrid::s4u::NetZone::get_property()` and :cpp:func:`simgrid::s4u::NetZone::set_property()`
-
- |br| `examples/s4u/platform-properties/s4u-platform-properties.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/platform-properties/s4u-platform-properties.cpp>`_
- |br| `examples/s4u/platform-properties/s4u-platform-properties_d.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/platform-properties/s4u-platform-properties_d.xml>`_
- |br| `examples/platforms/prop.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/prop.xml>`_
-
- - **Specifying state profiles:** shows how to specify when the
- resources must be turned off and on again, and how to react to such
- failures in your code.
-
- |br| `examples/platforms/small_platform_failures.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/small_platform_failures.xml>`_
- |br| The state profiles in `examples/platforms/profiles <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/profiles>`_
-
- - **Specifying speed profiles:** shows how to specify an external
- load to resources, variating their peak speed over time.
-
- |br| `examples/platforms/small_platform_profile.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/small_platform_profile.xml>`_
- |br| The speed, bandwidth and latency profiles in `examples/platforms/profiles <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/profiles>`_
-
-=================
-Energy Simulation
-=================
-
- - **Describing the energy profiles in the platform:**
- This platform file contains the energy profile of each links and
- hosts, which is necessary to get energy consumption predictions.
- As usual, you should not trust our example, and you should strive
- to double-check that your instantiation matches your target platform.
- |br| `examples/platforms/energy_platform.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/energy_platform.xml>`_
-
- - **Consumption due to the CPU:**
- This example shows how to retrieve the amount of energy consumed
- by the CPU during computations, and the impact of the pstate.
- |br| `examples/s4u/energy-exec/s4u-energy-exec.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/energy-exec/s4u-energy-exec.cpp>`_
-
- - **Consumption due to the network:**
- This example shows how to retrieve and display the energy consumed
- by the network during communications.
- |br| `examples/s4u/energy-link/s4u-energy-link.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/energy-link/s4u-energy-link.cpp>`_
-
- - **Modeling the shutdown and boot of hosts:**
- Simple example of model of model for the energy consumption during
- the host boot and shutdown periods.
- |br| `examples/s4u/energy-boot/platform_boot.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/energy-boot/platform_boot.xml>`_
- |br| `examples/s4u/energy-boot/s4u-energy-boot.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/energy-boot/s4u-energy-boot.cpp>`_
-
-=======================
-Tracing and Visualizing
-=======================
-
-Tracing can be activated by various configuration options which
-are illustrated in these example. See also the
-:ref:`full list of options related to tracing <tracing_tracing_options>`.
-
-It is interesting to run the process-create example with the following
-options to see the task executions:
-
- - **Platform Tracing:**
- This program is a toy example just loading the platform, so that
- you can play with the platform visualization. Recommanded options:
- ``--cfg=tracing:yes --cfg=tracing/categorized:yes``
- |br| `examples/s4u/trace-platform/s4u-trace-platform.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/trace-platform/s4u-trace-platform.cpp>`_
-
-========================
-Larger SimGrid Examplars
-========================
-
-This section contains application examples that are somewhat larger
-than the previous examples.
-
- - **Ping Pong:**
- This simple example just sends one message back and forth.
- The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to
- the simulators (as detailed in Section :ref:`options`).
- |br| `examples/s4u/app-pingpong/s4u-app-pingpong.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/app-pingpong/s4u-app-pingpong.cpp>`_
-
- - **Token ring:**
- Shows how to implement a classical communication pattern, where a
- token is exchanged along a ring to reach every participant.
- |br| `examples/s4u/app-token-ring/s4u-app-token-ring.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/app-token-ring/s4u-app-token-ring.cpp>`_
-
- - **Master Workers:**
- Another good old example, where one Master process has a bunch of task to dispatch to a set of several Worker
- processes. This example comes in two equivalent variants, one
- where the actors are specified as simple functions (which is easier to
- understand for newcomers) and one where the actors are specified
- as classes (which is more powerful for the users wanting to build
- their own projects upon the example).
- |br| `examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp>`_
- |br| `examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp>`_
-
-Data diffusion
---------------
-
- - **Bit Torrent:**
- Classical protocol for Peer-to-Peer data diffusion.
- |br| `examples/s4u/app-bittorrent/s4u-bittorrent.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/app-bittorrent/s4u-bittorrent.cpp>`_
-
- - **Chained Send:**
- Data broadcast over a ring of processes.
- |br| `examples/s4u/app-chainsend/s4u-app-chainsend.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/app-chainsend/s4u-app-chainsend.cpp>`_
-
-Distributed Hash Tables (DHT)
------------------------------
-
- - **Chord Protocol**
- One of the most famous DHT protocol.
- |br| `examples/s4u/dht-chord/s4u-dht-chord.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/dht-chord/s4u-dht-chord.cpp>`_
-
-.. _s4u_ex_clouds:
-
-Simulating Clouds
------------------
-
- - **Cloud basics**
- This example starts some computations both on PMs and VMs, and
- migrates some VMs around.
- |br| `examples/s4u/cloud-simple/s4u-cloud-simple.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/cloud-simple/s4u-cloud-simple.cpp>`_
-
-.. TODO:: document here the examples about clouds and plugins
-
-=======================
-Model-Checking Examples
-=======================
-
-The model-checker can be used to exhaustively search for issues in the
-tested application. It must be activated at compile time, but this
-mode is rather experimental in SimGrid (as of v3.22). You should not
-enable it unless you really want to formally verify your applications:
-SimGrid is slower and maybe less robust when MC is enabled.
-
- - **Failing assert**
- In this example, two actors send some data to a central server,
- which asserts that the messages are always received in the same order.
- This is obviously wrong, and the model-checker correctly finds a
- counter-example to that assertion.
- |br| `examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp>`_
-
-.. |br| raw:: html
-
- <br />
-
-.. |cpp| image:: /img/lang_cpp.png
- :align: middle
- :width: 12
-
-.. |py| image:: /img/lang_python.png
- :align: middle
- :width: 12
XBT_INFO("Let's move to %s to execute %.2f Mflops (5sec on %s and 5sec on %s)", first->get_cname(), flopAmount / 1e6,
first->get_cname(), second->get_cname());
- simgrid::s4u::this_actor::migrate(first);
+ simgrid::s4u::this_actor::set_host(first);
simgrid::s4u::this_actor::execute(flopAmount);
XBT_INFO("I wake up on %s. Let's suspend a bit", simgrid::s4u::this_actor::get_host()->get_cname());
simgrid::s4u::this_actor::sleep_for(5);
XBT_INFO("After 5 seconds, move the process to %s", jacquelin->get_cname());
- actor->migrate(jacquelin);
+ actor->set_host(jacquelin);
simgrid::s4u::this_actor::sleep_until(15);
XBT_INFO("At t=15, move the process to %s and resume it.", fafard->get_cname());
- actor->migrate(fafard);
+ actor->set_host(fafard);
actor->resume();
}
/** Number of blocks asked by each request */
constexpr unsigned long BLOCKS_REQUESTED = 2UL;
-constexpr bool ENABLE_END_GAME_MODE = true;
constexpr double SLEEP_DURATION = 1.0;
#define BITS_TO_BYTES(x) (((x) / 8 + (x) % 8) ? 1 : 0)
XBT_DEBUG(" \t for piece %d (%d,%d)", message->piece, message->block_index,
message->block_index + message->block_length);
xbt_assert(not remote_peer->choked_download);
- xbt_assert(remote_peer->am_interested || ENABLE_END_GAME_MODE,
- "Can't received a piece if I'm not interested without end-game mode!"
- "piece (%d) bitfield (%u) remote bitfield (%u)",
- message->piece, bitfield_, remote_peer->bitfield);
xbt_assert(not remote_peer->choked_download, "Can't received a piece if I'm choked !");
xbt_assert((message->piece >= 0 && static_cast<unsigned int>(message->piece) < FILE_PIECES),
"Wrong piece received");
}
} else {
XBT_DEBUG("However, we already have it");
- xbt_assert(ENABLE_END_GAME_MODE, "Should not happen because we don't use end game mode !");
requestNewPieceTo(remote_peer);
}
break;
// end game mode
if (countPieces(current_pieces) >= (FILE_PIECES - countPieces(bitfield_)) && isInterestedBy(remote_peer)) {
- if (not ENABLE_END_GAME_MODE)
- return -1;
int nb_interesting_pieces = 0;
// compute the number of interesting pieces
for (unsigned int i = 0; i < FILE_PIECES; i++)
ok = False
while not ok:
my_id = random.randint(0, max_id)
- ok = not my_id in all_ids
+ ok = my_id not in all_ids
known_id = all_ids[random.randint(0, len(all_ids) - 1)]
start_date = i * 10
line = " <process host=\"node-%d.simgrid.org\" function=\"node\">\n <argument value=\"%s\"/>"\
file->move(newpath);
// Test attaching some user data to the file
- file->set_userdata(new std::string("777"));
- std::string* file_data = static_cast<std::string*>(file->get_userdata());
+ file->set_data(new std::string("777"));
+ std::string* file_data = static_cast<std::string*>(file->get_data());
XBT_INFO("User data attached to the file: %s", file_data->c_str());
delete file_data;
#include "smpi/smpi.h"
#include "smpi/sampi.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_plugin_load_balancer_example, smpi, "Simple tracing test for SAMPI functions");
-
int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
#include <xbt/backtrace.hpp>
#include <xbt/ex.h>
+#include <xbt/string.hpp>
#include <atomic>
#include <functional>
}
};
+class XBT_PUBLIC ParseError : public Exception, public std::invalid_argument {
+ int line_;
+ std::string file_;
+ std::string msg_;
+
+public:
+ ParseError(int line, std::string& file, std::string&& msg)
+ : Exception(XBT_THROW_POINT, std::move(msg)), std::invalid_argument(msg), line_(line), file_(file), msg_(msg)
+ {
+ }
+
+ const char* what() const noexcept override
+ {
+ return bprintf("Parse error at %s:%d: %s", file_.c_str(), line_, msg_.c_str());
+ }
+};
+
class XBT_PUBLIC ForcefulKillException {
/** @brief Exception launched to kill an actor; DO NOT BLOCK IT!
*
#include <xbt/dict.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @brief Actor datatype.
@ingroup m_actor_management
You should not access directly to the fields of the pointed structure, but always use the provided API to interact
with actors.
*/
+XBT_PUBLIC sg_actor_t sg_actor_init(const char* name, sg_host_t host);
+/** Start the previously initialized actor.
+ *
+ * Note that argv is copied over, so you should free your own copy once the actor is started. */
+XBT_PUBLIC void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv);
XBT_PUBLIC aid_t sg_actor_get_PID(sg_actor_t actor);
XBT_PUBLIC aid_t sg_actor_get_PPID(sg_actor_t actor);
XBT_PUBLIC sg_actor_t sg_actor_by_PID(aid_t pid);
XBT_PUBLIC sg_actor_t sg_actor_restart(sg_actor_t actor);
void sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart);
XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
-XBT_PUBLIC void sg_actor_migrate(sg_actor_t process, sg_host_t host);
+
+XBT_ATTRIB_DEPRECATED_v329("Please use sg_actor_set_host() instead") XBT_PUBLIC
+ void sg_actor_migrate(sg_actor_t process, sg_host_t host);
+
+XBT_PUBLIC void sg_actor_set_host(sg_actor_t actor, sg_host_t host);
XBT_PUBLIC void sg_actor_join(sg_actor_t actor, double timeout);
XBT_PUBLIC void sg_actor_kill(sg_actor_t actor);
XBT_PUBLIC void sg_actor_kill_all();
XBT_PUBLIC aid_t sg_actor_self_get_pid();
XBT_PUBLIC aid_t sg_actor_self_get_ppid();
XBT_PUBLIC const char* sg_actor_self_get_name();
+XBT_PUBLIC void* sg_actor_self_data();
+XBT_PUBLIC void sg_actor_self_data_set(void* data);
XBT_PUBLIC void sg_actor_self_execute(double flops);
XBT_PUBLIC void sg_actor_ref(sg_actor_t actor);
XBT_PUBLIC void sg_actor_unref(sg_actor_t actor);
-XBT_PUBLIC void* sg_actor_data(sg_actor_t actor);
+XBT_PUBLIC void* sg_actor_data(const_sg_actor_t actor);
XBT_PUBLIC void sg_actor_data_set(sg_actor_t actor, void* userdata);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_ACTOR_H_ */
#endif
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC sg_bar_t sg_barrier_init(unsigned int count);
XBT_PUBLIC void sg_barrier_destroy(sg_bar_t bar);
XBT_PUBLIC int sg_barrier_wait(sg_bar_t bar);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_BARRIER_H_ */
#include <simgrid/forward.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @brief Creates a condition variable */
XBT_PUBLIC sg_cond_t sg_cond_init();
/** @brief Destroys the given mutex variable */
XBT_PUBLIC void sg_cond_destroy(sg_cond_t cond);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_COND_H_ */
#define SIMGRID_VERSION_PATCH @SIMGRID_VERSION_PATCH@
#define SIMGRID_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** Retrieves the version numbers of the used dynamic library (so, DLL or dynlib), while
SIMGRID_VERSION_MAJOR and friends give the version numbers of the used header files */
XBT_PUBLIC void sg_version_get(int* major, int* minor, int* patch);
/** Display the version information and some additional blurb. */
XBT_PUBLIC void sg_version();
-SG_END_DECL()
+SG_END_DECL
/* Version as a single integer. v3.4 is 30400, v3.16.2 is 31602, v42 will be 420000, and so on. */
#include <simgrid/forward.h>
-/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL /* C interface */
+/** Initialize the SimGrid engine, taking the command line parameters of your main function. */
XBT_PUBLIC void simgrid_init(int* argc, char** argv);
+
+/** Creates a new platform, including hosts, links, and the routing table.
+ *
+ * \rst
+ * See also: :ref:`platform`.
+ * \endrst
+ */
XBT_PUBLIC void simgrid_load_platform(const char* filename);
+/** Load a deployment file and launch the actors that it contains
+ *
+ * \rst
+ * See also: :ref:`deploy`.
+ * \endrst
+ */
XBT_PUBLIC void simgrid_load_deployment(const char* filename);
+/** Run the simulation after initialization */
XBT_PUBLIC void simgrid_run();
+/** Registers the main function of an actor that will be launched from the deployment file */
XBT_PUBLIC void simgrid_register_function(const char* name, int (*code)(int, char**));
+/** Registers a function as the default main function of actors
+ *
+ * It will be used as fallback when the function requested from the deployment file was not registered.
+ * It is used for trace-based simulations (see examples/s4u/replay-comms and similar).
+ */
XBT_PUBLIC void simgrid_register_default(int (*code)(int, char**));
+/** Retrieve the simulation time (in seconds) */
XBT_PUBLIC double simgrid_get_clock();
+/** Retrieve the number of actors in the simulation */
+XBT_PUBLIC int simgrid_get_actor_count();
+/** @brief Allow other libraries to react to the --help flag, too
+ *
+ * When finding --help on the command line, simgrid usually stops right after displaying its help message.
+ * If you are writing a library using simgrid, you may want to display your own help message before everything stops.
+ * If so, just call this function before having simgrid parsing the command line, and you will be given the control
+ * even if the user is asking for help.
+ */
XBT_PUBLIC void sg_config_continue_after_help();
-SG_END_DECL()
+
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_ENGINE_H_ */
typedef s4u_File* sg_file_t;
typedef s4u_VM* sg_vm_t;
typedef s4u_Actor* sg_actor_t;
+typedef const s4u_Actor* const_sg_actor_t;
typedef struct s_smx_simcall* smx_simcall_t;
#include <xbt/dynar.h>
#include <simgrid/forward.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @brief Host datatype.
*
* A <em>location</em> (or <em>host</em>) is any possible place where an actor may run. Thus it is represented as a
XBT_PUBLIC void sg_host_dump(sg_host_t ws);
XBT_PUBLIC void sg_host_get_actor_list(sg_host_t host, xbt_dynar_t whereto);
-SG_END_DECL()
+SG_END_DECL
#endif /* SIMGRID_HOST_H_ */
#include <simgrid/msg.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Functions to manage tracing categories */
XBT_PUBLIC void TRACE_category(const char* category);
XBT_PUBLIC xbt_dynar_t TRACE_get_node_types();
XBT_PUBLIC xbt_dynar_t TRACE_get_edge_types();
-SG_END_DECL()
+SG_END_DECL
#endif /* INSTR_H_ */
#include <simgrid/simdag.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void jedule_log_sd_event(SD_task_t task);
XBT_PUBLIC void jedule_sd_init(void);
XBT_PUBLIC void jedule_sd_exit(void);
XBT_PUBLIC void jedule_sd_dump(const char* filename);
-SG_END_DECL()
+SG_END_DECL
#endif /* JEDULE_SD_BINDING_H_ */
/** @details An action is a consumption on a resource (e.g.: a communication for the network).
*
* It is related (but still different) from activities, that are the stuff on which an actor can be blocked.
- * See simgrid::s4u::Activity for more details.
+ *
+ * - A sequential execution activity encompasses 2 actions: one for the exec itself,
+ * and a time-limited sleep used as timeout detector.
+ * - A point-to-point communication activity encompasses 3 actions: one for the comm itself
+ * (which spans on all links of the path), and one infinite sleep used as failure detector
+ * on both sender and receiver hosts.
+ * - Synchronization activities may possibly be connected to no action.
+
*/
class XBT_PUBLIC Action {
friend ActionHeap;
virtual double next_occurring_event_lazy(double now);
virtual double next_occurring_event_full(double now);
- XBT_ATTRIB_DEPRECATED_v329("Please use next_occurring_event()") double next_occuring_event(double now)
+ XBT_ATTRIB_DEPRECATED_v329("Please use next_occurring_event()") virtual double next_occuring_event(double now) final
{
return next_occurring_event(now);
}
- XBT_ATTRIB_DEPRECATED_v329("Please use next_occurring_event_lazy()") double next_occuring_event_lazy(double now)
+ XBT_ATTRIB_DEPRECATED_v329("Please use next_occurring_event_lazy()") virtual double next_occuring_event_lazy(
+ double now) final
{
return next_occurring_event_lazy(now);
}
- XBT_ATTRIB_DEPRECATED_v329("Please use next_occurring_event_full()") double next_occuring_event_full(double now)
+ XBT_ATTRIB_DEPRECATED_v329("Please use next_occurring_event_full()") virtual double next_occuring_event_full(
+ double now) final
{
return next_occurring_event_full(now);
}
*/
virtual bool next_occurring_event_is_idempotent() { return true; }
- XBT_ATTRIB_DEPRECATED_v329("Please use next_occurring_event_is_idempotent()") bool next_occuring_event_is_idempotent()
+ XBT_ATTRIB_DEPRECATED_v329(
+ "Please use next_occurring_event_is_idempotent()") virtual bool next_occuring_event_is_idempotent() final
{
return next_occurring_event_is_idempotent();
}
#include <xbt/base.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC const char* sg_link_name(sg_link_t link);
XBT_PUBLIC sg_link_t sg_link_by_name(const char* name);
XBT_PUBLIC int sg_link_is_shared(sg_link_t link);
XBT_PUBLIC void sg_link_data_set(sg_link_t link, void* data);
XBT_PUBLIC int sg_link_count();
XBT_PUBLIC sg_link_t* sg_link_list();
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_LINK_H_ */
#include <xbt/base.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void sg_mailbox_set_receiver(const char* alias);
XBT_PUBLIC int sg_mailbox_listen(const char* alias);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_MAILBOX_H_ */
#include <stddef.h> /* size_t */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC int MC_random(int min, int max);
#endif
-SG_END_DECL()
+SG_END_DECL
#endif /* SIMGRID_MODELCHECKER_H */
XBT_PUBLIC void MSG_create_environment(const char* file);
/** @brief Creates the application described in the provided file */
XBT_PUBLIC void MSG_launch_application(const char* file);
+
+#ifndef DOXYGEN
/** @brief register functions bypassing the parser */
-XBT_PUBLIC void MSG_set_function(const char* host_id, const char* function_name, xbt_dynar_t arguments);
+XBT_ATTRIB_DEPRECATED_v329("This function will be removed. Speak up if you need it.") XBT_PUBLIC
+ void MSG_set_function(const char* host_id, const char* function_name, xbt_dynar_t arguments);
+#endif
/** @brief A clock (in second). */
XBT_PUBLIC double MSG_get_clock();
XBT_PUBLIC unsigned long int MSG_get_sent_msg();
/************************** Process handling *********************************/
-XBT_PUBLIC void MSG_process_userdata_init();
XBT_PUBLIC msg_process_t MSG_process_create(const char* name, xbt_main_func_t code, void* data, msg_host_t host);
XBT_PUBLIC msg_process_t MSG_process_create_with_arguments(const char* name, xbt_main_func_t code, void* data,
msg_host_t host, int argc, char** argv);
#include <simgrid/forward.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC sg_mutex_t sg_mutex_init();
XBT_PUBLIC void sg_mutex_lock(sg_mutex_t mutex);
XBT_PUBLIC void sg_mutex_unlock(sg_mutex_t mutex);
XBT_PUBLIC int sg_mutex_try_lock(sg_mutex_t mutex);
XBT_PUBLIC void sg_mutex_destroy(sg_mutex_t mutex);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_MUTEX_H_ */
#include <simgrid/forward.h>
#include <xbt/base.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void sg_host_dvfs_plugin_init();
#define MSG_host_dvfs_plugin_init() sg_host_dvfs_plugin_init()
-SG_END_DECL()
+SG_END_DECL
#endif
#include <xbt/base.h>
#include <simgrid/forward.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void sg_host_energy_plugin_init();
XBT_PUBLIC void sg_host_energy_update_all();
#define MSG_host_get_power_range_slope_at(host,pstate) sg_host_get_power_range_slope_at((host), (pstate))
#define MSG_host_get_current_consumption(host) sg_host_get_current_consumption(host)
-SG_END_DECL()
+SG_END_DECL
#endif
////////////////
typedef sg_file_t msg_file_t; // MSG backwards compatibility
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void sg_storage_file_system_init();
XBT_PUBLIC sg_file_t sg_file_open(const char* fullpath, void* data);
XBT_PUBLIC sg_size_t sg_file_read(sg_file_t fd, sg_size_t size);
#define MSG_host_get_storage_content(st) sg_host_get_storage_content(st)
-SG_END_DECL()
+SG_END_DECL
// C++ interface
//////////////////
* mountpoints.
* For now, you cannot change the mountpoints programmatically, and must declare them from your platform file.
*/
-class XBT_PUBLIC File {
+class XBT_PUBLIC File : public xbt::Extendable<File> {
public:
File(const std::string& fullpath, void* userdata);
File(const std::string& fullpath, sg_host_t host, void* userdata);
sg_size_t write(sg_size_t size, int write_inside=0);
/** Allows to store user data on that host */
- void set_userdata(void* data) { userdata_ = data; }
+ XBT_ATTRIB_DEPRECATED_v329("Please use set_data()") void set_userdata(void* data) { set_data(data); }
/** Retrieves the previously stored data */
- void* get_userdata() { return userdata_; }
+ XBT_ATTRIB_DEPRECATED_v329("Please use get_data()") void* get_userdata() { return get_data(); }
sg_size_t size();
void seek(sg_offset_t pos); /** Sets the file head to the given position. */
std::string path_;
std::string fullpath_;
sg_size_t current_position_ = SEEK_SET;
- void* userdata_ = nullptr;
};
class XBT_PUBLIC FileSystemDiskExt {
#include <simgrid/forward.h>
#include <xbt/base.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void sg_vm_live_migration_plugin_init();
XBT_PRIVATE void sg_vm_dirty_page_tracking_init();
#define MSG_vm_is_migrating(vm) sg_vm_is_migrating(vm)
#define MSG_vm_migrate(vm, dst_pm) sg_vm_migrate((vm), (dst_pm))
-SG_END_DECL()
+SG_END_DECL
#endif
#include <simgrid/forward.h>
#include <xbt/base.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void sg_host_load_plugin_init();
XBT_PUBLIC double sg_host_get_current_load(sg_host_t host);
#define MSG_host_get_computed_flops(host) sg_host_get_computed_flops(host)
#define MSG_host_get_avg_load(host) sg_host_get_avg_load(host)
-SG_END_DECL()
+SG_END_DECL
#endif
#include <simgrid/forward.h>
#include <xbt/base.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void sg_load_balancer_plugin_init();
-SG_END_DECL()
+SG_END_DECL
#endif
*
* This class is the ancestor of every activities that an actor can undertake.
* That is, activities are all the things that do take time to the actor in the simulated world.
- *
- * They are somewhat linked but not identical to simgrid::kernel::resource::Action,
- * that are stuff occurring on a resource:
- *
- * - A sequential execution activity encompasses 2 actions: one for the exec itself,
- * and a time-limited sleep used as timeout detector.
- * - A point-to-point communication activity encompasses 3 actions: one for the comm itself
- * (which spans on all links of the path), and one infinite sleep used as failure detector
- * on both sender and receiver hosts.
- * - Synchronization activities may possibly be connected to no action.
*/
class XBT_PUBLIC Activity {
friend Comm;
* It is forbidden to change the amount of work once the Activity is started */
Activity* set_remaining(double remains);
- /** Put some user data onto the Activity */
-
+ /** Returns the internal implementation of this Activity */
kernel::activity::ActivityImpl* get_impl() const { return pimpl_.get(); }
private:
namespace simgrid {
namespace s4u {
-/**
- *
- * An actor is an independent stream of execution in your distributed application.
+/** \beginrst An actor is an independent stream of execution in your distributed application.
+ * It is located on a (simulated) :cpp:class:`host <simgrid::s4u::Host>`, but can interact
+ * with the whole simulated platform.
*
* You can think of an actor as a process in your distributed application, or as a thread in a multithreaded program.
* This is the only component in SimGrid that actually does something on its own, executing its own code.
* A resource will not get used if you don't schedule activities on them. This is the code of Actors that create and
- * schedule these activities.
- *
- * An actor is located on a (simulated) host, but it can interact
- * with the whole simulated platform.
- *
- * The s4u::Actor API is strongly inspired from the C++11 threads.
- * The <a href="http://en.cppreference.com/w/cpp/thread">documentation
- * of this standard</a> may help to understand the philosophy of the S4U
- * Actors.
- *
- * @section s4u_actor_def Defining the skeleton of an Actor
- *
- * As in the <a href="http://en.cppreference.com/w/cpp/thread">C++11
- * standard</a>, you can declare the code of your actor either as a
- * pure function or as an object. It is very simple with functions:
- *
- * @code{.cpp}
- * #include <simgrid/s4u/actor.hpp>
- *
- * // Declare the code of your worker
- * void worker() {
- * printf("Hello s4u");
- * simgrid::s4u::this_actor::execute(5*1024*1024); // Get the worker executing a task of 5 MFlops
- * };
- *
- * // From your main or from another actor, create your actor on the host Jupiter
- * // The following line actually creates a new actor, even if there is no "new".
- * Actor("Alice", simgrid::s4u::Host::by_name("Jupiter"), worker);
- * @endcode
- *
- * But some people prefer to encapsulate their actors in classes and
- * objects to save the actor state in a cleanly dedicated location.
- * The syntax is slightly more complicated, but not much.
- *
- * @code{.cpp}
- * #include <simgrid/s4u/actor.hpp>
- *
- * // Declare the class representing your actors
- * class Worker {
- * public:
- * void operator()() { // Two pairs of () because this defines the method called ()
- * printf("Hello s4u");
- * simgrid::s4u::this_actor::execute(5*1024*1024); // Get the worker executing a task of 5 MFlops
- * }
- * };
- *
- * // From your main or from another actor, create your actor. Note the () after Worker
- * Actor("Bob", simgrid::s4u::Host::by_name("Jupiter"), Worker());
- * @endcode
- *
- * @section s4u_actor_flesh Fleshing your actor
- *
- * The body of your actor can use the functions of the
- * simgrid::s4u::this_actor namespace to interact with the world.
- * This namespace contains the methods to start new activities
- * (executions, communications, etc), and to get informations about
- * the currently running thread (its location, etc).
- *
- * Please refer to the @link simgrid::s4u::this_actor full API @endlink.
- *
- *
- * @section s4u_actor_deploy Using a deployment file
- *
- * @warning This is currently not working with S4U. Sorry about that.
- *
- * The best practice is to use an external deployment file as
- * follows, because it makes it easier to test your application in
- * differing settings. Load this file with
- * s4u::Engine::loadDeployment() before the simulation starts.
- * Refer to the @ref deployment section for more information.
+ * schedule these activities. **Please refer to the** :ref:`examples <s4u_ex_actors>` **for more information.**
*
- * @code{.xml}
- * <?xml version='1.0'?>
- * <!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
- * <platform version="4.1">
+ * This API is strongly inspired from the C++11 threads.
+ * The `documentation of this standard <http://en.cppreference.com/w/cpp/thread>`_
+ * may help to understand the philosophy of the SimGrid actors.
*
- * <!-- Start an actor called 'master' on the host called 'Tremblay' -->
- * <actor host="Tremblay" function="master">
- * <!-- Here come the parameter that you want to feed to this instance of master -->
- * <argument value="20"/> <!-- argv[1] -->
- * <argument value="50000000"/> <!-- argv[2] -->
- * <argument value="1000000"/> <!-- argv[3] -->
- * <argument value="5"/> <!-- argv[4] -->
- * </actor>
- *
- * <!-- Start an actor called 'worker' on the host called 'Jupiter' -->
- * <actor host="Jupiter" function="worker"/> <!-- Don't provide any parameter ->>
- *
- * </platform>
- * @endcode
- *
- * @{
- */
-
-/** @brief Simulation Agent */
+ * \endrst */
class XBT_PUBLIC Actor : public xbt::Extendable<Actor> {
#ifndef DOXYGEN
friend Exec;
explicit Actor(smx_actor_t pimpl) : pimpl_(pimpl) {}
public:
-
+#ifndef DOXYGEN
// ***** No copy *****
Actor(Actor const&) = delete;
Actor& operator=(Actor const&) = delete;
// ***** Reference count *****
friend XBT_PUBLIC void intrusive_ptr_add_ref(Actor * actor);
friend XBT_PUBLIC void intrusive_ptr_release(Actor * actor);
+#endif
+ /** Retrieve the amount of references on that object. Useful to debug the automatic refcounting */
int get_refcount();
// ***** Actor creation *****
static xbt::signal<void(Actor const&)> on_sleep;
/** Signal to others that an actor wakes up for a sleep **/
static xbt::signal<void(Actor const&)> on_wake_up;
- /** Signal to others that an actor is going to migrated to another host**/
- static xbt::signal<void(Actor const&)> on_migration_start;
/** Signal to others that an actor is has been migrated to another host **/
- static xbt::signal<void(Actor const&)> on_migration_end;
+ static xbt::signal<void(Actor const&, Host const& previous_location)> on_host_change;
+#ifndef DOXYGEN
+ static xbt::signal<void(Actor const&)> on_migration_start; // XBT_ATTRIB_DEPRECATED_v329
+ static xbt::signal<void(Actor const&)> on_migration_end; // XBT_ATTRIB_DEPRECATED_v329
+#endif
+
/** Signal indicating that an actor terminated its code.
* The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore.
* If you want to free extra data when the actor's destructor is called, use Actor::on_destruction.
* If you want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
static xbt::signal<void(Actor const&)> on_destruction;
- /** Create an actor from a std::function<void()>
- *
- * If the actor is restarted, the actor has a fresh copy of the function.
- */
+ /** Create an actor from a std::function<void()>.
+ * If the actor is restarted, it gets a fresh copy of the function. */
static ActorPtr create(const std::string& name, s4u::Host* host, const std::function<void()>& code);
+ /** Create an actor, but don't start it yet.
+ *
+ * This is usefull to set some properties or extension before actually starting it */
static ActorPtr init(const std::string& name, s4u::Host* host);
+ /** Start a previously initialized actor */
ActorPtr start(const std::function<void()>& code);
- /** Create an actor from a std::function
- *
- * If the actor is restarted, the actor has a fresh copy of the function.
- */
+ /** Create an actor from a callable thing. */
template <class F> static ActorPtr create(const std::string& name, s4u::Host* host, F code)
{
return create(name, host, std::function<void()>(std::move(code)));
return create(name, host, std::bind(std::move(code), std::move(args)...));
}
- // Create actor from function name:
+ /** Create actor from function name and a vector of strings as arguments. */
static ActorPtr create(const std::string& name, s4u::Host* host, const std::string& function,
std::vector<std::string> args);
/** Retrieves the actor ID of that actor's creator */
aid_t get_ppid() const;
- /** Suspend an actor, that is blocked until resume()ed by another actor */
+ /** Suspend an actor, that is blocked until resumeed by another actor */
void suspend();
- /** Resume an actor that was previously suspend()ed */
+ /** Resume an actor that was previously suspended */
void resume();
/** Returns true if the actor is suspended. */
* Asynchronous activities started by the actor are not migrated automatically, so you have
* to take care of this yourself (only you knows which ones should be migrated).
*/
- void migrate(Host * new_host);
+ void set_host(Host* new_host);
+#ifndef DOXYGEN
+ XBT_ATTRIB_DEPRECATED_v329("Please use set_host() instead") void migrate(Host* new_host) { set_host(new_host); }
+#endif
/** Ask the actor to die.
*
* Any blocking activity will be canceled, and it will be rescheduled to free its memory.
* Being killed is not something that actors can defer or avoid.
- *
- * SimGrid still have sometimes issues when you kill actors that are currently communicating and such.
- * Still. Please report any bug that you may encounter with a minimal working example.
*/
void kill();
* blocked until bob terminates.
*/
void join(double timeout);
+ /** Kill that actor and restart it from start. */
Actor* restart();
/** Kill all actors (but the issuer). Being killed is not something that actors can delay or avoid. */
XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
const std::vector<double>& bytes_amounts);
-/** \rst
- * Block the current actor until the built :ref:`parallel execution <API_s4u_parallel_execute>` completes, or until the
- * timeout. \endrst
- */
+/** Block the current actor until the built parallel execution completes, or until the timeout. */
XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
const std::vector<double>& bytes_amounts, double timeout);
+/** Initialize a sequential execution that must then be started manually */
XBT_PUBLIC ExecPtr exec_init(double flops_amounts);
+/** Initialize a parallel execution that must then be started manually */
XBT_PUBLIC ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
const std::vector<double>& bytes_amounts);
XBT_PUBLIC void on_exit(const std::function<void(bool)>& fun);
/** @brief Migrate the current actor to a new host. */
-XBT_PUBLIC void migrate(Host* new_host);
+XBT_PUBLIC void set_host(Host* new_host);
+#ifndef DOXYGEN
+XBT_ATTRIB_DEPRECATED_v329("Please use set_host() instead") XBT_PUBLIC void migrate(Host* new_host);
+#endif
/** @} */
}
std::atomic_int_fast32_t refcount_{0};
public:
+ /** Creates a barrier for the given amount of actors */
explicit Barrier(unsigned int count);
- ~Barrier() = default;
#ifndef DOXYGEN
+ ~Barrier() = default;
Barrier(Barrier const&) = delete;
Barrier& operator=(Barrier const&) = delete;
#endif
+ /** Creates a barrier for the given amount of actors */
static BarrierPtr create(unsigned int expected_actors);
+ /** Blocks into the barrier. Every waiting actors will be unlocked once the expected amount of actors reaches the barrier */
int wait();
#ifndef DOXYGEN
public:
explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {}
+
+#ifndef DOXYGEN
ConditionVariable(ConditionVariable const&) = delete;
ConditionVariable& operator=(ConditionVariable const&) = delete;
friend XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariable * cond);
friend XBT_PUBLIC void intrusive_ptr_release(ConditionVariable * cond);
+#endif
static ConditionVariablePtr create();
/** Finalize the default engine and all its dependencies */
static void shutdown();
- /** @brief Run the simulation */
+ /** @brief Run the simulation after initialization */
void run();
/** @brief Retrieve the simulation time (in seconds) */
/** @brief Retrieve the engine singleton */
static s4u::Engine* get_instance();
- /** @brief Load a platform file describing the environment
- *
- * The environment is either a XML file following the simgrid.dtd formalism, or a lua file.
- * Some examples can be found in the directory examples/platforms.
- */
void load_platform(const std::string& platf);
- /** Registers the main function of an actor that will be launched from the deployment file */
void register_function(const std::string& name, int (*code)(int, char**));
- /** Registers the main function of an actor that will be launched from the deployment file */
void register_function(const std::string& name, void (*code)(std::vector<std::string>));
-
- /** Registers a function as the default main function of actors
- *
- * It will be used as fallback when the function requested from the deployment file was not registered.
- * It is used for trace-based simulations (see examples/s4u/replay-comms and similar).
- */
void register_default(int (*code)(int, char**));
template <class F> void register_actor(const std::string& name)
});
}
- /** @brief Load a deployment file and launch the actors that it contains */
void load_deployment(const std::string& deploy);
protected:
#include <simgrid/forward.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC sg_sem_t sg_sem_init(int initial_value);
XBT_PUBLIC void sg_sem_acquire(sg_sem_t sem);
XBT_PUBLIC int sg_sem_acquire_timeout(sg_sem_t sem, double timeout);
XBT_PUBLIC void sg_sem_destroy(sg_sem_t sem);
XBT_PUBLIC int sg_sem_would_block(sg_sem_t sem);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_SEMAPHORE_H_ */
#include <set>
#endif
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @brief Link opaque datatype
@ingroup SD_link_api
//SD_route_get_size
//SD_route_get_list
//TRACE_sd_set_task_category
-SG_END_DECL()
+SG_END_DECL
#ifdef __cplusplus
namespace simgrid {
} e_smx_state_t;
/** @} */
-/* ****************************** Process *********************************** */
-
-typedef enum {
- SMX_EXIT_SUCCESS = 0,
- SMX_EXIT_FAILURE = 1
-} smx_process_exit_status_t;
-/** @} */
-
/******************************* Networking ***********************************/
extern unsigned smx_context_stack_size;
extern unsigned smx_context_guard_size;
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC smx_actor_t SIMIX_process_from_PID(aid_t PID);
double SIMIX_timer_get_date(smx_timer_t timer);
XBT_PUBLIC void SIMIX_display_process_status();
-SG_END_DECL()
+SG_END_DECL
/******************************** Deployment **********************************/
-SG_BEGIN_DECL()
-XBT_PUBLIC void SIMIX_function_register_default(xbt_main_func_t code);
+SG_BEGIN_DECL
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_register_default() or Engine::register_default()") XBT_PUBLIC
+ void SIMIX_function_register_default(xbt_main_func_t code);
+XBT_ATTRIB_DEPRECATED_v329("This function will be removed in 3.29") XBT_PUBLIC void SIMIX_init_application();
-XBT_PUBLIC void SIMIX_init_application();
XBT_PUBLIC void SIMIX_process_set_function(const char* process_host, const char* process_function,
xbt_dynar_t arguments, double process_start_time, double process_kill_time);
-SG_END_DECL()
+SG_END_DECL
#ifdef __cplusplus
-XBT_PUBLIC void SIMIX_function_register(const std::string& name, void (*code)(std::vector<std::string>));
-XBT_PUBLIC void SIMIX_function_register(const std::string& name, xbt_main_func_t code);
-XBT_PUBLIC void SIMIX_launch_application(const std::string& file);
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_register_function() or Engine::register_function()") XBT_PUBLIC
+ void SIMIX_function_register(const std::string& name, void (*code)(std::vector<std::string>));
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_register_function() or Engine::register_function()") XBT_PUBLIC
+ void SIMIX_function_register(const std::string& name, xbt_main_func_t code);
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_load_deployment() or Engine::load_deployment()") XBT_PUBLIC
+ void SIMIX_launch_application(const std::string& file);
#endif
/********************************* Process ************************************/
-SG_BEGIN_DECL()
-XBT_PUBLIC int SIMIX_process_count();
+SG_BEGIN_DECL
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_get_actor_count()") XBT_PUBLIC int SIMIX_process_count();
XBT_PUBLIC smx_actor_t SIMIX_process_self();
XBT_PUBLIC const char* SIMIX_process_self_get_name();
-XBT_PUBLIC void SIMIX_process_self_set_data(void* data);
-XBT_PUBLIC void* SIMIX_process_self_get_data();
-SG_END_DECL()
+XBT_ATTRIB_DEPRECATED_v329("This function will be removed in 3.29") XBT_PUBLIC
+ void SIMIX_process_self_set_data(void* data);
+XBT_ATTRIB_DEPRECATED_v329("This function will be removed in 3.29") XBT_PUBLIC void* SIMIX_process_self_get_data();
+SG_END_DECL
#ifdef __cplusplus
XBT_PUBLIC void SIMIX_process_on_exit(smx_actor_t process, const std::function<void(bool /*failed*/)>& fun);
#endif
/**************************** Process simcalls ********************************/
-SG_BEGIN_DECL()
-void simcall_process_set_data(smx_actor_t process, void* data);
+SG_BEGIN_DECL
+XBT_ATTRIB_DEPRECATED_v329("This function will be removed in 3.29") void simcall_process_set_data(smx_actor_t process,
+ void* data);
XBT_ATTRIB_DEPRECATED_v328("Please use Actor::suspend()") XBT_PUBLIC void simcall_process_suspend(smx_actor_t process);
XBT_ATTRIB_DEPRECATED_v328("Please use Actor::join()") XBT_PUBLIC
void simcall_process_join(smx_actor_t process, double timeout);
-/* Sleep control */
-XBT_PUBLIC e_smx_state_t simcall_process_sleep(double duration);
-SG_END_DECL()
+XBT_ATTRIB_DEPRECATED_v329("Please use sg_actor_sleep_for()") XBT_PUBLIC e_smx_state_t
+ simcall_process_sleep(double duration);
+SG_END_DECL
/************************** Communication simcalls ****************************/
#endif
/************************** Synchro simcalls **********************************/
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC smx_mutex_t simcall_mutex_init();
XBT_PUBLIC void simcall_mutex_lock(smx_mutex_t mutex);
XBT_PUBLIC int simcall_mutex_trylock(smx_mutex_t mutex);
XBT_PUBLIC void simcall_sem_acquire(smx_sem_t sem);
XBT_PUBLIC int simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration);
-SG_END_DECL()
+SG_END_DECL
/***************************** Io **************************************/
#ifdef __cplusplus
XBT_PUBLIC e_smx_state_t simcall_io_wait(const smx_activity_t& io);
#endif
/************************** MC simcalls **********************************/
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC int simcall_mc_random(int min, int max);
-SG_END_DECL()
+SG_END_DECL
#endif
#include <xbt/base.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC const char* sg_storage_get_name(sg_storage_t storage);
XBT_PUBLIC sg_storage_t sg_storage_get_by_name(const char* name);
XBT_PUBLIC sg_size_t sg_storage_read(sg_storage_t storage, sg_size_t size);
XBT_PUBLIC sg_size_t sg_storage_write(sg_storage_t storage, sg_size_t size);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_STORAGE_H_ */
#include <xbt/base.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @brief Opaque type describing a Virtual Machine.
* @ingroup msg_VMs
XBT_PUBLIC void sg_vm_shutdown(sg_vm_t vm);
XBT_PUBLIC void sg_vm_destroy(sg_vm_t vm);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_VM_H_ */
#include <xbt/dict.h>
/* C interface */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC sg_netzone_t sg_zone_get_root();
XBT_PUBLIC const char* sg_zone_get_name(sg_netzone_t zone);
XBT_PUBLIC void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, char* value);
XBT_PUBLIC void sg_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto);
-SG_END_DECL()
+SG_END_DECL
#endif /* INCLUDE_SIMGRID_ZONE_H_ */
namespace simgrid {
namespace smpi {
-class Coll;
class Colls;
class Comm;
class Datatype;
#define free(ptr) _sampi_free(ptr)
#endif
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void* _sampi_malloc(size_t size);
XBT_PUBLIC void* _sampi_calloc(size_t n_elm, size_t elm_size);
AMPI_CALL(XBT_PUBLIC int, MPI_Iteration_out, (MPI_Comm comm))
AMPI_CALL(XBT_PUBLIC void, MPI_Migrate, (MPI_Comm comm))
-SG_END_DECL()
+SG_END_DECL
#endif
type _XBT_CONCAT(P, name) args
#endif
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
#define MPI_THREAD_SINGLE 0
#define MPI_THREAD_FUNNELED 1
#define MPI_THREAD_SERIALIZED 2
XBT_PUBLIC_DATA const MPI_Datatype MPI_COUNT;
//defines for fortran compatibility
-#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
+#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__) || defined(__aarch64__)
#define MPI_INTEGER MPI_INT
#define MPI_2INTEGER MPI_2INT
#define MPI_LOGICAL MPI_INT
XBT_PUBLIC void SMPI_init();
XBT_PUBLIC void SMPI_finalize();
-SG_END_DECL()
+SG_END_DECL
/* C++ declarations for shared_malloc */
#ifdef __cplusplus
void set_data(void* data){
extensions_[0]=data;
}
- void* get_data(){
- return extensions_[0];
- }
+ void* get_data() const { return extensions_[0]; }
// Convenience extension access when the type has a associated EXTENSION ID:
template <class U> U* extension() const { return extension<U>(U::EXTENSION_ID); }
template<class U> void extension_set(U* p) { extension_set<U>(U::EXTENSION_ID, p); }
#include <xbt/log.h>
#include <xbt/misc.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC_DATA int xbt_log_no_loc; /* Do not show the backtrace on failed backtrace when doing our tests */
XBT_PUBLIC void xbt_backtrace_display_current();
#endif
/** @} */
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_ASSERTS_H */
#include <xbt/dynar.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
typedef struct xbt_automaton_state {
char* id;
XBT_PUBLIC void xbt_automaton_propositional_symbol_free_voidp(void* ps);
XBT_PUBLIC void xbt_automaton_free(xbt_automaton_t a);
-SG_END_DECL()
+SG_END_DECL
#endif
#include <string>
#include <vector>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @brief Shows a backtrace of the current location */
XBT_PUBLIC void xbt_backtrace_display_current();
-SG_END_DECL()
+SG_END_DECL
namespace simgrid {
namespace xbt {
/* C++ users need love */
#ifndef SG_BEGIN_DECL
# ifdef __cplusplus
-# define SG_BEGIN_DECL() extern "C" {
+# define SG_BEGIN_DECL extern "C" {
# else
-# define SG_BEGIN_DECL()
+# define SG_BEGIN_DECL
# endif
#endif
#ifndef SG_END_DECL
# ifdef __cplusplus
-# define SG_END_DECL() }
+# define SG_END_DECL }
# else
-# define SG_END_DECL()
+# define SG_END_DECL
# endif
#endif
/* End of cruft for C++ */
typedef void* xbt_cfg_t;
#endif
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Set the value of the cell @a name in @a cfg with the provided value.*/
XBT_PUBLIC void sg_cfg_set_int(const char* name, int val);
XBT_PUBLIC int sg_cfg_get_boolean(const char* name);
/** @} */
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_CONFIG_H */
#include <stdint.h> /* uintptr_t */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @addtogroup XBT_dict
* @brief The dictionary data structure (comparable to hash tables)
char buff[512];
sprintf(buff,"some very precious data");
- xbt_dict_set(mydict,"my data", strdup(buff), NULL);
+ xbt_dict_set(mydict,"my data", strdup(buff));
sprintf(buff,"another good stuff");
- xbt_dict_set(mydict,"my data", strdup(buff), NULL); // previous data gets erased (and freed) by second add
+ xbt_dict_set(mydict,"my data", strdup(buff)); // previous data gets erased (and freed) by second add
@endverbatim
*/
* @{
*/
-XBT_PUBLIC void xbt_dict_set(xbt_dict_t dict, const char* key, void* data, void_f_pvoid_t free_ctn);
+XBT_PUBLIC void xbt_dict_set(xbt_dict_t dict, const char* key, void* data);
XBT_PUBLIC void* xbt_dict_get(xbt_dict_t dict, const char* key);
XBT_PUBLIC void* xbt_dict_get_or_null(xbt_dict_t dict, const char* key);
XBT_PUBLIC char* xbt_dict_get_key(xbt_dict_t dict, const void* data);
*
* @{
*/
-XBT_PUBLIC void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data, void_f_pvoid_t free_ctn);
+XBT_PUBLIC void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data);
XBT_PUBLIC void* xbt_dict_get_ext(xbt_dict_t dict, const char* key, int key_len);
XBT_PUBLIC void* xbt_dict_get_or_null_ext(xbt_dict_t dict, const char* key, int key_len);
XBT_PUBLIC void xbt_dict_remove_ext(xbt_dict_t dict, const char* key, int key_len);
/** @} */
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_DICT_H */
#include <xbt/base.h> /* SG_BEGIN_DECL */
#include <xbt/function_types.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @addtogroup XBT_dynar
* @brief DynArr are dynamically sized vector which may contain any type of variables.
(_cursor)++)
#endif
/** @} */
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_DYNAR_H */
* exactly play nicely together.
*/
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** Helper function used to throw exceptions in C */
XBT_ATTRIB_NORETURN XBT_PUBLIC void _xbt_throw(char* message, int value, const char* file, int line, const char* func);
*/
#define DIE_IMPOSSIBLE xbt_die("The Impossible Did Happen (yet again)")
-SG_END_DECL()
+SG_END_DECL
/** @} */
#endif /* __XBT_EX_H__ */
#include <xbt/base.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
typedef void (*void_f_pvoid_t) (void *);
typedef void *(*pvoid_f_void_t) (void);
typedef int (*xbt_main_func_t) (int argc, char *argv[]);
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_FUNCTION_TYPE_H */
#include <xbt/dynar.h>
#include <xbt/misc.h> /* SG_BEGIN_DECL */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
- /** @addtogroup XBT_graph
- * @brief A graph data type with several interesting algorithms
- *
- * @{
- */
+/** @addtogroup XBT_graph
+ * @brief A graph data type with several interesting algorithms
+ *
+ * @{
+ */
typedef struct xbt_node *xbt_node_t;
typedef struct xbt_edge *xbt_edge_t;
XBT_PUBLIC xbt_node_t xbt_graph_edge_get_source(xbt_edge_t e);
XBT_PUBLIC xbt_node_t xbt_graph_edge_get_target(xbt_edge_t e);
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_GRAPH_H */
/** @} */
#include <stddef.h> /* NULL */
#include <stdio.h> /* FILE */
#include <xbt/misc.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/**@brief Log priorities
* @ingroup XBT_log
*
* Implementation of XBT_LOG_NEW_SUBCATEGORY, which must declare "extern parent" in addition to avoid an extra
* declaration of root when XBT_LOG_NEW_SUBCATEGORY is called by XBT_LOG_NEW_CATEGORY */
#define XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \
- SG_BEGIN_DECL() \
+ SG_BEGIN_DECL \
extern void _XBT_LOGV_CTOR(catName)(void) XBT_ATTRIB_CONSTRUCTOR(600); \
void _XBT_LOGV_CTOR(catName)(void) \
{ \
_xbt_log_cat_init(&_XBT_LOGV(catName), xbt_log_priority_uninitialized); \
} \
} \
- SG_END_DECL() \
+ SG_END_DECL \
XBT_EXPORT_NO_IMPORT s_xbt_log_category_t _XBT_LOGV(catName) = { \
&_XBT_LOGV(parent), \
NULL /* firstChild */, \
*/
#define XBT_HELP(...) XBT_CINFO(xbt_help, __VA_ARGS__)
-SG_END_DECL()
+SG_END_DECL
#endif /* ! _XBT_LOG_H_ */
#include <xbt/function_types.h>
#include <xbt/misc.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @addtogroup XBT_mallocator
* @brief The mallocator system
XBT_PUBLIC void xbt_mallocator_initialization_is_done(int protect);
/** @} */
-SG_END_DECL()
+SG_END_DECL
#endif /* _XBT_MALLOCATOR_H */
#include <stdarg.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** Cache the size of a memory page for the current system. */
XBT_PUBLIC_DATA int xbt_pagesize;
XBT_PUBLIC char* bprintf(const char* fmt, ...) XBT_ATTRIB_PRINTF(1, 2);
/** @} */
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_MISC_H */
#include <xbt/misc.h> /* XBT_PUBLIC */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC void xbt_init(int* argc, char** argv);
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_MODULE_H */
#include <stdarg.h> /* va_* */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @addtogroup XBT_str
* @brief String manipulation functions
}
/**@}*/
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_STR_H */
#include <xbt/function_types.h>
#include <xbt/misc.h> /* SG_BEGIN_DECL */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @addtogroup XBT_synchro
* @brief XBT synchronization tools
/** @} */
-SG_END_DECL()
+SG_END_DECL
#endif /* _XBT_THREAD_H */
#include <stdlib.h>
#include <stdarg.h> /* va_list */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* They live in asserts.h, but need to be declared before this module.
double declaration to cut dependency cycle */
/** @brief should be given a pointer to pointer, and frees the second one */
XBT_PUBLIC void xbt_free_ref(void* d) XBT_FREE_NOEXCEPT;
-SG_END_DECL()
+SG_END_DECL
#define xbt_new(type, count) ((type*)xbt_malloc (sizeof (type) * (count)))
/** @brief like calloc, but xbt_die() on error
#include <xbt/function_types.h>
#include <xbt/misc.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
XBT_PUBLIC const char* xbt_procname(void);
/** Contains all the parameters we got from the command line (including argv[0]) */
XBT_PUBLIC_DATA xbt_dynar_t xbt_cmdline;
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_VIRTU_H */
#include <xbt/misc.h> /* XBT_PUBLIC */
#include <stddef.h> /* size_t */
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @brief get time in seconds
*
XBT_PUBLIC void xbt_os_threadtimer_resume(xbt_os_timer_t timer);
XBT_PUBLIC void xbt_os_threadtimer_stop(xbt_os_timer_t timer);
-SG_END_DECL()
+SG_END_DECL
#endif
#sonar.java.binaries
#sonar.cfamily.build-wrapper-output
#sonar.cfamily.gcov.reportsPath
-#sonar.python.coverage.reportPath
+#sonar.python.coverage.reportPaths
#sonar.coverage.jacoco.xmlReportPaths
#sonar.cfamily.threads
{
const char *deploymentFile = env->GetStringUTFChars(jdeploymentFile, 0);
- SIMIX_function_register_default(java_main);
+ simgrid_register_default(java_main);
MSG_launch_application(deploymentFile);
}
#include "simgrid/msg.h"
#include <jni.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
#ifndef JNIEXPORT
JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAll(JNIEnv *env, jclass cls, jobjectArray jcomms, jdouble timeout);
JNIEXPORT int JNICALL Java_org_simgrid_msg_Comm_waitAny(JNIEnv *env, jclass cls, jobjectArray jcomms);
-SG_END_DECL()
+SG_END_DECL
#endif
#include "simgrid/plugins/file_system.h"
#include <jni.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
#ifndef JNIEXPORT
JNIEXPORT void JNICALL Java_org_simgrid_msg_File_seek(JNIEnv *env, jobject jfile, jlong joffset, jlong jorigin);
JNIEXPORT void JNICALL Java_org_simgrid_msg_File_close(JNIEnv *env, jobject jfile);
-SG_END_DECL()
+SG_END_DECL
#endif
#include "simgrid/plugins/file_system.h"
#include <jni.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
#ifndef JNIEXPORT
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentLoad(JNIEnv *env, jobject jhost);
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getAvgLoad(JNIEnv *env, jobject jhost);
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getComputedFlops (JNIEnv *env, jobject jhost);
-SG_END_DECL()
+SG_END_DECL
#endif
}
/* change the host of the process */
- process->migrate(host);
+ process->set_host(host);
/* change the host java side */
env->SetObjectField(jprocess, jprocess_field_Process_host, jhost);
#include "simgrid/msg.h"
#include <jni.h>
-SG_BEGIN_DECL();
+SG_BEGIN_DECL;
/* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
#ifndef JNIEXPORT
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime(JNIEnv* env, jobject jprocess, jdouble jkilltime);
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
-SG_END_DECL();
+SG_END_DECL;
#endif
#include "simgrid/msg.h"
#include <jni.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** Returns a new java instance of a storage. */
jobject jstorage_new_instance(JNIEnv * env);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getHost(JNIEnv * env,jobject jstorage);
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Storage_all(JNIEnv *env, jclass cls);
-SG_END_DECL()
+SG_END_DECL
#endif
#include "xbt/base.h"
#include <jni.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeInit(JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_init(JNIEnv * env, jobject obj);
JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Semaphore_wouldBlock(JNIEnv * env, jobject obj);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_nativeFinalize(JNIEnv * env, jobject obj);
-SG_END_DECL()
+SG_END_DECL
#endif
#include <jni.h>
#include "simgrid/msg.h"
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** Binds a native instance to a java instance. */
void jtask_bind(jobject jtask, msg_task_t task, JNIEnv * env);
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Task_listenFromHost(JNIEnv* env, jclass cls, jstring jalias, jobject jhost);
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Task_listenFrom(JNIEnv* env, jclass cls, jstring jalias);
-SG_END_DECL()
+SG_END_DECL
#endif
#include <jni.h>
#include "simgrid/msg.h"
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
#ifndef JNIEXPORT
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_shutdown(JNIEnv* env, jobject jvm);
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_destroy(JNIEnv* env, jobject jvm);
-SG_END_DECL()
+SG_END_DECL
#endif
#endif
/* end of eclipse-mandated pimple */
-// Define a new category
-XBT_LOG_NEW_DEFAULT_CATEGORY (jtrace, "TRACE for Java(TM)");
-
JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostStateDeclare(JNIEnv * env, jclass cls, jstring js)
{
const char *s = env->GetStringUTFChars(js, 0);
#include "simgrid/s4u/Host.hpp"
#include <lauxlib.h>
-XBT_LOG_NEW_DEFAULT_CATEGORY(lua_host, "Lua Host module");
-
constexpr char HOST_MODULE_NAME[] = "simgrid.host";
constexpr char HOST_FIELDNAME[] = "__simgrid_host";
#include <lauxlib.h>
-XBT_LOG_NEW_DEFAULT_CATEGORY(lua_platf, "Lua bindings (platform module)");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_platf, lua, "Lua bindings (platform module)");
constexpr char PLATF_MODULE_NAME[] = "simgrid.engine";
constexpr char AS_FIELDNAME[] = "__simgrid_as";
py::arg("flops"), py::arg("priority") = 1);
m2.def("exec_init", [](double flops){return simgrid::s4u::this_actor::exec_init(flops);});
m2.def("get_host", &simgrid::s4u::this_actor::get_host, "Retrieves host on which the current actor is located");
- m2.def("migrate", &simgrid::s4u::this_actor::migrate, "Moves the current actor to another host, see :cpp:func:`void simgrid::s4u::this_actor::migrate()`",
- py::arg("dest"));
+ m2.def("set_host", &simgrid::s4u::this_actor::set_host,
+ "Moves the current actor to another host, see :cpp:func:`void simgrid::s4u::this_actor::set_host()`",
+ py::arg("dest"));
m2.def("sleep_for", sleep_for_fun,
"Block the actor sleeping for that amount of seconds, see :cpp:func:`void simgrid::s4u::this_actor::sleep_for`", py::arg("duration"));
m2.def("sleep_until", sleep_until_fun,
}
});
},
- "Create an actor from a function or an object, see :cpp:func:`simgrid::s4u::Actor::create()`")
- .def_property("host", &Actor::get_host, &Actor::migrate, "The host on which this actor is located")
+ "Create an actor from a function or an object.")
+ .def_property("host", &Actor::get_host, &Actor::set_host, "The host on which this actor is located")
+ .def_property_readonly("name", &Actor::get_cname, "The name of this actor.")
.def_property_readonly("pid", &Actor::get_pid, "The PID (unique identifier) of this actor.")
+ .def_property_readonly("ppid", &Actor::get_ppid,
+ "The PID (unique identifier) of the actor that created this one.")
.def("by_pid", &Actor::by_pid, "Retrieve an actor by its PID")
.def("daemonize", &Actor::daemonize,
- "This actor will be automatically terminated when the last non-daemon actor finishes, see :cpp:func:`void "
- "simgrid::s4u::Actor::daemonize()`")
+ "This actor will be automatically terminated when the last non-daemon actor finishes (more info in the C++ "
+ "documentation).")
+ .def("is_daemon", &Actor::is_daemon,
+ "Returns True if that actor is a daemon and will be terminated automatically when the last non-daemon actor "
+ "terminates.")
.def("join", py::overload_cast<double>(&Actor::join),
- "Wait for the actor to finish, see :cpp:func:`void simgrid::s4u::Actor::join(double)`", py::arg("timeout"))
+ "Wait for the actor to finish (more info in the C++ documentation).", py::arg("timeout"))
.def("kill", [](ActorPtr act) { act->kill(); }, "Kill that actor")
.def("kill_all", &Actor::kill_all, "Kill all actors but the caller.")
- .def("migrate", &Actor::migrate,
- "Moves that actor to another host, see :cpp:func:`void simgrid::s4u::Actor::migrate()`", py::arg("dest"))
- .def("self", &Actor::self, "Retrieves the current actor, see :cpp:func:`void simgrid::s4u::Actor::self()`")
+ .def("self", &Actor::self, "Retrieves the current actor.")
.def("is_suspended", &Actor::is_suspended, "Returns True if that actor is currently suspended.")
.def("suspend", &Actor::suspend, "Suspend that actor, that is blocked until resume()ed by another actor.")
.def("resume", &Actor::resume, "Resume that actor, that was previously suspend()ed.");
#include <ucontext.h>
#endif
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
struct s_stack_region{
void *address;
};
typedef struct s_stack_region s_stack_region_t;
-SG_END_DECL()
+SG_END_DECL
#endif
#define STD_HEAP_SIZE (sizeof(void*)<=4 ? (100*1024*1024) : (1ll*1024*1024*1024*1024))
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/********************************* Global *************************************/
XBT_ATTRIB_NORETURN XBT_PUBLIC void MC_run();
/********************************* Memory *************************************/
XBT_PUBLIC void MC_memory_init(); /* Initialize the memory subsystem */
-SG_END_DECL()
+SG_END_DECL
#endif
#include <xbt/base.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
#ifdef COVERAGE
extern void __gcov_flush();
#define coverage_checkpoint() (void)0
#endif
-SG_END_DECL()
+SG_END_DECL
#endif
#include "xbt/dict.h"
#include "xbt/dynar.h"
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Datatype representing a separate heap. The whole point of the mmalloc module is to allow several such heaps in the
* process. It thus works by redefining all the classical memory management functions (malloc and friends) with an
xbt_mheap_t mmalloc_get_current_heap(void);
#endif
-SG_END_DECL()
+SG_END_DECL
#endif /* SIMGRID_MMALLOC_H */
});
}
-static long long int counter = 0;
-
-static void instr_actor_on_migration_start(simgrid::s4u::Actor const& actor)
+static void instr_actor_on_host_change(simgrid::s4u::Actor const& actor,
+ simgrid::s4u::Host const& /*previous_location*/)
{
- // start link
+ static long long int counter = 0;
container_t container = simgrid::instr::Container::by_name(instr_pid(actor));
- simgrid::instr::Container::get_root()->get_link("ACTOR_LINK")->start_event(container, "M", std::to_string(counter));
+ simgrid::instr::LinkType* link = simgrid::instr::Container::get_root()->get_link("ACTOR_LINK");
+ // start link
+ link->start_event(container, "M", std::to_string(counter));
// destroy existing container of this process
container->remove_from_parent();
-}
-
-static void instr_actor_on_migration_end(simgrid::s4u::Actor const& actor)
-{
// create new container on the new_host location
simgrid::instr::Container::by_name(actor.get_host()->get_name())->create_child(instr_pid(actor), "ACTOR");
// end link
- simgrid::instr::Container::get_root()
- ->get_link("ACTOR_LINK")
- ->end_event(simgrid::instr::Container::by_name(instr_pid(actor)), "M", std::to_string(counter));
+ link->end_event(simgrid::instr::Container::by_name(instr_pid(actor)), "M", std::to_string(counter));
counter++;
}
simgrid::s4u::Comm::on_completion.connect([](simgrid::s4u::Actor const& actor) {
simgrid::instr::Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event();
});
- simgrid::s4u::Actor::on_migration_start.connect(instr_actor_on_migration_start);
- simgrid::s4u::Actor::on_migration_end.connect(instr_actor_on_migration_end);
+ simgrid::s4u::Actor::on_host_change.connect(instr_actor_on_host_change);
}
if (TRACE_vm_is_enabled()) {
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/EngineImpl.hpp"
+#include "simgrid/Exception.hpp"
#include "simgrid/kernel/routing/NetPoint.hpp"
#include "simgrid/kernel/routing/NetZoneImpl.hpp"
#include "simgrid/s4u/Host.hpp"
#include "src/kernel/resource/DiskImpl.hpp"
+#include "src/simix/smx_private.hpp"
#include "src/surf/StorageImpl.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/xml/platf_private.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
+
+extern int surf_parse_lineno;
namespace simgrid {
namespace kernel {
for (auto const& kv : storages_)
if (kv.second)
- kv.second->get_impl()->destroy();
+ kv.second->destroy();
for (auto const& kv : links_)
if (kv.second)
- kv.second->get_impl()->destroy();
+ kv.second->destroy();
+}
+
+void EngineImpl::load_deployment(const std::string& file)
+{
+ sg_platf_exit();
+ sg_platf_init();
+
+ surf_parse_open(file);
+ surf_parse();
+ surf_parse_close();
+}
+void EngineImpl::register_function(const std::string& name, xbt_main_func_t code)
+{
+ simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
+ return simgrid::xbt::wrap_main(code, std::move(args));
+ };
}
+
+void EngineImpl::register_function(const std::string& name, void (*code)(std::vector<std::string>))
+{
+ simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
+ return std::bind(std::move(code), std::move(args));
+ };
}
+
+void EngineImpl::register_default(xbt_main_func_t code)
+{
+ simix_global->default_function = [code](std::vector<std::string> args) {
+ return simgrid::xbt::wrap_main(code, std::move(args));
+ };
}
+
+} // namespace kernel
+} // namespace simgrid
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <simgrid/s4u/NetZone.hpp>
-
#include <map>
+#include <simgrid/s4u/NetZone.hpp>
+#include <simgrid/simix.hpp>
#include <string>
#include <unordered_map>
class EngineImpl {
std::map<std::string, s4u::Host*> hosts_;
- std::map<std::string, s4u::Link*> links_;
- std::map<std::string, s4u::Storage*> storages_;
+ std::map<std::string, resource::LinkImpl*> links_;
+ std::map<std::string, resource::StorageImpl*> storages_;
std::unordered_map<std::string, routing::NetPoint*> netpoints_;
friend s4u::Engine;
EngineImpl(const EngineImpl&) = delete;
EngineImpl& operator=(const EngineImpl&) = delete;
virtual ~EngineImpl();
+
+ void load_deployment(const std::string& file);
+ void register_function(const std::string& name, xbt_main_func_t code);
+ void register_function(const std::string& name, void (*code)(std::vector<std::string>));
+ void register_default(xbt_main_func_t code);
+
routing::NetZoneImpl* netzone_root_ = nullptr;
};
#include "src/kernel/activity/MutexImpl.hpp"
#include "src/kernel/activity/SynchroRaw.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ConditionVariable, simix_synchro, "Condition variables");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_condition, simix_synchro, "Condition variables");
/********************************* Condition **********************************/
actor->set_properties(*properties);
/* Add the process to it's host process list */
- host->pimpl_->process_list_.push_back(*actor);
+ host->pimpl_->add_actor(actor);
/* Now insert it in the global process list and in the process to run list */
simix_global->process_list[actor->get_pid()] = actor;
simix_global->mutex.lock();
simix_global->process_list.erase(pid_);
- if (host_ && host_process_list_hook.is_linked())
- simgrid::xbt::intrusive_erase(host_->pimpl_->process_list_, *this);
+ if (host_ && host_actor_list_hook.is_linked())
+ host_->pimpl_->remove_actor(this);
if (not smx_destroy_list_hook.is_linked()) {
#if SIMGRID_HAVE_MC
xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this);
void ActorImpl::kill(ActorImpl* actor)
{
+ xbt_assert(actor != simix_global->maestro_process, "Killing maestro is a rather bad idea");
if (actor->finished_) {
XBT_DEBUG("Ignoring request to kill actor %s@%s that is already dead", actor->get_cname(),
actor->host_->get_cname());
if (context_->iwannadie) {
XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
- // throw simgrid::kernel::context::ForcefulKillException(); Does not seem to properly kill the actor
context_->stop();
THROW_IMPOSSIBLE;
}
void ActorImpl::set_host(s4u::Host* dest)
{
- xbt::intrusive_erase(host_->pimpl_->process_list_, *this);
+ host_->pimpl_->remove_actor(this);
host_ = dest;
- dest->pimpl_->process_list_.push_back(*this);
+ dest->pimpl_->add_actor(this);
}
ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host)
XBT_DEBUG("Start context '%s'", get_cname());
/* Add the actor to its host's actor list */
- host_->pimpl_->process_list_.push_back(*this);
+ host_->pimpl_->add_actor(this);
simix_global->process_list[pid_] = this;
/* Now insert it in the global actor list and in the actor to run list */
} // namespace kernel
} // namespace simgrid
-int SIMIX_process_count()
+int SIMIX_process_count() // XBT_ATTRIB_DEPRECATED_v329
{
return simix_global->process_list.size();
}
+// XBT_DEPRECATED_v329
void* SIMIX_process_self_get_data()
{
smx_actor_t self = SIMIX_process_self();
return self->get_user_data();
}
+// XBT_DEPRECATED_v329
void SIMIX_process_self_set_data(void* data)
{
SIMIX_process_self()->set_user_data(data);
by exceptions and logging events */
const char* SIMIX_process_self_get_name()
{
-
- smx_actor_t process = SIMIX_process_self();
- if (process == nullptr || process == simix_global->maestro_process)
- return "maestro";
-
- return process->get_cname();
+ return SIMIX_is_maestro() ? "maestro" : SIMIX_process_self()->get_cname();
}
/**
class XBT_PUBLIC ActorImpl : public surf::PropertyHolder {
s4u::Host* host_ = nullptr; /* the host on which the actor is running */
+ // XBT_DEPRECATED_v329
void* userdata_ = nullptr; /* kept for compatibility, it should be replaced with moddata */
aid_t pid_ = 0;
aid_t ppid_ = -1;
double get_kill_time();
void set_kill_time(double kill_time);
- boost::intrusive::list_member_hook<> host_process_list_hook; /* simgrid::simix::Host::process_list */
+ boost::intrusive::list_member_hook<> host_actor_list_hook; /* simgrid::simix::Host::process_list */
boost::intrusive::list_member_hook<> smx_destroy_list_hook; /* simix_global->actors_to_destroy */
boost::intrusive::list_member_hook<> smx_synchro_hook; /* {mutex,cond,sem}->sleeping */
// Accessors to private fields
s4u::Host* get_host() { return host_; }
void set_host(s4u::Host* dest);
+ // XBT_DEPRECATED_v329
void* get_user_data() { return userdata_; }
+ // XBT_DEPRECATED_v329
void set_user_data(void* data) { userdata_ = data; }
aid_t get_pid() const { return pid_; }
aid_t get_ppid() const { return ppid_; }
class DiskImpl : public Resource, public surf::PropertyHolder {
bool currently_destroying_ = false;
s4u::Host* host_ = nullptr;
+ s4u::Disk piface_;
public:
DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
~DiskImpl() override;
/** @brief Public interface */
- s4u::Disk piface_;
s4u::Disk* get_iface() { return &piface_; }
/** @brief Check if the Storage is used (if an action currently uses its resources) */
bool is_used() override;
std::vector<std::string> parameters;
std::vector<std::string> tmp;
boost::split(parameters, cluster->topo_parameters, boost::is_any_of(";"));
- const std::string error_msg {"Fat trees are defined by the levels number and 3 vectors, see the documentation for more information"};
// TODO : we have to check for zeros and negative numbers, or it might crash
- if (parameters.size() != 4) {
- surf_parse_error(error_msg);
- }
+ surf_parse_assert(
+ parameters.size() == 4,
+ "Fat trees are defined by the levels number and 3 vectors, see the documentation for more information.");
// The first parts of topo_parameters should be the levels number
try {
this->levels_ = std::stoi(parameters[0]);
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("First parameter is not the amount of levels:") + parameters[0]);
+ surf_parse_error(std::string("First parameter is not the amount of levels: ") + parameters[0]);
}
// Then, a l-sized vector standing for the children number by level
boost::split(tmp, parameters[1], boost::is_any_of(","));
- if (tmp.size() != this->levels_) {
- surf_parse_error(error_msg);
- }
+ surf_parse_assert(tmp.size() == this->levels_, std::string("You specified ") + std::to_string(this->levels_) +
+ " levels but the child count vector (the first one) contains " +
+ std::to_string(tmp.size()) + " levels.");
+
for (size_t i = 0; i < tmp.size(); i++) {
try {
this->num_children_per_node_.push_back(std::stoi(tmp[i]));
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid lower level node number:") + tmp[i]);
+ surf_parse_error(std::string("Invalid child count: ") + tmp[i]);
}
}
// Then, a l-sized vector standing for the parents number by level
boost::split(tmp, parameters[2], boost::is_any_of(","));
- if (tmp.size() != this->levels_) {
- surf_parse_error(error_msg);
- }
+ surf_parse_assert(tmp.size() == this->levels_, std::string("You specified ") + std::to_string(this->levels_) +
+ " levels but the parent count vector (the second one) contains " +
+ std::to_string(tmp.size()) + " levels.");
for (size_t i = 0; i < tmp.size(); i++) {
try {
this->num_parents_per_node_.push_back(std::stoi(tmp[i]));
} catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid upper level node number:") + tmp[i]);
+ surf_parse_error(std::string("Invalid parent count: ") + tmp[i]);
}
}
// Finally, a l-sized vector standing for the ports number with the lower level
boost::split(tmp, parameters[3], boost::is_any_of(","));
- if (tmp.size() != this->levels_) {
- surf_parse_error(error_msg);
- }
+ surf_parse_assert(tmp.size() == this->levels_, std::string("You specified ") + std::to_string(this->levels_) +
+ " levels but the port count vector (the third one) contains " +
+ std::to_string(tmp.size()) + " levels.");
for (size_t i = 0; i < tmp.size(); i++) {
try {
this->num_port_lower_level_.push_back(std::stoi(tmp[i]));
#include <memory>
#include <unistd.h>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_main, mc, "Entry point for simgrid-mc");
-
static inline
char** argvdup(int argc, char** argv)
{
* communicate with the MC (declared in modelchecker.h).
*/
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client_api, mc,
- "Public API for the model-checked application");
-
// MC_random() is in mc_base.cpp
void MC_assert(int prop)
using simgrid::mc::remote;
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_pattern, mc,
- "Logging specific to MC communication patterns");
-
static void MC_patterns_copy(std::vector<simgrid::mc::PatternCommunication*>& dest,
std::vector<simgrid::mc::PatternCommunication> const& source)
{
#include <climits>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_config, mc, "Configuration of the Model Checker");
-
#if SIMGRID_HAVE_MC
namespace simgrid {
namespace mc {
#include <sys/stat.h>
#include <fcntl.h>
-#include "xbt/log.h"
-
#include "mc/mc.h"
#include "src/mc/mc_private.hpp"
#include "src/xbt/mmalloc/mmprivate.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_memory, mc,
- "Logging specific to MC (memory)");
-
/* Initialize the model-checker memory subsystem */
/* It creates the two heap regions: std_heap and mc_heap */
void MC_memory_init()
using simgrid::mc::remote;
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_state, mc, "Logging specific to MC (state)");
-
namespace simgrid {
namespace mc {
while (1) {
ssize_t c = pread(this->memory_file, res.data() + off, res.size() - off, (off_t)address.address() + off);
- if (c == -1) {
- if (errno == EINTR)
- continue;
- else
- xbt_die("Could not read from from remote process");
- }
- if (c == 0)
- xbt_die("Could not read string from remote process");
+ if (c == -1 && errno == EINTR)
+ continue;
+ xbt_assert(c > 0, "Could not read string from remote process");
void* p = memchr(res.data() + off, '\0', c);
if (p)
#include "simgrid/forward.h"
#include "stdint.h"
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
// ***** Environment variables for passing context to the model-checked process
XBT_PRIVATE const char* MC_message_type_name(enum e_mc_message_type type);
-SG_END_DECL()
+SG_END_DECL
#endif
#include <cstring> // memcpy, memcmp
#include <unistd.h>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_page_snapshot, mc, "Logging specific to mc_page_snapshot");
-
namespace simgrid {
namespace mc {
#define MAP_POPULATE MAP_PREFAULT_READ
#endif
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_RegionSnaphot, mc, "Logging specific to region snapshots");
-
namespace simgrid {
namespace mc {
#include "src/instr/instr_private.hpp"
#include "src/msg/msg_private.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_comm, msg, "Logging specific to MSG (comm)");
-
namespace simgrid {
namespace msg {
#include <xbt/config.hpp>
XBT_LOG_NEW_CATEGORY(msg, "All MSG categories");
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, "Logging specific to MSG (kernel)");
bool MSG_Global_t::debug_multiple_use = false;
MSG_Global_t* msg_global = nullptr;
-simgrid::xbt::Extension<simgrid::s4u::Actor, simgrid::msg::ActorUserData> simgrid::msg::ActorUserData::EXTENSION_ID;
static void MSG_exit();
msg_global->sent_msg = 0;
msg_global->task_copy_callback = nullptr;
msg_global->process_data_cleanup = nullptr;
- MSG_process_userdata_init();
+ simgrid::s4u::Actor::on_termination.connect([](simgrid::s4u::Actor const& actor) {
+ // free the data if a function was provided
+ void* userdata = sg_actor_data(&actor);
+ if (userdata && msg_global->process_data_cleanup)
+ msg_global->process_data_cleanup(userdata);
+ });
}
if(MC_is_active()){
}
void MSG_process_migrate(sg_actor_t actor, sg_host_t host)
{
- sg_actor_migrate(actor, host);
+ sg_actor_set_host(actor, host);
}
void MSG_process_join(sg_actor_t actor, double timeout)
{
}
}
+/** @brief Returns the user data of a process.
+ *
+ * This function checks whether @a process is a valid pointer and returns the user data associated to this process.
+ */
+void* MSG_process_get_data(msg_process_t process)
+{
+ xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
+
+ /* get from SIMIX the MSG process data, and then the user data */
+ return sg_actor_data(process);
+}
+
+/** @brief Sets the user data of a process.
+ *
+ * This function checks whether @a process is a valid pointer and sets the user data associated to this process.
+ */
+msg_error_t MSG_process_set_data(msg_process_t process, void* data)
+{
+ xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
+ sg_actor_data_set(process, data);
+
+ return MSG_OK;
+}
+
msg_process_t MSG_process_attach(const char* name, void* data, msg_host_t host, xbt_dict_t properties)
{
return sg_actor_attach(name, data, host, properties);
{
sg_actor_unref(process);
}
-
+/** @brief Return the current number MSG processes. */
+int MSG_process_get_number()
+{
+ return simgrid_get_actor_count();
+}
/* ************************** NetZones *************************** */
sg_netzone_t MSG_zone_get_root()
{
#include "simgrid/msg.h"
#include "src/kernel/activity/CommImpl.hpp"
#include <simgrid/modelchecker.h>
+#include <xbt/Extendable.hpp>
#include <cmath>
/**************** datatypes **********************************/
namespace simgrid {
namespace msg {
-class Task {
+class Task : public xbt::Extendable<Task> {
std::string name_ = "";
std::string tracing_category_ = "";
- void* userdata_ = nullptr;
long long int id_;
double timeout_ = 0.0;
void set_tracing_category(const char* category) { tracing_category_ = category ? std::string(category) : ""; }
const std::string& get_tracing_category() { return tracing_category_; }
bool has_tracing_category() { return not tracing_category_.empty(); }
- void* get_user_data() { return userdata_; }
- void set_user_data(void* data) { userdata_ = data; }
+ XBT_ATTRIB_DEPRECATED_v329("Please use set_data()") void* get_user_data() { return get_data(); }
+ XBT_ATTRIB_DEPRECATED_v329("Please use get_data()") void set_user_data(void* data) { set_data(data); }
long long int get_id() { return id_; }
double get_priority() { return priority_; }
void set_priority(double priority);
msg_error_t get_status() { return status_; }
};
-class ActorUserData {
- void* userdata_ = nullptr;
-
-public:
- static xbt::Extension<simgrid::s4u::Actor, ActorUserData> EXTENSION_ID;
-
- void set_user_data(void* data) { userdata_ = data; }
- void* get_user_data() { return userdata_; }
-};
-
} // namespace msg
} // namespace simgrid
#include "src/instr/instr_private.hpp"
#include "src/simix/smx_private.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, "Logging specific to MSG (process)");
-
std::string instr_pid(simgrid::s4u::Actor const& proc)
{
return std::string(proc.get_name()) + "-" + std::to_string(proc.get_pid());
}
-void MSG_process_userdata_init()
-{
- if (not msg_global)
- msg_global = new MSG_Global_t();
-
- if (not simgrid::msg::ActorUserData::EXTENSION_ID.valid())
- simgrid::msg::ActorUserData::EXTENSION_ID = simgrid::s4u::Actor::extension_create<simgrid::msg::ActorUserData>();
- simgrid::s4u::Actor::on_creation.connect([](simgrid::s4u::Actor& actor) {
- XBT_DEBUG("creating the extension to store user data");
- actor.extension_set(new simgrid::msg::ActorUserData());
- });
-
- simgrid::s4u::Actor::on_destruction.connect([](simgrid::s4u::Actor const& actor) {
- // free the data if a function was provided
- auto extension = actor.extension<simgrid::msg::ActorUserData>();
- void* userdata = extension ? extension->get_user_data() : nullptr;
- if (userdata && msg_global->process_data_cleanup) {
- msg_global->process_data_cleanup(userdata);
- }
- });
-}
-
/******************************** Process ************************************/
/** @brief Creates and runs a new #msg_process_t.
*
int argc, char **argv, xbt_dict_t properties)
{
xbt_assert(host != nullptr, "Invalid parameters: host param must not be nullptr");
- simgrid::simix::ActorCode function;
- if (code)
- function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
-
- simgrid::s4u::ActorPtr actor;
+ sg_actor_t actor = sg_actor_init(std::move(name), host);
try {
if (data != nullptr) {
- actor = simgrid::s4u::Actor::init(std::move(name), host);
- actor->extension<simgrid::msg::ActorUserData>()->set_user_data(data);
+ sg_actor_data_set(actor, data);
xbt_dict_cursor_t cursor = nullptr;
char* key;
char* value;
xbt_dict_foreach (properties, cursor, key, value)
actor->set_property(key, value);
- actor->start(std::move(function));
- } else
- actor = simgrid::s4u::Actor::create(std::move(name), host, std::move(function));
+ }
+ sg_actor_start(actor, code, argc, argv);
} catch (simgrid::HostFailureException const&) {
xbt_die("Could not launch a new process on failed host %s.", host->get_cname());
}
xbt_free(argv);
simgrid::s4u::this_actor::yield();
- return actor.get();
-}
-
-/** @brief Returns the user data of a process.
- *
- * This function checks whether @a process is a valid pointer and returns the user data associated to this process.
- */
-void* MSG_process_get_data(msg_process_t process)
-{
- xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
-
- /* get from SIMIX the MSG process data, and then the user data */
- return process->extension<simgrid::msg::ActorUserData>()->get_user_data();
-}
-
-/** @brief Sets the user data of a process.
- *
- * This function checks whether @a process is a valid pointer and sets the user data associated to this process.
- */
-msg_error_t MSG_process_set_data(msg_process_t process, void *data)
-{
- xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
- process->extension<simgrid::msg::ActorUserData>()->set_user_data(data);
-
- return MSG_OK;
+ return actor;
}
/** @brief Sets a cleanup function to be called to free the userdata of a process when a process is destroyed.
return res;
}
-/** @brief Return the current number MSG processes. */
-int MSG_process_get_number()
-{
- return SIMIX_process_count();
-}
-
/** @brief Add a function to the list of "on_exit" functions for the current process.
* The on_exit functions are the functions executed when your process is killed.
* You should use them to free the data used by your process.
*/
void MSG_process_on_exit(int_f_int_pvoid_t fun, void* data)
{
- simgrid::s4u::this_actor::on_exit(
- [fun, data](bool failed) { fun(failed ? SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS, data); });
+ simgrid::s4u::this_actor::on_exit([fun, data](bool failed) { fun(failed ? 1 /*FAILURE*/ : 0 /*SUCCESS*/, data); });
}
namespace msg {
Task::Task(const std::string& name, double flops_amount, double bytes_amount, void* data)
- : name_(name), userdata_(data), flops_amount(flops_amount), bytes_amount(bytes_amount)
+ : name_(name), flops_amount(flops_amount), bytes_amount(bytes_amount)
{
static std::atomic_ullong counter{0};
id_ = counter++;
+ set_data(data);
if (MC_is_active())
MC_ignore_heap(&(id_), sizeof(id_));
}
/** @brief Return the user data of the given task */
void* MSG_task_get_data(msg_task_t task)
{
- return task->get_user_data();
+ return task->get_data();
}
/** @brief Sets the user data of a given task */
void MSG_task_set_data(msg_task_t task, void *data)
{
- task->set_user_data(data);
+ task->set_data(data);
}
/** @brief Returns the sender of the given task */
#include <fstream>
#include <numeric>
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file, "S4U files");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_file, s4u, "S4U files");
int sg_storage_max_file_descriptors = 1024;
namespace simgrid {
File::File(const std::string& fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
-File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath), userdata_(userdata)
+File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath)
{
+ this->set_data(userdata);
// this cannot fail because we get a xbt_die if the mountpoint does not exist
if (not host->get_mounted_storages().empty()) {
Storage* st = nullptr;
void* sg_file_get_data(sg_file_t fd)
{
- return fd->get_userdata();
+ return fd->get_data();
}
void sg_file_set_data(sg_file_t fd, void* data)
{
- fd->set_userdata(data);
+ fd->set_data(data);
}
/**
for (auto const& entry : *content) {
sg_size_t* psize = new sg_size_t;
*psize = entry.second;
- xbt_dict_set(content_as_dict, entry.first.c_str(), psize, nullptr);
+ xbt_dict_set(content_as_dict, entry.first.c_str(), psize);
}
return content_as_dict;
}
xbt_assert((host != nullptr), "Invalid parameters");
xbt_dict_t contents = xbt_dict_new_homogeneous(nullptr);
for (auto const& elm : host->get_mounted_storages())
- xbt_dict_set(contents, elm.first.c_str(), sg_storage_get_content(elm.second), nullptr);
+ xbt_dict_set(contents, elm.first.c_str(), sg_storage_get_content(elm.second));
return contents;
}
/** @defgroup plugin_host_energy
- @rst
+ @beginrst
This is the energy plugin, enabling to account not only for computation time, but also for the dissipated energy in the
simulated platform.
To activate this plugin, first call :cpp:func:`sg_host_energy_plugin_init()` before your :cpp:func:`MSG_init()`, and then use
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
return;
- // TODO Trace: set to zero the energy variable associated to host->getName()
+ // TODO Trace: set to zero the energy variable associated to host->get_name()
host.extension_set(new HostEnergy(&host));
}
});
}
+static void ensure_plugin_inited()
+{
+ if (not HostEnergy::EXTENSION_ID.valid())
+ throw std::logic_error("The Energy plugin is not active. Please call sg_host_energy_plugin_init() before calling "
+ "any function related to that plugin.");
+}
+
/** @ingroup plugin_host_energy
* @brief Returns the total energy consumed by the host so far (in Joules)
*
*/
double sg_host_get_consumed_energy(sg_host_t host)
{
- xbt_assert(HostEnergy::EXTENSION_ID.valid(),
- "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+ ensure_plugin_inited();
return host->extension<HostEnergy>()->get_consumed_energy();
}
*/
double sg_host_get_idle_consumption(sg_host_t host)
{
- xbt_assert(HostEnergy::EXTENSION_ID.valid(),
- "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+ ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_idle_at(0);
}
*/
double sg_host_get_idle_consumption_at(sg_host_t host, int pstate)
{
- xbt_assert(HostEnergy::EXTENSION_ID.valid(),
- "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+ ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_idle_at(pstate);
}
*/
double sg_host_get_wattmin_at(sg_host_t host, int pstate)
{
- xbt_assert(HostEnergy::EXTENSION_ID.valid(),
- "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+ ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_min_at(pstate);
}
/** @ingroup plugin_host_energy
*/
double sg_host_get_wattmax_at(sg_host_t host, int pstate)
{
- xbt_assert(HostEnergy::EXTENSION_ID.valid(),
- "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+ ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_max_at(pstate);
}
/** @ingroup plugin_host_energy
*/
double sg_host_get_power_range_slope_at(sg_host_t host, int pstate)
{
- xbt_assert(HostEnergy::EXTENSION_ID.valid(),
- "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+ ensure_plugin_inited();
return host->extension<HostEnergy>()->get_power_range_slope_at(pstate);
}
/** @ingroup plugin_host_energy
*/
double sg_host_get_current_consumption(sg_host_t host)
{
- xbt_assert(HostEnergy::EXTENSION_ID.valid(),
- "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+ ensure_plugin_inited();
return host->extension<HostEnergy>()->get_current_watts_value();
}
/** @defgroup plugin_host_load
- @rst
+ @beginrst
Simple plugin that monitors the current load for each host.
continue;
XBT_DEBUG("Update link %s", link->get_cname());
- LinkEnergy* link_energy = link->piface_.extension<LinkEnergy>();
+ LinkEnergy* link_energy = link->get_iface()->extension<LinkEnergy>();
link_energy->init_watts_range_list();
link_energy->update();
}
simgrid::kernel::resource::NetworkAction const& action, simgrid::kernel::resource::Action::State /* previous */) {
for (simgrid::kernel::resource::LinkImpl* link : action.links()) {
if (link != nullptr)
- link->piface_.extension<LinkEnergy>()->update();
+ link->get_iface()->extension<LinkEnergy>()->update();
}
});
*/
double sg_link_get_consumed_energy(sg_link_t link)
{
+ if (not LinkEnergy::EXTENSION_ID.valid())
+ throw std::logic_error("The Energy plugin is not active. Please call sg_link_energy_plugin_init() before calling "
+ "sg_link_get_consumed_energy().");
return link->extension<LinkEnergy>()->get_consumed_energy();
}
throw VmFailureException(XBT_THROW_POINT, xbt::string_printf("Actor %s cannot suspend the VM %s in which it runs",
issuer->get_cname(), piface_->get_cname()));
- XBT_DEBUG("suspend VM(%s), where %zu processes exist", piface_->get_cname(), process_list_.size());
+ XBT_DEBUG("suspend VM(%s), where %zu actors exist", piface_->get_cname(), get_actor_count());
action_->suspend();
- for (auto& smx_process : process_list_) {
- XBT_DEBUG("suspend %s", smx_process.get_cname());
- smx_process.suspend();
+ for (auto& actor : actor_list_) {
+ XBT_DEBUG("suspend %s", actor.get_cname());
+ actor.suspend();
}
- XBT_DEBUG("suspend all processes on the VM done done");
+ XBT_DEBUG("suspend all actors on the VM done done");
vm_state_ = s4u::VirtualMachine::state::SUSPENDED;
}
throw VmFailureException(XBT_THROW_POINT,
xbt::string_printf("Cannot resume VM %s: it was not suspended", piface_->get_cname()));
- XBT_DEBUG("Resume VM %s, containing %zu processes.", piface_->get_cname(), process_list_.size());
+ XBT_DEBUG("Resume VM %s, containing %zu actors.", piface_->get_cname(), get_actor_count());
action_->resume();
- for (auto& smx_process : process_list_) {
- XBT_DEBUG("resume %s", smx_process.get_cname());
- smx_process.resume();
+ for (auto& actor : actor_list_) {
+ XBT_DEBUG("resume %s", actor.get_cname());
+ actor.resume();
}
vm_state_ = s4u::VirtualMachine::state::RUNNING;
XBT_VERB("Shutting down the VM %s even if it's not running but %s", piface_->get_cname(), stateName);
}
- XBT_DEBUG("shutdown VM %s, that contains %zu processes", piface_->get_cname(), process_list_.size());
+ XBT_DEBUG("shutdown VM %s, that contains %zu actors", piface_->get_cname(), get_actor_count());
- for (auto& smx_process : process_list_) {
- XBT_DEBUG("kill %s@%s on behalf of %s which shutdown that VM.", smx_process.get_cname(),
- smx_process.get_host()->get_cname(), issuer->get_cname());
- issuer->kill(&smx_process);
+ for (auto& actor : actor_list_) {
+ XBT_DEBUG("kill %s@%s on behalf of %s which shutdown that VM.", actor.get_cname(), actor.get_host()->get_cname(),
+ issuer->get_cname());
+ issuer->kill(&actor);
}
set_state(s4u::VirtualMachine::state::DESTROYED);
double next_occurring_event(double now) override;
void update_actions_state(double /*now*/, double /*delta*/) override{};
+ kernel::resource::Action* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
+ const double* bytes_amount, double rate) override
+ {
+ return nullptr;
+ };
};
}
}
#include "src/plugins/vm/VirtualMachineImpl.hpp"
#include "src/plugins/vm/VmHostExt.hpp"
-XBT_LOG_NEW_DEFAULT_CATEGORY(vm_live_migration, "S4U virtual machines live migration");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(vm_live_migration, s4u, "S4U virtual machines live migration");
namespace simgrid {
namespace vm {
#include "src/plugins/vm/VmHostExt.hpp"
#include "src/surf/cpu_cas01.hpp"
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_vm, "S4U virtual machines");
-
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_vm, s4u, "S4U virtual machines");
namespace simgrid {
namespace s4u {
#include "src/include/mc/mc.h"
#include "src/kernel/activity/ExecImpl.hpp"
#include "src/mc/mc_replay.hpp"
-#include "src/simix/smx_private.hpp"
#include "src/surf/HostImpl.hpp"
#include <algorithm>
#include <sstream>
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor, "S4U actors");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_actor, s4u, "S4U actors");
namespace simgrid {
namespace s4u {
xbt::signal<void(Actor const&)> s4u::Actor::on_resume;
xbt::signal<void(Actor const&)> s4u::Actor::on_sleep;
xbt::signal<void(Actor const&)> s4u::Actor::on_wake_up;
-xbt::signal<void(Actor const&)> s4u::Actor::on_migration_start;
-xbt::signal<void(Actor const&)> s4u::Actor::on_migration_end;
+xbt::signal<void(Actor const&)> s4u::Actor::on_migration_start; // deprecated
+xbt::signal<void(Actor const&)> s4u::Actor::on_migration_end; // deprecated
+xbt::signal<void(Actor const&, Host const& previous_location)> s4u::Actor::on_host_change;
xbt::signal<void(Actor const&)> s4u::Actor::on_termination;
xbt::signal<void(Actor const&)> s4u::Actor::on_destruction;
return self_context->get_actor()->ciface();
}
+
ActorPtr Actor::init(const std::string& name, s4u::Host* host)
{
- smx_actor_t self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = SIMIX_process_self();
kernel::actor::ActorImpl* actor =
kernel::actor::simcall([self, &name, host] { return self->init(name, host).get(); });
return actor->iface();
ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::function<void()>& code)
{
- smx_actor_t self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = SIMIX_process_self();
kernel::actor::ActorImpl* actor =
kernel::actor::simcall([self, &name, host, &code] { return self->init(name, host)->start(code); });
void Actor::join(double timeout)
{
- auto issuer = SIMIX_process_self();
- auto target = pimpl_;
+ kernel::actor::ActorImpl* issuer = SIMIX_process_self();
+ kernel::actor::ActorImpl* target = pimpl_;
kernel::actor::simcall_blocking<void>([issuer, target, timeout] {
if (target->finished_) {
// The joined process is already finished, just wake up the issuer right away
pimpl_->set_auto_restart(autorestart);
kernel::actor::ProcessArg* arg = new kernel::actor::ProcessArg(pimpl_->get_host(), pimpl_);
- XBT_DEBUG("Adding Process %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname());
- pimpl_->get_host()->pimpl_->actors_at_boot_.emplace_back(arg);
+ XBT_DEBUG("Adding %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname());
+ pimpl_->get_host()->pimpl_->add_actor_at_boot(arg);
});
}
kernel::actor::simcall([this, &fun] { SIMIX_process_on_exit(pimpl_, fun); });
}
-void Actor::migrate(Host* new_host)
+void Actor::set_host(Host* new_host)
{
- s4u::Actor::on_migration_start(*this);
+ if (s4u::Actor::on_migration_start.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329
+ static bool already_warned = false;
+ if (not already_warned) {
+ XBT_INFO("Please use s4u::Actor::on_host_change instead of s4u::Actor::on_migration_start. This will be removed "
+ "in v3.29");
+ already_warned = true;
+ }
+ s4u::Actor::on_migration_start(*this);
+ }
+
+ auto* previous_location = get_host();
kernel::actor::simcall([this, new_host]() {
if (pimpl_->waiting_synchro != nullptr) {
this->pimpl_->set_host(new_host);
});
- s4u::Actor::on_migration_end(*this);
+ if (s4u::Actor::on_migration_end.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329
+ static bool already_warned = false;
+ if (not already_warned) {
+ XBT_INFO("Please use s4u::Actor::on_host_change instead of s4u::Actor::on_migration_end. This will be removed in "
+ "v3.29");
+ already_warned = true;
+ }
+ s4u::Actor::on_migration_end(*this);
+ }
+
+ s4u::Actor::on_host_change(*this, *previous_location);
}
s4u::Host* Actor::get_host() const
void Actor::suspend()
{
- auto issuer = SIMIX_process_self();
- auto target = pimpl_;
+ kernel::actor::ActorImpl* issuer = SIMIX_process_self();
+ kernel::actor::ActorImpl* target = pimpl_;
s4u::Actor::on_suspend(*this);
kernel::actor::simcall_blocking<void>([issuer, target]() {
target->suspend();
void Actor::kill()
{
- kernel::actor::ActorImpl* process = SIMIX_process_self();
- kernel::actor::simcall([this, process] {
- xbt_assert(pimpl_ != simix_global->maestro_process, "Killing maestro is a rather bad idea");
- process->kill(pimpl_);
- });
+ kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::simcall([this, self] { self->kill(pimpl_); });
}
// ***** Static functions *****
ActorPtr Actor::by_pid(aid_t pid)
{
- kernel::actor::ActorImpl* process = SIMIX_process_from_PID(pid);
- if (process != nullptr)
- return process->iface();
+ kernel::actor::ActorImpl* actor = SIMIX_process_from_PID(pid);
+ if (actor != nullptr)
+ return actor->iface();
else
return ActorPtr();
}
*/
bool is_maestro()
{
- kernel::actor::ActorImpl* process = SIMIX_process_self();
- return process == nullptr || process == simix_global->maestro_process;
+ return SIMIX_is_maestro();
}
void sleep_for(double duration)
*
* @see simgrid::s4u::Actor::migrate() for more information
*/
-void migrate(Host* new_host)
+void set_host(Host* new_host)
{
- SIMIX_process_self()->iface()->migrate(new_host);
+ SIMIX_process_self()->iface()->set_host(new_host);
+}
+void migrate(Host* new_host) // deprecated
+{
+ set_host(new_host);
}
} // namespace this_actor
/* **************************** Public C interface *************************** */
+sg_actor_t sg_actor_init(const char* name, sg_host_t host)
+{
+ return simgrid::s4u::Actor::init(name, host).get();
+}
+
+void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv)
+{
+ simgrid::simix::ActorCode function;
+ if (code)
+ function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
+ actor->start(std::move(function));
+}
+
/** @ingroup m_actor_management
* @brief Returns the process ID of @a actor.
*
if (props == nullptr)
return nullptr;
for (auto const& kv : *props) {
- xbt_dict_set(as_dict, kv.first.c_str(), xbt_strdup(kv.second.c_str()), nullptr);
+ xbt_dict_set(as_dict, kv.first.c_str(), xbt_strdup(kv.second.c_str()));
}
return as_dict;
}
*
* This function changes the value of the #sg_host_t on which @a actor is running.
*/
-void sg_actor_migrate(sg_actor_t process, sg_host_t host)
+void sg_actor_set_host(sg_actor_t actor, sg_host_t host)
+{
+ actor->set_host(host);
+}
+void sg_actor_migrate(sg_actor_t process, sg_host_t host) // deprecated
{
- process->migrate(host);
+ process->set_host(host);
}
/** @ingroup m_actor_management
return simgrid::s4u::this_actor::get_cname();
}
+void* sg_actor_self_data()
+{
+ return simgrid::s4u::Actor::self()->get_data();
+}
+
+void sg_actor_self_data_set(void* userdata)
+{
+ simgrid::s4u::Actor::self()->set_data(userdata);
+}
+
sg_actor_t sg_actor_self()
{
return simgrid::s4u::Actor::self();
}
/** @brief Return the user data of a #sg_actor_t */
-void* sg_actor_data(sg_actor_t actor)
+void* sg_actor_data(const_sg_actor_t actor)
{
return actor->get_data();
}
#include "simgrid/simix.h"
#include "xbt/log.hpp"
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_barrier, "S4U barrier");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_barrier, s4u, "S4U barrier");
namespace simgrid {
namespace s4u {
#include "src/instr/instr_private.hpp"
#include "src/kernel/EngineImpl.hpp"
#include "src/simix/smx_private.hpp" // For access to simix_global->process_list
+#include "src/surf/StorageImpl.hpp"
#include "src/surf/network_interface.hpp"
#include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
#include <simgrid/Exception.hpp>
}
/**
- * @brief A platform loader.
+ * Creates a new platform, including hosts, links, and the routing table.
*
- * Creates a new platform, including hosts, links, and the routing_table.
- * @param platf a filename of the XML description of a platform. This file follows this DTD :
- *
- * @include src/surf/xml/simgrid.dtd
- *
- * Here is a small example of such a platform
- *
- * @include examples/platforms/small_platform.xml
+ * \rst
+ * See also: :ref:`platform`.
+ * \endrst
*/
void Engine::load_platform(const std::string& platf)
{
double start = xbt_os_time();
- try {
- parse_platform_file(platf);
- } catch (const Exception& e) {
- xbt_die("Error while loading %s: %s", platf.c_str(), e.what());
- }
+ parse_platform_file(platf);
double end = xbt_os_time();
XBT_DEBUG("PARSE TIME: %g", (end - start));
}
+/** Registers the main function of an actor that will be launched from the deployment file */
void Engine::register_function(const std::string& name, int (*code)(int, char**))
{
- SIMIX_function_register(name, code);
+ pimpl->register_function(name, code);
}
+
+/** Registers the main function of an actor that will be launched from the deployment file */
void Engine::register_function(const std::string& name, void (*code)(std::vector<std::string>))
{
- SIMIX_function_register(name, code);
+ pimpl->register_function(name, code);
}
+/** Registers a function as the default main function of actors
+ *
+ * It will be used as fallback when the function requested from the deployment file was not registered.
+ * It is used for trace-based simulations (see examples/s4u/replay-comms and similar).
+ */
void Engine::register_default(int (*code)(int, char**))
{
- SIMIX_function_register_default(code);
+ pimpl->register_default(code);
}
+
+/** Load a deployment file and launch the actors that it contains
+ *
+ * \rst
+ * See also: :ref:`deploy`.
+ * \endrst
+ */
void Engine::load_deployment(const std::string& deploy)
{
- SIMIX_launch_application(deploy);
+ pimpl->load_deployment(deploy);
}
-/** @brief Returns the amount of hosts in the platform */
+
+/** Returns the amount of hosts in the platform */
size_t Engine::get_host_count()
{
return pimpl->hosts_.size();
if (pimpl->links_.find(name) == pimpl->links_.end())
throw std::invalid_argument(std::string("Link not found: ") + name);
- return pimpl->links_.at(name);
+ return pimpl->links_.at(name)->get_iface();
}
/** @brief Find an link from its name (or nullptr if that link does not exist) */
Link* Engine::link_by_name_or_null(const std::string& name)
{
auto link = pimpl->links_.find(name);
- return link == pimpl->links_.end() ? nullptr : link->second;
+ return link == pimpl->links_.end() ? nullptr : link->second->get_iface();
}
void Engine::link_register(const std::string& name, Link* link)
{
- pimpl->links_[name] = link;
+ pimpl->links_[name] = link->get_impl();
}
void Engine::link_unregister(const std::string& name)
{
std::vector<Storage*> res;
for (auto const& kv : pimpl->storages_)
- res.push_back(kv.second);
+ res.push_back(kv.second->get_iface());
return res;
}
if (pimpl->storages_.find(name) == pimpl->storages_.end())
throw std::invalid_argument(std::string("Storage not found: ") + name);
- return pimpl->storages_.at(name);
+ return pimpl->storages_.at(name)->get_iface();
}
/** @brief Find a storage from its name (or nullptr if that storage does not exist) */
Storage* Engine::storage_by_name_or_null(const std::string& name)
{
auto storage = pimpl->storages_.find(name);
- return storage == pimpl->storages_.end() ? nullptr : storage->second;
+ return storage == pimpl->storages_.end() ? nullptr : storage->second->get_iface();
}
void Engine::storage_register(const std::string& name, Storage* storage)
{
- pimpl->storages_[name] = storage;
+ pimpl->storages_[name] = storage->get_impl();
}
void Engine::storage_unregister(const std::string& name)
{
std::vector<Link*> res;
for (auto const& kv : pimpl->links_)
- res.push_back(kv.second);
+ res.push_back(kv.second->get_iface());
return res;
}
std::vector<Link*> Engine::get_filtered_links(const std::function<bool(Link*)>& filter)
{
std::vector<Link*> filtered_list;
- for (auto const& kv : pimpl->links_)
- if (filter(kv.second))
- filtered_list.push_back(kv.second);
+ for (auto const& kv : pimpl->links_) {
+ Link* l = kv.second->get_iface();
+ if (filter(l))
+ filtered_list.push_back(l);
+ }
return filtered_list;
}
{
return simgrid::s4u::Engine::get_clock();
}
+int simgrid_get_actor_count()
+{
+ return simgrid::s4u::Engine::get_instance()->get_actor_count();
+}
#include "simgrid/s4u/Exec.hpp"
#include "simgrid/s4u/VirtualMachine.hpp"
#include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include "src/simix/smx_private.hpp"
#include "src/surf/HostImpl.hpp"
#include <algorithm>
void Host::turn_off()
{
if (is_on()) {
- kernel::actor::simcall([this] {
+ kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::simcall([this, self] {
for (VirtualMachine* const& vm : vm::VirtualMachineImpl::allVms_)
if (vm->get_pm() == this) {
vm->shutdown();
vm->turn_off();
}
this->pimpl_cpu->turn_off();
- this->pimpl_->turn_off();
+ this->pimpl_->turn_off(self);
on_state_change(*this);
});
std::vector<kernel::resource::LinkImpl*> linkImpls;
this->route_to(dest, linkImpls, latency);
for (kernel::resource::LinkImpl* const& l : linkImpls)
- links.push_back(&l->piface_);
+ links.push_back(l->get_iface());
}
/** @brief Just like Host::routeTo, but filling an array of link implementations */
if (mounts_ == nullptr) {
mounts_ = new std::unordered_map<std::string, Storage*>();
for (auto const& m : this->pimpl_->storage_) {
- mounts_->insert({m.first, &m.second->piface_});
+ mounts_->insert({m.first, m.second->get_iface()});
}
}
return *mounts_;
for (auto const& elm : host->get_mounted_storages()) {
const char* mount_name = elm.first.c_str();
sg_storage_t storage = elm.second;
- xbt_dict_set(res, mount_name, (void*)storage->get_cname(), nullptr);
+ xbt_dict_set(res, mount_name, (void*)storage->get_cname());
}
return res;
if (props == nullptr)
return nullptr;
for (auto const& elm : *props) {
- xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
+ xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()));
}
return as_dict;
}
sg_host_t sg_host_self()
{
- smx_actor_t process = SIMIX_process_self();
- return (process == nullptr) ? nullptr : process->get_host();
+ return SIMIX_is_maestro() ? nullptr : SIMIX_process_self()->get_host();
}
/* needs to be public and without simcall for exceptions and logging events */
const char* sg_host_self_get_name()
{
- sg_host_t host = sg_host_self();
- if (host == nullptr || SIMIX_process_self() == simix_global->maestro_process)
- return "";
-
- return host->get_cname();
+ return SIMIX_is_maestro() ? "" : SIMIX_process_self()->get_host()->get_cname();
}
double sg_host_load(sg_host_t host)
#include "src/kernel/activity/IoImpl.hpp"
#include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_io, s4u_activity, "S4U asynchronous IOs");
-
namespace simgrid {
namespace s4u {
#include "src/surf/network_interface.hpp"
#include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_link, s4u, "Logging specific to the S4U links");
-
namespace simgrid {
namespace s4u {
#include "simgrid/s4u/NetZone.hpp"
#include "simgrid/zone.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_netzone, "S4U Networking Zones");
-
namespace simgrid {
namespace s4u {
void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto)
{
for (auto const& elem : netzone->get_children()) {
- xbt_dict_set(whereto, elem->get_cname(), static_cast<void*>(elem), nullptr);
+ xbt_dict_set(whereto, elem->get_cname(), static_cast<void*>(elem));
}
}
if (props == nullptr)
return nullptr;
for (auto const& elm : *props) {
- xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
+ xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()));
}
return as_dict;
}
return simcall_BODY_execution_waitany_for(execs, count, timeout);
}
-void simcall_process_join(smx_actor_t process, double timeout)
+void simcall_process_join(smx_actor_t process, double timeout) // XBT_DEPRECATED_v328
{
SIMIX_process_self()->join(process, timeout);
}
-void simcall_process_suspend(smx_actor_t process)
+void simcall_process_suspend(smx_actor_t process) // XBT_DEPRECATED_v328
{
process->iface()->suspend();
}
-e_smx_state_t simcall_process_sleep(double duration)
+e_smx_state_t simcall_process_sleep(double duration) // XBT_DEPRECATED_v329
{
SIMIX_process_self()->sleep(duration);
return SIMIX_DONE;
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "simgrid/Exception.hpp"
#include "simgrid/s4u/Host.hpp"
#include "smx_private.hpp"
#include "src/surf/xml/platf_private.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
#include <simgrid/engine.h>
+#include <simgrid/s4u/Engine.hpp>
#include <string>
#include <vector>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_deployment, simix, "Logging specific to SIMIX (deployment)");
-extern int surf_parse_lineno;
-
-void SIMIX_init_application()
+void SIMIX_init_application() // XBT_DEPRECATED_v329
{
sg_platf_exit();
sg_platf_init();
}
-/**
- * @brief An application deployer.
- *
- * Creates the process described in @a file.
- * @param file a filename of a xml description of the application. This file
- * follows this DTD :
- *
- * @include surfxml.dtd
- *
- * Here is a small example of such a platform
- *
- * @include small_deployment.xml
- *
- */
-void SIMIX_launch_application(const std::string& file)
-{
- XBT_ATTRIB_UNUSED int parse_status;
- xbt_assert(simix_global, "SIMIX_global_init has to be called before SIMIX_launch_application.");
-
- SIMIX_init_application();
-
- surf_parse_open(file);
- try {
- parse_status = surf_parse();
- surf_parse_close();
- xbt_assert(not parse_status, "Parse error at %s:%d", file.c_str(), surf_parse_lineno);
- } catch (const simgrid::Exception&) {
- XBT_ERROR(
- "Unrecoverable error at %s:%d. The full exception stack follows, in case it helps you to diagnose the problem.",
- file.c_str(), surf_parse_lineno);
- throw;
- }
-}
-
-// Wrap a main() function into a ActorCodeFactory:
-static simgrid::simix::ActorCodeFactory toActorCodeFactory(xbt_main_func_t code)
+void SIMIX_launch_application(const std::string& file) // XBT_DEPRECATED_v329
{
- return [code](std::vector<std::string> args) { return simgrid::xbt::wrap_main(code, std::move(args)); };
+ simgrid_load_deployment(file.c_str());
}
-static simgrid::simix::ActorCodeFactory toActorCodeFactory(void (*code)(std::vector<std::string>))
+void SIMIX_function_register(const std::string& name, xbt_main_func_t code) // XBT_DEPRECATED_v329
{
- return [code](std::vector<std::string> args) { return std::bind(std::move(code), std::move(args)); };
+ simgrid::s4u::Engine::get_instance()->register_function(name, code);
}
-
-/**
- * @brief Registers a #xbt_main_func_t code in a global table.
- *
- * Registers a code function in a global table.
- * This table is then used by #SIMIX_launch_application.
- * @param name the reference name of the function.
- * @param code the function
- */
-void SIMIX_function_register(const std::string& name, xbt_main_func_t code)
+void SIMIX_function_register(const std::string& name, void (*code)(std::vector<std::string>)) // XBT_DEPRECATED_v329
{
- simix_global->registered_functions[name] = toActorCodeFactory(code);
+ simgrid::s4u::Engine::get_instance()->register_function(name, code);
}
-void SIMIX_function_register(const std::string& name, void (*code)(std::vector<std::string>))
-{
- simix_global->registered_functions[name] = toActorCodeFactory(code);
-}
-
-/**
- * @brief Registers a #xbt_main_func_t code as default value.
- *
- * Registers a code function as being the default value. This function will get used by SIMIX_launch_application() when
- * there is no registered function of the requested name in.
- * @param code the function
- */
-void SIMIX_function_register_default(xbt_main_func_t code)
+void SIMIX_function_register_default(xbt_main_func_t code) // XBT_DEPRECATED_v329
{
- xbt_assert(simix_global, "SIMIX_global_init has to be called before SIMIX_function_register.");
- simix_global->default_function = toActorCodeFactory(code);
+ simgrid::s4u::Engine::get_instance()->register_default(code);
}
/**
/** @brief Bypass the parser, get arguments, and set function to each process */
void SIMIX_process_set_function(const char* process_host, const char* process_function, xbt_dynar_t arguments,
- double process_start_time, double process_kill_time)
+ double process_start_time, double process_kill_time) // XBT_ATTRIB_DEPRECATED_v329
{
simgrid::kernel::routing::ActorCreationArgs actor;
namespace simgrid {
namespace simix {
-simgrid::config::Flag<double> cfg_verbose_exit{
- "debug/verbose-exit", {"verbose-exit"}, "Display the actor status at exit", true};
-}
+config::Flag<double> cfg_verbose_exit{"debug/verbose-exit", {"verbose-exit"}, "Display the actor status at exit", true};
+} // namespace simix
} // namespace simgrid
+
XBT_ATTRIB_NORETURN static void inthandler(int)
{
if (simgrid::simix::cfg_verbose_exit) {
namespace simgrid {
namespace simix {
-Timer* Timer::set(double date, simgrid::xbt::Task<void()>&& callback)
+Timer* Timer::set(double date, xbt::Task<void()>&& callback)
{
Timer* timer = new Timer(date, std::move(callback));
timer->handle_ = simix_timers.emplace(std::make_pair(date, timer));
/** @brief cancels a timer that was added earlier */
void Timer::remove()
{
- simgrid::simix::simix_timers.erase(handle_);
+ simix_timers.erase(handle_);
delete this;
}
void Global::empty_trash()
{
while (not actors_to_destroy.empty()) {
- smx_actor_t actor = &actors_to_destroy.front();
+ kernel::actor::ActorImpl* actor = &actors_to_destroy.front();
actors_to_destroy.pop_front();
XBT_DEBUG("Getting rid of %s (refcount: %d)", actor->get_cname(), actor->get_refcount());
intrusive_ptr_release(actor);
actors_to_run.clear();
}
-simgrid::config::Flag<double> cfg_breakpoint{
+config::Flag<double> cfg_breakpoint{
"debug/breakpoint", {"simix/breakpoint"}, "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
-}
-}
+} // namespace simix
+} // namespace simgrid
static simgrid::simix::ActorCode maestro_code;
void SIMIX_set_maestro(void (*code)(void*), void* data)
}
#if HAVE_SMPI
- if (SIMIX_process_count()>0){
+ if (simix_global->process_list.size() > 0) {
if(smpi_process()->initialized()){
xbt_die("Process exited without calling MPI_Finalize - Killing simulation");
}else{
/* Kill all processes (but maestro) */
simix_global->maestro_process->kill_all();
- simix_global->context_factory->run_all();
+ simix_global->run_all_actors();
simix_global->empty_trash();
/* Exit the SIMIX network module */
* That would thus be a pure waste of time.
*/
- for (smx_actor_t const& process : simix_global->actors_that_ran) {
- if (process->simcall.call_ != SIMCALL_NONE) {
- process->simcall_handle(0);
+ for (auto const& actor : simix_global->actors_that_ran) {
+ if (actor->simcall.call_ != SIMCALL_NONE) {
+ actor->simcall_handle(0);
}
}
/* List the process and their state */
XBT_INFO("Legend of the following listing: \"Process <pid> (<name>@<host>): <status>\"");
for (auto const& kv : simix_global->process_list) {
- smx_actor_t actor = kv.second;
+ simgrid::kernel::actor::ActorImpl* actor = kv.second;
if (actor->waiting_synchro) {
int SIMIX_is_maestro()
{
- smx_actor_t self = SIMIX_process_self();
- return simix_global == nullptr /*SimDag*/ || self == nullptr || self == simix_global->maestro_process;
+ if (simix_global == nullptr) // SimDag
+ return true;
+ simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
+ return self == nullptr || self == simix_global->maestro_process;
}
namespace simix {
class Global {
- friend XBT_PUBLIC bool simgrid::s4u::this_actor::is_maestro();
-
public:
bool execute_tasks();
/**
void run_all_actors();
smx_context_factory_t context_factory = nullptr;
- std::vector<smx_actor_t> actors_to_run;
- std::vector<smx_actor_t> actors_that_ran;
- std::map<aid_t, smx_actor_t> process_list;
+ std::vector<kernel::actor::ActorImpl*> actors_to_run;
+ std::vector<kernel::actor::ActorImpl*> actors_that_ran;
+ std::map<aid_t, kernel::actor::ActorImpl*> process_list;
boost::intrusive::list<kernel::actor::ActorImpl,
boost::intrusive::member_hook<kernel::actor::ActorImpl, boost::intrusive::list_member_hook<>,
&kernel::actor::ActorImpl::smx_destroy_list_hook>>
* That way, the MCer would not need to have the list of actors on its side.
* These info could be published by the MCed to the MCer in a way inspired of vd.so
*/
- xbt_dynar_t actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
- xbt_dynar_t dead_actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
+ xbt_dynar_t actors_vector = xbt_dynar_new(sizeof(kernel::actor::ActorImpl*), nullptr);
+ xbt_dynar_t dead_actors_vector = xbt_dynar_new(sizeof(kernel::actor::ActorImpl*), nullptr);
#endif
- smx_actor_t maestro_process = nullptr;
+ kernel::actor::ActorImpl* maestro_process = nullptr;
// Maps function names to actor code:
- std::unordered_map<std::string, simgrid::simix::ActorCodeFactory> registered_functions;
+ std::unordered_map<std::string, simix::ActorCodeFactory> registered_functions;
// This might be used when no corresponding function name is registered:
- simgrid::simix::ActorCodeFactory default_function;
+ simix::ActorCodeFactory default_function;
std::mutex mutex;
- std::vector<simgrid::xbt::Task<void()>> tasks;
- std::vector<simgrid::xbt::Task<void()>> tasksTemp;
+ std::vector<xbt::Task<void()>> tasks;
+ std::vector<xbt::Task<void()>> tasksTemp;
- std::vector<simgrid::kernel::actor::ActorImpl*> daemons;
+ std::vector<kernel::actor::ActorImpl*> daemons;
};
}
}
MPI_COMM_WORLD->add_f();
MPI_BYTE->add_f();//MPI_BYTE
MPI_CHAR->add_f();//MPI_CHARACTER
-#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
- MPI_C_BOOL->add_f();//MPI_LOGICAL
- MPI_INT->add_f();//MPI_INTEGER
-#else
- MPI_C_BOOL->add_f();//MPI_LOGICAL
- MPI_LONG->add_f();//MPI_INTEGER
-#endif
+ if(sizeof(void*)==8) {
+ MPI_C_BOOL->add_f();//MPI_LOGICAL
+ MPI_INT->add_f();//MPI_INTEGER
+ } else {
+ MPI_C_BOOL->add_f();//MPI_LOGICAL
+ MPI_LONG->add_f();//MPI_INTEGER
+ }
MPI_INT8_T->add_f();//MPI_INTEGER1
MPI_INT16_T->add_f();//MPI_INTEGER2
MPI_INT32_T->add_f();//MPI_INTEGER4
MPI_DOUBLE->add_f();//MPI_DOUBLE_PRECISION
MPI_COMPLEX8->add_f();//MPI_COMPLEX
MPI_COMPLEX16->add_f();//MPI_DOUBLE_COMPLEX
-#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
- MPI_2INT->add_f();//MPI_2INTEGER
-#else
- MPI_2LONG->add_f();//MPI_2INTEGER
-#endif
+ if(sizeof(void*)==8)
+ MPI_2INT->add_f();//MPI_2INTEGER
+ else
+ MPI_2LONG->add_f();//MPI_2INTEGER
MPI_UINT8_T->add_f();//MPI_LOGICAL1
MPI_UINT16_T->add_f();//MPI_LOGICAL2
MPI_UINT32_T->add_f();//MPI_LOGICAL4
int
-Coll_allgather_2dmesh::allgather(const void *send_buff, int send_count, MPI_Datatype
- send_type, void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+allgather__2dmesh(const void *send_buff, int send_count, MPI_Datatype
+ send_type, void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Aint extent;
namespace smpi{
-int Coll_allgather_3dmesh::allgather(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+int allgather__3dmesh(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint extent;
namespace simgrid{
namespace smpi{
// Allgather - gather/bcast algorithm
-int Coll_allgather_GB::allgather(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+int allgather__GB(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
int num_procs;
num_procs = comm->size();
// Allgather-Non-Topology-Specific-Logical-Ring algorithm
int
-Coll_allgather_NTSLR_NB::allgather(const void *sbuf, int scount, MPI_Datatype stype,
- void *rbuf, int rcount, MPI_Datatype rtype,
- MPI_Comm comm)
+allgather__NTSLR_NB(const void *sbuf, int scount, MPI_Datatype stype,
+ void *rbuf, int rcount, MPI_Datatype rtype,
+ MPI_Comm comm)
{
MPI_Aint rextent, sextent;
MPI_Status status, status2;
// irregular case use default MPI fucntions
if (scount * sextent != rcount * rextent) {
XBT_WARN("MPI_allgather_NTSLR_NB use default MPI_allgather.");
- Coll_allgather_default::allgather(sbuf, scount, stype, rbuf, rcount, rtype, comm);
+ allgather__default(sbuf, scount, stype, rbuf, rcount, rtype, comm);
return MPI_SUCCESS;
}
// Allgather-Non-Topology-Specific-Logical-Ring algorithm
int
-Coll_allgather_NTSLR::allgather(const void *sbuf, int scount, MPI_Datatype stype,
- void *rbuf, int rcount, MPI_Datatype rtype,
- MPI_Comm comm)
+allgather__NTSLR(const void *sbuf, int scount, MPI_Datatype stype,
+ void *rbuf, int rcount, MPI_Datatype rtype,
+ MPI_Comm comm)
{
MPI_Aint rextent, sextent;
MPI_Status status;
// irregular case use default MPI fucntions
if (scount * sextent != rcount * rextent) {
XBT_WARN("MPI_allgather_NTSLR use default MPI_allgather.");
- Coll_allgather_default::allgather(sbuf, scount, stype, rbuf, rcount, rtype, comm);
+ allgather__default(sbuf, scount, stype, rbuf, rcount, rtype, comm);
return MPI_SUCCESS;
}
namespace smpi{
-int Coll_allgather_SMP_NTS::allgather(const void *sbuf, int scount,
- MPI_Datatype stype, void *rbuf,
- int rcount, MPI_Datatype rtype,
- MPI_Comm comm)
+int allgather__SMP_NTS(const void *sbuf, int scount,
+ MPI_Datatype stype, void *rbuf,
+ int rcount, MPI_Datatype rtype,
+ MPI_Comm comm)
{
int src, dst, comm_size, rank;
comm_size = comm->size();
/* for too small number of processes, use default implementation */
if (comm_size <= num_core) {
XBT_WARN("MPI_allgather_SMP_NTS use default MPI_allgather.");
- Coll_allgather_default::allgather(sbuf, scount, stype, rbuf, rcount, rtype, comm);
+ allgather__default(sbuf, scount, stype, rbuf, rcount, rtype, comm);
return MPI_SUCCESS;
}
-int Coll_allgather_bruck::allgather(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+int allgather__bruck(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
// MPI variables
MPI_Status status;
namespace smpi{
-int Coll_allgather_loosely_lr::allgather(const void *sbuf, int scount,
- MPI_Datatype stype, void *rbuf,
- int rcount, MPI_Datatype rtype,
- MPI_Comm comm)
+int allgather__loosely_lr(const void *sbuf, int scount,
+ MPI_Datatype stype, void *rbuf,
+ int rcount, MPI_Datatype rtype,
+ MPI_Comm comm)
{
int comm_size, rank;
int tag = COLL_TAG_ALLGATHER;
namespace simgrid{
namespace smpi{
-int Coll_allgather_mvapich2_smp::allgather(const void *sendbuf,int sendcnt, MPI_Datatype sendtype,
+int allgather__mvapich2_smp(const void *sendbuf,int sendcnt, MPI_Datatype sendtype,
void *recvbuf, int recvcnt,MPI_Datatype recvtype,
MPI_Comm comm)
{
- mpi_errno = Coll_allgather_mpich::allgather(sendtmpbuf,
+ mpi_errno = allgather__mpich(sendtmpbuf,
(recvcnt*local_size),
recvtype,
recvbuf, (recvcnt*local_size), recvtype,
namespace smpi{
int
-Coll_allgather_ompi_neighborexchange::allgather(const void *sbuf, int scount,
+allgather__ompi_neighborexchange(const void *sbuf, int scount,
MPI_Datatype sdtype,
void* rbuf, int rcount,
MPI_Datatype rdtype,
XBT_DEBUG(
"coll:tuned:allgather_intra_neighborexchange WARNING: odd size %d, switching to ring algorithm",
size);
- return Coll_allgather_ring::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__ring(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
}
XBT_DEBUG(
int
-Coll_allgather_pair::allgather(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+allgather__pair(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint extent;
namespace smpi{
int
-Coll_allgather_rdb::allgather(const void *sbuf, int send_count,
- MPI_Datatype send_type, void *rbuf,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+allgather__rdb(const void *sbuf, int send_count,
+ MPI_Datatype send_type, void *rbuf,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
// MPI variables
MPI_Status status;
// now only work with power of two processes
int
-Coll_allgather_rhv::allgather(const void *sbuf, int send_count,
- MPI_Datatype send_type, void *rbuf,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+allgather__rhv(const void *sbuf, int send_count,
+ MPI_Datatype send_type, void *rbuf,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Status status;
MPI_Aint s_extent, r_extent;
if (send_chunk != recv_chunk) {
XBT_WARN("MPI_allgather_rhv use default MPI_allgather.");
- Coll_allgather_default::allgather(sbuf, send_count, send_type, rbuf, recv_count,
- recv_type, comm);
+ allgather__default(sbuf, send_count, send_type, rbuf, recv_count,
+ recv_type, comm);
return MPI_SUCCESS;
}
int
-Coll_allgather_ring::allgather(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+allgather__ring(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint extent;
namespace smpi{
-int Coll_allgather_smp_simple::allgather(const void *send_buf, int scount,
- MPI_Datatype stype, void *recv_buf,
- int rcount, MPI_Datatype rtype,
- MPI_Comm comm)
+int allgather__smp_simple(const void *send_buf, int scount,
+ MPI_Datatype stype, void *recv_buf,
+ int rcount, MPI_Datatype rtype,
+ MPI_Comm comm)
{
int src, dst, comm_size, rank;
comm_size = comm->size();
int
-Coll_allgather_spreading_simple::allgather(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type,
- MPI_Comm comm)
+allgather__spreading_simple(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint extent;
int i, src, dst, rank, num_procs, num_reqs;
namespace smpi{
// Allgather - gather/bcast algorithm
-int Coll_allgatherv_GB::allgatherv(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- const int *recv_counts, const int *recv_disps, MPI_Datatype recv_type,
- MPI_Comm comm)
+int allgatherv__GB(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ const int *recv_counts, const int *recv_disps, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
Colls::gatherv(send_buff, send_count, send_type, recv_buff, recv_counts, recv_disps, recv_type, 0, comm);
int num_procs, i, current, max = 0;
namespace simgrid{
namespace smpi{
-int Coll_allgatherv_mpich_rdb::allgatherv (
+int allgatherv__mpich_rdb(
const void *sendbuf,
int sendcount,
MPI_Datatype sendtype,
namespace simgrid{
namespace smpi{
-int
-Coll_allgatherv_mpich_ring::allgatherv(const void *sendbuf, int sendcount,
- MPI_Datatype send_type, void *recvbuf,
- const int *recvcounts, const int *displs, MPI_Datatype recvtype,
- MPI_Comm comm)
+int allgatherv__mpich_ring(const void *sendbuf, int sendcount,
+ MPI_Datatype send_type, void *recvbuf,
+ const int *recvcounts, const int *displs, MPI_Datatype recvtype,
+ MPI_Comm comm)
{
char * sbuf = NULL, * rbuf = NULL;
* [6] [6] [6] [6] [6] [6] [6]
*/
-namespace simgrid{
-namespace smpi{
-
-int Coll_allgatherv_ompi_bruck::allgatherv(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void *rbuf, const int *rcounts,
- const int *rdispls,
- MPI_Datatype rdtype,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+
+int allgatherv__ompi_bruck(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void *rbuf, const int *rcounts,
+ const int *rdispls,
+ MPI_Datatype rdtype,
+ MPI_Comm comm)
{
int sendto, recvfrom, blockcount, i;
unsigned int distance;
namespace smpi{
int
-Coll_allgatherv_ompi_neighborexchange::allgatherv(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, const int *rcounts, const int *rdispls,
- MPI_Datatype rdtype,
- MPI_Comm comm)
+allgatherv__ompi_neighborexchange(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, const int *rcounts, const int *rdispls,
+ MPI_Datatype rdtype,
+ MPI_Comm comm)
{
int line = -1;
int rank, size;
rank = comm->rank();
if (size % 2) {
- XBT_DEBUG(
- "coll:tuned:allgatherv_ompi_neighborexchange WARNING: odd size %d, switching to ring algorithm",
+ XBT_DEBUG("allgatherv__ompi_neighborexchange WARNING: odd size %d, switching to ring algorithm",
size);
- return Coll_allgatherv_ring::allgatherv(sbuf, scount, sdtype,
+ return allgatherv__ring(sbuf, scount, sdtype,
rbuf, rcounts,
rdispls, rdtype,
comm);
namespace smpi{
int
-Coll_allgatherv_pair::allgatherv(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- const int *recv_counts, const int *recv_disps, MPI_Datatype recv_type,
- MPI_Comm comm)
+allgatherv__pair(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ const int *recv_counts, const int *recv_disps, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint extent;
namespace smpi{
int
-Coll_allgatherv_ring::allgatherv(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- const int *recv_counts, const int *recv_disps, MPI_Datatype recv_type,
- MPI_Comm comm)
+allgatherv__ring(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ const int *recv_counts, const int *recv_disps, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint extent;
*/
//#include <star-reduction.c>
-namespace simgrid{
-namespace smpi{
-int
-Coll_allreduce_lr::allreduce(const void *sbuf, void *rbuf, int rcount,
- MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int allreduce__lr(const void *sbuf, void *rbuf, int rcount,
+ MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
{
int tag = COLL_TAG_ALLREDUCE;
MPI_Status status;
/* when communication size is smaller than number of process (not support) */
if (rcount < size) {
XBT_WARN("MPI_allreduce_lr use default MPI_allreduce.");
- Coll_allreduce_default::allreduce(sbuf, rbuf, rcount, dtype, op, comm);
+ allreduce__default(sbuf, rbuf, rcount, dtype, op, comm);
return MPI_SUCCESS;
}
#include "../colls_private.hpp"
#include <algorithm>
-namespace simgrid{
-namespace smpi{
-int Coll_allreduce_mvapich2_rs::allreduce(const void *sendbuf,
- void *recvbuf,
- int count,
- MPI_Datatype datatype,
- MPI_Op op, MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int allreduce__mvapich2_rs(const void *sendbuf,
+ void *recvbuf,
+ int count,
+ MPI_Datatype datatype,
+ MPI_Op op, MPI_Comm comm)
{
int mpi_errno = MPI_SUCCESS;
int newrank = 0;
#include "../colls_private.hpp"
-#define MPIR_Allreduce_pt2pt_rd_MV2 Coll_allreduce_rdb::allreduce
-#define MPIR_Allreduce_pt2pt_rs_MV2 Coll_allreduce_mvapich2_rs::allreduce
+#define MPIR_Allreduce_pt2pt_rd_MV2 allreduce__rdb
+#define MPIR_Allreduce_pt2pt_rs_MV2 allreduce__mvapich2_rs
extern int (*MV2_Allreducection)(const void *sendbuf,
void *recvbuf,
/* general two level allreduce helper function */
-int Coll_allreduce_mvapich2_two_level::allreduce(const void *sendbuf,
+int allreduce__mvapich2_two_level(const void *sendbuf,
void *recvbuf,
int count,
MPI_Datatype datatype,
//if not set (use of the algo directly, without mvapich2 selector)
if(MV2_Allreduce_intra_function==NULL)
- MV2_Allreduce_intra_function = Coll_allreduce_mpich::allreduce;
+ MV2_Allreduce_intra_function = allreduce__mpich;
if(MV2_Allreducection==NULL)
- MV2_Allreducection = Coll_allreduce_rdb::allreduce;
+ MV2_Allreducection = allreduce__rdb;
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
#include "../colls_private.hpp"
-namespace simgrid{
-namespace smpi{
-int
-Coll_allreduce_ompi_ring_segmented::allreduce(const void *sbuf, void *rbuf, int count,
- MPI_Datatype dtype,
- MPI_Op op,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int allreduce__ompi_ring_segmented(const void *sbuf, void *rbuf, int count,
+ MPI_Datatype dtype,
+ MPI_Op op,
+ MPI_Comm comm)
{
int ret = MPI_SUCCESS;
int line;
/* Special case for count less than size * segcount - use regular ring */
if (count < size * segcount) {
XBT_DEBUG( "coll:tuned:allreduce_ring_segmented rank %d/%d, count %d, switching to regular ring", rank, size, count);
- return (Coll_allreduce_lr::allreduce(sbuf, rbuf, count, dtype, op,
- comm));
+ return (allreduce__lr(sbuf, rbuf, count, dtype, op, comm));
}
/* Determine the number of phases of the algorithm */
#include "../colls_private.hpp"
namespace simgrid{
namespace smpi{
-int Coll_allreduce_rab_rdb::allreduce(const void *sbuff, void *rbuff, int count,
- MPI_Datatype dtype, MPI_Op op,
- MPI_Comm comm)
+int allreduce__rab_rdb(const void *sbuff, void *rbuff, int count,
+ MPI_Datatype dtype, MPI_Op op,
+ MPI_Comm comm)
{
int tag = COLL_TAG_ALLREDUCE;
unsigned int mask, pof2, i, recv_idx, last_idx, send_idx, send_cnt;
namespace simgrid{
namespace smpi{
// NP pow of 2 for now
-int Coll_allreduce_rab1::allreduce(const void *sbuff, void *rbuff,
- int count, MPI_Datatype dtype,
- MPI_Op op, MPI_Comm comm)
+int allreduce__rab1(const void *sbuff, void *rbuff,
+ int count, MPI_Datatype dtype,
+ MPI_Op op, MPI_Comm comm)
{
MPI_Status status;
MPI_Aint extent;
namespace simgrid{
namespace smpi{
// this requires that count >= NP
-int Coll_allreduce_rab2::allreduce(const void *sbuff, void *rbuff,
- int count, MPI_Datatype dtype,
- MPI_Op op, MPI_Comm comm)
+int allreduce__rab2(const void *sbuff, void *rbuff,
+ int count, MPI_Datatype dtype,
+ MPI_Op op, MPI_Comm comm)
{
MPI_Aint s_extent;
int i, rank, nprocs;
//#include <star-reduction.c>
namespace simgrid{
namespace smpi{
-int Coll_allreduce_rdb::allreduce(const void *sbuff, void *rbuff, int count,
- MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
+int allreduce__rdb(const void *sbuff, void *rbuff, int count,
+ MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
{
int nprocs, rank, tag = COLL_TAG_ALLREDUCE;
int mask, dst, pof2, newrank, rem, newdst;
#include "../colls_private.hpp"
namespace simgrid{
namespace smpi{
-int Coll_allreduce_redbcast::allreduce(const void *buf, void *buf2, int count,
- MPI_Datatype datatype, MPI_Op op,
- MPI_Comm comm)
+int allreduce__redbcast(const void *buf, void *buf2, int count,
+ MPI_Datatype datatype, MPI_Op op,
+ MPI_Comm comm)
{
Colls::reduce(buf, buf2, count, datatype, op, 0, comm);
Colls::bcast(buf2, count, datatype, 0, comm);
*/
namespace simgrid{
namespace smpi{
-int Coll_allreduce_smp_binomial_pipeline::allreduce(const void *send_buf,
- void *recv_buf, int count,
- MPI_Datatype dtype,
- MPI_Op op, MPI_Comm comm)
+int allreduce__smp_binomial_pipeline(const void *send_buf,
+ void *recv_buf, int count,
+ MPI_Datatype dtype,
+ MPI_Op op, MPI_Comm comm)
{
int comm_size, rank;
int tag = COLL_TAG_ALLREDUCE;
*/
namespace simgrid{
namespace smpi{
-int Coll_allreduce_smp_binomial::allreduce(const void *send_buf, void *recv_buf,
- int count, MPI_Datatype dtype,
- MPI_Op op, MPI_Comm comm)
+int allreduce__smp_binomial(const void *send_buf, void *recv_buf,
+ int count, MPI_Datatype dtype,
+ MPI_Op op, MPI_Comm comm)
{
int comm_size, rank;
int tag = COLL_TAG_ALLREDUCE;
*/
namespace simgrid{
namespace smpi{
-int Coll_allreduce_smp_rdb::allreduce(const void *send_buf, void *recv_buf, int count,
- MPI_Datatype dtype, MPI_Op op,
- MPI_Comm comm)
+int allreduce__smp_rdb(const void *send_buf, void *recv_buf, int count,
+ MPI_Datatype dtype, MPI_Op op,
+ MPI_Comm comm)
{
int comm_size, rank;
int tag = COLL_TAG_ALLREDUCE;
*/
namespace simgrid{
namespace smpi{
-int Coll_allreduce_smp_rsag_lr::allreduce(const void *send_buf, void *recv_buf,
- int count, MPI_Datatype dtype,
- MPI_Op op, MPI_Comm comm)
+int allreduce__smp_rsag_lr(const void *send_buf, void *recv_buf,
+ int count, MPI_Datatype dtype,
+ MPI_Op op, MPI_Comm comm)
{
int comm_size, rank;
int tag = COLL_TAG_ALLREDUCE;
*/
namespace simgrid{
namespace smpi{
-int Coll_allreduce_smp_rsag_rab::allreduce(const void *sbuf, void *rbuf, int count,
- MPI_Datatype dtype, MPI_Op op,
- MPI_Comm comm)
+int allreduce__smp_rsag_rab(const void *sbuf, void *rbuf, int count,
+ MPI_Datatype dtype, MPI_Op op,
+ MPI_Comm comm)
{
int comm_size, rank;
int tag = COLL_TAG_ALLREDUCE;
*/
namespace simgrid{
namespace smpi{
-int Coll_allreduce_smp_rsag::allreduce(const void *send_buf, void *recv_buf,
- int count, MPI_Datatype dtype, MPI_Op op,
- MPI_Comm comm)
+int allreduce__smp_rsag(const void *send_buf, void *recv_buf,
+ int count, MPI_Datatype dtype, MPI_Op op,
+ MPI_Comm comm)
{
int comm_size, rank;
int tag = COLL_TAG_ALLREDUCE;
namespace simgrid{
namespace smpi{
-int Coll_alltoall_2dmesh::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+int alltoall__2dmesh(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Status s;
MPI_Aint extent;
}
namespace simgrid{
namespace smpi{
-int Coll_alltoall_3dmesh::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+int alltoall__3dmesh(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Aint extent;
MPI_Status status;
namespace smpi{
-int Coll_alltoall_basic_linear::alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
- void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
+int alltoall__basic_linear(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
{
int system_tag = COLL_TAG_ALLTOALL;
int i;
int
-Coll_alltoall_bruck::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+alltoall__bruck(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Status status;
MPI_Aint extent;
#include "../colls_private.hpp"
namespace simgrid{
namespace smpi{
-int Coll_alltoall_mvapich2_scatter_dest::alltoall(
- const void *sendbuf,
- int sendcount,
- MPI_Datatype sendtype,
- void *recvbuf,
- int recvcount,
- MPI_Datatype recvtype,
- MPI_Comm comm)
+int alltoall__mvapich2_scatter_dest(const void *sendbuf,
+ int sendcount,
+ MPI_Datatype sendtype,
+ void *recvbuf,
+ int recvcount,
+ MPI_Datatype recvtype,
+ MPI_Comm comm)
{
int comm_size, i, j;
MPI_Aint sendtype_extent = 0, recvtype_extent = 0;
namespace simgrid{
namespace smpi{
int
-Coll_alltoall_pair_light_barrier::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type,
- MPI_Comm comm)
+alltoall__pair_light_barrier(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
MPI_Status s;
namespace simgrid{
namespace smpi{
int
-Coll_alltoall_pair_mpi_barrier::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+alltoall__pair_mpi_barrier(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Status s;
MPI_Aint send_chunk, recv_chunk;
namespace simgrid{
namespace smpi{
int
-Coll_alltoall_pair_one_barrier::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+alltoall__pair_one_barrier(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
****************************************************************************/
namespace simgrid{
namespace smpi{
-int Coll_alltoall_pair_rma::alltoall(const void *send_buff, int send_count, MPI_Datatype send_type,
- void *recv_buff, int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+int alltoall__pair_rma(const void *send_buff, int send_count, MPI_Datatype send_type,
+ void *recv_buff, int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
}
-int Coll_alltoall_pair::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+int alltoall__pair(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
****************************************************************************/
namespace simgrid{
namespace smpi{
-int Coll_alltoall_rdb::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+int alltoall__rdb(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
/* MPI variables */
MPI_Status status;
namespace simgrid{
namespace smpi{
int
-Coll_alltoall_ring_light_barrier::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type,
- MPI_Comm comm)
+alltoall__ring_light_barrier(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
MPI_Status s;
namespace simgrid{
namespace smpi{
int
-Coll_alltoall_ring_mpi_barrier::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+alltoall__ring_mpi_barrier(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Status s;
MPI_Aint send_chunk, recv_chunk;
namespace simgrid{
namespace smpi{
int
-Coll_alltoall_ring_one_barrier::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type,
- void *recv_buff, int recv_count,
- MPI_Datatype recv_type, MPI_Comm comm)
+alltoall__ring_one_barrier(const void *send_buff, int send_count,
+ MPI_Datatype send_type,
+ void *recv_buff, int recv_count,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Status s;
MPI_Aint send_chunk, recv_chunk;
* Author: Ahmad Faraj
****************************************************************************/
-namespace simgrid{
-namespace smpi{
-int
-Coll_alltoall_ring::alltoall(const void *send_buff, int send_count,
- MPI_Datatype send_type, void *recv_buff,
- int recv_count, MPI_Datatype recv_type,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int alltoall__ring(const void *send_buff, int send_count,
+ MPI_Datatype send_type, void *recv_buff,
+ int recv_count, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Status s;
MPI_Aint send_chunk, recv_chunk;
**/
namespace simgrid{
namespace smpi{
-int Coll_alltoallv_bruck::alltoallv(const void *sendbuf, const int *sendcounts, const int *senddisps,
- MPI_Datatype sendtype, void *recvbuf,
- const int *recvcounts,const int *recvdisps, MPI_Datatype recvtype,
- MPI_Comm comm)
+int alltoallv__bruck(const void *sendbuf, const int *sendcounts, const int *senddisps,
+ MPI_Datatype sendtype, void *recvbuf,
+ const int *recvcounts,const int *recvdisps, MPI_Datatype recvtype,
+ MPI_Comm comm)
{
int system_tag = COLL_TAG_ALLTOALLV;
int i, rank, size, err, count;
*/
namespace simgrid{
namespace smpi{
-int
-Coll_alltoallv_ompi_basic_linear::alltoallv(const void *sbuf, const int *scounts, const int *sdisps,
- MPI_Datatype sdtype,
- void *rbuf, const int *rcounts, const int *rdisps,
- MPI_Datatype rdtype,
- MPI_Comm comm)
+int alltoallv__ompi_basic_linear(const void *sbuf, const int *scounts, const int *sdisps,
+ MPI_Datatype sdtype,
+ void *rbuf, const int *rcounts, const int *rdisps,
+ MPI_Datatype rdtype,
+ MPI_Comm comm)
{
int i, size, rank;
char *psnd, *prcv;
* Author: Ahmad Faraj
****************************************************************************/
-namespace simgrid{
-namespace smpi{
-int
-Coll_alltoallv_pair_light_barrier::alltoallv(const void *send_buff, const int *send_counts, const int *send_disps,
- MPI_Datatype send_type,
- void *recv_buff, const int *recv_counts, const int *recv_disps,
- MPI_Datatype recv_type,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int alltoallv__pair_light_barrier(const void *send_buff, const int *send_counts, const int *send_disps,
+ MPI_Datatype send_type,
+ void *recv_buff, const int *recv_counts, const int *recv_disps,
+ MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
MPI_Status s;
* Author: Ahmad Faraj
****************************************************************************/
-namespace simgrid{
-namespace smpi{
-int
-Coll_alltoallv_pair_mpi_barrier::alltoallv(const void *send_buff, const int *send_counts, const int *send_disps,
- MPI_Datatype send_type,
- void *recv_buff, const int *recv_counts, const int *recv_disps,
- MPI_Datatype recv_type, MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int alltoallv__pair_mpi_barrier(const void *send_buff, const int *send_counts, const int *send_disps,
+ MPI_Datatype send_type,
+ void *recv_buff, const int *recv_counts, const int *recv_disps,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Status s;
MPI_Aint send_chunk, recv_chunk;
****************************************************************************/
namespace simgrid{
namespace smpi{
-int
-Coll_alltoallv_pair_one_barrier::alltoallv(const void *send_buff, const int *send_counts, const int *send_disps,
- MPI_Datatype send_type,
- void *recv_buff, const int *recv_counts, const int *recv_disps, MPI_Datatype recv_type, MPI_Comm comm)
+int alltoallv__pair_one_barrier(const void *send_buff, const int *send_counts, const int *send_disps,
+ MPI_Datatype send_type,
+ void *recv_buff, const int *recv_counts, const int *recv_disps, MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
* Author: Ahmad Faraj
****************************************************************************/
-namespace simgrid{
-namespace smpi{
-int Coll_alltoallv_pair::alltoallv(const void *send_buff, const int *send_counts, const int *send_disps,
- MPI_Datatype send_type,
- void *recv_buff, const int *recv_counts, const int *recv_disps,
- MPI_Datatype recv_type, MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int alltoallv__pair(const void *send_buff, const int *send_counts, const int *send_disps,
+ MPI_Datatype send_type,
+ void *recv_buff, const int *recv_counts, const int *recv_disps,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
****************************************************************************/
namespace simgrid{
namespace smpi{
-int
-Coll_alltoallv_ring_light_barrier::alltoallv(const void *send_buff, const int *send_counts, const int *send_disps,
- MPI_Datatype send_type,
- void *recv_buff, const int *recv_counts, const int *recv_disps,
- MPI_Datatype recv_type,
- MPI_Comm comm)
+int alltoallv__ring_light_barrier(const void *send_buff, const int *send_counts, const int *send_disps,
+ MPI_Datatype send_type,
+ void *recv_buff, const int *recv_counts, const int *recv_disps,
+ MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Aint send_chunk, recv_chunk;
MPI_Status s;
****************************************************************************/
namespace simgrid{
namespace smpi{
-int
-Coll_alltoallv_ring_mpi_barrier::alltoallv(const void *send_buff, const int *send_counts, const int *send_disps,
- MPI_Datatype send_type,
- void *recv_buff, const int *recv_counts, const int *recv_disps,
- MPI_Datatype recv_type, MPI_Comm comm)
+int alltoallv__ring_mpi_barrier(const void *send_buff, const int *send_counts, const int *send_disps,
+ MPI_Datatype send_type,
+ void *recv_buff, const int *recv_counts, const int *recv_disps,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Status s;
MPI_Aint send_chunk, recv_chunk;
****************************************************************************/
namespace simgrid{
namespace smpi{
-int
-Coll_alltoallv_ring_one_barrier::alltoallv(const void *send_buff, const int *send_counts, const int *send_disps,
- MPI_Datatype send_type,
- void *recv_buff, const int *recv_counts, const int *recv_disps,
- MPI_Datatype recv_type, MPI_Comm comm)
+int alltoallv__ring_one_barrier(const void *send_buff, const int *send_counts, const int *send_disps,
+ MPI_Datatype send_type,
+ void *recv_buff, const int *recv_counts, const int *recv_disps,
+ MPI_Datatype recv_type, MPI_Comm comm)
{
MPI_Status s;
MPI_Aint send_chunk, recv_chunk;
****************************************************************************/
namespace simgrid{
namespace smpi{
-int Coll_alltoallv_ring::alltoallv(const void* send_buff, const int* send_counts, const int* send_disps, MPI_Datatype send_type,
- void* recv_buff, const int* recv_counts, const int* recv_disps, MPI_Datatype recv_type,
- MPI_Comm comm)
+int alltoallv__ring(const void* send_buff, const int* send_counts, const int* send_disps, MPI_Datatype send_type,
+ void* recv_buff, const int* recv_counts, const int* recv_disps, MPI_Datatype recv_type,
+ MPI_Comm comm)
{
MPI_Status s;
MPI_Aint send_chunk, recv_chunk;
namespace simgrid{
namespace smpi{
-int Coll_barrier_mpich_smp::barrier(MPI_Comm comm)
+int barrier__mpich_smp(MPI_Comm comm)
{
int mpi_errno = MPI_SUCCESS;
int mpi_errno_ret = MPI_SUCCESS;
local_rank = shmem_comm->rank();
/* do the intranode barrier on all nodes */
if (shmem_comm != NULL) {
- mpi_errno = Coll_barrier_mpich::barrier(shmem_comm);
+ mpi_errno = barrier__mpich(shmem_comm);
if (mpi_errno) {
mpi_errno_ret+=mpi_errno;
}
leader_comm = comm->get_leaders_comm();
/* do the barrier across roots of all nodes */
if (leader_comm != NULL && local_rank == 0) {
- mpi_errno = Coll_barrier_mpich::barrier(leader_comm);
+ mpi_errno = barrier__mpich(leader_comm);
if (mpi_errno) {
mpi_errno_ret+=mpi_errno;
}
* anything) */
if (shmem_comm != NULL) {
int i = 0;
- mpi_errno = Coll_bcast_mpich::bcast(&i, 1, MPI_BYTE, 0, shmem_comm);
+ mpi_errno = bcast__mpich(&i, 1, MPI_BYTE, 0, shmem_comm);
if (mpi_errno) {
mpi_errno_ret+=mpi_errno;
}
#include "../colls_private.hpp"
namespace simgrid{
namespace smpi{
-int Coll_barrier_mvapich2_pair::barrier(MPI_Comm comm)
+int barrier__mvapich2_pair(MPI_Comm comm)
{
int size, rank;
* synchronous guarantee made by last ring of sends are synchronous
*
*/
-namespace simgrid{
-namespace smpi{
-int Coll_barrier_ompi_doublering::barrier(MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int barrier__ompi_doublering(MPI_Comm comm)
{
int rank, size;
int left, right;
* To make synchronous, uses sync sends and sync sendrecvs
*/
-int Coll_barrier_ompi_recursivedoubling::barrier(MPI_Comm comm)
+int barrier__ompi_recursivedoubling(MPI_Comm comm)
{
int rank, size, adjsize;
int mask, remote;
* To make synchronous, uses sync sends and sync sendrecvs
*/
-int Coll_barrier_ompi_bruck::barrier(MPI_Comm comm)
+int barrier__ompi_bruck(MPI_Comm comm)
{
int rank, size;
int distance, to, from;
* To make synchronous, uses sync sends and sync sendrecvs
*/
/* special case for two processes */
-int Coll_barrier_ompi_two_procs::barrier(MPI_Comm comm)
+int barrier__ompi_two_procs(MPI_Comm comm)
{
int remote;
/* copied function (with appropriate renaming) starts here */
-int Coll_barrier_ompi_basic_linear::barrier(MPI_Comm comm)
+int barrier__ompi_basic_linear(MPI_Comm comm)
{
int i;
int size = comm->size();
* Another recursive doubling type algorithm, but in this case
* we go up the tree and back down the tree.
*/
-int Coll_barrier_ompi_tree::barrier(MPI_Comm comm)
+int barrier__ompi_tree(MPI_Comm comm)
{
int rank, size, depth;
int jump, partner;
int bcast_NTSB_segment_size_in_byte = 8192;
namespace simgrid{
namespace smpi{
-int Coll_bcast_NTSB::bcast(void *buf, int count, MPI_Datatype datatype,
- int root, MPI_Comm comm)
+int bcast__NTSB(void *buf, int count, MPI_Datatype datatype,
+ int root, MPI_Comm comm)
{
int tag = COLL_TAG_BCAST;
MPI_Status status;
*/
namespace simgrid{
namespace smpi{
-int Coll_bcast_NTSL_Isend::bcast(void *buf, int count, MPI_Datatype datatype,
- int root, MPI_Comm comm)
+int bcast__NTSL_Isend(void *buf, int count, MPI_Datatype datatype,
+ int root, MPI_Comm comm)
{
int tag = COLL_TAG_BCAST;
MPI_Status status;
*/
namespace simgrid{
namespace smpi{
-int Coll_bcast_NTSL::bcast(void *buf, int count, MPI_Datatype datatype,
- int root, MPI_Comm comm)
+int bcast__NTSL(void *buf, int count, MPI_Datatype datatype,
+ int root, MPI_Comm comm)
{
int tag = COLL_TAG_BCAST;
MPI_Status status;
int bcast_SMP_binary_segment_byte = 8192;
namespace simgrid{
namespace smpi{
-int Coll_bcast_SMP_binary::bcast(void *buf, int count,
- MPI_Datatype datatype, int root,
- MPI_Comm comm)
+int bcast__SMP_binary(void *buf, int count,
+ MPI_Datatype datatype, int root,
+ MPI_Comm comm)
{
int tag = COLL_TAG_BCAST;
MPI_Status status;
host_num_core = comm->get_intra_comm()->size();
}else{
//implementation buggy in this case
- return Coll_bcast_mpich::bcast( buf , count, datatype,
- root, comm);
+ return bcast__mpich(buf , count, datatype, root, comm);
}
int segment = bcast_SMP_binary_segment_byte / extent;
#include "../colls_private.hpp"
namespace simgrid{
namespace smpi{
-int Coll_bcast_SMP_binomial::bcast(void *buf, int count,
- MPI_Datatype datatype, int root,
- MPI_Comm comm)
+int bcast__SMP_binomial(void *buf, int count,
+ MPI_Datatype datatype, int root,
+ MPI_Comm comm)
{
int mask = 1;
int size;
num_core = comm->get_intra_comm()->size();
}else{
//implementation buggy in this case
- return Coll_bcast_mpich::bcast( buf , count, datatype,
- root, comm);
+ return bcast__mpich(buf, count, datatype, root, comm);
}
int to_intra, to_inter;
int bcast_SMP_linear_segment_byte = 8192;
namespace simgrid{
namespace smpi{
-int Coll_bcast_SMP_linear::bcast(void *buf, int count,
- MPI_Datatype datatype, int root,
- MPI_Comm comm)
+int bcast__SMP_linear(void *buf, int count,
+ MPI_Datatype datatype, int root,
+ MPI_Comm comm)
{
int tag = COLL_TAG_BCAST;
MPI_Status status;
num_core = comm->get_intra_comm()->size();
}else{
//implementation buggy in this case
- return Coll_bcast_mpich::bcast( buf , count, datatype,
- root, comm);
+ return bcast__mpich(buf, count, datatype, root, comm);
}
int segment = bcast_SMP_linear_segment_byte / extent;
// call native when MPI communication size is too small
if (size <= num_core) {
XBT_WARN("MPI_bcast_SMP_linear use default MPI_bcast.");
- Coll_bcast_default::bcast(buf, count, datatype, root, comm);
+ bcast__default(buf, count, datatype, root, comm);
return MPI_SUCCESS;
}
// if root is not zero send to rank zero first
namespace simgrid{
namespace smpi{
/* Non-topology-specific pipelined linear-bcast function */
-int Coll_bcast_arrival_pattern_aware_wait::bcast(void *buf, int count,
- MPI_Datatype datatype,
- int root, MPI_Comm comm)
+int bcast__arrival_pattern_aware_wait(void *buf, int count,
+ MPI_Datatype datatype,
+ int root, MPI_Comm comm)
{
MPI_Status status;
MPI_Request request;
namespace simgrid{
namespace smpi{
/* Non-topology-specific pipelined linear-bcast function */
-int Coll_bcast_arrival_pattern_aware::bcast(void *buf, int count,
- MPI_Datatype datatype, int root,
- MPI_Comm comm)
+int bcast__arrival_pattern_aware(void *buf, int count,
+ MPI_Datatype datatype, int root,
+ MPI_Comm comm)
{
int tag = -COLL_TAG_BCAST;
MPI_Status status;
namespace simgrid{
namespace smpi{
/* Non-topology-specific pipelined linear-bcast function */
-int Coll_bcast_arrival_scatter::bcast(void *buf, int count,
- MPI_Datatype datatype, int root,
- MPI_Comm comm)
+int bcast__arrival_scatter(void *buf, int count,
+ MPI_Datatype datatype, int root,
+ MPI_Comm comm)
{
int tag = -COLL_TAG_BCAST;//in order to use ANY_TAG, make this one positive
int header_tag = -10;
* Author: MPIH / modified by Ahmad Faraj
****************************************************************************/
-namespace simgrid{
-namespace smpi{
-int
-Coll_bcast_binomial_tree::bcast(void *buff, int count,
- MPI_Datatype data_type, int root,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int bcast__binomial_tree(void *buff, int count,
+ MPI_Datatype data_type, int root,
+ MPI_Comm comm)
{
int src, dst, rank, num_procs, mask, relative_rank;
int tag = COLL_TAG_BCAST;
#include "../colls_private.hpp"
int flattree_segment_in_byte = 8192;
-namespace simgrid{
-namespace smpi{
-int
-Coll_bcast_flattree_pipeline::bcast(void *buff, int count,
- MPI_Datatype data_type, int root,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int bcast__flattree_pipeline(void *buff, int count,
+ MPI_Datatype data_type, int root,
+ MPI_Comm comm)
{
int i, j, rank, num_procs;
int tag = COLL_TAG_BCAST;
int increment = segment * extent;
if (pipe_length==0) {
XBT_WARN("MPI_bcast_flattree_pipeline use default MPI_bcast_flattree.");
- return Coll_bcast_flattree::bcast(buff, count, data_type, root, comm);
+ return bcast__flattree(buff, count, data_type, root, comm);
}
rank = comm->rank();
num_procs = comm->size();
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "../colls_private.hpp"
-namespace simgrid{
-namespace smpi{
-int
-Coll_bcast_flattree::bcast(void *buff, int count, MPI_Datatype data_type,
- int root, MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int bcast__flattree(void *buff, int count, MPI_Datatype data_type,
+ int root, MPI_Comm comm)
{
int i, rank, num_procs;
int tag = COLL_TAG_BCAST;
extern int mv2_bcast_two_level_system_size;
#define INTRA_NODE_ROOT 0
-#define MPIR_Pipelined_Bcast_Zcpy_MV2 Coll_bcast_mpich::bcast
-#define MPIR_Pipelined_Bcast_MV2 Coll_bcast_mpich::bcast
-#define MPIR_Bcast_binomial_MV2 Coll_bcast_binomial_tree::bcast
-#define MPIR_Bcast_scatter_ring_allgather_shm_MV2 Coll_bcast_scatter_LR_allgather::bcast
-#define MPIR_Bcast_scatter_doubling_allgather_MV2 Coll_bcast_scatter_rdb_allgather::bcast
-#define MPIR_Bcast_scatter_ring_allgather_MV2 Coll_bcast_scatter_LR_allgather::bcast
-#define MPIR_Shmem_Bcast_MV2 Coll_bcast_mpich::bcast
-#define MPIR_Bcast_tune_inter_node_helper_MV2 Coll_bcast_mvapich2_inter_node::bcast
-#define MPIR_Bcast_inter_node_helper_MV2 Coll_bcast_mvapich2_inter_node::bcast
-#define MPIR_Knomial_Bcast_intra_node_MV2 Coll_bcast_mvapich2_knomial_intra_node::bcast
-#define MPIR_Bcast_intra_MV2 Coll_bcast_mvapich2_intra_node::bcast
+#define MPIR_Pipelined_Bcast_Zcpy_MV2 bcast__mpich
+#define MPIR_Pipelined_Bcast_MV2 bcast__mpich
+#define MPIR_Bcast_binomial_MV2 bcast__binomial_tree
+#define MPIR_Bcast_scatter_ring_allgather_shm_MV2 bcast__scatter_LR_allgather
+#define MPIR_Bcast_scatter_doubling_allgather_MV2 bcast__scatter_rdb_allgather
+#define MPIR_Bcast_scatter_ring_allgather_MV2 bcast__scatter_LR_allgather
+#define MPIR_Shmem_Bcast_MV2 bcast__mpich
+#define MPIR_Bcast_tune_inter_node_helper_MV2 bcast__mvapich2_inter_node
+#define MPIR_Bcast_inter_node_helper_MV2 bcast__mvapich2_inter_node
+#define MPIR_Knomial_Bcast_intra_node_MV2 bcast__mvapich2_knomial_intra_node
+#define MPIR_Bcast_intra_MV2 bcast__mvapich2_intra_node
extern int zcpy_knomial_factor;
extern int mv2_pipelined_zcpy_knomial_factor;
#define mv2_bcast_large_msg 512*1024
#define mv2_knomial_intra_node_threshold 131072
#define mv2_scatter_rd_inter_leader_bcast 1
-namespace simgrid{
-namespace smpi{
-int Coll_bcast_mvapich2_inter_node::bcast(void *buffer,
- int count,
- MPI_Datatype datatype,
- int root,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int bcast__mvapich2_inter_node(void *buffer,
+ int count,
+ MPI_Datatype datatype,
+ int root,
+ MPI_Comm comm)
{
int rank;
int mpi_errno = MPI_SUCCESS;
if (MV2_Bcast_function==NULL){
- MV2_Bcast_function=Coll_bcast_mpich::bcast;
+ MV2_Bcast_function = bcast__mpich;
}
if (MV2_Bcast_intra_node_function==NULL){
- MV2_Bcast_intra_node_function= Coll_bcast_mpich::bcast;
+ MV2_Bcast_intra_node_function = bcast__mpich;
}
if(comm->get_leaders_comm()==MPI_COMM_NULL){
}
-int Coll_bcast_mvapich2_knomial_intra_node::bcast(void *buffer,
- int count,
- MPI_Datatype datatype,
- int root, MPI_Comm comm)
+int bcast__mvapich2_knomial_intra_node(void *buffer,
+ int count,
+ MPI_Datatype datatype,
+ int root, MPI_Comm comm)
{
int local_size = 0, rank;
int mpi_errno = MPI_SUCCESS;
int src, dst, mask, relative_rank;
int k;
if (MV2_Bcast_function==NULL){
- MV2_Bcast_function=Coll_bcast_mpich::bcast;
+ MV2_Bcast_function = bcast__mpich;
}
if (MV2_Bcast_intra_node_function==NULL){
- MV2_Bcast_intra_node_function= Coll_bcast_mpich::bcast;
+ MV2_Bcast_intra_node_function = bcast__mpich;
}
if(comm->get_leaders_comm()==MPI_COMM_NULL){
}
-int Coll_bcast_mvapich2_intra_node::bcast(void *buffer,
- int count,
- MPI_Datatype datatype,
- int root, MPI_Comm comm)
+int bcast__mvapich2_intra_node(void *buffer,
+ int count,
+ MPI_Datatype datatype,
+ int root, MPI_Comm comm)
{
int mpi_errno = MPI_SUCCESS;
int comm_size;
if (count == 0)
return MPI_SUCCESS;
if (MV2_Bcast_function==NULL){
- MV2_Bcast_function=Coll_bcast_mpich::bcast;
+ MV2_Bcast_function = bcast__mpich;
}
if (MV2_Bcast_intra_node_function==NULL){
- MV2_Bcast_intra_node_function= Coll_bcast_mpich::bcast;
+ MV2_Bcast_intra_node_function = bcast__mpich;
}
if(comm->get_leaders_comm()==MPI_COMM_NULL){
namespace simgrid{
namespace smpi{
-int Coll_bcast_ompi_pipeline::bcast( void* buffer,
- int original_count,
- MPI_Datatype datatype,
- int root,
- MPI_Comm comm)
+int bcast__ompi_pipeline( void* buffer,
+ int original_count,
+ MPI_Datatype datatype,
+ int root,
+ MPI_Comm comm)
{
int count_by_segment = original_count;
size_t type_size;
#include "../coll_tuned_topo.hpp"
#include "../colls_private.hpp"
#define MAXTREEFANOUT 32
-namespace simgrid{
-namespace smpi{
-
-int
-Coll_bcast_ompi_split_bintree::bcast ( void* buffer,
- int count,
- MPI_Datatype datatype,
- int root,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+
+int bcast__ompi_split_bintree( void* buffer,
+ int count,
+ MPI_Datatype datatype,
+ int root,
+ MPI_Comm comm)
{
unsigned int segsize ;
int rank, size;
(segsize > counts[0] * type_size) ||
(segsize > counts[1] * type_size) ) {
/* call linear version here ! */
- return (Coll_bcast_SMP_linear::bcast ( buffer, count, datatype,
- root, comm));
+ return bcast__SMP_linear( buffer, count, datatype, root, comm);
}
type_extent = datatype->get_extent();
* Author: MPIH / modified by Ahmad Faraj
****************************************************************************/
-namespace simgrid{
-namespace smpi{
-int
-Coll_bcast_scatter_LR_allgather::bcast(void *buff, int count,
- MPI_Datatype data_type, int root,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int bcast__scatter_LR_allgather(void *buff, int count,
+ MPI_Datatype data_type, int root,
+ MPI_Comm comm)
{
MPI_Aint extent;
MPI_Status status;
}
-int
-Coll_bcast_scatter_rdb_allgather::bcast (
+int bcast__scatter_rdb_allgather(
void *buffer,
int count,
MPI_Datatype datatype,
#include "../colls_private.hpp"
#include <algorithm>
-#define MPIR_Gather_MV2_Direct Coll_gather_ompi_basic_linear::gather
-#define MPIR_Gather_MV2_two_level_Direct Coll_gather_ompi_basic_linear::gather
-#define MPIR_Gather_intra Coll_gather_mpich::gather
+#define MPIR_Gather_MV2_Direct gather__ompi_basic_linear
+#define MPIR_Gather_MV2_two_level_Direct gather__ompi_basic_linear
+#define MPIR_Gather_intra gather__mpich
typedef int (*MV2_Gather_function_ptr) (const void *sendbuf,
int sendcnt,
MPI_Datatype sendtype,
-int Coll_gather_mvapich2_two_level::gather(const void *sendbuf,
- int sendcnt,
- MPI_Datatype sendtype,
- void *recvbuf,
- int recvcnt,
- MPI_Datatype recvtype,
- int root,
- MPI_Comm comm)
+int gather__mvapich2_two_level(const void *sendbuf,
+ int sendcnt,
+ MPI_Datatype sendtype,
+ void *recvbuf,
+ int recvcnt,
+ MPI_Datatype recvtype,
+ int root,
+ MPI_Comm comm)
{
unsigned char* leader_gather_buf = NULL;
int comm_size, rank;
// if not set (use of the algo directly, without mvapich2 selector)
if (MV2_Gather_intra_node_function == NULL)
- MV2_Gather_intra_node_function = Coll_gather_mpich::gather;
+ MV2_Gather_intra_node_function = gather__mpich;
if (comm->get_leaders_comm() == MPI_COMM_NULL) {
comm->init_smp();
#include "../coll_tuned_topo.hpp"
#include "../colls_private.hpp"
-namespace simgrid{
-namespace smpi{
+namespace simgrid {
+namespace smpi {
-int Coll_gather_ompi_binomial::gather(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
- MPI_Datatype rdtype, int root, MPI_Comm comm)
+int gather__ompi_binomial(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
+ MPI_Datatype rdtype, int root, MPI_Comm comm)
{
int line = -1;
int i;
* Accepts: - same arguments as MPI_Gather(), first segment size
* Returns: - MPI_SUCCESS or error code
*/
-int Coll_gather_ompi_linear_sync::gather(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void *rbuf, int rcount,
- MPI_Datatype rdtype,
- int root,
- MPI_Comm comm)
+int gather__ompi_linear_sync(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void *rbuf, int rcount,
+ MPI_Datatype rdtype,
+ int root,
+ MPI_Comm comm)
{
int i;
int ret, line;
* Accepts: - same arguments as MPI_Gather()
* Returns: - MPI_SUCCESS or error code
*/
-int Coll_gather_ompi_basic_linear::gather(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
- MPI_Datatype rdtype, int root, MPI_Comm comm)
+int gather__ompi_basic_linear(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
+ MPI_Datatype rdtype, int root, MPI_Comm comm)
{
int i;
int err;
/* Non-topology-specific pipelined linear-bcast function
0->1, 1->2 ,2->3, ....., ->last node : in a pipeline fashion
*/
-namespace simgrid{
-namespace smpi{
-int Coll_reduce_NTSL::reduce(const void *buf, void *rbuf, int count,
- MPI_Datatype datatype, MPI_Op op, int root,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int reduce__NTSL(const void *buf, void *rbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, int root,
+ MPI_Comm comm)
{
int tag = COLL_TAG_REDUCE;
MPI_Status status;
/* when count is not divisible by block size, use default BCAST for the remainder */
if ((remainder != 0) && (count > segment)) {
XBT_WARN("MPI_reduce_NTSL use default MPI_reduce.");
- Coll_reduce_default::reduce((char *)buf + (pipe_length * increment),
- (char *)rbuf + (pipe_length * increment), remainder, datatype, op, root,
- comm);
+ reduce__default((char *)buf + (pipe_length * increment),
+ (char *)rbuf + (pipe_length * increment), remainder, datatype, op, root,
+ comm);
}
smpi_free_tmp_buffer(tmp_buf);
namespace simgrid{
namespace smpi{
/* Non-topology-specific pipelined linear-reduce function */
-int Coll_reduce_arrival_pattern_aware::reduce(const void *buf, void *rbuf,
- int count,
- MPI_Datatype datatype,
- MPI_Op op, int root,
- MPI_Comm comm)
+int reduce__arrival_pattern_aware(const void *buf, void *rbuf,
+ int count,
+ MPI_Datatype datatype,
+ MPI_Op op, int root,
+ MPI_Comm comm)
{
int rank = comm->rank();
int tag = -COLL_TAG_REDUCE;
/* when count is not divisible by block size, use default BCAST for the remainder */
if ((remainder != 0) && (count > segment)) {
- Coll_reduce_default::reduce((char*)buf + (pipe_length * increment), (char*)rbuf + (pipe_length * increment),
- remainder, datatype, op, root, comm);
+ reduce__default((char*)buf + (pipe_length * increment), (char*)rbuf + (pipe_length * increment),
+ remainder, datatype, op, root, comm);
}
smpi_free_tmp_buffer(tmp_buf);
//#include <star-reduction.c>
namespace simgrid{
namespace smpi{
-int Coll_reduce_binomial::reduce(const void *sendbuf, void *recvbuf, int count,
- MPI_Datatype datatype, MPI_Op op, int root,
- MPI_Comm comm)
+int reduce__binomial(const void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, int root,
+ MPI_Comm comm)
{
MPI_Status status;
int comm_size, rank;
#include "../colls_private.hpp"
//#include <star-reduction.c>
-namespace simgrid{
-namespace smpi{
-int
-Coll_reduce_flat_tree::reduce(const void *sbuf, void *rbuf, int count,
- MPI_Datatype dtype, MPI_Op op,
- int root, MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int reduce__flat_tree(const void *sbuf, void *rbuf, int count,
+ MPI_Datatype dtype, MPI_Op op,
+ int root, MPI_Comm comm)
{
int i, tag = COLL_TAG_REDUCE;
int size;
return 0;
}
-namespace simgrid{
-namespace smpi{
-int Coll_reduce_mvapich2_knomial::reduce (
+namespace simgrid {
+namespace smpi {
+int reduce__mvapich2_knomial(
const void *sendbuf,
void *recvbuf,
int count,
#define SHMEM_COLL_BLOCK_SIZE (local_size * mv2_g_shmem_coll_max_msg_size)
#define mv2_use_knomial_reduce 1
-#define MPIR_Reduce_inter_knomial_wrapper_MV2 Coll_reduce_mvapich2_knomial::reduce
-#define MPIR_Reduce_intra_knomial_wrapper_MV2 Coll_reduce_mvapich2_knomial::reduce
-#define MPIR_Reduce_binomial_MV2 Coll_reduce_binomial::reduce
-#define MPIR_Reduce_redscat_gather_MV2 Coll_reduce_scatter_gather::reduce
-#define MPIR_Reduce_shmem_MV2 Coll_reduce_ompi_basic_linear::reduce
+#define MPIR_Reduce_inter_knomial_wrapper_MV2 reduce__mvapich2_knomial
+#define MPIR_Reduce_intra_knomial_wrapper_MV2 reduce__mvapich2_knomial
+#define MPIR_Reduce_binomial_MV2 reduce__binomial
+#define MPIR_Reduce_redscat_gather_MV2 reduce__scatter_gather
+#define MPIR_Reduce_shmem_MV2 reduce__ompi_basic_linear
extern int (*MV2_Reduce_function)( const void *sendbuf,
void *recvbuf,
int count,
MPI_Datatype datatype,
MPI_Op op, int root, MPI_Comm comm);
-namespace simgrid{
-namespace smpi{
-int Coll_reduce_mvapich2_two_level::reduce( const void *sendbuf,
- void *recvbuf,
- int count,
- MPI_Datatype datatype,
- MPI_Op op,
- int root,
- MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int reduce__mvapich2_two_level( const void *sendbuf,
+ void *recvbuf,
+ int count,
+ MPI_Datatype datatype,
+ MPI_Op op,
+ int root,
+ MPI_Comm comm)
{
int mpi_errno = MPI_SUCCESS;
int my_rank, total_size, local_rank, local_size;
//if not set (use of the algo directly, without mvapich2 selector)
if(MV2_Reduce_function==NULL)
- MV2_Reduce_function=Coll_reduce_mpich::reduce;
+ MV2_Reduce_function = reduce__mpich;
if(MV2_Reduce_intra_function==NULL)
- MV2_Reduce_intra_function=Coll_reduce_mpich::reduce;
+ MV2_Reduce_intra_function = reduce__mpich;
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
*/
-int Coll_reduce_ompi_chain::reduce(const void *sendbuf, void *recvbuf, int count,
- MPI_Datatype datatype,
- MPI_Op op, int root,
- MPI_Comm comm
- )
+int reduce__ompi_chain(const void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype,
+ MPI_Op op, int root,
+ MPI_Comm comm
+ )
{
uint32_t segsize=64*1024;
int segcount = count;
}
-int Coll_reduce_ompi_pipeline::reduce(const void *sendbuf, void *recvbuf,
- int count, MPI_Datatype datatype,
- MPI_Op op, int root,
- MPI_Comm comm )
+int reduce__ompi_pipeline(const void *sendbuf, void *recvbuf,
+ int count, MPI_Datatype datatype,
+ MPI_Op op, int root,
+ MPI_Comm comm )
{
uint32_t segsize;
segcount, 0);
}
-int Coll_reduce_ompi_binary::reduce(const void *sendbuf, void *recvbuf,
- int count, MPI_Datatype datatype,
- MPI_Op op, int root,
- MPI_Comm comm)
+int reduce__ompi_binary(const void *sendbuf, void *recvbuf,
+ int count, MPI_Datatype datatype,
+ MPI_Op op, int root,
+ MPI_Comm comm)
{
uint32_t segsize;
int segcount = count;
segcount, 0);
}
-int Coll_reduce_ompi_binomial::reduce(const void *sendbuf, void *recvbuf,
- int count, MPI_Datatype datatype,
- MPI_Op op, int root,
- MPI_Comm comm)
+int reduce__ompi_binomial(const void *sendbuf, void *recvbuf,
+ int count, MPI_Datatype datatype,
+ MPI_Op op, int root,
+ MPI_Comm comm)
{
uint32_t segsize=0;
* Accepts: same as MPI_Reduce()
* Returns: MPI_SUCCESS or error code
*/
-int Coll_reduce_ompi_in_order_binary::reduce(const void *sendbuf, void *recvbuf,
- int count,
- MPI_Datatype datatype,
- MPI_Op op, int root,
- MPI_Comm comm)
+int reduce__ompi_in_order_binary(const void *sendbuf, void *recvbuf,
+ int count,
+ MPI_Datatype datatype,
+ MPI_Op op, int root,
+ MPI_Comm comm)
{
uint32_t segsize=0;
int ret;
* Returns: - MPI_SUCCESS or error code
*/
-int
-Coll_reduce_ompi_basic_linear::reduce(const void *sbuf, void *rbuf, int count,
- MPI_Datatype dtype,
- MPI_Op op,
- int root,
- MPI_Comm comm)
+int reduce__ompi_basic_linear(const void *sbuf, void *rbuf, int count,
+ MPI_Datatype dtype,
+ MPI_Op op,
+ int root,
+ MPI_Comm comm)
{
int i, rank, size;
ptrdiff_t true_extent, lb, extent;
#endif /*REDUCE_LIMITS*/
-int Coll_reduce_rab::reduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
+int reduce__rab(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
{
return( MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, root, comm, 0) );
}
-int Coll_allreduce_rab::allreduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+int allreduce__rab(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
return( MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, -1, comm, 1) );
}
*/
namespace simgrid{
namespace smpi{
-int Coll_reduce_scatter_gather::reduce(const void *sendbuf, void *recvbuf,
- int count, MPI_Datatype datatype,
- MPI_Op op, int root, MPI_Comm comm)
+int reduce__scatter_gather(const void *sendbuf, void *recvbuf,
+ int count, MPI_Datatype datatype,
+ MPI_Op op, int root, MPI_Comm comm)
{
MPI_Status status;
int comm_size, rank, pof2, rem, newrank;
namespace simgrid{
namespace smpi{
-int Coll_reduce_scatter_mpich_pair::reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[],
- MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+int reduce_scatter__mpich_pair(const void *sendbuf, void *recvbuf, const int recvcounts[],
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int rank, comm_size, i;
MPI_Aint extent, true_extent, true_lb;
}
-int Coll_reduce_scatter_mpich_noncomm::reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[],
- MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+int reduce_scatter__mpich_noncomm(const void *sendbuf, void *recvbuf, const int recvcounts[],
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int mpi_errno = MPI_SUCCESS;
int comm_size = comm->size() ;
-int Coll_reduce_scatter_mpich_rdb::reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[],
+int reduce_scatter__mpich_rdb(const void *sendbuf, void *recvbuf, const int recvcounts[],
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int rank, comm_size, i;
* Returns: - MPI_SUCCESS or error code
* Limitation: - Works only for commutative operations.
*/
-namespace simgrid{
-namespace smpi{
-int
-Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf,
- void *rbuf,
- const int *rcounts,
- MPI_Datatype dtype,
- MPI_Op op,
- MPI_Comm comm
- )
+namespace simgrid {
+namespace smpi {
+int reduce_scatter__ompi_basic_recursivehalving(const void *sbuf,
+ void *rbuf,
+ const int *rcounts,
+ MPI_Datatype dtype,
+ MPI_Op op,
+ MPI_Comm comm
+ )
{
int i, rank, size, count, err = MPI_SUCCESS;
int tmp_size = 1, remain = 0, tmp_rank;
* DONE :)
*
*/
-int
-Coll_reduce_scatter_ompi_ring::reduce_scatter(const void *sbuf, void *rbuf, const int *rcounts,
- MPI_Datatype dtype,
- MPI_Op op,
- MPI_Comm comm
- )
+int reduce_scatter__ompi_ring(const void *sbuf, void *rbuf, const int *rcounts,
+ MPI_Datatype dtype,
+ MPI_Op op,
+ MPI_Comm comm
+ )
{
int ret, line, rank, size, i, k, recv_from, send_to, total_count, max_block_count;
int inbi;
*/
#include "../colls_private.hpp"
-#define MPIR_Scatter_MV2_Binomial Coll_scatter_ompi_binomial::scatter
-#define MPIR_Scatter_MV2_Direct Coll_scatter_ompi_basic_linear::scatter
+#define MPIR_Scatter_MV2_Binomial scatter__ompi_binomial
+#define MPIR_Scatter_MV2_Direct scatter__ompi_basic_linear
extern int (*MV2_Scatter_intra_function) (const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
namespace simgrid{
namespace smpi{
-int Coll_scatter_mvapich2_two_level_direct::scatter(const void *sendbuf,
- int sendcnt,
- MPI_Datatype sendtype,
- void *recvbuf,
- int recvcnt,
- MPI_Datatype recvtype,
- int root, MPI_Comm comm)
+int scatter__mvapich2_two_level_direct(const void *sendbuf,
+ int sendcnt,
+ MPI_Datatype sendtype,
+ void *recvbuf,
+ int recvcnt,
+ MPI_Datatype recvtype,
+ int root, MPI_Comm comm)
{
int comm_size, rank;
int local_rank, local_size;
MPI_Comm shmem_comm, leader_comm;
//if not set (use of the algo directly, without mvapich2 selector)
if(MV2_Scatter_intra_function==NULL)
- MV2_Scatter_intra_function=Coll_scatter_mpich::scatter;
+ MV2_Scatter_intra_function = scatter__mpich;
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
}
-int Coll_scatter_mvapich2_two_level_binomial::scatter(const void *sendbuf,
- int sendcnt,
- MPI_Datatype sendtype,
- void *recvbuf,
- int recvcnt,
- MPI_Datatype recvtype,
- int root, MPI_Comm comm)
+int scatter__mvapich2_two_level_binomial(const void *sendbuf,
+ int sendcnt,
+ MPI_Datatype sendtype,
+ void *recvbuf,
+ int recvcnt,
+ MPI_Datatype recvtype,
+ int root, MPI_Comm comm)
{
int comm_size, rank;
int local_rank, local_size;
//if not set (use of the algo directly, without mvapich2 selector)
if(MV2_Scatter_intra_function==NULL)
- MV2_Scatter_intra_function=Coll_scatter_mpich::scatter;
+ MV2_Scatter_intra_function = scatter__mpich;
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
namespace simgrid{
namespace smpi{
-int Coll_scatter_ompi_binomial::scatter(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
- MPI_Datatype rdtype, int root, MPI_Comm comm)
+int scatter__ompi_binomial(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
+ MPI_Datatype rdtype, int root, MPI_Comm comm)
{
int line = -1;
int i;
* Accepts: - same arguments as MPI_Scatter()
* Returns: - MPI_SUCCESS or error code
*/
-int Coll_scatter_ompi_basic_linear::scatter(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
- MPI_Datatype rdtype, int root, MPI_Comm comm)
+int scatter__ompi_basic_linear(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
+ MPI_Datatype rdtype, int root, MPI_Comm comm)
{
int i, rank, size, err;
char *ptmp;
}
#define AUTOMATIC_COLL_BENCH(cat, ret, args, args2) \
- ret _XBT_CONCAT3(Coll_, cat, _automatic)::cat(COLL_UNPAREN args) \
+ ret _XBT_CONCAT2(cat, __automatic)(COLL_UNPAREN args) \
{ \
double time1, time2, time_min = DBL_MAX; \
int min_coll = -1, global_coll = -1; \
continue; \
if (Colls::_XBT_CONCAT3(mpi_coll_, cat, _description)[i].name == "default") \
continue; \
- Coll_barrier_default::barrier(comm); \
+ barrier__default(comm); \
TRACE_AUTO_COLL(cat) \
time1 = SIMIX_get_clock(); \
try { \
} \
time2 = SIMIX_get_clock(); \
buf_out = time2 - time1; \
- Coll_reduce_default::reduce((void*)&buf_out, (void*)&buf_in, 1, MPI_DOUBLE, MPI_MAX, 0, comm); \
+ reduce__default((void*)&buf_out, (void*)&buf_in, 1, MPI_DOUBLE, MPI_MAX, 0, comm); \
if (time2 - time1 < time_min) { \
min_coll = i; \
time_min = time2 - time1; \
#include "smpi_request.hpp"
#include "xbt/config.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI (coll)");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI collectives.");
#define COLL_SETTER(cat, ret, args, args2) \
int(*Colls::cat) args; \
return -1;
}
-COLL_APPLY(COLL_SETTER,COLL_GATHER_SIG,"");
+int(*Colls::gather) (const void *send_buff, int send_count, MPI_Datatype send_type,
+ void *recv_buff, int recv_count, MPI_Datatype recv_type,
+ int root, MPI_Comm comm);
+void Colls::set_gather(const std::string& name)
+{
+ int id = find_coll_description(mpi_coll_gather_description, name, "gather");
+ gather = reinterpret_cast<int(*)(const void *send_buff, int send_count, MPI_Datatype send_type,
+ void *recv_buff, int recv_count, MPI_Datatype recv_type,
+ int root, MPI_Comm comm)>(mpi_coll_gather_description[id].coll);
+ if (gather == nullptr)
+ xbt_die("Collective gather set to nullptr!");
+}
+
+//COLL_APPLY(COLL_SETTER,COLL_GATHER_SIG,"");
COLL_APPLY(COLL_SETTER,COLL_ALLGATHER_SIG,"");
COLL_APPLY(COLL_SETTER,COLL_ALLGATHERV_SIG,"");
COLL_APPLY(COLL_SETTER,COLL_REDUCE_SIG,"");
namespace simgrid{
namespace smpi{
-int Coll_bcast_default::bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
+int bcast__default(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
{
- return Coll_bcast_binomial_tree::bcast(buf, count, datatype, root, comm);
+ return bcast__binomial_tree(buf, count, datatype, root, comm);
}
-int Coll_barrier_default::barrier(MPI_Comm comm)
+int barrier__default(MPI_Comm comm)
{
- return Coll_barrier_ompi_basic_linear::barrier(comm);
+ return barrier__ompi_basic_linear(comm);
}
-int Coll_gather_default::gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
+int gather__default(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
{
MPI_Request request;
return Request::wait(&request, MPI_STATUS_IGNORE);
}
-int Coll_reduce_scatter_default::reduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcounts, MPI_Datatype datatype, MPI_Op op,
- MPI_Comm comm)
+int reduce_scatter__default(const void *sendbuf, void *recvbuf, const int *recvcounts, MPI_Datatype datatype, MPI_Op op,
+ MPI_Comm comm)
{
int rank = comm->rank();
}
unsigned char* tmpbuf = smpi_get_tmp_sendbuffer(count * datatype->get_extent());
- int ret = Coll_reduce_default::reduce(sendbuf, tmpbuf, count, datatype, op, 0, comm);
+ int ret = reduce__default(sendbuf, tmpbuf, count, datatype, op, 0, comm);
if(ret==MPI_SUCCESS)
ret = Colls::scatterv(tmpbuf, recvcounts, displs, datatype, recvbuf, recvcounts[rank], datatype, 0, comm);
delete[] displs;
}
-int Coll_allgather_default::allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
- void *recvbuf,int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
+int allgather__default(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf,int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
{
MPI_Request request;
Colls::iallgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, &request);
return Request::wait(&request, MPI_STATUS_IGNORE);
}
-int Coll_allgatherv_default::allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf,
- const int *recvcounts, const int *displs, MPI_Datatype recvtype, MPI_Comm comm)
+int allgatherv__default(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf,
+ const int *recvcounts, const int *displs, MPI_Datatype recvtype, MPI_Comm comm)
{
MPI_Request request;
Colls::iallgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm, &request, 0);
return MPI_SUCCESS;
}
-int Coll_scatter_default::scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
- void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
+int scatter__default(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
{
MPI_Request request;
Colls::iscatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, &request, 0);
return Request::wait(&request, MPI_STATUS_IGNORE);
}
-int Coll_reduce_default::reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root,
- MPI_Comm comm)
+int reduce__default(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root,
+ MPI_Comm comm)
{
//non commutative case, use a working algo from openmpi
if (op != MPI_OP_NULL && (datatype->flags() & DT_FLAG_DERIVED || not op->is_commutative())) {
- return Coll_reduce_ompi_basic_linear::reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
+ return reduce__ompi_basic_linear(sendbuf, recvbuf, count, datatype, op, root, comm);
}
MPI_Request request;
Colls::ireduce(sendbuf, recvbuf, count, datatype, op, root, comm, &request, 0);
return Request::wait(&request, MPI_STATUS_IGNORE);
}
-int Coll_allreduce_default::allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+int allreduce__default(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
//FIXME: have mpi_ireduce and iallreduce handle derived datatypes correctly
if(datatype->flags() & DT_FLAG_DERIVED)
- return Coll_allreduce_ompi::allreduce(sendbuf, recvbuf, count, datatype, op, comm);
+ return allreduce__ompi(sendbuf, recvbuf, count, datatype, op, comm);
int ret;
- ret = Coll_reduce_default::reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
+ ret = reduce__default(sendbuf, recvbuf, count, datatype, op, 0, comm);
if(ret==MPI_SUCCESS)
- ret = Coll_bcast_default::bcast(recvbuf, count, datatype, 0, comm);
+ ret = bcast__default(recvbuf, count, datatype, 0, comm);
return ret;
}
-int Coll_alltoall_default::alltoall(const void *sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount, MPI_Datatype rdtype, MPI_Comm comm)
+int alltoall__default(const void *sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount, MPI_Datatype rdtype, MPI_Comm comm)
{
- return Coll_alltoall_ompi::alltoall(sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);
+ return alltoall__ompi(sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);
}
-int Coll_alltoallv_default::alltoallv(const void *sendbuf, const int *sendcounts, const int *senddisps, MPI_Datatype sendtype,
- void *recvbuf, const int *recvcounts, const int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
+int alltoallv__default(const void *sendbuf, const int *sendcounts, const int *senddisps, MPI_Datatype sendtype,
+ void *recvbuf, const int *recvcounts, const int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
{
MPI_Request request;
Colls::ialltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm, &request, 0);
int count,
MPI_Datatype datatype,
MPI_Op op, MPI_Comm comm) ={
- Coll_allreduce_rdb::allreduce,
- Coll_allreduce_rab1::allreduce,
- Coll_allreduce_redbcast::allreduce,
- Coll_allreduce_mvapich2_two_level::allreduce,
- Coll_allreduce_smp_binomial::allreduce,
- Coll_allreduce_mvapich2_two_level::allreduce,
- Coll_allreduce_ompi_ring_segmented::allreduce,
- Coll_allreduce_ompi_ring_segmented::allreduce
+ allreduce__rdb,
+ allreduce__rab1,
+ allreduce__redbcast,
+ allreduce__mvapich2_two_level,
+ allreduce__smp_binomial,
+ allreduce__mvapich2_two_level,
+ allreduce__ompi_ring_segmented,
+ allreduce__ompi_ring_segmented
};
intel_tuning_table_element intel_allreduce_table[] =
void* rbuf, int rcount,
MPI_Datatype rdtype,
MPI_Comm comm) ={
- Coll_alltoall_bruck::alltoall,
- Coll_alltoall_mvapich2_scatter_dest::alltoall,
- Coll_alltoall_pair::alltoall,
- Coll_alltoall_mvapich2::alltoall//Plum is proprietary ? (and super efficient)
+ alltoall__bruck,
+ alltoall__mvapich2_scatter_dest,
+ alltoall__pair,
+ alltoall__mvapich2//Plum is proprietary ? (and super efficient)
};
/*I_MPI_ADJUST_BARRIER
*/
static int intel_barrier_gather_scatter(MPI_Comm comm){
//our default barrier performs a antibcast/bcast
- Coll_barrier_default::barrier(comm);
+ barrier__default(comm);
return MPI_SUCCESS;
}
int (*intel_barrier_functions_table[])(MPI_Comm comm) ={
- Coll_barrier_ompi_basic_linear::barrier,
- Coll_barrier_ompi_recursivedoubling::barrier,
- Coll_barrier_ompi_basic_linear::barrier,
- Coll_barrier_ompi_recursivedoubling::barrier,
+ barrier__ompi_basic_linear,
+ barrier__ompi_recursivedoubling,
+ barrier__ompi_basic_linear,
+ barrier__ompi_recursivedoubling,
intel_barrier_gather_scatter,
intel_barrier_gather_scatter
};
int (*intel_bcast_functions_table[])(void *buff, int count,
MPI_Datatype datatype, int root,
MPI_Comm comm) ={
- Coll_bcast_binomial_tree::bcast,
- //Coll_bcast_scatter_rdb_allgather::bcast,
- Coll_bcast_NTSL::bcast,
- Coll_bcast_NTSL::bcast,
- Coll_bcast_SMP_binomial::bcast,
- //Coll_bcast_scatter_rdb_allgather::bcast,
- Coll_bcast_NTSL::bcast,
- Coll_bcast_SMP_linear::bcast,
- Coll_bcast_mvapich2::bcast,//we don't know shumilin's algo'
+ bcast__binomial_tree,
+ //bcast__scatter_rdb_allgather,
+ bcast__NTSL,
+ bcast__NTSL,
+ bcast__SMP_binomial,
+ //bcast__scatter_rdb_allgather,
+ bcast__NTSL,
+ bcast__SMP_linear,
+ bcast__mvapich2,//we don't know shumilin's algo'
};
intel_tuning_table_element intel_bcast_table[] =
int count, MPI_Datatype datatype,
MPI_Op op, int root,
MPI_Comm comm) ={
- Coll_reduce_mvapich2::reduce,
- Coll_reduce_binomial::reduce,
- Coll_reduce_mvapich2::reduce,
- Coll_reduce_mvapich2_two_level::reduce,
- Coll_reduce_rab::reduce,
- Coll_reduce_rab::reduce
+ reduce__mvapich2,
+ reduce__binomial,
+ reduce__mvapich2,
+ reduce__mvapich2_two_level,
+ reduce__rab,
+ reduce__rab
};
intel_tuning_table_element intel_reduce_table[] =
MPI_Op op,
MPI_Comm comm)
{
- Coll_reduce_scatter_default::reduce_scatter(sbuf, rbuf, rcounts,dtype, op,comm);
+ reduce_scatter__default(sbuf, rbuf, rcounts,dtype, op,comm);
return MPI_SUCCESS;
}
MPI_Comm comm)
{
if(op==MPI_OP_NULL || op->is_commutative())
- return Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(sbuf, rbuf, rcounts,dtype, op,comm);
+ return reduce_scatter__ompi_basic_recursivehalving(sbuf, rbuf, rcounts,dtype, op,comm);
else
- return Coll_reduce_scatter_mvapich2::reduce_scatter(sbuf, rbuf, rcounts,dtype, op,comm);
+ return reduce_scatter__mvapich2(sbuf, rbuf, rcounts,dtype, op,comm);
}
int (*intel_reduce_scatter_functions_table[])( const void *sbuf, void *rbuf,
MPI_Comm comm
) ={
intel_reduce_scatter_recursivehalving,
- Coll_reduce_scatter_mpich_pair::reduce_scatter,
- Coll_reduce_scatter_mpich_rdb::reduce_scatter,
+ reduce_scatter__mpich_pair,
+ reduce_scatter__mpich_rdb,
intel_reduce_scatter_reduce_scatterv,
intel_reduce_scatter_reduce_scatterv
};
MPI_Datatype rdtype,
MPI_Comm comm
) ={
- Coll_allgather_rdb::allgather,
- Coll_allgather_bruck::allgather,
- Coll_allgather_ring::allgather,
- Coll_allgather_GB::allgather
+ allgather__rdb,
+ allgather__bruck,
+ allgather__ring,
+ allgather__GB
};
intel_tuning_table_element intel_allgather_table[] =
MPI_Datatype rdtype,
MPI_Comm comm
) ={
- Coll_allgatherv_mpich_rdb::allgatherv,
- Coll_allgatherv_ompi_bruck::allgatherv,
- Coll_allgatherv_ring::allgatherv,
- Coll_allgatherv_GB::allgatherv
+ allgatherv__mpich_rdb,
+ allgatherv__ompi_bruck,
+ allgatherv__ring,
+ allgatherv__GB
};
intel_tuning_table_element intel_allgatherv_table[] =
int root,
MPI_Comm comm
) ={
- Coll_gather_ompi_binomial::gather,
- Coll_gather_ompi_binomial::gather,
- Coll_gather_mvapich2::gather
+ gather__ompi_binomial,
+ gather__ompi_binomial,
+ gather__mvapich2
};
intel_tuning_table_element intel_gather_table[] =
MPI_Datatype rdtype,
int root, MPI_Comm comm
) ={
- Coll_scatter_ompi_binomial::scatter,
- Coll_scatter_ompi_binomial::scatter,
- Coll_scatter_mvapich2::scatter
+ scatter__ompi_binomial,
+ scatter__ompi_binomial,
+ scatter__mvapich2
};
intel_tuning_table_element intel_scatter_table[] =
MPI_Datatype rdtype,
MPI_Comm comm
) ={
- Coll_alltoallv_ompi_basic_linear::alltoallv,
- Coll_alltoallv_bruck::alltoallv
+ alltoallv__ompi_basic_linear,
+ alltoallv__bruck
};
intel_tuning_table_element intel_alltoallv_table[] =
size_t block_dsize = 1;
#define IMPI_COLL_SELECT(cat, ret, args, args2) \
- ret _XBT_CONCAT3(Coll_, cat, _impi)::cat(COLL_UNPAREN args) \
+ ret _XBT_CONCAT2(cat, __impi)(COLL_UNPAREN args) \
{ \
int comm_size = comm->size(); \
int i = 0; \
*/
namespace simgrid{
namespace smpi{
-int Coll_allreduce_mpich::allreduce(const void *sbuf, void *rbuf, int count,
+int allreduce__mpich(const void *sbuf, void *rbuf, int count,
MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
{
size_t dsize, block_dsize;
comm->init_smp();
}
if(op->is_commutative())
- return Coll_allreduce_mvapich2_two_level::allreduce (sbuf, rbuf,count, dtype, op, comm);
+ return allreduce__mvapich2_two_level(sbuf, rbuf,count, dtype, op, comm);
}
/* find nearest power-of-two less than or equal to comm_size */
if (block_dsize > large_message && count >= pof2 && (op==MPI_OP_NULL || op->is_commutative())) {
//for long messages
- return Coll_allreduce_rab_rdb::allreduce (sbuf, rbuf, count, dtype, op, comm);
+ return allreduce__rab_rdb(sbuf, rbuf, count, dtype, op, comm);
}else {
//for short ones and count < pof2
- return Coll_allreduce_rdb::allreduce (sbuf, rbuf, count, dtype, op, comm);
+ return allreduce__rdb(sbuf, rbuf, count, dtype, op, comm);
}
}
End Algorithm: MPI_Alltoall
*/
-int Coll_alltoall_mpich::alltoall(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, int rcount,
- MPI_Datatype rdtype,
- MPI_Comm comm)
+int alltoall__mpich(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, int rcount,
+ MPI_Datatype rdtype,
+ MPI_Comm comm)
{
int communicator_size;
size_t dsize, block_dsize;
block_dsize = dsize * scount;
if ((block_dsize < short_size) && (communicator_size >= 8)) {
- return Coll_alltoall_bruck::alltoall(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return alltoall__bruck(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
} else if (block_dsize < medium_size) {
- return Coll_alltoall_mvapich2_scatter_dest::alltoall(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return alltoall__mvapich2_scatter_dest(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
}else if (communicator_size%2){
- return Coll_alltoall_pair::alltoall(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return alltoall__pair(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
}
- return Coll_alltoall_ring::alltoall (sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return alltoall__ring(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
}
-int Coll_alltoallv_mpich::alltoallv(const void *sbuf, const int *scounts, const int *sdisps,
- MPI_Datatype sdtype,
- void *rbuf, const int *rcounts, const int *rdisps,
- MPI_Datatype rdtype,
- MPI_Comm comm
- )
+int alltoallv__mpich(const void *sbuf, const int *scounts, const int *sdisps,
+ MPI_Datatype sdtype,
+ void *rbuf, const int *rcounts, const int *rdisps,
+ MPI_Datatype rdtype,
+ MPI_Comm comm
+ )
{
/* For starters, just keep the original algorithm. */
- return Coll_alltoallv_bruck::alltoallv(sbuf, scounts, sdisps, sdtype,
- rbuf, rcounts, rdisps,rdtype,
- comm);
+ return alltoallv__bruck(sbuf, scounts, sdisps, sdtype,
+ rbuf, rcounts, rdisps,rdtype,
+ comm);
}
-int Coll_barrier_mpich::barrier(MPI_Comm comm)
+int barrier__mpich(MPI_Comm comm)
{
- return Coll_barrier_ompi_bruck::barrier(comm);
+ return barrier__ompi_bruck(comm);
}
/* This is the default implementation of broadcast. The algorithm is:
*/
-int Coll_bcast_mpich::bcast(void *buff, int count,
- MPI_Datatype datatype, int root,
- MPI_Comm comm
+int bcast__mpich(void *buff, int count,
+ MPI_Datatype datatype, int root,
+ MPI_Comm comm
)
{
/* Decision function based on MX results for
comm->init_smp();
}
if(comm->is_uniform())
- return Coll_bcast_SMP_binomial::bcast(buff, count, datatype, root, comm);
+ return bcast__SMP_binomial(buff, count, datatype, root, comm);
}
communicator_size = comm->size();
single-element broadcasts */
if ((message_size < small_message_size) || (communicator_size <= 8)) {
/* Binomial without segmentation */
- return Coll_bcast_binomial_tree::bcast (buff, count, datatype,
- root, comm);
+ return bcast__binomial_tree(buff, count, datatype, root, comm);
} else if (message_size < intermediate_message_size && !(communicator_size%2)) {
// SplittedBinary with 1KB segments
- return Coll_bcast_scatter_rdb_allgather::bcast(buff, count, datatype,
- root, comm);
+ return bcast__scatter_rdb_allgather(buff, count, datatype, root, comm);
}
//Handle large message sizes
- return Coll_bcast_scatter_LR_allgather::bcast (buff, count, datatype,
- root, comm);
+ return bcast__scatter_LR_allgather(buff, count, datatype, root, comm);
}
*/
-int Coll_reduce_mpich::reduce(const void *sendbuf, void *recvbuf,
+int reduce__mpich(const void *sendbuf, void *recvbuf,
int count, MPI_Datatype datatype,
MPI_Op op, int root,
MPI_Comm comm
comm->init_smp();
}
if (op->is_commutative() == 1)
- return Coll_reduce_mvapich2_two_level::reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
+ return reduce__mvapich2_two_level(sendbuf, recvbuf, count, datatype, op, root, comm);
}
communicator_size = comm->size();
pof2 >>= 1;
if ((count < pof2) || (message_size < 2048) || (op != MPI_OP_NULL && not op->is_commutative())) {
- return Coll_reduce_binomial::reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
+ return reduce__binomial(sendbuf, recvbuf, count, datatype, op, root, comm);
}
- return Coll_reduce_scatter_gather::reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
+ return reduce__scatter_gather(sendbuf, recvbuf, count, datatype, op, root, comm);
}
*/
-int Coll_reduce_scatter_mpich::reduce_scatter(const void *sbuf, void *rbuf,
- const int *rcounts,
- MPI_Datatype dtype,
- MPI_Op op,
- MPI_Comm comm
- )
+int reduce_scatter__mpich(const void *sbuf, void *rbuf,
+ const int *rcounts,
+ MPI_Datatype dtype,
+ MPI_Op op,
+ MPI_Comm comm
+ )
{
int comm_size, i;
size_t total_message_size;
}
if( (op==MPI_OP_NULL || op->is_commutative()) && total_message_size > 524288) {
- return Coll_reduce_scatter_mpich_pair::reduce_scatter (sbuf, rbuf, rcounts,
- dtype, op,
- comm);
+ return reduce_scatter__mpich_pair(sbuf, rbuf, rcounts, dtype, op, comm);
} else if ((op != MPI_OP_NULL && not op->is_commutative())) {
int is_block_regular = 1;
for (i = 0; i < (comm_size - 1); ++i) {
if (pof2 == comm_size && is_block_regular) {
/* noncommutative, pof2 size, and block regular */
- return Coll_reduce_scatter_mpich_noncomm::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+ return reduce_scatter__mpich_noncomm(sbuf, rbuf, rcounts, dtype, op, comm);
}
- return Coll_reduce_scatter_mpich_rdb::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+ return reduce_scatter__mpich_rdb(sbuf, rbuf, rcounts, dtype, op, comm);
}else{
- return Coll_reduce_scatter_mpich_rdb::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+ return reduce_scatter__mpich_rdb(sbuf, rbuf, rcounts, dtype, op, comm);
}
}
End Algorithm: MPI_Allgather
*/
-int Coll_allgather_mpich::allgather(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, int rcount,
- MPI_Datatype rdtype,
- MPI_Comm comm
- )
+int allgather__mpich(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, int rcount,
+ MPI_Datatype rdtype,
+ MPI_Comm comm
+ )
{
int communicator_size, pow2_size;
size_t dsize, total_dsize;
- for everything else use ring.
*/
if ((pow2_size == communicator_size) && (total_dsize < 524288)) {
- return Coll_allgather_rdb::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__rdb(sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);
} else if (total_dsize <= 81920) {
- return Coll_allgather_bruck::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__bruck(sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);
}
- return Coll_allgather_ring::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__ring(sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);
}
End Algorithm: MPI_Allgatherv
*/
-int Coll_allgatherv_mpich::allgatherv(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, const int *rcounts,
- const int *rdispls,
- MPI_Datatype rdtype,
- MPI_Comm comm
- )
+int allgatherv__mpich(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, const int *rcounts,
+ const int *rdispls,
+ MPI_Datatype rdtype,
+ MPI_Comm comm
+ )
{
int communicator_size, pow2_size,i;
size_t total_dsize;
for (pow2_size = 1; pow2_size < communicator_size; pow2_size <<=1);
if ((pow2_size == communicator_size) && (total_dsize < 524288)) {
- return Coll_allgatherv_mpich_rdb::allgatherv(sbuf, scount, sdtype,
- rbuf, rcounts, rdispls, rdtype,
- comm);
+ return allgatherv__mpich_rdb(sbuf, scount, sdtype, rbuf, rcounts, rdispls, rdtype, comm);
} else if (total_dsize <= 81920) {
- return Coll_allgatherv_ompi_bruck::allgatherv(sbuf, scount, sdtype,
- rbuf, rcounts, rdispls, rdtype,
- comm);
+ return allgatherv__ompi_bruck(sbuf, scount, sdtype, rbuf, rcounts, rdispls, rdtype, comm);
}
- return Coll_allgatherv_mpich_ring::allgatherv(sbuf, scount, sdtype,
- rbuf, rcounts, rdispls, rdtype,
- comm);
+ return allgatherv__mpich_ring(sbuf, scount, sdtype, rbuf, rcounts, rdispls, rdtype, comm);
}
/* This is the default implementation of gather. The algorithm is:
End Algorithm: MPI_Gather
*/
-int Coll_gather_mpich::gather(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, int rcount,
- MPI_Datatype rdtype,
- int root,
- MPI_Comm comm
- )
+int gather__mpich(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, int rcount,
+ MPI_Datatype rdtype,
+ int root,
+ MPI_Comm comm
+ )
{
- return Coll_gather_ompi_binomial::gather (sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- root, comm);
+ return gather__ompi_binomial(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ root, comm);
}
/* This is the default implementation of scatter. The algorithm is:
*/
-int Coll_scatter_mpich::scatter(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, int rcount,
- MPI_Datatype rdtype,
- int root, MPI_Comm comm
- )
+int scatter__mpich(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, int rcount,
+ MPI_Datatype rdtype,
+ int root, MPI_Comm comm
+ )
{
std::unique_ptr<unsigned char[]> tmp_buf;
if(comm->rank()!=root){
scount = rcount;
sdtype = rdtype;
}
- return Coll_scatter_ompi_binomial::scatter(sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm);
+ return scatter__ompi_binomial(sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm);
}
}
}
#include "smpi_mvapich2_selector_stampede.hpp"
-namespace simgrid{
-namespace smpi{
+namespace simgrid {
+namespace smpi {
-int Coll_alltoall_mvapich2::alltoall( const void *sendbuf, int sendcount,
- MPI_Datatype sendtype,
- void* recvbuf, int recvcount,
- MPI_Datatype recvtype,
- MPI_Comm comm)
+int alltoall__mvapich2( const void *sendbuf, int sendcount,
+ MPI_Datatype sendtype,
+ void* recvbuf, int recvcount,
+ MPI_Datatype recvtype,
+ MPI_Comm comm)
{
if(mv2_alltoall_table_ppn_conf==NULL)
return (mpi_errno);
}
-int Coll_allgather_mvapich2::allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
+int allgather__mvapich2(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
MPI_Comm comm)
{
recvbuf, recvcount, recvtype,
comm);
}else{
- mpi_errno = Coll_allgather_mpich::allgather(sendbuf, sendcount, sendtype,
+ mpi_errno = allgather__mpich(sendbuf, sendcount, sendtype,
recvbuf, recvcount, recvtype,
comm);
}
return mpi_errno;
}
-int Coll_gather_mvapich2::gather(const void *sendbuf,
+int gather__mvapich2(const void *sendbuf,
int sendcnt,
MPI_Datatype sendtype,
void *recvbuf,
} else {
// Indeed, direct (non SMP-aware)gather is MPICH one
- mpi_errno = Coll_gather_mpich::gather(sendbuf, sendcnt, sendtype,
+ mpi_errno = gather__mpich(sendbuf, sendcnt, sendtype,
recvbuf, recvcnt, recvtype,
root, comm);
}
return mpi_errno;
}
-int Coll_allgatherv_mvapich2::allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
+int allgatherv__mvapich2(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int *recvcounts, const int *displs,
MPI_Datatype recvtype, MPI_Comm comm )
{
-int Coll_allreduce_mvapich2::allreduce(const void *sendbuf,
+int allreduce__mvapich2(const void *sendbuf,
void *recvbuf,
int count,
MPI_Datatype datatype,
}
-int Coll_alltoallv_mvapich2::alltoallv(const void *sbuf, const int *scounts, const int *sdisps,
+int alltoallv__mvapich2(const void *sbuf, const int *scounts, const int *sdisps,
MPI_Datatype sdtype,
void *rbuf, const int *rcounts, const int *rdisps,
MPI_Datatype rdtype,
{
if (sbuf == MPI_IN_PLACE) {
- return Coll_alltoallv_ompi_basic_linear::alltoallv(sbuf, scounts, sdisps, sdtype,
- rbuf, rcounts, rdisps,rdtype,
- comm);
+ return alltoallv__ompi_basic_linear(sbuf, scounts, sdisps, sdtype,
+ rbuf, rcounts, rdisps, rdtype,
+ comm);
} else /* For starters, just keep the original algorithm. */
- return Coll_alltoallv_ring::alltoallv(sbuf, scounts, sdisps, sdtype,
- rbuf, rcounts, rdisps,rdtype,
- comm);
+ return alltoallv__ring(sbuf, scounts, sdisps, sdtype,
+ rbuf, rcounts, rdisps, rdtype,
+ comm);
}
-int Coll_barrier_mvapich2::barrier(MPI_Comm comm)
+int barrier__mvapich2(MPI_Comm comm)
{
- return Coll_barrier_mvapich2_pair::barrier(comm);
+ return barrier__mvapich2_pair(comm);
}
-int Coll_bcast_mvapich2::bcast(void *buffer,
- int count,
- MPI_Datatype datatype,
- int root, MPI_Comm comm)
+int bcast__mvapich2(void *buffer,
+ int count,
+ MPI_Datatype datatype,
+ int root, MPI_Comm comm)
{
int mpi_errno = MPI_SUCCESS;
int comm_size/*, rank*/;
-int Coll_reduce_mvapich2::reduce(const void *sendbuf,
+int reduce__mvapich2(const void *sendbuf,
void *recvbuf,
int count,
MPI_Datatype datatype,
}
-int Coll_reduce_scatter_mvapich2::reduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcnts,
+int reduce_scatter__mvapich2(const void *sendbuf, void *recvbuf, const int *recvcnts,
MPI_Datatype datatype, MPI_Op op,
MPI_Comm comm)
{
recvcnts, datatype,
op, comm);
}
- mpi_errno = Coll_reduce_scatter_mpich_rdb::reduce_scatter(sendbuf, recvbuf,
- recvcnts, datatype,
- op, comm);
+ mpi_errno = reduce_scatter__mpich_rdb(sendbuf, recvbuf,
+ recvcnts, datatype,
+ op, comm);
}
delete[] disps;
return mpi_errno;
-int Coll_scatter_mvapich2::scatter(const void *sendbuf,
+int scatter__mvapich2(const void *sendbuf,
int sendcnt,
MPI_Datatype sendtype,
void *recvbuf,
int* mv2_size_alltoall_tuning_table = NULL;
mv2_alltoall_tuning_table** mv2_alltoall_thresholds_table = NULL;
-#define MPIR_Alltoall_bruck_MV2 simgrid::smpi::Coll_alltoall_bruck::alltoall
-#define MPIR_Alltoall_RD_MV2 simgrid::smpi::Coll_alltoall_rdb::alltoall
-#define MPIR_Alltoall_Scatter_dest_MV2 simgrid::smpi::Coll_alltoall_mvapich2_scatter_dest::alltoall
-#define MPIR_Alltoall_pairwise_MV2 simgrid::smpi::Coll_alltoall_pair::alltoall
-#define MPIR_Alltoall_inplace_MV2 simgrid::smpi::Coll_alltoall_ring::alltoall
+#define MPIR_Alltoall_bruck_MV2 simgrid::smpi::alltoall__bruck
+#define MPIR_Alltoall_RD_MV2 simgrid::smpi::alltoall__rdb
+#define MPIR_Alltoall_Scatter_dest_MV2 simgrid::smpi::alltoall__mvapich2_scatter_dest
+#define MPIR_Alltoall_pairwise_MV2 simgrid::smpi::alltoall__pair
+#define MPIR_Alltoall_inplace_MV2 simgrid::smpi::alltoall__ring
static void init_mv2_alltoall_tables_stampede()
{
return 0;
}
-#define MPIR_Allgather_Bruck_MV2 simgrid::smpi::Coll_allgather_bruck::allgather
-#define MPIR_Allgather_RD_MV2 simgrid::smpi::Coll_allgather_rdb::allgather
-#define MPIR_Allgather_Ring_MV2 simgrid::smpi::Coll_allgather_ring::allgather
-#define MPIR_2lvl_Allgather_MV2 simgrid::smpi::Coll_allgather_mvapich2_smp::allgather
+#define MPIR_Allgather_Bruck_MV2 simgrid::smpi::allgather__bruck
+#define MPIR_Allgather_RD_MV2 simgrid::smpi::allgather__rdb
+#define MPIR_Allgather_Ring_MV2 simgrid::smpi::allgather__ring
+#define MPIR_2lvl_Allgather_MV2 simgrid::smpi::allgather__mvapich2_smp
static void init_mv2_allgather_tables_stampede()
{
MV2_Gather_function_ptr MV2_Gather_inter_leader_function = NULL;
MV2_Gather_function_ptr MV2_Gather_intra_node_function = NULL;
-#define MPIR_Gather_MV2_Direct simgrid::smpi::Coll_gather_ompi_basic_linear::gather
-#define MPIR_Gather_MV2_two_level_Direct simgrid::smpi::Coll_gather_mvapich2_two_level::gather
-#define MPIR_Gather_intra simgrid::smpi::Coll_gather_mpich::gather
+#define MPIR_Gather_MV2_Direct simgrid::smpi::gather__ompi_basic_linear
+#define MPIR_Gather_MV2_two_level_Direct simgrid::smpi::gather__mvapich2_two_level
+#define MPIR_Gather_intra simgrid::smpi::gather__mpich
static void init_mv2_gather_tables_stampede()
{
int mv2_size_allgatherv_tuning_table = 0;
mv2_allgatherv_tuning_table* mv2_allgatherv_thresholds_table = NULL;
-#define MPIR_Allgatherv_Rec_Doubling_MV2 simgrid::smpi::Coll_allgatherv_mpich_rdb::allgatherv
-#define MPIR_Allgatherv_Bruck_MV2 simgrid::smpi::Coll_allgatherv_ompi_bruck::allgatherv
-#define MPIR_Allgatherv_Ring_MV2 simgrid::smpi::Coll_allgatherv_mpich_ring::allgatherv
+#define MPIR_Allgatherv_Rec_Doubling_MV2 simgrid::smpi::allgatherv__mpich_rdb
+#define MPIR_Allgatherv_Bruck_MV2 simgrid::smpi::allgatherv__ompi_bruck
+#define MPIR_Allgatherv_Ring_MV2 simgrid::smpi::allgatherv__mpich_ring
static void init_mv2_allgatherv_tables_stampede()
{
return MPI_SUCCESS;
}
-#define MPIR_Allreduce_pt2pt_rd_MV2 simgrid::smpi::Coll_allreduce_rdb::allreduce
-#define MPIR_Allreduce_pt2pt_rs_MV2 simgrid::smpi::Coll_allreduce_mvapich2_rs::allreduce
-#define MPIR_Allreduce_two_level_MV2 simgrid::smpi::Coll_allreduce_mvapich2_two_level::allreduce
+#define MPIR_Allreduce_pt2pt_rd_MV2 simgrid::smpi::allreduce__rdb
+#define MPIR_Allreduce_pt2pt_rs_MV2 simgrid::smpi::allreduce__mvapich2_rs
+#define MPIR_Allreduce_two_level_MV2 simgrid::smpi::allreduce__mvapich2_two_level
static void init_mv2_allreduce_tables_stampede()
{
#define INTRA_NODE_ROOT 0
-#define MPIR_Pipelined_Bcast_Zcpy_MV2 simgrid::smpi::Coll_bcast_mpich::bcast
-#define MPIR_Pipelined_Bcast_MV2 simgrid::smpi::Coll_bcast_mpich::bcast
-#define MPIR_Bcast_binomial_MV2 simgrid::smpi::Coll_bcast_binomial_tree::bcast
-#define MPIR_Bcast_scatter_ring_allgather_shm_MV2 simgrid::smpi::Coll_bcast_scatter_LR_allgather::bcast
-#define MPIR_Bcast_scatter_doubling_allgather_MV2 simgrid::smpi::Coll_bcast_scatter_rdb_allgather::bcast
-#define MPIR_Bcast_scatter_ring_allgather_MV2 simgrid::smpi::Coll_bcast_scatter_LR_allgather::bcast
-#define MPIR_Shmem_Bcast_MV2 simgrid::smpi::Coll_bcast_mpich::bcast
-#define MPIR_Bcast_tune_inter_node_helper_MV2 simgrid::smpi::Coll_bcast_mvapich2_inter_node::bcast
-#define MPIR_Bcast_inter_node_helper_MV2 simgrid::smpi::Coll_bcast_mvapich2_inter_node::bcast
-#define MPIR_Knomial_Bcast_intra_node_MV2 simgrid::smpi::Coll_bcast_mvapich2_knomial_intra_node::bcast
-#define MPIR_Bcast_intra_MV2 simgrid::smpi::Coll_bcast_mvapich2_intra_node::bcast
+#define MPIR_Pipelined_Bcast_Zcpy_MV2 simgrid::smpi::bcast__mpich
+#define MPIR_Pipelined_Bcast_MV2 simgrid::smpi::bcast__mpich
+#define MPIR_Bcast_binomial_MV2 simgrid::smpi::bcast__binomial_tree
+#define MPIR_Bcast_scatter_ring_allgather_shm_MV2 simgrid::smpi::bcast__scatter_LR_allgather
+#define MPIR_Bcast_scatter_doubling_allgather_MV2 simgrid::smpi::bcast__scatter_rdb_allgather
+#define MPIR_Bcast_scatter_ring_allgather_MV2 simgrid::smpi::bcast__scatter_LR_allgather
+#define MPIR_Shmem_Bcast_MV2 simgrid::smpi::bcast__mpich
+#define MPIR_Bcast_tune_inter_node_helper_MV2 simgrid::smpi::bcast__mvapich2_inter_node
+#define MPIR_Bcast_inter_node_helper_MV2 simgrid::smpi::bcast__mvapich2_inter_node
+#define MPIR_Knomial_Bcast_intra_node_MV2 simgrid::smpi::bcast__mvapich2_knomial_intra_node
+#define MPIR_Bcast_intra_MV2 simgrid::smpi::bcast__mvapich2_intra_node
static void init_mv2_bcast_tables_stampede()
{
int (*MV2_Reduce_intra_function)(const void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root,
MPI_Comm comm_ptr) = NULL;
-#define MPIR_Reduce_inter_knomial_wrapper_MV2 simgrid::smpi::Coll_reduce_mvapich2_knomial::reduce
-#define MPIR_Reduce_intra_knomial_wrapper_MV2 simgrid::smpi::Coll_reduce_mvapich2_knomial::reduce
-#define MPIR_Reduce_binomial_MV2 simgrid::smpi::Coll_reduce_binomial::reduce
-#define MPIR_Reduce_redscat_gather_MV2 simgrid::smpi::Coll_reduce_scatter_gather::reduce
-#define MPIR_Reduce_shmem_MV2 simgrid::smpi::Coll_reduce_ompi_basic_linear::reduce
-#define MPIR_Reduce_two_level_helper_MV2 simgrid::smpi::Coll_reduce_mvapich2_two_level::reduce
+#define MPIR_Reduce_inter_knomial_wrapper_MV2 simgrid::smpi::reduce__mvapich2_knomial
+#define MPIR_Reduce_intra_knomial_wrapper_MV2 simgrid::smpi::reduce__mvapich2_knomial
+#define MPIR_Reduce_binomial_MV2 simgrid::smpi::reduce__binomial
+#define MPIR_Reduce_redscat_gather_MV2 simgrid::smpi::reduce__scatter_gather
+#define MPIR_Reduce_shmem_MV2 simgrid::smpi::reduce__ompi_basic_linear
+#define MPIR_Reduce_two_level_helper_MV2 simgrid::smpi::reduce__mvapich2_two_level
static void init_mv2_reduce_tables_stampede()
{
static int MPIR_Reduce_Scatter_Basic_MV2(const void* sendbuf, void* recvbuf, const int* recvcnts, MPI_Datatype datatype, MPI_Op op,
MPI_Comm comm)
{
- simgrid::smpi::Coll_reduce_scatter_default::reduce_scatter(sendbuf, recvbuf, recvcnts, datatype, op, comm);
+ simgrid::smpi::reduce_scatter__default(sendbuf, recvbuf, recvcnts, datatype, op, comm);
return MPI_SUCCESS;
}
-#define MPIR_Reduce_scatter_non_comm_MV2 simgrid::smpi::Coll_reduce_scatter_mpich_noncomm::reduce_scatter
-#define MPIR_Reduce_scatter_Rec_Halving_MV2 \
- simgrid::smpi::Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter
-#define MPIR_Reduce_scatter_Pair_Wise_MV2 simgrid::smpi::Coll_reduce_scatter_mpich_pair::reduce_scatter
+#define MPIR_Reduce_scatter_non_comm_MV2 simgrid::smpi::reduce_scatter__mpich_noncomm
+#define MPIR_Reduce_scatter_Rec_Halving_MV2 simgrid::smpi::reduce_scatter__ompi_basic_recursivehalving
+#define MPIR_Reduce_scatter_Pair_Wise_MV2 simgrid::smpi::reduce_scatter__mpich_pair
static void init_mv2_reduce_scatter_tables_stampede()
{
return 0;
}
-#define MPIR_Scatter_MV2_Binomial simgrid::smpi::Coll_scatter_ompi_binomial::scatter
-#define MPIR_Scatter_MV2_Direct simgrid::smpi::Coll_scatter_ompi_basic_linear::scatter
-#define MPIR_Scatter_MV2_two_level_Binomial simgrid::smpi::Coll_scatter_mvapich2_two_level_binomial::scatter
-#define MPIR_Scatter_MV2_two_level_Direct simgrid::smpi::Coll_scatter_mvapich2_two_level_direct::scatter
+#define MPIR_Scatter_MV2_Binomial simgrid::smpi::scatter__ompi_binomial
+#define MPIR_Scatter_MV2_Direct simgrid::smpi::scatter__ompi_basic_linear
+#define MPIR_Scatter_MV2_two_level_Binomial simgrid::smpi::scatter__mvapich2_two_level_binomial
+#define MPIR_Scatter_MV2_two_level_Direct simgrid::smpi::scatter__mvapich2_two_level_direct
static void init_mv2_scatter_tables_stampede()
{
#include "colls_private.hpp"
-namespace simgrid{
-namespace smpi{
+namespace simgrid {
+namespace smpi {
-int Coll_allreduce_ompi::allreduce(const void *sbuf, void *rbuf, int count,
- MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
+int allreduce__ompi(const void *sbuf, void *rbuf, int count,
+ MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
{
size_t dsize, block_dsize;
int comm_size = comm->size();
block_dsize = dsize * count;
if (block_dsize < intermediate_message) {
- return (Coll_allreduce_rdb::allreduce (sbuf, rbuf,
- count, dtype,
- op, comm));
+ return allreduce__rdb(sbuf, rbuf, count, dtype, op, comm);
}
if( ((op==MPI_OP_NULL) || op->is_commutative()) && (count > comm_size) ) {
if ((comm_size * segment_size >= block_dsize)) {
//FIXME: ok, these are not the right algorithms, try to find closer ones
// lr is a good match for allreduce_ring (difference is mainly the use of sendrecv)
- return Coll_allreduce_lr::allreduce(sbuf, rbuf, count, dtype,
- op, comm);
+ return allreduce__lr(sbuf, rbuf, count, dtype, op, comm);
} else {
- return (Coll_allreduce_ompi_ring_segmented::allreduce (sbuf, rbuf,
- count, dtype,
- op, comm
- /*segment_size*/));
+ return allreduce__ompi_ring_segmented(sbuf, rbuf, count, dtype, op, comm /*segment_size*/);
}
}
- return (Coll_allreduce_redbcast::allreduce(sbuf, rbuf, count,
- dtype, op, comm));
+ return allreduce__redbcast(sbuf, rbuf, count, dtype, op, comm);
}
-int Coll_alltoall_ompi::alltoall(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, int rcount,
- MPI_Datatype rdtype,
- MPI_Comm comm)
+int alltoall__ompi(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, int rcount,
+ MPI_Datatype rdtype,
+ MPI_Comm comm)
{
int communicator_size;
size_t dsize, block_dsize;
block_dsize = dsize * scount;
if ((block_dsize < 200) && (communicator_size > 12)) {
- return Coll_alltoall_bruck::alltoall(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return alltoall__bruck(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype, comm);
} else if (block_dsize < 3000) {
- return Coll_alltoall_basic_linear::alltoall(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return alltoall__basic_linear(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype, comm);
}
- return Coll_alltoall_ring::alltoall (sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return alltoall__ring(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype, comm);
}
-int Coll_alltoallv_ompi::alltoallv(const void *sbuf, const int *scounts, const int *sdisps,
- MPI_Datatype sdtype,
- void *rbuf, const int *rcounts, const int *rdisps,
- MPI_Datatype rdtype,
- MPI_Comm comm
- )
+int alltoallv__ompi(const void *sbuf, const int *scounts, const int *sdisps,
+ MPI_Datatype sdtype,
+ void *rbuf, const int *rcounts, const int *rdisps,
+ MPI_Datatype rdtype,
+ MPI_Comm comm
+ )
{
/* For starters, just keep the original algorithm. */
- return Coll_alltoallv_ring::alltoallv(sbuf, scounts, sdisps, sdtype,
- rbuf, rcounts, rdisps,rdtype,
- comm);
+ return alltoallv__ring(sbuf, scounts, sdisps, sdtype,
+ rbuf, rcounts, rdisps,rdtype,
+ comm);
}
-
-int Coll_barrier_ompi::barrier(MPI_Comm comm)
+int barrier__ompi(MPI_Comm comm)
{ int communicator_size = comm->size();
if( 2 == communicator_size )
- return Coll_barrier_ompi_two_procs::barrier(comm);
+ return barrier__ompi_two_procs(comm);
/* * Basic optimisation. If we have a power of 2 number of nodes*/
/* * the use the recursive doubling algorithm, otherwise*/
/* * bruck is the one we want.*/
for( ; communicator_size > 0; communicator_size >>= 1 ) {
if( communicator_size & 0x1 ) {
if( has_one )
- return Coll_barrier_ompi_bruck::barrier(comm);
+ return barrier__ompi_bruck(comm);
has_one = 1;
}
}
}
- return Coll_barrier_ompi_recursivedoubling::barrier(comm);
+ return barrier__ompi_recursivedoubling(comm);
}
-int Coll_bcast_ompi::bcast(void *buff, int count,
- MPI_Datatype datatype, int root,
- MPI_Comm comm
- )
+int bcast__ompi(void *buff, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
{
/* Decision function based on MX results for
messages up to 36MB and communicator sizes up to 64 nodes */
single-element broadcasts */
if ((message_size < small_message_size) || (count <= 1)) {
/* Binomial without segmentation */
- return Coll_bcast_binomial_tree::bcast (buff, count, datatype,
- root, comm);
+ return bcast__binomial_tree(buff, count, datatype, root, comm);
} else if (message_size < intermediate_message_size) {
// SplittedBinary with 1KB segments
- return Coll_bcast_ompi_split_bintree::bcast(buff, count, datatype,
- root, comm);
+ return bcast__ompi_split_bintree(buff, count, datatype, root, comm);
}
//Handle large message sizes
else if (communicator_size < (a_p128 * message_size + b_p128)) {
//Pipeline with 128KB segments
//segsize = 1024 << 7;
- return Coll_bcast_ompi_pipeline::bcast (buff, count, datatype,
- root, comm);
+ return bcast__ompi_pipeline(buff, count, datatype, root, comm);
} else if (communicator_size < 13) {
// Split Binary with 8KB segments
- return Coll_bcast_ompi_split_bintree::bcast(buff, count, datatype,
- root, comm);
+ return bcast__ompi_split_bintree(buff, count, datatype, root, comm);
} else if (communicator_size < (a_p64 * message_size + b_p64)) {
// Pipeline with 64KB segments
//segsize = 1024 << 6;
- return Coll_bcast_ompi_pipeline::bcast (buff, count, datatype,
- root, comm);
+ return bcast__ompi_pipeline(buff, count, datatype, root, comm);
} else if (communicator_size < (a_p16 * message_size + b_p16)) {
//Pipeline with 16KB segments
//segsize = 1024 << 4;
- return Coll_bcast_ompi_pipeline::bcast (buff, count, datatype,
- root, comm);
+ return bcast__ompi_pipeline(buff, count, datatype, root, comm);
}
/* Pipeline with 8KB segments */
//segsize = 1024 << 3;
- return Coll_bcast_flattree_pipeline::bcast (buff, count, datatype,
- root, comm
- /*segsize*/);
+ return bcast__flattree_pipeline(buff, count, datatype, root, comm /*segsize*/);
#if 0
/* this is based on gige measurements */
if (communicator_size < 4) {
- return Coll_bcast_intra_basic_linear::bcast (buff, count, datatype, root, comm, module);
+ return bcast__intra_basic_linear(buff, count, datatype, root, comm, module);
}
if (communicator_size == 4) {
if (message_size < 524288) segsize = 0;
else segsize = 16384;
- return Coll_bcast_intra_bintree::bcast (buff, count, datatype, root, comm, module, segsize);
+ return bcast__intra_bintree(buff, count, datatype, root, comm, module, segsize);
}
if (communicator_size <= 8 && message_size < 4096) {
- return Coll_bcast_intra_basic_linear::bcast (buff, count, datatype, root, comm, module);
+ return bcast__intra_basic_linear(buff, count, datatype, root, comm, module);
}
if (communicator_size > 8 && message_size >= 32768 && message_size < 524288) {
segsize = 16384;
- return Coll_bcast_intra_bintree::bcast (buff, count, datatype, root, comm, module, segsize);
+ return bcast__intra_bintree(buff, count, datatype, root, comm, module, segsize);
}
if (message_size >= 524288) {
segsize = 16384;
- return Coll_bcast_intra_pipeline::bcast (buff, count, datatype, root, comm, module, segsize);
+ return bcast__intra_pipeline(buff, count, datatype, root, comm, module, segsize);
}
segsize = 0;
/* once tested can swap this back in */
- /* return Coll_bcast_intra_bmtree::bcast (buff, count, datatype, root, comm, segsize); */
- return Coll_bcast_intra_bintree::bcast (buff, count, datatype, root, comm, module, segsize);
+ /* return bcast__intra_bmtree(buff, count, datatype, root, comm, segsize); */
+ return bcast__intra_bintree(buff, count, datatype, root, comm, module, segsize);
#endif /* 0 */
}
-int Coll_reduce_ompi::reduce(const void *sendbuf, void *recvbuf,
- int count, MPI_Datatype datatype,
- MPI_Op op, int root,
- MPI_Comm comm
- )
+int reduce__ompi(const void *sendbuf, void *recvbuf,
+ int count, MPI_Datatype datatype,
+ MPI_Op op, int root,
+ MPI_Comm comm)
{
int communicator_size=0;
//int segsize = 0;
*/
if ((op != MPI_OP_NULL) && not op->is_commutative()) {
if ((communicator_size < 12) && (message_size < 2048)) {
- return Coll_reduce_ompi_basic_linear::reduce(sendbuf, recvbuf, count, datatype, op, root, comm /*, module*/);
+ return reduce__ompi_basic_linear(sendbuf, recvbuf, count, datatype, op, root, comm /*, module*/);
}
- return Coll_reduce_ompi_in_order_binary::reduce(sendbuf, recvbuf, count, datatype, op, root, comm /*, module,
+ return reduce__ompi_in_order_binary(sendbuf, recvbuf, count, datatype, op, root, comm /*, module,
0, max_requests*/);
}
if ((communicator_size < 8) && (message_size < 512)){
/* Linear_0K */
- return Coll_reduce_ompi_basic_linear::reduce (sendbuf, recvbuf, count, datatype, op, root, comm);
+ return reduce__ompi_basic_linear(sendbuf, recvbuf, count, datatype, op, root, comm);
} else if (((communicator_size < 8) && (message_size < 20480)) ||
(message_size < 2048) || (count <= 1)) {
/* Binomial_0K */
//segsize = 0;
- return Coll_reduce_ompi_binomial::reduce(sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
- segsize, max_requests*/);
+ return reduce__ompi_binomial(sendbuf, recvbuf, count, datatype, op, root, comm/*, module, segsize, max_requests*/);
} else if (communicator_size > (a1 * message_size + b1)) {
// Binomial_1K
//segsize = 1024;
- return Coll_reduce_ompi_binomial::reduce(sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
+ return reduce__ompi_binomial(sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
segsize, max_requests*/);
} else if (communicator_size > (a2 * message_size + b2)) {
// Pipeline_1K
//segsize = 1024;
- return Coll_reduce_ompi_pipeline::reduce (sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
+ return reduce__ompi_pipeline(sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
segsize, max_requests*/);
} else if (communicator_size > (a3 * message_size + b3)) {
// Binary_32K
//segsize = 32*1024;
- return Coll_reduce_ompi_binary::reduce( sendbuf, recvbuf, count, datatype, op, root,
+ return reduce__ompi_binary( sendbuf, recvbuf, count, datatype, op, root,
comm/*, module, segsize, max_requests*/);
}
// if (communicator_size > (a4 * message_size + b4)) {
// Pipeline_64K
// segsize = 64*1024;
// }
- return Coll_reduce_ompi_pipeline::reduce (sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
+ return reduce__ompi_pipeline(sendbuf, recvbuf, count, datatype, op, root, comm/*, module,
segsize, max_requests*/);
#if 0
fanout = communicator_size - 1;
/* when linear implemented or taken from basic put here, right now using chain as a linear system */
/* it is implemented and I shouldn't be calling a chain with a fanout bigger than MAXTREEFANOUT from topo.h! */
- return Coll_reduce_intra_basic_linear::reduce (sendbuf, recvbuf, count, datatype, op, root, comm, module);
- /* return Coll_reduce_intra_chain::reduce (sendbuf, recvbuf, count, datatype, op, root, comm, segsize, fanout); */
+ return reduce__intra_basic_linear(sendbuf, recvbuf, count, datatype, op, root, comm, module);
+ /* return reduce__intra_chain(sendbuf, recvbuf, count, datatype, op, root, comm, segsize, fanout); */
}
if (message_size < 524288) {
if (message_size <= 65536 ) {
}
/* later swap this for a binary tree */
/* fanout = 2; */
- return Coll_reduce_intra_chain::reduce (sendbuf, recvbuf, count, datatype, op, root, comm, module,
- segsize, fanout, max_requests);
+ return reduce__intra_chain(sendbuf, recvbuf, count, datatype, op, root, comm, module,
+ segsize, fanout, max_requests);
}
segsize = 1024;
- return Coll_reduce_intra_pipeline::reduce (sendbuf, recvbuf, count, datatype, op, root, comm, module,
- segsize, max_requests);
+ return reduce__intra_pipeline(sendbuf, recvbuf, count, datatype, op, root, comm, module,
+ segsize, max_requests);
#endif /* 0 */
}
-int Coll_reduce_scatter_ompi::reduce_scatter(const void *sbuf, void *rbuf,
- const int *rcounts,
- MPI_Datatype dtype,
- MPI_Op op,
- MPI_Comm comm
- )
+int reduce_scatter__ompi(const void *sbuf, void *rbuf,
+ const int *rcounts,
+ MPI_Datatype dtype,
+ MPI_Op op,
+ MPI_Comm comm
+ )
{
int comm_size, i, pow2;
size_t total_message_size, dsize;
const size_t large_message_size = 256 * 1024;
int zerocounts = 0;
- XBT_DEBUG("Coll_reduce_scatter_ompi::reduce_scatter");
+ XBT_DEBUG("reduce_scatter__ompi");
comm_size = comm->size();
// We need data size for decision function
}
if (((op != MPI_OP_NULL) && not op->is_commutative()) || (zerocounts)) {
- Coll_reduce_scatter_default::reduce_scatter(sbuf, rbuf, rcounts, dtype, op, comm);
+ reduce_scatter__default(sbuf, rbuf, rcounts, dtype, op, comm);
return MPI_SUCCESS;
}
if ((total_message_size <= small_message_size) ||
((total_message_size <= large_message_size) && (pow2 == comm_size)) ||
(comm_size >= a * total_message_size + b)) {
- return
- Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(sbuf, rbuf, rcounts,
- dtype, op,
- comm);
+ return reduce_scatter__ompi_basic_recursivehalving(sbuf, rbuf, rcounts, dtype, op, comm);
}
- return Coll_reduce_scatter_ompi_ring::reduce_scatter(sbuf, rbuf, rcounts,
- dtype, op,
- comm);
-
-
-
+ return reduce_scatter__ompi_ring(sbuf, rbuf, rcounts, dtype, op, comm);
}
-int Coll_allgather_ompi::allgather(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, int rcount,
- MPI_Datatype rdtype,
- MPI_Comm comm
- )
+int allgather__ompi(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, int rcount,
+ MPI_Datatype rdtype,
+ MPI_Comm comm
+ )
{
int communicator_size, pow2_size;
size_t dsize, total_dsize;
/* Special case for 2 processes */
if (communicator_size == 2) {
- return Coll_allgather_pair::allgather (sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm/*, module*/);
+ return allgather__pair(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm/*, module*/);
}
/* Determine complete data size */
*/
if (total_dsize < 50000) {
if (pow2_size == communicator_size) {
- return Coll_allgather_rdb::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__rdb(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
} else {
- return Coll_allgather_bruck::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__bruck(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
}
} else {
if (communicator_size % 2) {
- return Coll_allgather_ring::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__ring(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
} else {
- return Coll_allgather_ompi_neighborexchange::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__ompi_neighborexchange(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
}
}
- for everything else use ring.
*/
if ((pow2_size == communicator_size) && (total_dsize < 524288)) {
- return Coll_allgather_rdb::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__rdb(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
} else if (total_dsize <= 81920) {
- return Coll_allgather_bruck::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__bruck(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
}
- return Coll_allgather_ring::allgather(sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- comm);
+ return allgather__ring(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ comm);
#endif /* defined(USE_MPICH2_DECISION) */
}
-int Coll_allgatherv_ompi::allgatherv(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, const int *rcounts,
- const int *rdispls,
- MPI_Datatype rdtype,
- MPI_Comm comm
- )
+int allgatherv__ompi(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, const int *rcounts,
+ const int *rdispls,
+ MPI_Datatype rdtype,
+ MPI_Comm comm
+ )
{
int i;
int communicator_size;
/* Special case for 2 processes */
if (communicator_size == 2) {
- return Coll_allgatherv_pair::allgatherv(sbuf, scount, sdtype,
- rbuf, rcounts, rdispls, rdtype,
- comm);
+ return allgatherv__pair(sbuf, scount, sdtype,
+ rbuf, rcounts, rdispls, rdtype,
+ comm);
}
/* Determine complete data size */
/* Decision based on allgather decision. */
if (total_dsize < 50000) {
- return Coll_allgatherv_ompi_bruck::allgatherv(sbuf, scount, sdtype,
- rbuf, rcounts, rdispls, rdtype,
- comm);
+ return allgatherv__ompi_bruck(sbuf, scount, sdtype,
+ rbuf, rcounts, rdispls, rdtype,
+ comm);
} else {
if (communicator_size % 2) {
- return Coll_allgatherv_ring::allgatherv(sbuf, scount, sdtype,
- rbuf, rcounts, rdispls, rdtype,
- comm);
+ return allgatherv__ring(sbuf, scount, sdtype,
+ rbuf, rcounts, rdispls, rdtype,
+ comm);
} else {
- return Coll_allgatherv_ompi_neighborexchange::allgatherv(sbuf, scount, sdtype,
- rbuf, rcounts, rdispls, rdtype,
- comm);
+ return allgatherv__ompi_neighborexchange(sbuf, scount, sdtype,
+ rbuf, rcounts, rdispls, rdtype,
+ comm);
}
}
}
-int Coll_gather_ompi::gather(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, int rcount,
- MPI_Datatype rdtype,
- int root,
- MPI_Comm comm
- )
+int gather__ompi(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, int rcount,
+ MPI_Datatype rdtype,
+ int root,
+ MPI_Comm comm
+ )
{
//const int large_segment_size = 32768;
//const int small_segment_size = 1024;
/* root, comm);*/
/* } else*/ if (block_size > intermediate_block_size) {
- return Coll_gather_ompi_linear_sync::gather (sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- root, comm);
+ return gather__ompi_linear_sync(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ root, comm);
} else if ((communicator_size > large_communicator_size) ||
((communicator_size > small_communicator_size) &&
(block_size < small_block_size))) {
- return Coll_gather_ompi_binomial::gather (sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- root, comm);
+ return gather__ompi_binomial(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ root, comm);
}
// Otherwise, use basic linear
- return Coll_gather_ompi_basic_linear::gather (sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- root, comm);
+ return gather__ompi_basic_linear(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ root, comm);
}
-int Coll_scatter_ompi::scatter(const void *sbuf, int scount,
- MPI_Datatype sdtype,
- void* rbuf, int rcount,
- MPI_Datatype rdtype,
- int root, MPI_Comm comm
- )
+int scatter__ompi(const void *sbuf, int scount,
+ MPI_Datatype sdtype,
+ void* rbuf, int rcount,
+ MPI_Datatype rdtype,
+ int root, MPI_Comm comm
+ )
{
const size_t small_block_size = 300;
const int small_comm_size = 10;
scount = rcount;
sdtype = rdtype;
}
- return Coll_scatter_ompi_binomial::scatter(sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm);
+ return scatter__ompi_binomial(sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm);
}
- return Coll_scatter_ompi_basic_linear::scatter (sbuf, scount, sdtype,
- rbuf, rcount, rdtype,
- root, comm);
+ return scatter__ompi_basic_linear(sbuf, scount, sdtype,
+ rbuf, rcount, rdtype,
+ root, comm);
}
}
#define COLL_DESCRIPTION(cat, ret, args, name) \
{ \
_XBT_STRINGIFY(name) \
- , _XBT_STRINGIFY(cat) " " _XBT_STRINGIFY(name) " collective", (void*)_XBT_CONCAT4(Coll_, cat, _, name)::cat \
+ , _XBT_STRINGIFY(cat) " " _XBT_STRINGIFY(name) " collective", (void*)_XBT_CONCAT3(cat, __, name) \
}
#define COLL_PROTO(cat, ret, args, name) \
- class _XBT_CONCAT4(Coll_, cat, _, name) : public Coll { \
- public: \
- static ret cat(COLL_UNPAREN args); \
- };
+ ret _XBT_CONCAT3(cat, __, name) args;
#define COLL_UNPAREN(...) __VA_ARGS__
static void set_collectives();
// for each collective type, create the set_* prototype, the description array and the function pointer
+// static void set_gather(const std::string& name);
+// static s_mpi_coll_description_t mpi_coll_gather_description[];
+// static int(*gather)(const void *send_buff, int send_count, MPI_Datatype send_type, void *recv_buff, int recv_count, MPI_Datatype recv_type,
+// int root, MPI_Comm comm);
COLL_APPLY(COLL_DEFS, COLL_GATHER_SIG, "")
COLL_APPLY(COLL_DEFS, COLL_ALLGATHER_SIG, "")
COLL_APPLY(COLL_DEFS, COLL_ALLGATHERV_SIG, "")
static void (*smpi_coll_cleanup_callback)();
};
-class Coll {
-public:
- // for each collective type, create a function member
- COLL_APPLY(COLL_SIG, COLL_GATHER_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_ALLGATHER_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_ALLGATHERV_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_REDUCE_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_ALLREDUCE_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_REDUCE_SCATTER_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_SCATTER_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_BARRIER_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_BCAST_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_ALLTOALL_SIG, "")
- COLL_APPLY(COLL_SIG, COLL_ALLTOALLV_SIG, "")
-};
-
/*************
* GATHER *
*************/
}
void * smpi_process_get_user_data(){
- return simgrid::s4u::Actor::self()->get_impl()->get_user_data();
+ return simgrid::s4u::Actor::self()->get_data();
}
void smpi_process_set_user_data(void *data){
- simgrid::s4u::Actor::self()->get_impl()->set_user_data(data);
+ simgrid::s4u::Actor::self()->set_data(data);
}
void smpi_comm_set_copy_data_callback(void (*callback) (smx_activity_t, void*, size_t))
} else {
recvbuf = nullptr;
}
- Coll_gather_default::gather(sendbuf, 2, MPI_INT, recvbuf, 2, MPI_INT, 0, this);
+ gather__default(sendbuf, 2, MPI_INT, recvbuf, 2, MPI_INT, 0, this);
xbt_free(sendbuf);
/* Do the actual job */
if (myrank == 0) {
MPI_Comm Comm::find_intra_comm(int * leader){
//get the indices of all processes sharing the same simix host
- auto& process_list = sg_host_self()->pimpl_->process_list_;
+ auto& actor_list = sg_host_self()->pimpl_->actor_list_;
int intra_comm_size = 0;
int min_index = INT_MAX; // the minimum index will be the leader
- for (auto& actor : process_list) {
+ for (auto& actor : actor_list) {
int index = actor.get_pid();
if (this->group()->rank(actor.ciface()) != MPI_UNDEFINED) { // Is this process in the current group?
intra_comm_size++;
XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size);
MPI_Group group_intra = new Group(intra_comm_size);
int i = 0;
- for (auto& actor : process_list) {
+ for (auto& actor : actor_list) {
if (this->group()->rank(actor.ciface()) != MPI_UNDEFINED) {
group_intra->set_mapping(actor.ciface(), i);
i++;
std::fill_n(leaders_map, comm_size, 0);
std::fill_n(leader_list, comm_size, -1);
- Coll_allgather_ring::allgather(&leader, 1, MPI_INT , leaders_map, 1, MPI_INT, this);
+ allgather__ring(&leader, 1, MPI_INT , leaders_map, 1, MPI_INT, this);
if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
if(comm_intra->rank()==0) {
int is_uniform = 1;
int* non_uniform_map = xbt_new0(int,leader_group_size);
- Coll_allgather_ring::allgather(&my_local_size, 1, MPI_INT,
+ allgather__ring(&my_local_size, 1, MPI_INT,
non_uniform_map, 1, MPI_INT, leader_comm);
for(i=0; i < leader_group_size; i++) {
if(non_uniform_map[0] != non_uniform_map[i]) {
}
is_uniform_=is_uniform;
}
- Coll_bcast_scatter_LR_allgather::bcast(&(is_uniform_),1, MPI_INT, 0, comm_intra );
+ bcast__scatter_LR_allgather(&(is_uniform_),1, MPI_INT, 0, comm_intra );
if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
}
int global_blocked;
- Coll_allreduce_default::allreduce(&is_blocked, &(global_blocked), 1, MPI_INT, MPI_LAND, this);
+ allreduce__default(&is_blocked, &(global_blocked), 1, MPI_INT, MPI_LAND, this);
if(MPI_COMM_WORLD==MPI_COMM_UNINITIALIZED || this==MPI_COMM_WORLD){
if(this->rank()==0){
if(type != MPI_UNDEFINED)
return res;
else{
+ xbt_assert(res->refcount_ == 1); // ensure the next call to Comm::destroy really frees the comm
Comm::destroy(res);
return MPI_COMM_NULL;
}
#include "smpi_group.hpp"
#include "smpi_comm.hpp"
#include <string>
-#include <xbt/log.h>
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_group, smpi, "Logging specific to SMPI (group)");
simgrid::smpi::Group mpi_MPI_GROUP_EMPTY;
MPI_Group MPI_GROUP_EMPTY=&mpi_MPI_GROUP_EMPTY;
#include "ampi.hpp"
#include <smpi/sampi.h>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(plugin_pampi, smpi, "Logging specific to the AMPI functions");
-
static std::vector<size_t> memory_size(500, 0); // FIXME cheinrich This needs to be dynamic
static std::map</*address*/ void*, size_t> alloc_table; // Keep track of all allocations
#include <src/instr/instr_smpi.hpp>
#include <src/smpi/include/smpi_actor.hpp>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_sampi, instr, "Tracing (S)AMPI");
-
static std::map<std::string, std::string> ampi_colors = {{"migrate", "0.2 0.5 0.2"},
{"iteration", "0.5 0.5 0.5"}
};
// Update the process and host mapping in SimGrid.
XBT_DEBUG("Migrating process %li from %s to %s", my_proc_id, cur_host->get_cname(), migrate_to_host->get_cname());
TRACE_smpi_process_change_host(my_proc_id, migrate_to_host);
- simgrid::s4u::this_actor::migrate(migrate_to_host);
+ simgrid::s4u::this_actor::set_host(migrate_to_host);
}
smpilb_bar.wait();
/*********
* Model *
*********/
-/* Helper function for executeParallelTask */
-static inline double has_cost(const double* array, size_t pos)
-{
- if (array)
- return array[pos];
- return -1.0;
-}
-
-kernel::resource::Action* HostModel::execute_parallel(const std::vector<s4u::Host*>& host_list,
- const double* flops_amount, const double* bytes_amount,
- double rate)
-{
- kernel::resource::Action* action = nullptr;
- if ((host_list.size() == 1) && (has_cost(bytes_amount, 0) <= 0) && (has_cost(flops_amount, 0) > 0)) {
- action = host_list[0]->pimpl_cpu->execution_start(flops_amount[0]);
- } else if ((host_list.size() == 1) && (has_cost(flops_amount, 0) <= 0)) {
- action = surf_network_model->communicate(host_list[0], host_list[0], bytes_amount[0], rate);
- } else if ((host_list.size() == 2) && (has_cost(flops_amount, 0) <= 0) && (has_cost(flops_amount, 1) <= 0)) {
- int nb = 0;
- double value = 0.0;
-
- for (size_t i = 0; i < host_list.size() * host_list.size(); i++) {
- if (has_cost(bytes_amount, i) > 0.0) {
- nb++;
- value = has_cost(bytes_amount, i);
- }
- }
- if (nb == 1) {
- action = surf_network_model->communicate(host_list[0], host_list[1], value, rate);
- } else if (nb == 0) {
- xbt_die("Cannot have a communication with no flop to exchange in this model. You should consider using the "
- "ptask model");
- } else {
- xbt_die("Cannot have a communication that is not a simple point-to-point in this model. You should consider "
- "using the ptask model");
- }
- } else {
- xbt_die(
- "This model only accepts one of the following. You should consider using the ptask model for the other cases.\n"
- " - execution with one host only and no communication\n"
- " - Self-comms with one host only\n"
- " - Communications with two hosts and no computation");
- }
- return action;
-}
-
/************
* Resource *
************/
HostImpl::~HostImpl()
{
/* All processes should be gone when the host is turned off (by the end of the simulation). */
- if (not process_list_.empty()) {
+ if (not actor_list_.empty()) {
std::string msg = std::string("Shutting down host, but it's not empty:");
- for (auto const& process : process_list_)
+ for (auto const& process : actor_list_)
msg += "\n\t" + std::string(process.get_name());
SIMIX_display_process_status();
}
/** Kill all actors hosted here */
-void HostImpl::turn_off()
+void HostImpl::turn_off(kernel::actor::ActorImpl* issuer)
{
- if (not process_list_.empty()) {
- for (auto& actor : process_list_) {
- XBT_DEBUG("Killing Actor %s@%s on behalf of %s which turned off that host.", actor.get_cname(),
- actor.get_host()->get_cname(), SIMIX_process_self()->get_cname());
- SIMIX_process_self()->kill(&actor);
- }
+ for (auto& actor : actor_list_) {
+ XBT_DEBUG("Killing Actor %s@%s on behalf of %s which turned off that host.", actor.get_cname(),
+ actor.get_host()->get_cname(), issuer->get_cname());
+ issuer->kill(&actor);
}
// When a host is turned off, we want to keep only the actors that should restart for when it will boot again.
// Then get rid of the others.
std::vector<s4u::ActorPtr> HostImpl::get_all_actors()
{
std::vector<s4u::ActorPtr> res;
- for (auto& actor : process_list_)
+ for (auto& actor : actor_list_)
res.push_back(actor.ciface());
return res;
}
size_t HostImpl::get_actor_count()
{
- return process_list_.size();
+ return actor_list_.size();
}
std::vector<s4u::Disk*> HostImpl::get_disks()
{
std::vector<s4u::Disk*> disks;
for (auto const& d : disks_)
- disks.push_back(&d->piface_);
+ disks.push_back(d->get_iface());
return disks;
}
std::vector<const char*> storages;
for (auto const& s : storage_)
if (s.second->get_host() == piface_->get_cname())
- storages.push_back(s.second->piface_.get_cname());
+ storages.push_back(s.second->get_iface()->get_cname());
return storages;
}
virtual kernel::resource::Action* execute_parallel(const std::vector<s4u::Host*>& host_list,
const double* flops_amount, const double* bytes_amount,
- double rate);
+ double rate) = 0;
};
/************
* @details An host represents a machine with a aggregation of a Cpu, a RoutingEdge and a Storage
*/
class XBT_PRIVATE HostImpl : public simgrid::surf::PropertyHolder {
+ std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
+ s4u::Host* piface_ = nullptr; // FIXME: why don't we store a s4u::Host here as we do everywhere else?
public:
+ friend simgrid::vm::VirtualMachineImpl;
explicit HostImpl(s4u::Host* host);
virtual ~HostImpl();
std::map<std::string, kernel::resource::StorageImpl*> storage_;
std::vector<kernel::resource::DiskImpl*> disks_;
- s4u::Host* piface_ = nullptr;
+ s4u::Host* get_iface() { return piface_; }
void turn_on();
- void turn_off();
+ void turn_off(kernel::actor::ActorImpl* issuer);
std::vector<s4u::ActorPtr> get_all_actors();
size_t get_actor_count();
+ void add_actor(kernel::actor::ActorImpl* actor) { actor_list_.push_back(*actor); }
+ void remove_actor(kernel::actor::ActorImpl* actor) { xbt::intrusive_erase(actor_list_, *actor); }
+ void add_actor_at_boot(kernel::actor::ProcessArg* arg) { actors_at_boot_.emplace_back(arg); }
typedef boost::intrusive::list<
kernel::actor::ActorImpl,
boost::intrusive::member_hook<kernel::actor::ActorImpl, boost::intrusive::list_member_hook<>,
- &kernel::actor::ActorImpl::host_process_list_hook>>
+ &kernel::actor::ActorImpl::host_actor_list_hook>>
ActorList;
// FIXME: make these private
- ActorList process_list_;
- std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
+ ActorList actor_list_;
};
}
}
* @details A Storage represent a storage unit (e.g.: hard drive, usb key)
*/
class StorageImpl : public Resource, public surf::PropertyHolder {
+ s4u::Storage piface_;
+
public:
/** @brief Storage constructor */
StorageImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double bread, double bwrite,
~StorageImpl() override;
- /** @brief Public interface */
- s4u::Storage piface_;
-
+ s4u::Storage* get_iface() { return &piface_; }
/** @brief Check if the Storage is used (if an action currently uses its resources) */
bool is_used() override;
{
all_existing_models.push_back(this);
}
+
double HostCLM03Model::next_occurring_event(double now)
{
double min_by_cpu = surf_cpu_model_pm->next_occurring_event(now);
/* I've no action to update */
}
+/* Helper function for executeParallelTask */
+static inline double has_cost(const double* array, size_t pos)
+{
+ if (array)
+ return array[pos];
+ return -1.0;
+}
+
+kernel::resource::Action* HostCLM03Model::execute_parallel(const std::vector<s4u::Host*>& host_list,
+ const double* flops_amount, const double* bytes_amount,
+ double rate)
+{
+ kernel::resource::Action* action = nullptr;
+ if ((host_list.size() == 1) && (has_cost(bytes_amount, 0) <= 0) && (has_cost(flops_amount, 0) > 0)) {
+ action = host_list[0]->pimpl_cpu->execution_start(flops_amount[0]);
+ } else if ((host_list.size() == 1) && (has_cost(flops_amount, 0) <= 0)) {
+ action = surf_network_model->communicate(host_list[0], host_list[0], bytes_amount[0], rate);
+ } else if ((host_list.size() == 2) && (has_cost(flops_amount, 0) <= 0) && (has_cost(flops_amount, 1) <= 0)) {
+ int nb = 0;
+ double value = 0.0;
+
+ for (size_t i = 0; i < host_list.size() * host_list.size(); i++) {
+ if (has_cost(bytes_amount, i) > 0.0) {
+ nb++;
+ value = has_cost(bytes_amount, i);
+ }
+ }
+ if (nb == 1) {
+ action = surf_network_model->communicate(host_list[0], host_list[1], value, rate);
+ } else if (nb == 0) {
+ xbt_die("Cannot have a communication with no flop to exchange in this model. You should consider using the "
+ "ptask model");
+ } else {
+ xbt_die("Cannot have a communication that is not a simple point-to-point in this model. You should consider "
+ "using the ptask model");
+ }
+ } else {
+ xbt_die(
+ "This model only accepts one of the following. You should consider using the ptask model for the other cases.\n"
+ " - execution with one host only and no communication\n"
+ " - Self-comms with one host only\n"
+ " - Communications with two hosts and no computation");
+ }
+ return action;
+}
+
} // namespace surf
} // namespace simgrid
HostCLM03Model();
double next_occurring_event(double now) override;
void update_actions_state(double now, double delta) override;
+ kernel::resource::Action* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
+ const double* bytes_amount, double rate) override;
};
}
}
if (link->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
NetworkWifiLink* wifi_link = static_cast<NetworkWifiLink*>(link);
- double rate = wifi_link->get_host_rate(src);
- if (rate == -1)
- rate = wifi_link->get_host_rate(dst);
- xbt_assert(rate != -1,
+ double wifi_rate = wifi_link->get_host_rate(src);
+ if (wifi_rate == -1.0)
+ wifi_rate = wifi_link->get_host_rate(dst);
+ xbt_assert(wifi_rate != -1.0,
"None of the source (%s) or destination (%s) is connected to the Access Point '%s'. "
"Please use set_host_rate() on all stations.",
src->get_cname(), dst->get_cname(), link->get_cname());
- get_maxmin_system()->expand(link->get_constraint(), action->get_variable(), 1.0 / rate);
+ get_maxmin_system()->expand(link->get_constraint(), action->get_variable(), 1.0 / wifi_rate);
} else {
get_maxmin_system()->expand(link->get_constraint(), action->get_variable(), 1.0);
if (policy == s4u::Link::SharingPolicy::FATPIPE)
get_constraint()->unshare();
- simgrid::s4u::Link::on_creation(this->piface_);
+ simgrid::s4u::Link::on_creation(*get_iface());
}
void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
*/
class LinkImpl : public Resource, public surf::PropertyHolder {
bool currently_destroying_ = false;
+ s4u::Link piface_;
protected:
LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint);
void destroy(); // Must be called instead of the destructor
/** @brief Public interface */
- s4u::Link piface_;
+ s4u::Link* get_iface() { return &piface_; }
/** @brief Get the bandwidth in bytes per second of current Link */
virtual double get_bandwidth();
bandwidth_.peak = bandwidth;
latency_.peak = latency;
- s4u::Link::on_creation(this->piface_);
+ s4u::Link::on_creation(*this->get_iface());
}
LinkNS3::~LinkNS3() = default;
for (auto bandwidth : bandwidths)
bandwidths_.push_back({bandwidth, 1.0, nullptr});
- simgrid::s4u::Link::on_creation(this->piface_);
+ simgrid::s4u::Link::on_creation(*get_iface());
}
void NetworkWifiLink::set_host_rate(s4u::Host* host, int rate_level)
if (policy == s4u::Link::SharingPolicy::FATPIPE)
get_constraint()->unshare();
- s4u::Link::on_creation(this->piface_);
+ s4u::Link::on_creation(*get_iface());
}
kernel::resource::CpuAction* CpuL07::execution_start(double size)
simgrid::kernel::actor::ProcessArg* arg =
new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
- host->pimpl_->actors_at_boot_.emplace_back(arg);
+ host->pimpl_->add_actor_at_boot(arg);
if (start_time > SIMIX_get_clock()) {
: StorageImpl(model, name, maxminSystem, bread, bwrite, type_id, content_name, size, attach)
{
XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
- s4u::Storage::on_creation(this->piface_);
+ s4u::Storage::on_creation(*get_iface());
}
StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type)
#endif
const std::vector<surf_model_description_t> surf_cpu_model_description = {
- {"Cas01", "Simplistic CPU model (time=size/power).", &surf_cpu_model_init_Cas01},
+ {"Cas01", "Simplistic CPU model (time=size/speed).", &surf_cpu_model_init_Cas01},
};
const std::vector<surf_model_description_t> surf_host_model_description = {
XBT_PUBLIC void surf_parse_open(const std::string& file);
XBT_PUBLIC void surf_parse_close();
-XBT_PUBLIC void surf_parse_assert(bool cond, const std::string& msg);
-XBT_ATTRIB_NORETURN XBT_PUBLIC void surf_parse_error(const std::string& msg);
+XBT_PUBLIC void surf_parse_assert(bool cond, std::string&& msg);
+XBT_ATTRIB_NORETURN XBT_PUBLIC void surf_parse_error(std::string&& msg);
XBT_PUBLIC void surf_parse_assert_netpoint(const std::string& hostname, const std::string& pre,
const std::string& post);
const std::string& name);
XBT_PUBLIC double surf_parse_get_speed(const char* string, const char* entity_kind, const std::string& name);
-XBT_PUBLIC int surf_parse(); /* Entry-point to the parser */
+XBT_PUBLIC void surf_parse(); /* Entry-point to the parser */
#endif
void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect)
{
- xbt_assert(traces_set_list.find(trace_connect->trace) != traces_set_list.end(),
- "Cannot connect trace %s to %s: trace unknown", trace_connect->trace.c_str(),
- trace_connect->element.c_str());
+ surf_parse_assert(traces_set_list.find(trace_connect->trace) != traces_set_list.end(),
+ std::string("Cannot connect trace ")+ trace_connect->trace+ " to "+trace_connect->element+": trace unknown");
switch (trace_connect->kind) {
case simgrid::kernel::routing::TraceConnectKind::HOST_AVAIL:
// Use XML parser
- int parse_status;
-
/* init the flex parser */
surf_parse_open(file);
/* Do the actual parsing */
- parse_status = surf_parse();
+ surf_parse();
/* connect all profiles relative to hosts */
for (auto const& elm : trace_connect_list_host_avail) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
-
- simgrid::s4u::Host* host = simgrid::s4u::Host::by_name_or_null(elm.second);
- xbt_assert(host, "Host %s undefined", elm.second.c_str());
- simgrid::kernel::resource::Cpu* cpu = host->pimpl_cpu;
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"HOST_AVAIL\">: Trace ")+elm.first+" undefined.");
+ auto profile = traces_set_list.at(elm.first);
- cpu->set_state_profile(profile);
+ auto host = simgrid::s4u::Host::by_name_or_null(elm.second);
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"HOST_AVAIL\">: Host ")+elm.second+" undefined.");
+ host->set_state_profile(profile);
}
for (auto const& elm : trace_connect_list_host_speed) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
-
- simgrid::s4u::Host* host = simgrid::s4u::Host::by_name_or_null(elm.second);
- xbt_assert(host, "Host %s undefined", elm.second.c_str());
- simgrid::kernel::resource::Cpu* cpu = host->pimpl_cpu;
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"SPEED\">: Trace ")+elm.first+" undefined.");
+ auto profile = traces_set_list.at(elm.first);
- cpu->set_speed_profile(profile);
+ auto host = simgrid::s4u::Host::by_name_or_null(elm.second);
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"SPEED\">: Host ")+elm.second+" undefined.");
+ host->set_speed_profile(profile);
}
for (auto const& elm : trace_connect_list_link_avail) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"LINK_AVAIL\">: Trace ")+elm.first+" undefined.");
+ auto profile = traces_set_list.at(elm.first);
- sg_link_t link = simgrid::s4u::Link::by_name(elm.second);
- xbt_assert(link, "Link %s undefined", elm.second.c_str());
+ auto link = simgrid::s4u::Link::by_name(elm.second);
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"LINK_AVAIL\">: Link ")+elm.second+" undefined.");
link->set_state_profile(profile);
}
for (auto const& elm : trace_connect_list_link_bw) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
- sg_link_t link = simgrid::s4u::Link::by_name(elm.second);
- xbt_assert(link, "Link %s undefined", elm.second.c_str());
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"BANDWIDTH\">: Trace ")+elm.first+" undefined.");
+ auto profile = traces_set_list.at(elm.first);
+
+ auto link = simgrid::s4u::Link::by_name(elm.second);
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"BANDWIDTH\">: Link ")+elm.second+" undefined.");
link->set_bandwidth_profile(profile);
}
for (auto const& elm : trace_connect_list_link_lat) {
- xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
- simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
- sg_link_t link = simgrid::s4u::Link::by_name(elm.second);
- xbt_assert(link, "Link %s undefined", elm.second.c_str());
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"LATENCY\">: Trace ")+elm.first+" undefined.");
+ auto profile = traces_set_list.at(elm.first);
+
+ auto link = simgrid::s4u::Link::by_name(elm.second);
+ surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"LATENCY\">: Link ")+elm.second+" undefined.");
link->set_latency_profile(profile);
}
surf_parse_close();
-
- if (parse_status)
- surf_parse_error(std::string("Parse error in ") + file);
}
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "simgrid/Exception.hpp"
#include "simgrid/kernel/routing/NetPoint.hpp"
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/sg_config.hpp"
/*
* Helping functions
*/
-void surf_parse_assert(bool cond, const std::string& msg)
+void surf_parse_assert(bool cond, std::string&& msg)
{
- if (not cond) {
- int lineno = surf_parse_lineno;
- cleanup();
- XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename.c_str(), lineno, msg.c_str());
- surf_exit();
- xbt_die("Exiting now");
- }
+ if (not cond)
+ surf_parse_error(std::move(msg));
}
-void surf_parse_error(const std::string& msg)
+void surf_parse_error(std::string&& msg)
{
- int lineno = surf_parse_lineno;
- cleanup();
- XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename.c_str(), lineno, msg.c_str());
- surf_exit();
- xbt_die("Exiting now");
+ throw simgrid::ParseError(surf_parse_lineno, surf_parsed_filename, std::move(msg));
}
void surf_parse_assert_netpoint(const std::string& hostname, const std::string& pre, const std::string& post)
break;
}
}
- surf_parse_error(msg);
+ surf_parse_error(std::move(msg));
}
double surf_parse_get_double(const std::string& s)
void STag_surfxml_platform() {
XBT_ATTRIB_UNUSED double version = surf_parse_get_double(A_surfxml_platform_version);
- xbt_assert((version >= 1.0), "******* BIG FAT WARNING *********\n "
+ surf_parse_assert((version >= 1.0), "******* BIG FAT WARNING *********\n "
"You're using an ancient XML file.\n"
"Since SimGrid 3.1, units are Bytes, Flops, and seconds "
"instead of MBytes, MFlops and seconds.\n"
"Last, do not forget to also update your values for "
"the calls to MSG_task_create (if any).");
- xbt_assert((version >= 3.0), "******* BIG FAT WARNING *********\n "
+ surf_parse_assert((version >= 3.0), "******* BIG FAT WARNING *********\n "
"You're using an old XML file.\n"
"Use simgrid_update_xml to update your file automatically. "
"This program is installed automatically with SimGrid, or "
"available in the tools/ directory of the source archive.");
- xbt_assert((version >= 4.0),
- "******* FILE %s IS TOO OLD (v:%.1f) *********\n "
+ surf_parse_assert((version >= 4.0),
+ std::string("******* THIS FILE IS TOO OLD (v:")+std::to_string(version)+") *********\n "
"Changes introduced in SimGrid 3.13:\n"
" - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
" - In <trace_connect>, attribute kind=\"POWER\" is now kind=\"SPEED\".\n"
"\n\n"
"Use simgrid_update_xml to update your file automatically. "
"This program is installed automatically with SimGrid, or "
- "available in the tools/ directory of the source archive.",
- surf_parsed_filename.c_str(), version);
+ "available in the tools/ directory of the source archive.");
if (version < 4.1) {
XBT_INFO("You're using a v%.1f XML file (%s) while the current standard is v4.1 "
"That's fine, the new version is backward compatible. \n\n"
"available in the tools/ directory of the source archive.",
version, surf_parsed_filename.c_str());
}
- xbt_assert(version <= 4.1,
- "******* FILE %s COMES FROM THE FUTURE (v:%.1f) *********\n "
+ surf_parse_assert(version <= 4.1,
+ std::string("******* THIS FILE COMES FROM THE FUTURE (v:")+std::to_string(version)+") *********\n "
"The most recent formalism that this version of SimGrid understands is v4.1.\n"
- "Please update your code, or use another, more adapted, file.",
- surf_parsed_filename.c_str(), version);
+ "Please update your code, or use another, more adapted, file.");
}
void ETag_surfxml_platform(){
simgrid::s4u::Engine::on_platform_created();
}
/* Call the lexer to parse the currently opened file */
-int surf_parse()
+void surf_parse()
{
- return surf_parse_lex();
+ bool err = surf_parse_lex();
+ surf_parse_assert(not err, "Flex returned an error code");
}
#include "xbt/automaton.h"
#include <stdio.h> /* printf */
-#include <xbt/log.h>
#include <xbt/sysdep.h>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_automaton, xbt, "Automaton");
-
struct xbt_automaton_propositional_symbol{
char* pred;
/** Callback used to evaluate the value of the symbol */
#if HAVE_UNISTD_H
# include <unistd.h> /* isatty */
#endif
-#include <xbt/log.h>
#include <xbt/sysdep.h>
#include "parserPromela.tab.cacc"
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_automaton);
-
static xbt_automaton_t parsed_automaton;
char* state_id_src;
-/* A Bison parser, made by GNU Bison 3.4.1. */
+/* A Bison parser, made by GNU Bison 3.4.2. */
/* Bison implementation for Yacc-like parsers in C
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.4.1"
+#define YYBISON_VERSION "3.4.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
# define YY_XBT_AUTOMATON_PARSER_PARSERPROMELA_TAB_HACC_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
-# define YYDEBUG 0
+# define YYDEBUG 1
#endif
#if YYDEBUG
extern int xbt_automaton_parser_debug;
if (yytype < YYNTOKENS)
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yytype);
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
}
case 4:
#line 64 "parserPromela.yacc"
{ new_state((yyvsp[-1].string), 1);}
-#line 1271 "parserPromela.tab.cacc"
+#line 1273 "parserPromela.tab.cacc"
break;
case 7:
#line 68 "parserPromela.yacc"
{ new_transition((yyvsp[-1].string), (yyvsp[-4].label));}
-#line 1277 "parserPromela.tab.cacc"
+#line 1279 "parserPromela.tab.cacc"
break;
case 8:
#line 71 "parserPromela.yacc"
{ (yyval.label) = (yyvsp[-1].label); }
-#line 1283 "parserPromela.tab.cacc"
+#line 1285 "parserPromela.tab.cacc"
break;
case 9:
#line 72 "parserPromela.yacc"
{ (yyval.label) = xbt_automaton_exp_label_new_or((yyvsp[-2].label), (yyvsp[0].label)); }
-#line 1289 "parserPromela.tab.cacc"
+#line 1291 "parserPromela.tab.cacc"
break;
case 10:
#line 73 "parserPromela.yacc"
{ (yyval.label) = xbt_automaton_exp_label_new_and((yyvsp[-2].label), (yyvsp[0].label)); }
-#line 1295 "parserPromela.tab.cacc"
+#line 1297 "parserPromela.tab.cacc"
break;
case 11:
#line 74 "parserPromela.yacc"
{ (yyval.label) = xbt_automaton_exp_label_new_not((yyvsp[0].label)); }
-#line 1301 "parserPromela.tab.cacc"
+#line 1303 "parserPromela.tab.cacc"
break;
case 12:
#line 75 "parserPromela.yacc"
{ (yyval.label) = xbt_automaton_exp_label_new_one(); }
-#line 1307 "parserPromela.tab.cacc"
+#line 1309 "parserPromela.tab.cacc"
break;
case 13:
#line 76 "parserPromela.yacc"
{ (yyval.label) = xbt_automaton_exp_label_new_predicat((yyvsp[0].string)); }
-#line 1313 "parserPromela.tab.cacc"
+#line 1315 "parserPromela.tab.cacc"
break;
-#line 1317 "parserPromela.tab.cacc"
+#line 1319 "parserPromela.tab.cacc"
default: break;
}
-/* A Bison parser, made by GNU Bison 3.4.1. */
+/* A Bison parser, made by GNU Bison 3.4.2. */
/* Bison interface for Yacc-like parsers in C
# define YY_XBT_AUTOMATON_PARSER_PARSERPROMELA_TAB_HACC_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
-# define YYDEBUG 0
+# define YYDEBUG 1
#endif
#if YYDEBUG
extern int xbt_automaton_parser_debug;
#include "src/internal_config.h"
#include <xbt/backtrace.hpp>
-#include <xbt/log.h>
#include <xbt/string.hpp>
#include <xbt/sysdep.h>
#include <xbt/virtu.h>
#include <boost/stacktrace.hpp>
#endif
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_backtrace, xbt, "Backtrace");
-
/** @brief show the backtrace of the current point (lovely while debugging) */
void xbt_backtrace_display_current()
{
* @param key the key to set the new data
* @param key_len the size of the @a key
* @param data the data to add in the dict
- * @param free_ctn unused parameter (kept for compatibility)
*
* Set the @a data in the structure under the @a key, which can be any kind of data, as long as its length is provided
* in @a key_len.
*/
-void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data,
- XBT_ATTRIB_UNUSED void_f_pvoid_t free_ctn)
+void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data)
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
* @param dict the dict
* @param key the key to set the new data
* @param data the data to add in the dict
- * @param free_ctn unused parameter (kept for compatibility)
*
* set the @a data in the structure under the @a key, which is a null terminated string.
*/
-void xbt_dict_set(xbt_dict_t dict, const char *key, void *data, void_f_pvoid_t free_ctn)
+void xbt_dict_set(xbt_dict_t dict, const char* key, void* data)
{
- xbt_dict_set_ext(dict, key, strlen(key), data, free_ctn);
+ xbt_dict_set_ext(dict, key, strlen(key), data);
}
/**
#include "dict_private.h" /* prototypes of this module */
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict_elm, xbt_dict, "Dictionaries internals");
-
xbt_mallocator_t dict_elm_mallocator = NULL;
xbt_dictelm_t xbt_dictelm_new(const char* key, int key_len, unsigned int hash_code, void* content)
#include "xbt/dict.h"
#include "xbt/mallocator.h"
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
typedef struct s_xbt_dict {
void_f_pvoid_t free_f;
XBT_PRIVATE void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element);
XBT_PRIVATE void xbt_dictelm_set_data(xbt_dict_t dict, xbt_dictelm_t element, void* data);
-SG_END_DECL()
+SG_END_DECL
#endif
INFO("Add " << STR(data_to_fill) << " under " << STR(key));
- xbt_dict_set(head, key, data, nullptr);
+ xbt_dict_set(head, key, data);
}
static void debugged_add(xbt_dict_t head, const char* key)
head = new_fixture();
count_check_get_key(head, 7);
INFO("Change 123 to 'Changed 123'");
- xbt_dict_set(head, "123", xbt_strdup("Changed 123"), nullptr);
+ xbt_dict_set(head, "123", xbt_strdup("Changed 123"));
count_check_get_key(head, 7);
INFO("Change 123 back to '123'");
- xbt_dict_set(head, "123", xbt_strdup("123"), nullptr);
+ xbt_dict_set(head, "123", xbt_strdup("123"));
count_check_get_key(head, 7);
INFO("Change 12a to 'Dummy 12a'");
- xbt_dict_set(head, "12a", xbt_strdup("Dummy 12a"), nullptr);
+ xbt_dict_set(head, "12a", xbt_strdup("Dummy 12a"));
count_check_get_key(head, 7);
INFO("Change 12a to '12a'");
- xbt_dict_set(head, "12a", xbt_strdup("12a"), nullptr);
+ xbt_dict_set(head, "12a", xbt_strdup("12a"));
count_check_get_key(head, 7);
INFO("Traverse the resulting dictionary");
xbt_dict_t head = new_fixture();
INFO("Store nullptr under 'null'");
- xbt_dict_set(head, "null", nullptr, nullptr);
+ xbt_dict_set(head, "null", nullptr);
search_ext(head, "null", nullptr);
INFO("Check whether I see it while traversing...");
data = (char*)xbt_dict_get_or_null(head, key);
} while (data != nullptr);
- xbt_dict_set(head, key, key, nullptr);
+ xbt_dict_set(head, key, key);
data = (char*)xbt_dict_get(head, key);
REQUIRE(not strcmp(key, data)); // Retrieved value != Injected value
char* key = (char*)xbt_malloc(10);
snprintf(key, 10, "%d", j);
- xbt_dict_set(head, key, key, nullptr);
+ xbt_dict_set(head, key, key);
}
INFO("Count the elements (retrieving the key and data for each)");
INFO("Insert elements");
for (int i = 0; i < count; ++i)
- xbt_dict_set_ext(dict, (char*)&i, sizeof(i), (void*)(intptr_t)i, nullptr);
+ xbt_dict_set_ext(dict, (char*)&i, sizeof(i), (void*)(intptr_t)i);
REQUIRE(xbt_dict_size(dict) == (unsigned)count); // Bad number of elements in the dictionary
INFO("Check elements");
static void handler()
{
- // Avoid doing crazy things if we get an uncaught exception inside
- // an uncaught exception
+ // Avoid doing crazy things if we get an uncaught exception inside an uncaught exception
static std::atomic_flag lock = ATOMIC_FLAG_INIT;
if (lock.test_and_set()) {
XBT_ERROR("Handling an exception raised an exception. Bailing out.");
std::rethrow_exception(e);
}
+ // Parse error are handled differently, as the call stack does not matter, only the file location
+ catch (simgrid::ParseError& e) {
+ XBT_ERROR("%s", e.what());
+ XBT_ERROR("Exiting now.");
+ std::abort();
+ }
+
// We manage C++ exception ourselves
catch (std::exception& e) {
log_exception(xbt_log_priority_critical, "Uncaught exception", e);
catch (const simgrid::ForcefulKillException&) {
XBT_ERROR("Received a ForcefulKillException at the top-level exception handler. Maybe a Java->C++ call that is not "
- "protected "
- "in a try/catch?");
+ "protected in a try/catch?");
show_backtrace(bt);
}
std::abort();
}
}
+ XBT_INFO("BAM");
}
void install_exception_handler()
#define ADDRESS(B) ((void*) (((ADDR2UINT(B)) - 1) * BLOCKSIZE + (char*) mdp -> heapbase))
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Doubly linked lists of free fragments. */
struct list {
XBT_PRIVATE size_t mmalloc_get_bytes_used_remote(size_t heaplimit, const malloc_info* heapinfo);
-SG_END_DECL()
+SG_END_DECL
#endif
#include "src/kernel/activity/MutexImpl.hpp"
#include "xbt/synchro.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt, "Synchronization mechanism");
-
/****** mutex related functions ******/
xbt_mutex_t xbt_mutex_init(void)
{
#define XBT_MODINTER_H
#include "xbt/misc.h"
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/* Modules definitions */
extern int smx_cleaned;
extern int xbt_initialized;
-SG_END_DECL()
+SG_END_DECL
#endif
/** Number of blocks asked by each request */
#define BLOCKS_REQUESTED 2
-#define ENABLE_END_GAME_MODE 1
#define SLEEP_DURATION 1
int count_pieces(unsigned int bitfield)
// Add the peers the tracker gave us to our peer list.
xbt_dynar_foreach (data->peers, i, peer_id) {
if (peer_id != peer->id)
- xbt_dict_set_ext(peer->peers, (char*)&peer_id, sizeof(int), connection_new(peer_id), NULL);
+ xbt_dict_set_ext(peer->peers, (char*)&peer_id, sizeof(int), connection_new(peer_id));
}
success = 1;
// free the communication and the task
{
if ((remote_peer->interested != 0) && (remote_peer->choked_upload == 0)) {
// add in the active peers set
- xbt_dict_set_ext(peer->active_peers, (char*)&remote_peer->id, sizeof(int), remote_peer, NULL);
+ xbt_dict_set_ext(peer->active_peers, (char*)&remote_peer->id, sizeof(int), remote_peer);
} else if (xbt_dict_get_or_null_ext(peer->active_peers, (char*)&remote_peer->id, sizeof(int))) {
xbt_dict_remove_ext(peer->active_peers, (char*)&remote_peer->id, sizeof(int));
}
case MESSAGE_HANDSHAKE:
// Check if the peer is in our connection list.
if (remote_peer == 0) {
- xbt_dict_set_ext(peer->peers, (char*)&message->peer_id, sizeof(int), connection_new(message->peer_id), NULL);
+ xbt_dict_set_ext(peer->peers, (char*)&message->peer_id, sizeof(int), connection_new(message->peer_id));
send_handshake(peer, message->mailbox);
}
// Send our bitfield to the peer
XBT_DEBUG(" \t for piece %d (%d,%d)", message->index, message->block_index,
message->block_index + message->block_length);
xbt_assert(!remote_peer->choked_download);
- xbt_assert(remote_peer->am_interested || ENABLE_END_GAME_MODE,
- "Can't received a piece if I'm not interested wihtout end-game mode!"
- "piece (%d) bitfield(%u) remote bitfield(%u)",
- message->index, peer->bitfield, remote_peer->bitfield);
xbt_assert(remote_peer->choked_download != 1, "Can't received a piece if I'm choked !");
xbt_assert((message->index >= 0 && message->index < FILE_PIECES), "Wrong piece received");
// TODO: Execute à computation.
}
} else {
XBT_DEBUG("However, we already have it");
- xbt_assert(ENABLE_END_GAME_MODE, "Should not happen because we don't use end game mode !");
request_new_piece_to_peer(peer, remote_peer);
}
break;
// end game mode
if (count_pieces(peer->current_pieces) >= (FILE_PIECES - count_pieces(peer->bitfield)) &&
(is_interested(peer, remote_peer) != 0)) {
-#if ENABLE_END_GAME_MODE == 0
- return -1;
-#endif
int nb_interesting_pieces = 0;
// compute the number of interesting pieces
for (int i = 0; i < FILE_PIECES; i++) {
// update the current round
peer->round = (peer->round + 1) % 3;
char* key;
- char* key_choked = NULL;
- connection_t peer_chosen = NULL;
- connection_t peer_choked = NULL;
+ char* choked_key = NULL;
+ connection_t chosen_peer = NULL;
+ connection_t choked_peer = NULL;
// remove a peer from the list
xbt_dict_cursor_t cursor = NULL;
xbt_dict_cursor_first(peer->active_peers, &cursor);
if (!xbt_dict_is_empty(peer->active_peers)) {
- key_choked = xbt_dict_cursor_get_key(cursor);
- peer_choked = xbt_dict_cursor_get_data(cursor);
+ choked_key = xbt_dict_cursor_get_key(cursor);
+ choked_peer = xbt_dict_cursor_get_data(cursor);
}
xbt_dict_cursor_free(&cursor);
if (connection->last_unchoke < unchoke_time && (connection->interested != 0) &&
(connection->choked_upload != 0)) {
unchoke_time = connection->last_unchoke;
- peer_chosen = connection;
+ chosen_peer = connection;
}
}
} else {
connection_t connection;
xbt_dict_foreach (peer->peers, cursor, key, connection) {
if (i == id_chosen) {
- peer_chosen = connection;
+ chosen_peer = connection;
break;
}
i++;
}
xbt_dict_cursor_free(&cursor);
- xbt_assert(peer_chosen != NULL, "A peer should have been selected at this point");
- if ((peer_chosen->interested == 0) || (peer_chosen->choked_upload == 0))
- peer_chosen = NULL;
+ xbt_assert(chosen_peer != NULL, "A peer should have been selected at this point");
+ if ((chosen_peer->interested == 0) || (chosen_peer->choked_upload == 0))
+ chosen_peer = NULL;
else
XBT_DEBUG("Nothing to do, keep going");
j++;
- } while (peer_chosen == NULL && j < MAXIMUM_PEERS);
+ } while (chosen_peer == NULL && j < MAXIMUM_PEERS);
} else {
// Use the "fastest download" policy.
connection_t connection;
xbt_dict_foreach (peer->peers, cursor, key, connection) {
if (connection->peer_speed > fastest_speed && (connection->choked_upload != 0) &&
(connection->interested != 0)) {
- peer_chosen = connection;
+ chosen_peer = connection;
fastest_speed = connection->peer_speed;
}
}
}
}
- if (peer_chosen != NULL)
- XBT_DEBUG("(%d) update_choked peers unchoked (%d) ; int (%d) ; choked (%d) ", peer->id, peer_chosen->id,
- peer_chosen->interested, peer_chosen->choked_upload);
-
- if (peer_choked != peer_chosen) {
- if (peer_choked != NULL) {
- xbt_assert((!peer_choked->choked_upload), "Tries to choked a choked peer");
- peer_choked->choked_upload = 1;
- xbt_assert((*((int*)key_choked) == peer_choked->id));
- update_active_peers_set(peer, peer_choked);
- XBT_DEBUG("(%d) Sending a CHOKE to %d", peer->id, peer_choked->id);
- send_choked(peer, peer_choked->mailbox);
+ if (chosen_peer != NULL)
+ XBT_DEBUG("(%d) update_choked peers unchoked (%d) ; int (%d) ; choked (%d) ", peer->id, chosen_peer->id,
+ chosen_peer->interested, chosen_peer->choked_upload);
+
+ if (choked_peer != chosen_peer) {
+ if (choked_peer != NULL) {
+ xbt_assert((!choked_peer->choked_upload), "Tries to choked a choked peer");
+ choked_peer->choked_upload = 1;
+ xbt_assert((*((int*)choked_key) == choked_peer->id));
+ update_active_peers_set(peer, choked_peer);
+ XBT_DEBUG("(%d) Sending a CHOKE to %d", peer->id, choked_peer->id);
+ send_choked(peer, choked_peer->mailbox);
}
- if (peer_chosen != NULL) {
- xbt_assert((peer_chosen->choked_upload), "Tries to unchoked an unchoked peer");
- peer_chosen->choked_upload = 0;
- xbt_dict_set_ext(peer->active_peers, (char*)&peer_chosen->id, sizeof(int), peer_chosen, NULL);
- peer_chosen->last_unchoke = MSG_get_clock();
- XBT_DEBUG("(%d) Sending a UNCHOKE to %d", peer->id, peer_chosen->id);
- update_active_peers_set(peer, peer_chosen);
- send_unchoked(peer, peer_chosen->mailbox);
+ if (chosen_peer != NULL) {
+ xbt_assert((chosen_peer->choked_upload), "Tries to unchoked an unchoked peer");
+ chosen_peer->choked_upload = 0;
+ xbt_dict_set_ext(peer->active_peers, (char*)&chosen_peer->id, sizeof(int), chosen_peer);
+ chosen_peer->last_unchoke = MSG_get_clock();
+ XBT_DEBUG("(%d) Sending a UNCHOKE to %d", peer->id, chosen_peer->id);
+ update_active_peers_set(peer, chosen_peer);
+ send_unchoked(peer, chosen_peer->mailbox);
}
}
}
#include "tracker.h"
#include <simgrid/msg.h>
-#include <stdio.h> /* snprintf */
-
/** Bittorrent example launcher */
int main(int argc, char* argv[])
{
- msg_host_t host;
- unsigned i;
-
MSG_init(&argc, argv);
/* Check the arguments */
MSG_create_environment(argv[1]);
- xbt_dynar_t host_list = MSG_hosts_as_dynar();
- xbt_dynar_foreach (host_list, i, host) {
- char descr[512];
- snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host));
- }
-
MSG_function_register("tracker", tracker);
MSG_function_register("peer", peer);
MSG_main();
- xbt_dynar_free(&host_list);
-
return 0;
}
ok = False
while not ok:
my_id = random.randint(0, max_id)
- ok = not my_id in all_ids
+ ok = my_id not in all_ids
start_date = i * 10
line = " <process host=\"node-%d.simgrid.org\" function=\"peer\">\n" % i
line += " <argument value=\"%d\"/>\n <argument value=\"%d\"/>\n" % (
static void task_cleanup_handler(void* task)
{
- if (task)
- MSG_task_destroy(static_cast<msg_task_t>(task));
+ MSG_task_destroy(static_cast<msg_task_t>(task));
}
static int process_daemon(int /*argc*/, char** /*argv*/)
-foreach(x actor actor-autorestart actor-migration
+foreach(x actor actor-autorestart
activity-lifecycle
comm-pt2pt wait-any-for
cloud-interrupt-migration cloud-sharing
## Add the tests.
## Some need to be run with all factories, some need not tesh to run
-foreach(x actor actor-autorestart actor-migration
+foreach(x actor actor-autorestart
activity-lifecycle wait-any-for
cloud-interrupt-migration concurrent_rw) # TODO: actor-autorestart is disabled for now
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
sleeper5->get_host()->turn_on();
XBT_INFO("Test %s is ending", __func__);
}
+
static void test_sleep_restart_end()
{
XBT_INFO("%s: Launch a sleep(5), and restart its host right when it stops", __func__);
bool sleeper_done = false;
simgrid::s4u::Actor::create("sleep5_restarted", all_hosts[1], [&sleeper_done]() {
- assert_exit(true, 5);
+ assert_exit(false, 5);
simgrid::s4u::this_actor::sleep_for(5);
- all_hosts[1]->turn_off(); // kill the host right at the end of this sleep and of this actor
sleeper_done = true;
});
+ simgrid::s4u::Actor::create("killer", all_hosts[0], []() {
+ simgrid::s4u::this_actor::sleep_for(5);
+ XBT_INFO("Killer!");
+ all_hosts[1]->turn_off();
+ all_hosts[1]->turn_on();
+ });
simgrid::s4u::this_actor::sleep_for(9);
- xbt_assert(sleeper_done, "Not sure of how the actor survived the shutdown of its host.");
- all_hosts[1]->turn_on();
+ xbt_assert(sleeper_done,
+ "Restarted actor was already dead in the scheduling round during which the host_off simcall was issued");
}
+
static void test_exec()
{
XBT_INFO("%s: Launch a execute(5s), and let it proceed", __func__);
exec5->get_host()->turn_on();
XBT_INFO("Test %s is ending", __func__);
}
+
static void test_exec_restart_end()
{
XBT_INFO("%s: Launch a execute(5s), and restart its host right when it stops", __func__);
"Restarted actor was already dead in the scheduling round during which the host_off simcall was issued");
}
+static void test_turn_off_itself()
+{
+ XBT_INFO("%s: Launch a sleep(5), then saw off the branch it's sitting on", __func__);
+
+ simgrid::s4u::Actor::create("sleep5_restarted", all_hosts[1], []() {
+ assert_exit(true, 5);
+ simgrid::s4u::this_actor::sleep_for(5);
+ simgrid::s4u::this_actor::get_host()->turn_off();
+ xbt_die("I should be dead now");
+ });
+ simgrid::s4u::this_actor::sleep_for(9);
+ all_hosts[1]->turn_on();
+ XBT_INFO("Test %s is ending", __func__);
+}
+
static void test_comm()
{
XBT_INFO("%s: Launch a communication", __func__);
* to avoid that they exit before their victim dereferences their name */
run_test("sleep restarted at start", test_sleep_restart_begin);
run_test("sleep restarted in middle", test_sleep_restart_middle);
- // run_test("sleep restarted at end", test_sleep_restart_end);
+ run_test("sleep restarted at end", test_sleep_restart_end);
run_test("exec", test_exec);
run_test("exec killed at start", test_exec_kill_begin);
run_test("exec restarted in middle", test_exec_restart_middle);
run_test("exec restarted at end", test_exec_restart_end);
+ run_test("turn off its own host", test_turn_off_itself);
+
run_test("comm", test_comm);
run_test("comm dsend and quit (put before get)", test_comm_dsend_and_quit_put_before_get);
run_test("comm dsend and quit (get before put)", test_comm_dsend_and_quit_get_before_put);
+++ /dev/null
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "simgrid/s4u.hpp"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_migration, "Messages specific for this s4u example");
-
-simgrid::s4u::Barrier* barrier;
-static simgrid::s4u::ActorPtr controlled_process;
-
-/* The Emigrant process will be moved from host to host. */
-static void emigrant()
-{
- XBT_INFO("I'll look for a new job on another machine ('Boivin') where the grass is greener.");
- simgrid::s4u::this_actor::migrate(
- simgrid::s4u::Host::by_name("Boivin")); /* - First, move to another host by myself */
-
- XBT_INFO("Yeah, found something to do");
- simgrid::s4u::this_actor::execute(98095000); /* - Execute some work there */
- simgrid::s4u::this_actor::sleep_for(2);
- XBT_INFO("Moving back home after work");
- simgrid::s4u::this_actor::migrate(simgrid::s4u::Host::by_name("Jacquelin")); /* - Move back to original location */
- simgrid::s4u::this_actor::migrate(simgrid::s4u::Host::by_name("Boivin")); /* - Go back to the other host to sleep*/
- simgrid::s4u::this_actor::sleep_for(4);
- controlled_process = simgrid::s4u::Actor::self(); /* - Get controlled at checkpoint */
- barrier->wait();
- simgrid::s4u::this_actor::suspend();
- simgrid::s4u::Host* h = simgrid::s4u::this_actor::get_host();
- XBT_INFO("I've been moved on this new host: %s", h->get_cname());
- XBT_INFO("Uh, nothing to do here. Stopping now");
-}
-
-/* The policeman check for emigrants and move them back to 'Jacquelin' */
-static void policeman()
-{
- XBT_INFO("Wait at the checkpoint."); /* - block on the mutex+condition */
- barrier->wait();
- controlled_process->migrate(simgrid::s4u::Host::by_name("Jacquelin")); /* - Move an emigrant to Jacquelin */
- XBT_INFO("I moved the emigrant");
- controlled_process->resume();
-}
-
-int main(int argc, char* argv[])
-{
- simgrid::s4u::Engine e(&argc, argv);
- e.load_platform(argv[1]);
-
- simgrid::s4u::Actor::create("emigrant", simgrid::s4u::Host::by_name("Jacquelin"), emigrant);
- simgrid::s4u::Actor::create("policeman", simgrid::s4u::Host::by_name("Boivin"), policeman);
-
- barrier = new simgrid::s4u::Barrier(2);
- e.run();
- XBT_INFO("Simulation time %g", e.get_clock());
- delete barrier;
-
- return 0;
-}
+++ /dev/null
-#!/usr/bin/env tesh
-
-p Testing the migration feature of S4U
-
-! output sort 19
-$ ${bindir:=.}/actor-migration ${platfdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (1:emigrant@Jacquelin) I'll look for a new job on another machine ('Boivin') where the grass is greener.
-> [ 0.000000] (1:emigrant@Boivin) Yeah, found something to do
-> [ 0.000000] (2:policeman@Boivin) Wait at the checkpoint.
-> [ 3.000000] (1:emigrant@Boivin) Moving back home after work
-> [ 7.000000] (0:maestro@) Simulation time 7
-> [ 7.000000] (1:emigrant@Jacquelin) I've been moved on this new host: Jacquelin
-> [ 7.000000] (1:emigrant@Jacquelin) Uh, nothing to do here. Stopping now
-> [ 7.000000] (2:policeman@Boivin) I moved the emigrant
$ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/flatifier ../platforms/bogus_disk_attachment.xml "--log=root.fmt:[%10.6r]%e[%i:%P@%h]%e%m%n"
> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks.
> [ 0.000000] [0:maestro@] Parse error at ../platforms/bogus_disk_attachment.xml:19: Unable to attach storage cdisk: host plouf does not exist.
-> [ 0.000000] [0:maestro@] Exiting now
+> [ 0.000000] [0:maestro@] Exiting now.
> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks.
> [ 0.000000] [0:maestro@] Parse error at ../platforms/bogus_missing_src_gateway.xml:14: zoneRoute gw_src='nod-cluster_router.cluster.us' does name a node. Existing netpoints:
> 'node-1.cluster.us','node-2.cluster.us','node-3.cluster.us','node-4.cluster.us','node-cluster_router.cluster.us','noeud-1.grappe.fr','noeud-2.grappe.fr','noeud-3.grappe.fr','noeud-4.grappe.fr','noeud-grappe_router.grappe.fr'
-> [ 0.000000] [0:maestro@] Exiting now
+> [ 0.000000] [0:maestro@] Exiting now.
! expect signal SIGABRT
$ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/flatifier ../platforms/bogus_missing_dst_gateway.xml "--log=root.fmt:[%10.6r]%e[%i:%P@%h]%e%m%n"
> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks.
> [ 0.000000] [0:maestro@] Parse error at ../platforms/bogus_missing_dst_gateway.xml:14: zoneRoute gw_dst='neud-grappe_router.grappe.fr' does name a node. Existing netpoints:
> 'node-1.cluster.us','node-2.cluster.us','node-3.cluster.us','node-4.cluster.us','node-cluster_router.cluster.us','noeud-1.grappe.fr','noeud-2.grappe.fr','noeud-3.grappe.fr','noeud-4.grappe.fr','noeud-grappe_router.grappe.fr'
-> [ 0.000000] [0:maestro@] Exiting now
+> [ 0.000000] [0:maestro@] Exiting now.
include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast
coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong
- type-hvector type-indexed type-struct type-vector bug-17132 timers privatization
+ type-hvector type-indexed type-struct type-vector bug-17132 gh-139 timers privatization
io-simple io-simple-at io-all io-all-at io-shared io-ordered)
add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
target_link_libraries(${x} simgrid)
foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast
coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong
- type-hvector type-indexed type-struct type-vector bug-17132 timers privatization
+ type-hvector type-indexed type-struct type-vector bug-17132 gh-139 timers privatization
macro-shared macro-partial-shared macro-partial-shared-communication
io-simple io-simple-at io-all io-all-at io-shared io-ordered)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
# Extra pt2pt pingpong test: broken usage ti-tracing
ADD_TESH_FACTORIES(tesh-smpi-broken "thread" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/pt2pt-pingpong --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pt2pt-pingpong broken_hostfiles.tesh)
ADD_TESH(tesh-smpi-replay-ti-tracing --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pt2pt-pingpong --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi/pt2pt-pingpong ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pt2pt-pingpong/TI_output.tesh)
-
+ ADD_TESH_FACTORIES(tesh-smpi-gh-139 "thread" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/gh-139 --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/gh-139 gh-139.tesh)
+
# Simple privatization tests
if(HAVE_PRIVATIZATION)
foreach(PRIVATIZATION dlopen mmap)
/* Bug report: https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165 */
-#include "xbt/log.h"
#include <stdio.h>
#include <mpi.h>
-XBT_LOG_NEW_DEFAULT_CATEGORY(MM_mpi, "Messages for this SMPI test");
-
int main(int argc, char ** argv)
{
size_t M = 8*1024;
--- /dev/null
+/* Copyright (c) 2019. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <mpi.h>
+#include <simgrid/msg.h>
+#include <simgrid/simix.h>
+#include <stdio.h>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(smpi_test, "Messages specific for this SMPI example");
+
+struct param {
+ MPI_Request* req;
+ int rank;
+};
+
+struct threadwrap {
+ void* father_data;
+ void* (*f)(void*);
+ void* param;
+};
+
+static int global_rank;
+void* req_wait(void* bar);
+
+// Thread creation helper
+
+static int thread_create_wrapper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+ int the_global_rank = global_rank;
+ struct threadwrap* t = (struct threadwrap*)sg_actor_self_data();
+ XBT_INFO("new thread has parameter rank %d and global variable rank %d", ((struct param*)(t->param))->rank,
+ the_global_rank);
+ sg_actor_self_data_set(t->father_data);
+ t->f(t->param);
+ sg_actor_self_data_set(NULL);
+ free(t);
+ return 0;
+}
+
+static void mpi_thread_create(const char* name, void* (*f)(void*), void* param)
+{
+ struct threadwrap* threadwrap = (struct threadwrap*)malloc(sizeof(*threadwrap));
+ threadwrap->father_data = sg_actor_self_data();
+ threadwrap->f = f;
+ threadwrap->param = param;
+ sg_actor_t actor = sg_actor_init(name, sg_host_self());
+ sg_actor_data_set(actor, threadwrap);
+ sg_actor_start(actor, thread_create_wrapper, 0, NULL);
+}
+
+static void mythread_create(const char* name, MPI_Request* req, int rank)
+{
+ struct param* param = (struct param*)malloc(sizeof(*param));
+ param->req = req;
+ param->rank = rank;
+ mpi_thread_create(name, req_wait, param);
+}
+
+// Actual application
+
+void* req_wait(void* bar)
+{
+ struct param* param = (struct param*)bar;
+ int rank;
+ MPI_Status status;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ XBT_INFO("%d has MPI rank %d and global variable rank %d", param->rank, rank, global_rank);
+ XBT_INFO("%d waiting request", rank);
+ MPI_Wait(param->req, &status);
+ XBT_INFO("%d request done", rank);
+ XBT_INFO("%d still has MPI rank %d and global variable %d", param->rank, rank, global_rank);
+ free(param);
+ return NULL;
+}
+
+int main(int argc, char* argv[])
+{
+ int rank;
+ int size;
+ char c = 0;
+ MPI_Request req;
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ XBT_INFO("I'm %d/%d", rank, size);
+ global_rank = rank;
+
+ if (rank == 0) {
+ c = 42;
+ MPI_Isend(&c, 1, MPI_CHAR, 1, 0, MPI_COMM_WORLD, &req);
+ mythread_create("wait send", &req, rank);
+ } else if (rank == 1) {
+ MPI_Irecv(&c, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &req);
+ mythread_create("wait recv", &req, rank);
+ }
+
+ sg_actor_sleep_for(1 + rank);
+ MPI_Finalize();
+ XBT_INFO("finally %d", c);
+ return 0;
+}
--- /dev/null
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -np 2 -platform ../../../examples/platforms/small_platform.xml -hostfile ../hostfile ${bindir:=.}/gh-139 --cfg=smpi/simulate-computation:no --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+> [Tremblay:0:(1) 0.000000] [smpi_test/INFO] I'm 0/2
+> [Jupiter:1:(2) 0.000000] [smpi_test/INFO] I'm 1/2
+> [Tremblay:wait send:(3) 0.000000] [smpi_test/INFO] new thread has parameter rank 0 and global variable rank 0
+> [Tremblay:wait send:(3) 0.000000] [smpi_test/INFO] 0 has MPI rank -333 and global variable rank 0
+> [Tremblay:wait send:(3) 0.000000] [smpi_test/INFO] -333 waiting request
+> [Tremblay:wait send:(3) 0.000000] [smpi_test/INFO] -333 request done
+> [Tremblay:wait send:(3) 0.000000] [smpi_test/INFO] 0 still has MPI rank -333 and global variable 0
+> [Jupiter:wait recv:(4) 0.000000] [smpi_test/INFO] new thread has parameter rank 1 and global variable rank 1
+> [Jupiter:wait recv:(4) 0.000000] [smpi_test/INFO] 1 has MPI rank -333 and global variable rank 1
+> [Jupiter:wait recv:(4) 0.000000] [smpi_test/INFO] -333 waiting request
+> [Jupiter:wait recv:(4) 0.002945] [smpi_test/INFO] -333 request done
+> [Jupiter:wait recv:(4) 0.002945] [smpi_test/INFO] 1 still has MPI rank -333 and global variable 1
+> [Tremblay:0:(1) 1.000000] [smpi_test/INFO] finally 42
+> [Jupiter:1:(2) 2.000000] [smpi_test/INFO] finally 42
doc/doxygen/uhood_switch.doc
doc/doxygen/uhood_arch.doc
+ examples/README.rst
+
docs/manpages/smpicc.1
docs/manpages/smpicxx.1
docs/manpages/smpif90.1
docs/requirements.txt
docs/source/conf.py
docs/source/Doxyfile
- docs/source/_ext/hidden_code_block.py
+ docs/find-missing.py
+ docs/source/_ext/autodoxy.py
+ docs/source/_ext/showfile.css
+ docs/source/_ext/showfile.js
+ docs/source/_ext/showfile.py
docs/source/_templates/breadcrumbs.html
docs/source/img/eclipseScreenShot.png
docs/source/img/extlink.png
docs/source/img/extlink.svg
docs/source/img/graphical-toc.svg
- docs/source/img/lang_cpp.png
- docs/source/img/lang_python.png
docs/source/img/smpi_simgrid_alltoall_pair_16.png
docs/source/img/smpi_simgrid_alltoall_ring_16.png
docs/source/img/zone_hierarchy.png
if(CMAKE_Fortran_COMPILER_ID MATCHES "GCC|PGI")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall")
- endif()
- if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
+ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Flang")
+ # flang >= 7 has a bug with common and debug flags. Ignore cmake-added -g in this case.
+ # https://github.com/flang-compiler/flang/issues/671
+ set(CMAKE_Fortran_FLAGS "-Wall")
+ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -warn all")
endif()
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint")
${CMAKE_HOME_DIRECTORY}/src/xbt/automaton/parserPromela.yacc
COMMENT "Generating automaton source files"
- COMMAND ${BISON_EXE} --name-prefix=xbt_automaton_parser_ -d parserPromela.yacc
+ COMMAND ${BISON_EXE} --name-prefix=xbt_automaton_parser_ -d -t parserPromela.yacc
COMMAND ${LEX_EXE} --prefix=xbt_automaton_parser_ --outfile=automaton_lexer.yy.c parserPromela.lex
WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/src/xbt/automaton/
)
chrpath \
libdw-dev libevent-dev libunwind8-dev \
linkchecker \
- && \
- pip3 install breathe 'sphinx>=1.8.0b1' sphinx_rtd_theme
+ python3-sphinx python3-breathe python3-sphinx-rtd-theme
\ No newline at end of file
#include "simgrid/msg.h"
#include "xbt/graph.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(graphicator, "Graphicator Logging System");
-
int main(int argc, char **argv)
{
MSG_init(&argc, argv);