dolfinx.jit

Functions

ffcx_jit(ufl_object[, …])

Compile UFL object with FFCX and CFFI.

get_parameters([priority_parameters])

Return (a copy of) the merged JIT parameter values for DOLFINX.

mpi_jit_decorator(local_jit, *args, **kwargs)

A decorator for jit compilation

class dolfinx.jit.Path(*args, **kwargs)[source]

Bases: pathlib.PurePath

PurePath subclass that can make system calls.

Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.

Construct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object.

absolute()[source]

Return an absolute version of this path. This function works even if the path doesn’t point to anything.

No normalization is done, i.e. all ‘.’ and ‘..’ will be kept along. Use resolve() to get the canonical path to a file.

chmod(mode)[source]

Change the permissions of the path, like os.chmod().

classmethod cwd()[source]

Return a new path pointing to the current working directory (as returned by os.getcwd()).

exists()[source]

Whether this path exists.

expanduser()[source]

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

glob(pattern)[source]

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

group()[source]

Return the group name of the file gid.

classmethod home()[source]

Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).

is_block_device()[source]

Whether this path is a block device.

is_char_device()[source]

Whether this path is a character device.

is_dir()[source]

Whether this path is a directory.

is_fifo()[source]

Whether this path is a FIFO.

is_file()[source]

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_mount()[source]

Check if this path is a POSIX mount point

is_socket()[source]

Whether this path is a socket.

Whether this path is a symbolic link.

iterdir()[source]

Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.

lchmod(mode)[source]

Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.

Create a hard link pointing to a path named target.

lstat()[source]

Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.

mkdir(mode=511, parents=False, exist_ok=False)[source]

Create a new directory at this given path.

open(mode='r', buffering=- 1, encoding=None, errors=None, newline=None)[source]

Open the file pointed by this path and return a file object, as the built-in open() function does.

owner()[source]

Return the login name of the file owner.

read_bytes()[source]

Open the file in bytes mode, read it, and close the file.

read_text(encoding=None, errors=None)[source]

Open the file in text mode, read it, and close the file.

rename(target)[source]

Rename this path to the given path, and return a new Path instance pointing to the given path.

replace(target)[source]

Rename this path to the given path, clobbering the existing destination if it exists, and return a new Path instance pointing to the given path.

resolve(strict=False)[source]

Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).

rglob(pattern)[source]

Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.

rmdir()[source]

Remove this directory. The directory must be empty.

samefile(other_path)[source]

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

stat()[source]

Return the result of the stat() system call on this path, like os.stat() does.

Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink’s.

touch(mode=438, exist_ok=True)[source]

Create this file with the given access mode, if it doesn’t exist.

Remove this file or link. If the path is a directory, use rmdir() instead.

write_bytes(data)[source]

Open the file in bytes mode, write to it, and close the file.

write_text(data, encoding=None, errors=None)[source]

Open the file in text mode, write to it, and close the file.

dolfinx.jit.ffcx_jit(ufl_object, form_compiler_parameters={}, jit_parameters={})[source]

Compile UFL object with FFCX and CFFI.

Parameters
  • ufl_object

  • form_compiler_parameters – Parameters used in FFCX compilation of this form. Run ffcx –help at the commandline to see all available options. Takes priority over all other parameter values, except for scalar_type which is determined by DOLFINX.

  • jit_parameters – Parameters used in CFFI JIT compilation of C code generated by FFCX. See python/dolfinx/jit.py for all available parameters. Takes priority over all other parameter values.

  • ordering of parameters controlling DOLFINX JIT compilation from (Priority) –

  • to lowest is (highest) – jit_parameters (API) $(pwd)/dolfinx_jit_parameters.json (local parameters) ~/.config/dolfinx/dolfinx_jit_parameters.json (user parameters) DOLFINX_DEFAULT_JIT_PARAMETERS in dolfinx.jit

  • ordering of parameters controlling FFCX from highest to lowest is (Priority) – scalar_type of DOLFINX form_compiler_parameters (API) $(pwd)/ffcx_parameters.json (local parameters) ~/.config/ffcx/ffcx_parameters.json (user parameters) FFCX_DEFAULT_PARAMETERS in ffcx.parameters

  • contents of the dolfinx_parameters.json files are cached on the first (The) –

  • Subsequent calls to this function use this cache. (call.) –

  • dolfinx_jit_parameters.json file (Example) – { “cffi_extra_compile_args”: [“-O2”, “-march=native” ], “cffi_verbose”: True }

dolfinx.jit.get_parameters(priority_parameters: Optional[dict] = None) → dict[source]

Return (a copy of) the merged JIT parameter values for DOLFINX.

Parameters

priority_parameters – take priority over all other parameter values (see notes)

Returns

dict

Return type

merged parameter values

Notes

See ffcx_jit for user facing documentation.

dolfinx.jit.mpi_jit_decorator(local_jit, *args, **kwargs)[source]

A decorator for jit compilation

Use this function as a decorator to any jit compiler function. In a parallel run, this function will first call the jit compilation function on the first process. When this is done, and the module is in the cache, it will call the jit compiler on the remaining processes, which will then use the cached module.