Generated Cap’n’Proto Struct Documentation

This section contains the documentation for the Cap’n’Proto generated classes. These classes are automatically generated from the Cap’n’Proto schema definitions and provide type-safe data structures and RPC interfaces.

Note

These are generated Cap’n’Proto struct and interface classes. For notes on how to deal with such classes, please consult the Cap’n’Proto C++ examples or the Cap’n’Proto documentation.

For more information about the Cap’n’Proto schemas used in FusionSC, see the Cap’n’Proto Schema Documentation section.

API Documentation

The generated classes are organized by schema module. Each schema file produces:

  • Structs: Data structures with typed fields

  • Interfaces: RPC service definitions with methods and parameters

  • Clients/Servers: C++ implementations for calling/implementation of services

For the complete list of generated classes, see the Cap’n’Proto documentation index.

namespace fsc

The FSC library.

Simple interface module for ZLib

Typedefs

using byte = kj::byte
template<typename T>
using References = typename internal::References_<T>::Type

Use this to figure out what datatype a DataRef points to.

template<typename T, unsigned int n>
using TVec = Eigen::TensorFixedSize<T, Eigen::Sizes<n>>
template<typename T>
using TVec3 = TVec<T, 3>
template<typename T>
using TVec4 = TVec<T, 4>
using TVec3d = TVec3<double>
using TVec4d = TVec4<double>
template<typename T, unsigned int n>
using Vec = Eigen::Vector<T, n>
template<typename T>
using Vec1 = Vec<T, 1>
template<typename T>
using Vec2 = Vec<T, 2>
template<typename T>
using Vec3 = Vec<T, 3>
template<typename T>
using Vec4 = Vec<T, 4>
using Vec1d = Vec<double, 1>
using Vec2d = Vec<double, 2>
using Vec3d = Vec<double, 3>
using Vec4d = Vec<double, 4>
using Vec1f = Vec<float, 1>
using Vec2f = Vec<float, 2>
using Vec3f = Vec<float, 3>
using Vec4f = Vec<float, 4>
using Vec1u = Vec<unsigned int, 1>
using Vec2u = Vec<unsigned int, 2>
using Vec3u = Vec<unsigned int, 3>
using Vec4u = Vec<unsigned int, 4>
using Vec1i = Vec<int, 1>
using Vec2i = Vec<int, 2>
using Vec3i = Vec<int, 3>
using Vec4i = Vec<int, 4>
template<typename T>
using Mat4 = Eigen::Matrix<T, 4, 4>
template<typename T>
using Mat3 = Eigen::Matrix<T, 3, 3>
template<typename T>
using Mat2 = Eigen::Matrix<T, 2, 2>
typedef Mat4<double> Mat4d
using Mat3d = Mat3<double>
using Mat2d = Mat2<double>
using Tensor3Ref = Eigen::TensorMap<Eigen::Tensor<double, 3>>
using Tensor2Ref = Eigen::TensorMap<Eigen::Tensor<double, 2>>
using Visitor = structio::Visitor
template<typename T>
using DeviceMappingType = decltype(mapToDevice(std::declval<T>(), std::declval<DeviceBase&>(), true))
template<typename T>
using DeviceType = decltype(std::declval<DeviceMappingType<T>>()->get())
using LocalVatNetworkBase = capnp::VatNetwork<lvn::VatId, lvn::ProvisionId, lvn::RecipientId, lvn::ThirdPartyCapId, lvn::JoinResult>
using Library = Own<const LibraryHandle>
using LibraryThread = Own<ThreadContext>

Enums

enum class KernelArgType

Specifies copy behavior for arguments around kernel invocation.

Values:

enumerator NOCOPY

Don’t copy data between host and device for this invocation.

enumerator IN

Only copy data to the device before kernel invocation.

enumerator OUT

Copy data to host after kernel invocation.

enumerator INOUT

Equivalent to IN and OUT.

enumerator ALIAS_IN
enumerator ALIAS_OUT
enumerator ALIAS_INOUT

Functions

inline Array<const byte> wordsToBytes(Array<const capnp::word> words)

Casts capnp word (8 bytes) array to byte array.

inline Array<const capnp::word> bytesToWords(Array<const byte> bytes)

Casts byte array to capnp word (8 bytes) array. Undefined if not aligned.

inline ArrayPtr<const capnp::word> bytesToWords(ArrayPtr<const byte> bytes)

Casts byte array to capnp word (8 bytes) array. Undefined if not aligned.

template<typename T, typename Cap, typename ...Attachments>
Cap::Client attach(T src, Attachments&&... attachments)
template<typename F>
kj::PromiseForResult<F, void> withBackoff(kj::Duration min, kj::Duration max, uint64_t growth, F func)
Own<kj::HttpService> createDataViewer(OneOf<DataRef<>::Client, Warehouse::Folder::Client, Warehouse::File<>::Client> root, capnp::SchemaLoader &loader)

Creates an HTTP service that can be used to take a closer look at objects.

Promise<bool> isDataRef(capnp::Capability::Client)

Checks if the object in question represents a DataRef object.

bool hasMaximumOrdinal(capnp::DynamicStruct::Reader in, unsigned int maxOrdinal)
Promise<void> removeDatarefsInStruct(capnp::AnyStruct::Reader in, capnp::AnyStruct::Builder out)
Promise<void> removeCapability(capnp::Capability::Client client, capnp::AnyPointer::Builder out)
Promise<void> removeDatarefs(capnp::AnyPointer::Reader in, capnp::AnyPointer::Builder out)
Promise<void> removeDatarefs(capnp::AnyStruct::Reader in, capnp::AnyStruct::Builder out)
size_t linearIndex(const capnp::List<uint64_t>::Reader &shape, const ArrayPtr<size_t> index)

Helper function for calculating linear index based on shape info.

DataRef<capnp::AnyPointer>::Client overrideRefs(DataRef<capnp::AnyPointer>::Client, kj::Array<capnp::Capability::Client>)

Provides an overlay over the input data ref that changes the references.

template<typename T>
constexpr bool isTemporary()
template<typename T, typename Cap = capnp::FromClient<T>, typename ...Attachments>
Cap::Client attachToClient(T src, Attachments&&... attachments)
template<typename T, typename = kj::EnableIf<capnp::kind<capnp::FromReader<T>>() == capnp::Kind::STRUCT>>
bool hasMaximumOrdinal(T in, unsigned int maxOrdinal)

Struct version checker.

When passing structured data between functions, Cap’n’proto will silently hide all fields which are not understood by the current version of the protocol. Likewise, if new fields are added, methods that do not yet understand them will likely not check for their presence. In many cases, this is useful behavior.

However, for scientific codes, when data are requested, it is extremely important that a given request is understood completely. This method aims to enable protocol evolution with this contraint, by checking whether a function, that can only interpret fields up to the given ordinal number in the given struct, will be able to fully understand the passed data. It does so by not only inspecting the ordinal numbers of set fields, but also by inspecting the wire representation of the struct, to ensure that there are no unknown fields set by a potentially newer version of the protocol.

Parameters:
  • in – The data to be checked for consistency.

  • maxOrdinal – An upper bound on the ordinal number of fields. Any field with an ordinal number exceeding this parameter (or unknown to this client) may only be set to its default value, otherwise this method will return false.

Returns:

true if the given struct meets the max ordinal requirements, otherwise false.

TEST_CASE ("parse-geqdsk")
void parseGeqdsk(AxisymmetricEquilibrium::Builder out, kj::StringPtr geqdsk)

Reads a geqdsk equilibrium file into an AxisymmetricEquilibrium object.

FSC_DECLARE_KERNEL(invertRflmKernel, Tensor3Ref, Tensor3Ref, Tensor3Ref, Tensor3Ref, double, double, double, double)
inline EIGEN_DEVICE_FUNC void mapInSectionKernel (unsigned int idx, uint64_t section, Tensor2Ref in, cu::RFLMKernelData::Builder out, cu::ReversibleFieldlineMapping::Reader mapping)
inline EIGEN_DEVICE_FUNC void fromFieldAlignedKernel (unsigned int idx, double phi0, double r0, cu::ReversibleFieldlineMapping::Reader mapping, Tensor2Ref inOut)
inline EIGEN_DEVICE_FUNC void toFieldAlignedKernel (unsigned int idx, double phi0, double r0, cu::ReversibleFieldlineMapping::Reader mapping, Tensor2Ref inOut)
FSC_DECLARE_KERNEL(fltKernel, cu::FLTKernelData::Builder, Eigen::TensorMap<Eigen::Tensor<double, 4>>, cu::FLTKernelRequest::Builder, cu::MergedGeometry::Reader, cu::IndexedGeometry::Reader, cu::IndexedGeometry::IndexData::Reader, cu::ReversibleFieldlineMapping::Reader, cu::GeometryMapping::MappingData::Reader)
Own<FLT::Server> newFLT(Own<DeviceBase> device, FLTConfig::Reader config)
void importRaw(kj::ArrayPtr<std::array<const double, 3>> vertices, kj::ArrayPtr<kj::Array<const size_t>> faces, MergedGeometry::Builder out)
kj::Tuple<kj::Array<std::array<double, 3>>, kj::Array<kj::Array<size_t>>> exportRaw(MergedGeometry::Reader merged, bool triangulate)
FSC_DECLARE_KERNEL(rayCastKernel, Eigen::TensorMap<Eigen::Tensor<double, 2>>, Eigen::TensorMap<Eigen::Tensor<double, 2>>, cu::MergedGeometry::Reader, cu::IndexedGeometry::Reader, cu::IndexedGeometry::IndexData::Reader, ArrayPtr<IntersectResult>)
EIGEN_DEVICE_FUNC void rayCastKernel (unsigned int idx, Eigen::TensorMap< Eigen::Tensor< double, 2 > > pStart, Eigen::TensorMap< Eigen::Tensor< double, 2 > > pEnd, cu::MergedGeometry::Reader geo, cu::IndexedGeometry::Reader index, cu::IndexedGeometry::IndexData::Reader indexData, ArrayPtr< IntersectResult > out)
Temporary<Geometry> readPly(kj::StringPtr filename)
void writePly(MergedGeometry::Reader merged, kj::StringPtr filename, bool binary)
TEST_CASE ("intersect")
TEST_CASE ("transform-cube")
TEST_CASE ("quad")
TEST_CASE ("index-cube")
double angle(Angle::Reader in)
Mat4d rotationAxisAngle(Vec3d center, Vec3d axis, double angle)

Calculates a rotation matrix around an axis and angle

void interpretPlane(Plane::Reader plane, Vec3d &normal, double &d)
void unrollMesh(double phi1, double phi2, Mesh::Reader meshIn, Mesh::Builder meshOut)
void clipMesh(Vec3d normal, double d, Mesh::Reader meshIn, Mesh::Builder meshOut)
void triangulateMesh(Mesh::Reader in, Mesh::Builder out, double maxEdgeLength)
Vec3u locationInGrid(Vec3d point, CartesianGrid::Reader grid)
inline EIGEN_DEVICE_FUNC Vec3u locationInGrid (Vec3d point, Vec3d min, Vec3d max, Vec3u size)
H5::DataSet createDataSet(H5::H5Location &parent, kj::StringPtr name, const H5::DataType &dType, kj::ArrayPtr<const H5Dim> dimensions)
H5::DataSet createDimension(H5::H5Location &parent, kj::StringPtr name, const H5::DataType &dType, const H5Dim &dim, bool hideFromNetcdf)
kj::Array<H5Dim> getDimensions(const H5::DataSet &ds)
size_t totalSize(const H5::DataSpace &space)
template<typename T>
const H5::PredType &h5Type()
template<typename Reader>
kj::Array<H5Dim> h5TensorDims(Reader reader)
template<typename T>
H5::DataSet createDataSet(H5::H5Location&, kj::StringPtr, kj::ArrayPtr<const H5Dim> = nullptr)
template<typename T>
H5::DataSet createDimension(H5::H5Location&, kj::StringPtr, const H5Dim&, bool hideFromNetcdf = false)
template<typename T>
T readScalar(const H5::DataSet&)
template<typename T>
void writeScalar(const H5::DataSet&, T)
template<typename T>
Array<T> readArray(const H5::DataSet&)
template<typename T>
void writeArray(const H5::DataSet&, const kj::ArrayPtr<const T> &data)
template<typename Builder, typename T = capnp::FromBuilder<Builder>>
void readTensor(const H5::DataSet&, Builder)
template<typename Reader, typename T = capnp::FromAny<Reader>>
void writeTensor(const H5::DataSet&, Reader)
template<typename T>
void writeArray(const H5::DataSet &ds, const ArrayPtr<const T> &data)
FSC_DECLARE_KERNEL(estimateDensityKernel, unsigned int, cu::KDTree::Reader, Eigen::TensorMap<Eigen::Tensor<double, 1>>, Eigen::TensorMap<Eigen::Tensor<double, 2>>, cu::DensityKernel::Reader, double, uint32_t, double, ArrayPtr<double>)
EIGEN_DEVICE_FUNC void estimateDensityKernel (unsigned int idx, cu::KDTree::Reader tree, Eigen::TensorMap< Eigen::Tensor< double, 1 > > weights, Eigen::TensorMap< Eigen::Tensor< double, 2 > > evalPoints, cu::DensityKernel::Reader kernel, double kernelDiam, uint32_t kernelDim, double tol, ArrayPtr< double > out)
Own<HFCamProvider::Server> newHFCamProvider(Own<DeviceBase> device)
TEST_CASE ("http")
capnp::Capability::Client connectInProcess(const LocalVatHub &hub, uint64_t address)
Own<const InProcessServer> newInProcessServer(kj::Function<capnp::Capability::Client()> serviceFactory, Library lib)
TEST_CASE ("indexBuild")
Own<KDTreeService::Server> newKDTreeService()
Tensor<double, 2> sample(KDTree::Reader index, double scale)
TEST_CASE ("c1cubic")
TEST_CASE ("c1interp")
template<typename Strategy, typename Vec, size_t... indices>
std::array<typename Strategy::Coeffs, sizeof...(indices)> calculateCoeffsND(Strategy &strategy, const Vec &lx, std::index_sequence<indices...> indexSequence)
inline EIGEN_DEVICE_FUNC Vec3u locationInGrid (Vec3d point, const cu::CartesianGrid::Reader &grid)
inline EIGEN_DEVICE_FUNC double vecdet (const Vec3d v0, const Vec3d v1, const Vec3d v2)
inline EIGEN_DEVICE_FUNC double intersectBox (const Vec3d &start, const Vec3d &end, const Vec3d &p1, const Vec3d &p2)
inline EIGEN_DEVICE_FUNC double intersectGridElement (const Vec3d &p1, const Vec3d &p2, const cu::CartesianGrid::Reader grid, size_t iX, size_t iY, size_t iZ)
inline EIGEN_DEVICE_FUNC double rayCastTriangle (const Vec3d point, const Vec3d direction, const Vec3d triangle[3])
inline EIGEN_DEVICE_FUNC uint32_t intersectGeometryAllEvents (const Vec3d p1, const Vec3d p2, cu::MergedGeometry::Reader geometry, cu::CartesianGrid::Reader grid, cu::IndexedGeometry::IndexData::Reader indexData, double lMax, cupnp::List< cu::FLTKernelEvent >::Builder eventBuffer, uint32_t eventCount)
Returns:

The new number of events in the event buffer, or eventBuffer.size() to indicate that we ran out of space.

inline EIGEN_DEVICE_FUNC IntersectResult intersectGeometryFirstHit (const Vec3d &p1, const Vec3d &p2, cu::MergedGeometry::Reader geometry, cu::IndexedGeometry::Reader index, cu::IndexedGeometry::IndexData::Reader indexData)
kj::Own<JobLauncher> newMpiScheduler(Own<JobLauncher> backend)
Own<JobLauncher> newSlurmScheduler(Own<JobLauncher> backend)
TEST_CASE ("slurm-parser")
TEST_CASE ("job-echo")
TEST_CASE ("job-failure")
Own<JobLauncher> newProcessScheduler(kj::StringPtr jobDir)
Job::Client runJob(JobLauncher &sched, kj::StringPtr cmd, kj::ArrayPtr<kj::StringPtr> args, kj::PathPtr wd)
Promise<kj::String> runToCompletion(Job::Client job)
TEST_CASE ("field-schema")
void writeJsonSchema(capnp::Type t, structio::Visitor &v)
void writeJsonSchema(capnp::Schema, structio::Visitor&)
void loadJson(capnp::DynamicStruct::Builder, kj::BufferedInputStream&, const JsonOptions& = JsonOptions())
void loadJson(capnp::ListSchema, kj::Function<capnp::DynamicList::Builder(size_t)>, kj::BufferedInputStream&, const JsonOptions& = JsonOptions())
capnp::DynamicValue::Reader loadJsonPrimitive(capnp::Type, kj::BufferedInputStream&, const JsonOptions& = JsonOptions())
void writeJson(capnp::DynamicValue::Reader, kj::BufferedOutputStream&, const JsonOptions& = JsonOptions())
Own<Eigen::GpuDevice> newGpuDevice()
void synchronizeGpuDevice(Eigen::GpuDevice &device, const Operation &op)

Schedules a promise to be fulfilled when all previous calls on the GPU device’s command stream are finished.

template<typename T>
constexpr bool isTriviallyCopyable()
template<typename T>
Own<DeviceMapping<T>> cloneMapping(Own<DeviceMapping<T>> &base)
template<typename T>
Own<DeviceMapping<T>> mapToDevice(T t, DeviceBase &device, bool allowAlias)
template<typename T>
Own<DeviceMapping<T>> mapToDevice(Own<DeviceMapping<T>> &&mapping, DeviceBase &device, bool allowAlias)
template<typename T>
Own<DeviceMapping<T>> mapToDevice(Own<DeviceMapping<T>> &mapping, DeviceBase &device, bool allowAlias)
template<typename T>
KernelArg<T> kArg(T in, bool copyToHost, bool copyToDevice, bool allowAlias)

Allows to override the copy behavior on a specified argument.

template<typename T>
KernelArg<T> kArg(T in, KernelArgType type)

Allows to override the copy behavior on a specified argument.

template<typename T>
KernelArg<Own<DeviceMapping<T>>> kArg(Own<DeviceMapping<T>> &ref, KernelArgType type)

Allows creation of a kernel arg form reference.

inline unsigned int numThreads()
template<typename HostType, typename CupnpType>
CuTypedMessageBuilder<HostType, CupnpType> cuBuilder(Own<capnp::MessageBuilder> builder)
template<typename HostType, typename CupnpType>
CuTypedMessageBuilder<HostType, CupnpType> cuBuilder(Temporary<HostType> &&tmp)
template<typename HostType, typename CupnpType>
CuTypedMessageBuilder<HostType, CupnpType> cuBuilder(MapNewMessage)
template<typename HostType, typename CupnpType>
CuTypedMessageReader<HostType, CupnpType> cuReader(Own<capnp::MessageReader> reader)
template<typename HostType, typename CupnpType>
CuTypedMessageReader<HostType, CupnpType> cuReader(LocalDataRef<HostType> ldr)
template<typename HostType, typename CupnpType>
CuTypedMessageReader<HostType, CupnpType> cuReader(std::nullptr_t)
template<typename HostType, typename CupnpType, typename T>
CuTypedMessageReader<HostType, CupnpType> cuReader(Maybe<T> maybe)
Own<LoadBalancer> newLoadBalancer(NetworkInterface::Client clt, LoadBalancerConfig::Reader config)
KJ_DECLARE_NON_POLYMORPHIC(LoadLimiter::Impl)
inline Library newLibrary(StartupParameters params = StartupParameters())
inline ThreadContext &getActiveThread()
inline bool hasActiveThread()
Own<FieldCache> lruFieldCache(unsigned int size)
FieldResolver::Client newCache(MagneticField::Reader field, ComputedField::Reader computed)

Creates a field resolver that will insert a cache instruction when detecting the passed field

TEST_CASE ("sphere_field")
TEST_CASE ("build-field-cancel")
TEST_CASE ("build-field")
TEST_CASE ("build-field-interp")
TEST_CASE ("build-field-gpu")
bool isBuiltin(MagneticField::Reader field)
bool isBuiltin(Filament::Reader filament)
ToroidalGridStruct readGrid(ToroidalGrid::Reader in, unsigned int maxOrdinal)
void writeGrid(const ToroidalGridStruct &in, ToroidalGrid::Builder out)
Own<FieldCalculator::Server> newFieldCalculator(Own<DeviceBase> dev)

Creates a new field calculator.

void simpleTokamak(MagneticField::Builder output, double rMajor, double rMinor, unsigned int nCoils, double Ip)

For testing

TEST_CASE ("matcher")
Own<Matcher::Server> newMatcher()
NetworkInterface::OpenPort::Client listenViaHttp(Own<kj::ConnectionReceiver> receiver, NetworkInterface::Listener::Client target, Own<kj::HttpService> fallback)
NetworkInterface::OpenPort::Client listenViaHttp(Own<kj::ConnectionReceiver> receiver, capnp::Capability::Client target, Own<kj::HttpService> fallback)
Warehouse::Client openWarehouse(db::Connection &conn, bool readOnly, kj::StringPtr tablePrefix)
FieldResolver::Client newOfflineFieldResolver(DataRef<OfflineData>::Client in)
GeometryResolver::Client newOfflineGeometryResolver(DataRef<OfflineData>::Client in)
void updateOfflineData(OfflineData::Builder dst, OfflineData::Reader updates)
Tensor<uint32_t, 2> triangulate(Tensor<double, 2> vertices)
Own<RootService::Server> createRoot(LocalConfig::Reader config)
Own<LocalResources::Server> createLocalResources(LocalConfig::Reader config)
kj::ArrayPtr<uint64_t> protectedInterfaces()

List of interface IDs that may not be called via network callss.

Own<db::Connection> connectSqlite(kj::StringPtr url, bool readOnly)
Promise<Own<SSHSession>> createSSHSession(Own<kj::AsyncIoStream> stream)
DataStore createStore()
Own<StreamConverter> newStreamConverter()
Own<kj::AsyncInputStream> buffer(Own<kj::AsyncInputStream> &&is, uint64_t limit)

Buffers the input stream

Creates an eagerly consuming buffer (based on linked list of blocks) that consumes data from the given input stream. The internal buffer blocks are released once the data is no longer required. The input stream features an optimized tee implementation that shared the buffer and only forks the buffer’s cursor position.

Own<MultiplexedOutputStream> multiplex(Own<kj::AsyncOutputStream> &&os)

Multiplexes the output stream

This returns an object that can safely allow multiple simultaneous writes to the given output stream by multiplexing write calls in turn with a FIFO.

Own<std::istream> asStdStream(kj::BufferedInputStream &is)

Wraps a buffered input stream into an std::istream

Own<std::ostream> asStdStream(kj::BufferedOutputStream &is)

Wraps a buffered output stream into an std::ostream.

template<typename T>
kj::String asYaml(T&&)
template<typename T, int rank, int options, typename Index, typename T2>
void readTensor(T2 reader, Tensor<T, rank, options, Index> &out)
template<typename T, int rank, int options, typename Index, typename T2>
kj::Array<size_t> readVardimTensor(T2 reader, size_t variableDim, Tensor<T, rank, options, Index> &out)
template<typename T, typename T2>
T readTensor(T2 reader)
template<typename T, typename Reader>
Own<TensorMap<const T>> mapTensor(Reader reader)
template<typename TensorType, typename T2>
void writeTensor(const TensorType &in, T2 builder)
template<typename TensorType, typename T2>
void writeVardimTensor(const TensorType &in, size_t variableDim, kj::ArrayPtr<size_t> vardimShape, T2 builder)
template<typename T>
void validateTensor(T t, kj::ArrayPtr<const Maybe<uint64_t>> shapeConstraints = nullptr)
void extractBrand(capnp::Schema in, capnp::schema::Brand::Builder out)
void extractType(capnp::Type in, capnp::schema::Type::Builder out)
template<typename T> Vec3< T > EIGEN_DEVICE_FUNC cross (const Vec3< T > &t1, const Vec3< T > &t2)
FSC_DECLARE_KERNEL(computeSurfaceKernel, cu::VmecKernelComm::Builder)
FSC_DECLARE_KERNEL(invertSurfaceKernel, cu::VmecKernelComm::Builder)
inline EIGEN_DEVICE_FUNC void computeSurfaceKernel (unsigned int idx, cu::VmecKernelComm::Builder comm)
inline EIGEN_DEVICE_FUNC void invertSurfaceKernel (unsigned int idx, cu::VmecKernelComm::Builder comm)
kj::String generateVmecInput(VmecRequest::Reader request, kj::PathPtr mgridFile)

Generates the input file for a VMEC request.

VMEC input file generator.

Generates the Fortran NAMELIST to be passed into VMEC.

Parameters:
  • request – The VMEC run request.

  • mgridPath – Path to the MGRID file required for free boundary runs.

void interpretOutputFile(kj::PathPtr path, VmecResult::Builder out)

VMEC result reader

Reads a wout.nc from VMEC and converts the contents into a response.

Warning

This function can only read NetCDF4/HDF5 files. VMEC writes NetCDF-classic format. Pre-process the output file with nccopy to convert it into NetCDF4.

Promise<void> writeMGridFile(kj::PathPtr path, ComputedField::Reader cField)

MGRID file generator

Writes a simple MGRID file from the computed field to the given destination path.

Own<VmecDriver::Server> createVmecDriver(Own<DeviceBase> &&dev, Own<JobLauncher> &&scheduler, VmecConfig::Reader config)

Create a VMEC service driver.

Parameters:
  • dev – Compute device for the surface inversion calculations.

  • launcher – Job launcher to use for the VMEC code (post-processing is done using the system launcher).

  • config – Configuration for the VMEC driver.

Variables

kj::StringPtr commitHash

Git commit hash extracted by the build system. May include a trailing “+” if modified.

constexpr double pi = 3.14159265358979323846
constexpr capnp::ReaderOptions READ_UNLIMITED = {std::numeric_limits<uint64_t>::max(), std::numeric_limits<int>::max()}
template<typename T>
struct _IsTemporary

Public Static Attributes

static constexpr bool val = false
template<typename T>
struct _IsTemporary<fsc::Temporary<T>>

Public Static Attributes

static constexpr bool val = true
struct ArchiveWriter

Public Functions

inline ArchiveWriter(const kj::File &file)
inline ~ArchiveWriter()
inline void write(capnp::word *dst, uint64_t value)
inline void writePrefix()
inline DataRecord &allocData(uint64_t nBytes)

Allocates data from the data section and creats a data record.

inline InfoRecord &allocInfo()

Allocates a new info record.

inline void writeInfo(Temporary<ArchiveInfo> infoSection)

Serializes the info section and finalizes the header.

inline void finalize(uint64_t rootObject)

Finalizes the file by writing root object and storing the file.

inline Promise<OneOf<std::nullptr_t, kj::Exception, uint64_t>> downloadRef(capnp::Capability::Client src)
inline Promise<void> writeArchive(DataRef<capnp::AnyPointer>::Client src)

Public Members

const kj::File &file
capnp::WordCount dataSize = 0 * WORDS

Current size of data section.

kj::TreeMap<ID, Promise<void>> downloadQueue

Promise that resolves when all DataRefs known to advertise (don’t trust this) a given hash have finished or failed downloading.

kj::TreeMap<ID, uint64_t> dataRecordsByHash

Map of all completed data blocks by hash.

kj::List<DataRecord, &DataRecord::link> dataRecords

List of all data records.

kj::List<InfoRecord, &InfoRecord::link> infoRecords

List of all object info records.

internal::DownloadTask<uint64_t>::Context downloadContext

Download context to use for de-duplication.

Public Static Attributes

static kj::StringPtr MAGIC_TAG = "FSCARCH"_kj
static kj::StringPtr DESCRIPTION = "This is an FSC / fusionsc archive file. To read it, please use the fusionsc toolkit to inspect its contents or refer it for details on the format"_kj
static capnp::WordCount MAGIC_TAG_SIZE = 1 * WORDS
static capnp::WordCount HEADER_SIZE_SIZE = 1 * WORDS
static capnp::WordCount HEADER_SIZE = 3 * WORDS
static capnp::WordCount DESCRIPTION_SIZE = (DESCRIPTION.size() + 7) / 8 * WORDS
static capnp::WordCount TOTAL_PREFIX_SIZE = MAGIC_TAG_SIZE + HEADER_SIZE_SIZE + HEADER_SIZE + DESCRIPTION_SIZE
struct DataRecord

Public Members

uint64_t id
capnp::WordCount offsetWords
uint64_t sizeBytes
uint64_t globalOffset
kj::ListLink<DataRecord> link
struct InfoRecord

Public Members

uint64_t id
Temporary<ArchiveInfo::ObjectInfo> info
kj::ListLink<InfoRecord> link
struct TransmissionProcess : public fsc::internal::DownloadTask<uint64_t>

Public Functions

inline TransmissionProcess(ArchiveWriter &parent, DataRef<capnp::AnyPointer>::Client src)
inline Promise<Maybe<uint64_t>> useCached() override
inline Promise<void> beginDownload() override
inline Promise<void> receiveData(kj::ArrayPtr<const kj::byte> data) override
inline Promise<void> finishDownload() override
inline Promise<uint64_t> buildResult() override
inline Promise<uint64_t> finalize(uint64_t blockID)

Public Members

ArchiveWriter &parent
Maybe<DataRecord&> block
size_t writeOffset = 0
template<typename T>
struct AtomicShared

Public Types

using Payload = T

Public Functions

template<typename ...Params>
inline AtomicShared(Params&&... t)
inline AtomicShared(const AtomicShared<T> &other)
inline AtomicShared(AtomicShared<T> &other)
inline AtomicShared<T> &operator=(const AtomicShared<T> &other)
AtomicShared(AtomicShared<T> &&other) = default
AtomicShared<T> &operator=(AtomicShared<T> &&other) = default
inline ~AtomicShared() noexcept
inline T &get()
inline const T &get() const
inline T &operator*()
inline T *operator->()
inline const T &operator*() const
inline const T *operator->() const
inline Own<T> asOwn()
struct BalancedIntervalSplit

Public Functions

inline BalancedIntervalSplit(size_t nTotal, size_t blockSize)
inline size_t blockCount()
inline size_t interval(size_t i)
inline size_t edge(size_t i)
struct BaseDirProvider : public fsc::JobDirProvider

Public Functions

BaseDirProvider(kj::StringPtr basePath)
Own<JobDir> createDir() override
struct Blob

Blob object.

Public Functions

virtual Own<Blob> addRef() = 0
virtual void incRef() = 0

Increases the in-database refcount.

virtual void decRef() = 0

Decreases the in-database refcount and deletes the blob if it hits 0.

virtual int64_t getRefcount() = 0

Reads the current in-database refcount.

virtual kj::Array<const byte> getHash() = 0

Reads the hash of the blob (or nullptr if the blob is under construction or deleted)

virtual int64_t getId() = 0

Returns the ID of the blob.

inline bool isFinished()

Checks whether incRef may be called on this blob.

virtual Own<BlobReader> open() = 0

Opens the blob for reading.

struct BlobBuilder : public kj::OutputStream

Construction helper for new Blobs. Inherits from kj::OutputStream.

This interface is responsible for managing the construction of a new Blob for the store. It can only be obtained through BlobStore::create(). Upon creation, a blob under construction is created with an implicit reference count of 1. The reference count may not be increased until the blob’s construction is finished.

The blob may be filled with data through the OutputStream interface. Once all data have been transferred, call the finish() method.

finish() will check for hash duplication.If the new blob’s hash is unique, that blob will be returned (and from now on its refcount can be increased). In case of a hash conflict, the new Blob will be deleted, the originally present blob with same hash will have its refcount increased by 1, and that blob will be returned.

This allows for interactions where the lifetime of the under-construction blob is attached to an external object during the construction phase, and the Blob can be deleted implicitly if that object gets deleted.

Public Functions

virtual bool tryConsume(kj::ArrayPtr<const byte> input) = 0

Alternative write API. This does not call the underlying database and only manipulates the compressor and the buffer. It can be called from other thread as long as no simul taneous other calls to the blob builder are made.

Returns true if the buffer was completely consumed. If it returns false, flush() must be called before calling tryConsume again. In this case, the next call to tryConsume MUST hold the same data as the previous call.

virtual void flush() = 0

Flushes buffer to database. UNLIKE tryConsume CAN NOT BE USED CROSS-THREAD.

virtual Own<Blob> finish() = 0

After write completion and hash key assignment, returns the finished blob (not neccessarily the same as the blob returned by getBlobUnderConstruction()

virtual Own<Blob> getBlobUnderConstruction() = 0
struct BlobReader : public kj::InputStream

Extended input stream interface that can outsource the compression to an external thread. Inherits from kj::InputStream.

Public Functions

virtual Promise<size_t> tryReadAsync(void *buf, size_t min, size_t max, const kj::Executor &decompressionThread) = 0
struct BlobStore

Blob storage interface.

Public Functions

virtual Own<BlobStore> addRef() = 0
virtual Maybe<Own<Blob>> find(kj::ArrayPtr<const byte> hash) = 0

Looks for a blob object in the database based on the given has key.

virtual Own<Blob> get(int64_t id) = 0

Returns a blob by its database ID.

virtual Own<BlobBuilder> create(size_t chunkSize) = 0

Allocates a new blob without hash key in the database to be written to.

struct BreakHandler

Helper to abort computations with CTRL + C.

Usage of this is slightly complicated. A single BreakHandler object should be created on stack before the FusionSC library itself is used (implementation constraint). However, its methods may only be used after library startup.

Public Functions

BreakHandler()
~BreakHandler()
Promise<void> onBreak()

Create a promise that resolves upon the next Ctrl + C event.

template<typename T>
inline Promise<T> wrap(Promise<T> in)

Wraps the promise so that it fails on the next Ctrl + C event.

template<typename Scalar>
struct C1CubicDeriv

Public Functions

inline constexpr C1CubicDeriv(Scalar f0, Scalar df0, Scalar f1, Scalar df1)
inline Scalar operator()(Scalar x)
inline Scalar d(Scalar x)
inline Scalar dd(Scalar x)

Public Members

const Scalar f0
const Scalar df0
const Scalar df1
const Scalar f1_minus_f0
const Scalar f_x0_x1_x2
template<typename Num>
struct C1CubicInterpolation

Continuously differentiable interpolation based on 3rd order Hermite splines. Interpolates exact up to 2nd order. Values on interval endpoints are exact. Derivatives equal their central finite difference.

Public Types

using Scalar = Num
using Coeffs = std::array<Scalar, 4>

Public Functions

inline constexpr EIGEN_DEVICE_FUNC size_t nPoints ()
inline constexpr EIGEN_DEVICE_FUNC std::array< Scalar, 4 > coefficients (Num x)
inline constexpr EIGEN_DEVICE_FUNC std::array< int, 4 > offsets ()
struct Compressor : public fsc::ZLib

Public Functions

Compressor(int level)
~Compressor()
State step(bool finish)

Performs compression until no more input or output bytes are available.

template<typename TensorType>
struct ConstTensorMapping : public fsc::DeviceMapping<kj::Array<const TensorType::Scalar>>

Subclassed by fsc::DeviceMapping< Own< TensorMap< const T > > >, fsc::DeviceMapping< Own< TensorMap< const TensorFixedSize< TVal, Dims, options, Index > > > >

Public Types

using Scalar = typename TensorType::Scalar

Public Functions

inline ConstTensorMapping(Shared<TensorMap<const TensorType>> tensor, DeviceBase &device, bool allowAlias)
inline TensorMap<TensorType> get()
inline TensorMap<const TensorType> getHost()

Public Members

TensorMap<const TensorType> hostMap
TensorMap<TensorType> deviceMap
struct CPUDevice : public fsc::CPUDeviceBase, public kj::Refcounted

Public Functions

CPUDevice(kj::Badge<CPUDevice>, unsigned int numThreads)
~CPUDevice()
Own<DeviceBase> addRef() override
Eigen::ThreadPoolDevice &eigenDevice()

Public Static Functions

static Own<CPUDevice> create(unsigned int numThreads)
static unsigned int estimateNumThreads()

Public Static Attributes

static int BRAND = 0
struct CPUDeviceBase : public fsc::DeviceBase

Subclassed by fsc::CPUDevice, fsc::LoopDevice

Public Functions

void updateDevice(kj::byte *devicePtr, const kj::byte *hostPtr, size_t size) override
void updateHost(kj::byte *hostPtr, const kj::byte *devicePtr, size_t size) override
kj::byte *map(const kj::byte *hostPtr, size_t size, bool allowAlias) override
void unmap(const kj::byte *hostPtr, kj::byte *devicePtr) override
kj::byte *translateToDevice(kj::byte *hostPtr) override
Promise<void> emplaceBarrier() override
DeviceBase(void *brand)
class CSPRNG

A cryptographically secure (pseudo-)random number generator. Currently implemented as a Botan-provided auto-seeding RNG, but might change without notice.

Public Functions

inline void randomize(kj::ArrayPtr<byte> target)
template<typename HostType, typename CupnpType>
struct CuTypedMessageBuilder

Public Members

Own<capnp::MessageBuilder> builder
template<typename HostType, typename CupnpType>
struct CuTypedMessageReader

Public Members

Own<capnp::MessageReader> reader
template<typename T = ::capnp::AnyPointer>
struct DataRef

Cap’n’proto interface for data objects.

The DataRef template is a special capability recognized all throughout the FSC library. It represents a link to a data storage location (local or remote), associated with a unique ID, which can be downloaded to local storage and accessed there. Locally downloaded data are represented by the LocalDataRef class, which subclasses DataRef::Client.

The stored data is expected to be in one of the two following formats:

  • If T is any type except capnp::Data, it must correspond to a Cap’n’proto struct type. In this case, the DataRef holds a message with the corresponding root type, and a capability table that tracks any remote objects in use by this message (including other DataRef instances).

  • If T is DataRef::Data, then the corresponding message can either be a raw binary or a Cap’n’proto message with a capnp::Data object as its root (note that the library will default to raw storage because of the laxer size constraints)

Once obtained, DataRefs can be freely passed around as part of RPC calls or data published in other DataRef::Client instances. The fsc runtime will do all it possibly can to protect the integrity of a DataRef. In the absence of hardware failure, data referenced via DataRef objects can only go out of use once all referencing DataRef objects do so as well.

DataRefs only represent a link to locally or remotely stored data. To access the underlying data, they must be converted into LocalDataRef instances using LocalDataService::download() methods.

Note

This is a generated Capnproto interface class. For notes on how to deal with such a class, please consult the Capnproto C++ examples (https://capnproto.org) or the generated API documentation

interface DataRef (T) {
    interface Receiver {
        begin @0 (numBytes : UInt64) -> ();
        receive @1 (data : Data) -> stream;
        done @2 () -> ();
    }
    
    metaAndCapTable @0 () -> (metadata : DataRefMetadata, table : List(Capability));
    rawBytes @1 (start : UInt64, end : UInt64) -> (data : Data);
    transmit @2 (start : UInt64, end : UInt64, receiver : Receiver);
}

Template Parameters:

T – Type of the root message stored in the data ref.

struct Client : public virtual capnp::Capability::Client

Actual interface object class.

Subclassed by fsc::LocalDataRef< T >

Public Functions

template<typename T2 = ::capnp::AnyPointer>
inline DataRef<T2>::Client asGeneric()
struct DataService

Remote interface to data service.

This interface serves as an access point to remotely download

Note

This is a generated Capnproto interface class. For notes on how to deal with such a class, please consult the Capnproto C++ examples (https://capnproto.org) or the generated API documentation

interface DataService @0xc6d48902ddb7e122 {
    store @0 [T] (id : Data, data : T, schema : AnyPointer) -> (ref : DataRef(T));
    # Upload a message to the remote data service and have it publish it
    
    clone @1 [T] (source : DataRef(T)) -> (ref : DataRef(T));
    # Have the remote data service download a DataRef and re-publish it
    
    hash @2 [T] (source : DataRef(T)) -> (hash : Data);
    # Have the remote service inspect the linked tree of refs and their content tables and
    # compute a hash based on the received information.
    
    cloneAllIntoMemory @3 [T] (source : DataRef(T)) -> (ref : DataRef(T));
    # Have the remote data service download a complete copy
}

struct DataStore

Public Functions

DataStore(fusionsc_DataStore *store)
~DataStore()
DataStore() = delete
DataStore(const DataStore&)
DataStore(DataStore&&)
DataStore &operator=(const DataStore&)
DataStore &operator=(DataStore&&)
fusionsc_DataStore *incRef()
fusionsc_DataStore *release()
StoreEntry publish(ArrayPtr<const byte> key, Array<const byte> data)
Maybe<StoreEntry> query(ArrayPtr<const byte> key)
void gc()
struct DBCache

Database cache object.

Public Functions

virtual Own<DBCache> addRef() = 0
virtual DataRef<capnp::AnyPointer>::Client cache(DataRef<capnp::AnyPointer>::Client) = 0

Downloads DataRef into cache and returns stored object.

struct Decompressor : public fsc::ZLib

Public Functions

Decompressor()
~Decompressor()
State step()

Performs decompression until no more input or output bytes are available.

struct DeviceBase

Compute device that can execute C++ kernels Manages a compute device (either a thread-pool or a GPU compute stream) with its own memory space.

Subclassed by fsc::CPUDeviceBase

Public Functions

DeviceBase(void *brand)
virtual ~DeviceBase()
template<typename ...T>
inline void addToBarrier(T&&... args)

Accepts arguments to be attached to the next barrier() promise.

Promise<void> barrier()

Returns a promise that resolves when all actions submitted to the device queue have finished.

virtual void updateDevice(kj::byte *devicePtr, const kj::byte *hostPtr, size_t size) = 0

Enqueues a host -> device copy operation.

Warning

Callers should ensure that hostPtr and devicePtr are valid until the next barrier promise is resolved, e.g. by passing appropriate keepalive objects via addToBarrier.

virtual void updateHost(kj::byte *hostPtr, const kj::byte *devicePtr, size_t size) = 0

Enqueues a device -> host copy operation.

Warning

Callers should ensure that hostPtr and devicePtr are valid until the next barrier promise is resolved, e.g. by passing appropriate keepalive objects via addToBarrier.

virtual kj::byte *map(const kj::byte *hostPtr, size_t size, bool allowAlias) = 0

Map a view of the obtained buffer to the device. Creates a view of the specified buffer in device memory space.

Note

It is rarely neccessary to call this method directly, instead an Own<DeviceMapping<kj::ArrayPtr>> can be obtained by calling mapToDevice(ArrayPtr).

Parameters:

allowAlias – Whether modifications in device memory are allowed to begin directly visible in host memory space (or other mappings). Note that this doesn’t force alias semantics, updateHost() must still be called to ensure the host data is correct, but it might become a noop.

Returns:

A pointer to the device buffer or nullptr, in which case the device buffer should be obtained via translateToDevice(hostPtr) (but the nullptr should still be passed to unmap).

virtual void unmap(const kj::byte *hostPtr, kj::byte *devicePtr) = 0

Unmap a host/device buffer pair.

virtual kj::byte *translateToDevice(kj::byte *hostPtr) = 0

If map() returned nullptr, call this method to obtain the device buffer pointer.

virtual Own<DeviceBase> addRef() = 0

Public Members

const void *brand
template<typename T>
struct DeviceMapping : public fsc::DeviceMappingBase

Subclassed by fsc::ConstTensorMapping< T >, fsc::ConstTensorMapping< TensorFixedSize< TVal, Dims, options, Index > >, fsc::TensorMapping< T >, fsc::TensorMapping< Tensor< TVal, tRank, tOpts, Index > >, fsc::TensorMapping< TensorFixedSize< TVal, Dims, options, Index > >, fsc::ConstTensorMapping< TensorType >, fsc::DeviceMapping< CuTypedMessageBuilder< HostType, CupnpType > >, fsc::DeviceMapping< CuTypedMessageReader< HostType, CupnpType > >, fsc::TensorMapping< TensorType >

Public Functions

inline DeviceMapping(T newTarget, DeviceBase &device, bool allowAlias)
inline void doUpdateDevice() override
inline void doUpdateHost() override
inline T get()

Public Members

T target
template<typename HostType, typename CupnpType>
struct DeviceMapping<CuTypedMessageBuilder<HostType, CupnpType>> : public fsc::DeviceMapping<Own<capnp::MessageBuilder>>

Public Types

using Parent = DeviceMapping<Own<capnp::MessageBuilder>>

Public Functions

inline DeviceMapping(CuTypedMessageBuilder<HostType, CupnpType> &&typedBuilder, DeviceBase &device, bool allowAlias)
inline cupnp::Location getUntyped()
inline CupnpType::Builder get()
inline capnp::MessageBuilder &getHostUntyped()
inline HostType::Builder getHost()
inline Own<DeviceMapping<CuTypedMessageBuilder<HostType, CupnpType>>> addRef()
template<typename HostType, typename CupnpType>
struct DeviceMapping<CuTypedMessageReader<HostType, CupnpType>> : public fsc::DeviceMapping<Own<capnp::MessageReader>>

Public Types

using Parent = DeviceMapping<Own<capnp::MessageReader>>

Public Functions

inline DeviceMapping(CuTypedMessageReader<HostType, CupnpType> &&typedReader, DeviceBase &device, bool allowAlias)
inline cupnp::Location getUntyped()
inline CupnpType::Reader get()
inline capnp::MessageReader &getHostUntyped()
inline HostType::Reader getHost()
inline Own<DeviceMapping<CuTypedMessageReader<HostType, CupnpType>>> addRef()
template<typename T>
struct DeviceMapping<KernelArg<T>> : public fsc::DeviceMappingBase

Public Functions

inline DeviceMapping(KernelArg<T> &&arg, DeviceBase &device, bool allowAlias__ignored)
inline void doUpdateHost() override
inline void doUpdateDevice() override
inline auto get()

Public Members

DeviceMappingType<T> target
bool copyToDevice
bool copyToHost
template<typename T>
struct DeviceMapping<kj::Array<const T>> : public fsc::DeviceMappingBase

Public Functions

inline DeviceMapping(kj::Array<const T> array, DeviceBase &device, bool allowAlias = false)
inline ~DeviceMapping()
inline void doUpdateHost() override
inline void doUpdateDevice() override
inline kj::ArrayPtr<T> get()
inline kj::ArrayPtr<const T> getHost()

Public Members

kj::Array<const T> hostArray
kj::byte *devicePtr
kj::ArrayPtr<T> deviceArray
template<typename T>
struct DeviceMapping<kj::Array<T>> : public fsc::DeviceMappingBase

Public Functions

inline DeviceMapping(kj::Array<T> array, DeviceBase &device, bool allowAlias = false)
inline ~DeviceMapping()
inline void doUpdateHost() override
inline void doUpdateDevice() override
inline kj::ArrayPtr<T> get()
inline kj::ArrayPtr<T> getHost()

Public Members

kj::Array<T> hostArray
kj::byte *devicePtr
kj::ArrayPtr<T> deviceArray
template<>
struct DeviceMapping<Own<capnp::MessageBuilder>> : public fsc::MessageMappingBase

Public Functions

DeviceMapping(Own<capnp::MessageBuilder> builder, DeviceBase &device, bool allowAlias)
~DeviceMapping()
void doUpdateHost() override
void doUpdateDevice() override
cupnp::Location get()
capnp::MessageBuilder &getHost()
inline Own<DeviceMapping<Own<capnp::MessageBuilder>>> addRef()
template<>
struct DeviceMapping<Own<capnp::MessageReader>> : public fsc::MessageMappingBase

Public Functions

DeviceMapping(Own<capnp::MessageReader> reader, DeviceBase &device, bool allowAlias)
~DeviceMapping()
void doUpdateHost() override
void doUpdateDevice() override
cupnp::Location get()
capnp::MessageReader &getHost()
inline Own<DeviceMapping<Own<capnp::MessageReader>>> addRef()
template<>
struct DeviceMapping<Own<kernels::MagKernelContext>> : public fsc::DeviceMappingBase

Public Functions

inline DeviceMapping(Own<kernels::MagKernelContext> &&p, DeviceBase &device, bool allowAlias)
inline void doUpdateDevice() override
inline void doUpdateHost() override
inline kernels::MagKernelContext get()

Public Members

Own<kernels::MagKernelContext> pCtx
template<typename T>
struct DeviceMapping<Own<TensorMap<const T>>> : public fsc::ConstTensorMapping<T>

Public Functions

inline DeviceMapping(Own<TensorMap<const T>> t, DeviceBase &device, bool allowAlias)
template<typename TVal, typename Dims, int options, typename Index>
struct DeviceMapping<Own<TensorMap<const TensorFixedSize<TVal, Dims, options, Index>>>> : public fsc::ConstTensorMapping<TensorFixedSize<TVal, Dims, options, Index>>

Public Functions

inline DeviceMapping(Own<TensorMap<const TensorFixedSize<TVal, Dims, options, Index>>> t, DeviceBase &device, bool allowAlias)
template<typename T>
struct DeviceMapping<Own<TensorMap<T>>> : public fsc::TensorMapping<T>

Public Functions

inline DeviceMapping(Own<TensorMap<T>> t, DeviceBase &device, bool allowAlias)
template<typename TVal, int tRank, int tOpts, typename Index>
struct DeviceMapping<Tensor<TVal, tRank, tOpts, Index>> : public fsc::TensorMapping<Tensor<TVal, tRank, tOpts, Index>>

Public Functions

inline DeviceMapping(Tensor<TVal, tRank, tOpts, Index> t, DeviceBase &device, bool allowAlias)
template<typename TVal, typename Dims, int options, typename Index>
struct DeviceMapping<TensorFixedSize<TVal, Dims, options, Index>> : public fsc::TensorMapping<TensorFixedSize<TVal, Dims, options, Index>>

Public Functions

inline DeviceMapping(TensorFixedSize<TVal, Dims, options, Index> t, DeviceBase &device, bool allowAlias)
struct DeviceMappingBase : public kj::Refcounted

Base class for DeviceMapping implementations that handles barriers.

Subclassed by fsc::DeviceMapping< kj::Array< const TensorType::Scalar > >, fsc::DeviceMapping< Own< capnp::MessageBuilder > >, fsc::DeviceMapping< Own< capnp::MessageReader > >, fsc::DeviceMapping< kj::Array< TensorType::Scalar > >, fsc::DeviceMapping< T >, fsc::DeviceMapping< KernelArg< T > >, fsc::DeviceMapping< Own< kernels::MagKernelContext > >, fsc::DeviceMapping< kj::Array< T > >, fsc::DeviceMapping< kj::Array< const T > >, fsc::MessageMappingBase

Public Functions

DeviceMappingBase(DeviceBase &device)
virtual ~DeviceMappingBase()
void updateHost()
void updateDevice()
Own<DeviceMappingBase> addRef()
struct FieldCache

Public Functions

virtual Maybe<Promise<LocalDataRef<Float64Tensor>>> check(kj::ArrayPtr<const byte> pointsHash, kj::ArrayPtr<const byte> fieldKey) = 0
virtual void put(kj::ArrayPtr<const byte> pointsHash, kj::ArrayPtr<const byte> fieldKey, Promise<LocalDataRef<Float64Tensor>>) = 0

Public Static Functions

static kj::Array<const byte> hashPoints(Eigen::TensorMap<Eigen::Tensor<double, 2>>)
class FieldResolverBase : public FieldResolver::Server

Public Functions

Promise<void> resolveField(ResolveFieldContext context) override
Promise<void> resolveFilament(ResolveFilamentContext context) override
virtual Promise<void> processField(MagneticField::Reader input, MagneticField::Builder output, ResolveFieldContext context)
virtual Promise<void> processFilament(Filament::Reader input, Filament::Builder output, ResolveFieldContext context)
struct GeometryLibImpl : public GeometryLib::Server

Public Functions

inline GeometryLibImpl(Own<DeviceBase> device)
Promise<void> merge(MergeContext) override
Promise<void> index(IndexContext) override
Promise<void> planarCut(PlanarCutContext) override
Promise<void> reduce(ReduceContext) override
Promise<void> weightedSample(WeightedSampleContext) override
Promise<void> intersect(IntersectContext) override
Promise<void> unroll(UnrollContext) override
Promise<void> planarClip(PlanarClipContext) override
Promise<void> triangulate(TriangulateContext) override

Public Members

Own<DeviceBase> device
struct GeometryResolverBase : public GeometryResolver::Server

Public Functions

Promise<void> resolveGeometry(ResolveGeometryContext context) override
virtual Promise<void> processGeometry(Geometry::Reader input, Geometry::Builder output, ResolveGeometryContext context)
Promise<void> processTransform(Transformed<Geometry>::Reader input, Transformed<Geometry>::Builder output, ResolveGeometryContext context)
struct H5Dim

Public Functions

H5Dim(const H5Dim &other) = default
H5Dim(const H5::DataSet&)

Dimension scale constructor

Extracts the information from the target dimension scale object. Requires the target dataset to begin a 1D dataset (NetCDF style)

inline H5Dim(const H5::DataSet &ds, hsize_t len, hsize_t maxLen)
inline H5Dim(hsize_t len, hsize_t maxLen)
inline H5Dim(hsize_t len)

Public Members

hsize_t length
hsize_t maxLength
Maybe<H5::DataSet> dataset

Public Static Functions

static inline H5Dim unlimited(hsize_t length)
struct HDF5Lib

Public Functions

HDF5Lib()
~HDF5Lib()

Public Static Attributes

static HDF5Lib INSTANCE
struct ID

Identifier class wrapping a byte array.

Public Functions

inline ID()
inline ID(const ID &other)
inline ID(ID &&other)
inline ID &operator=(const ID &other)
inline ID &operator=(ID &&other)
inline ID(const ArrayPtr<const byte> &data)
inline operator ArrayPtr<const byte>() const
inline ArrayPtr<const byte> asPtr() const
inline int cmp(const ArrayPtr<const byte> &other) const
inline int cmp(const ID &other) const
inline int cmp(decltype(nullptr)) const
template<typename T>
inline bool operator<(const T &other) const
template<typename T>
inline bool operator<=(const T &other) const
template<typename T>
inline bool operator>(const T &other) const
template<typename T>
inline bool operator>=(const T &other) const
template<typename T>
inline bool operator==(const T &other) const
template<typename T>
inline bool operator!=(const T &other) const

Public Members

Array<const byte> data

Public Static Functions

template<typename T>
static ID fromReader(T t)

Construct ID by from Reader. Requires data.h.

Creates ID from canonical representation of reader.

This method constructs an ID out of the canonical representation of the passed capnproto reader.

If the reader holds any capabilities (such as DataRef), the canonicalization will fail. Use fromReaderWithRefs() instead.

Note

Requires data.h

template<typename T>
static Promise<ID> fromReaderWithRefs(T t)

Construct ID from reader with datarefs. Requires data.h.

Creates ID from canonical representation of reader, replaces contained DataRef::Client s with their IDs.

In addition to fromReader(), this method also replaces all linked DataRef objects with their IDs. Since this might require remote calls, it can only return a Promise to an ID.

Note

Requires data.h

struct InProcessServer

Public Functions

virtual LocalVatHub getHub() const = 0
virtual Own<const InProcessServer> addRef() const = 0
template<typename T>
inline T::Client connect() const
inline capnp::Capability::Client connectBase() const
struct IntersectResult

Public Members

double l
size_t iMesh
size_t iElement
struct JobDir

Public Functions

virtual Own<JobDir> addRef() = 0
inline virtual ~JobDir()

Public Members

Own<const kj::Directory> dir
kj::Path absPath = nullptr
struct JobDirProvider

Subclassed by fsc::BaseDirProvider, fsc::JobLauncher

Public Functions

virtual Own<JobDir> createDir() = 0
inline virtual ~JobDirProvider() noexcept(false)
struct JobLauncher : public fsc::JobDirProvider

Public Functions

virtual Job::Client launch(JobRequest req) = 0
virtual Own<JobLauncher> addRef() = 0
inline virtual ~JobLauncher()
struct JobRequest

Public Functions

inline void setArguments(kj::ArrayPtr<const kj::StringPtr> newArgs)

Public Members

kj::String command
kj::Array<kj::String> arguments
Maybe<kj::Path> workDir
size_t numTasks = 1
size_t cpusPerTask = 1
struct JobServerBase : public Job::Server

Public Functions

Promise<void> eval(EvalContext) override
struct JsonOptions

Public Types

enum Dialect

Values:

enumerator JSON
enumerator CBOR
enumerator BSON

Public Functions

inline bool isBinary()

Public Members

Dialect dialect = JSON
bool quoteSpecialNums = true
kj::StringPtr jsonInf = "inf"
kj::StringPtr jsonNegInf = "-.inf"
kj::StringPtr jsonNan = ".nan"
template<int dims>
struct KDTreeIndex : public fsc::KDTreeIndexBase

Public Functions

inline CUPNP_FUNCTION FindResult findNearest (const Vec< double, dims > &x)
inline CUPNP_FUNCTION void findNearest (const Vec< double, dims > &x, FindResult &currentClosest, cu::KDTree::Node::Reader node)
inline double distance(const Vec<double, dims> &x1, const Vec<double, dims> &x2)

Public Static Functions

static inline Vec<double, dims> closestPoint(Vec<double, dims> x, cupnp::List<double>::Reader bounds)
static inline Vec<double, dims> furthestPoint(Vec<double, dims> x, cupnp::List<double>::Reader bounds)
struct KDTreeIndexBase

Subclassed by fsc::KDTreeIndex< dims >

Public Functions

inline CUPNP_FUNCTION KDTreeIndexBase(cu::KDTree::Reader tree)
inline CUPNP_FUNCTION NodeInfo getNode (uint64_t id)
struct FindResult

Public Members

double distance
uint64_t key
struct NodeInfo

Public Functions

inline CUPNP_FUNCTION double diameter ()
inline CUPNP_FUNCTION double diameterSqr ()

Public Members

cu::KDTree::Node::Reader node
cupnp::List<double>::Reader bounds
template<typename T>
struct KernelArg

Helper type that describes kernel arguments and their in/out semantics.

Note

For use with FSC_KARG(…)

Public Functions

inline KernelArg(T in, bool copyToHost, bool copyToDevice, bool allowAlias)

Public Members

T target
bool copyToHost = true
bool copyToDevice = true
bool allowAlias = false
template<typename Device>
struct KernelLauncher

Helper to launch an int-based kernel on a specific device. Currently supports thread-pool- and GPU devices.

Public Static Functions

template<typename Kernel, Kernel f, typename ...Params>
static inline Promise<void> launch(Device &device, size_t n, Eigen::TensorOpCost &cost, Promise<void> onCancel, Params... params)

Launches f on the computing capabilities owned by device. The cost parameter should contain an approximation of the computing expense for the kernel. On the thread-pool backend, if the expense is sufficiently small, the kernel will be computed in-line or with fewer threads.

The kernel will run asynchronously. It is guaranteed that it will not start before this function has returned.

template<>
struct KernelLauncher<CPUDevice>

Public Static Functions

template<typename Kernel, Kernel f, typename ...Params>
static inline Promise<void> launch(CPUDevice &device, size_t n, const Eigen::TensorOpCost &cost, Promise<void> onCancel, Params... params)
template<>
struct KernelLauncher<DeviceBase>

Public Static Functions

template<typename Kernel, Kernel func, typename ...Params>
static inline Promise<void> launch(DeviceBase &device, size_t n, const Eigen::TensorOpCost &cost, Promise<void> onCancel, Params... params)
template<>
struct KernelLauncher<LoopDevice>

Public Static Functions

template<typename Kernel, Kernel f, typename ...Params>
static inline Promise<void> launch(LoopDevice &device, size_t n, const Eigen::TensorOpCost &cost, Promise<void> onCancel, Params... params)
struct LibraryHandle : public kj::AtomicRefcounted

“Global” libary handle. This class serves as the dependency injection context for objects that should be shared across all threads. Currently, this is only the local data store table and a shared daemon runner.

Public Functions

LibraryHandle(StartupParameters params = StartupParameters())
~LibraryHandle()
inline kj::Own<const LibraryHandle> addRef() const
inline DataStore &store() const
const kj::Executor &worker() const
inline LibraryThread newThread(Maybe<kj::EventPort&> eventPort = nullptr) const
std::unique_ptr<Botan::HashFunction> defaultHash() const
template<typename Num>
struct LinearInterpolation

Simple fast linear interpolation strategy

Public Types

using Scalar = Num
using Coeffs = std::array<Scalar, 2>

Public Functions

inline constexpr EIGEN_DEVICE_FUNC size_t nPoints ()
inline constexpr EIGEN_DEVICE_FUNC std::array< Scalar, 2 > coefficients (Num x)
inline constexpr EIGEN_DEVICE_FUNC std::array< int, 2 > offsets ()
struct LoadBalancer

Public Functions

virtual Own<LoadBalancer> addRef() = 0
virtual StatusInfo status() = 0
virtual capnp::Capability::Client loadBalanced() = 0
inline virtual ~LoadBalancer() noexcept(false)
struct StatusInfo

Public Members

kj::Array<Backend> backends
struct Backend

Public Types

enum Status

Values:

enumerator OK
enumerator DISCONNECTED

Public Members

kj::String url
Status status
struct LoadLimiter

Public Functions

LoadLimiter(size_t capacity = 1)
size_t getCapacity()
void setCapacity(size_t newCapacity)
size_t getActive()
size_t getQueued()
Promise<Own<Token>> getToken()
template<typename C, typename T = capnp::FromClient<C>>
T::Client limit(C)
struct Impl : public kj::Refcounted

Public Functions

inline Own<Impl> addRef()
inline Impl(size_t cap)
inline void update()
inline Own<Token> createToken()

Public Members

size_t capacity
size_t nActive = 0
size_t nQueued = 0
kj::WaiterQueue<Own<Token>> queue
struct TokenImpl : public fsc::LoadLimiter::Token

Public Functions

inline TokenImpl(Impl &p)
inline ~TokenImpl()

Public Members

Own<Impl> parent
struct Token

Subclassed by fsc::LoadLimiter::Impl::TokenImpl

Public Functions

inline virtual ~Token() noexcept(false)
template<typename T = capnp::AnyPointer>
class LocalDataRef : public fsc::DataRef<T>::Client

Local version of DataRef::Client.

Data reference backed by local storage. In addition to the remote access functionality provided by the interface in capnp::DataRef, this class provides direct access to locally stored data. This class uses non-atomic reference counting for performance, so it can not be shared across threads. To share this to other threads, pass the DataRef::Client capability it inherits from via RPC and use that thread’s DataService to download it into a local reference. If this ref and the other DataServce share the same data store, the underlying data will not be copied, but shared between the references.

Public Functions

ArrayPtr<const byte> getRaw()

Provides direct access to the raw underlying byte array associated with this data reference.

Array<const byte> forkRaw()

Same as getRaw(), but provides an owning reference (that can be passed across threads)

T::Reader get(const capnp::ReaderOptions &options = READ_UNLIMITED)

Provides a structured view of the underlying data. If T is capnp::Data, the returned reader will be identical to getRaw(). Otherwise, this will interpret the backing array as a CapNProto message with the given type at its root. Note that if T is not capnp::Data, and the backing array can not be interpreted as a CapNProto message, this method will fail.

template<typename T2 = capnp::AnyPointer>
class LocalDataRef<T2> as()

Provides a new data reference sharing the underling buffer and capabilities, but having a different interpretation data type.

ArrayPtr<const byte> getID()
ArrayPtr<capnp::Capability::Client> getCapTable()
DataRefMetadata::Format::Reader getFormat()
DataRefMetadata::Reader getMetadata()
LocalDataRef(LocalDataRef<T> &other)
LocalDataRef(LocalDataRef<T> &&other)
LocalDataRef<T> &operator=(LocalDataRef<T> &other)
LocalDataRef<T> &operator=(LocalDataRef<T> &&other)
LocalDataRef<T> deepFork()

Creates a copy of this DataRef (sharing the data) that can be safely passed to other threads.

LocalDataRef() = delete
LocalDataRef(DataRef<capnp::AnyPointer>::Client capView, Own<internal::LocalDataRefImplV2> backend)
template<typename T2>
LocalDataRef(LocalDataRef<T2> &other)
template<typename T2>
LocalDataRef<T2> as()

Public Members

Own<internal::LocalDataRefImplV2> backend

Friends

friend class LocalDataRef
class LocalDataService

Publishes and downloads data into LocalDataRef instances.

Main entry point for handling local and remote data references. Can be used to both create remotely-downloadable data references with its ‘publish’ methods and download (as in, create local copies of) remote references with its ‘download’ methods.

Download methods

template<typename Reference, typename T = References<Reference>>
Promise<LocalDataRef<T>> download(Reference src, bool recursive = false)

Downloads remote DataRef::Client into LocalDataRef.

Downloads the data contained in the remote reference into the local backing store and links the remote capabilities into a local capability table.

Parameters:
  • src – The DataRef<T>::Client to download from (can also be a LocalDataRef<T>)

  • recursive – Whether to recursively download all referenced DataRef instances into the local data store as well. If true, all contained DataRef objects will point into local storage after the returned promise resolved, and are therefore guaranteed to instantly resolve in future download attempts.

Returns:

Promise to a local data ref instance which extends the interface by DataRef with direct access to the stored data.

template<typename Reference, typename T = References<Reference>>
Promise<Maybe<LocalDataRef<T>>> downloadIfNotNull(Reference src, bool recursive = false)

Downloads remote DataRef::Client into LocalDataRef if it is not null.

Downloads the data contained in the remote reference into the local backing store and links the remote capabilities into a local capability table.

Parameters:
  • src – The DataRef<T>::Client to download from (can also be a LocalDataRef<T>)

  • recursive – Whether to recursively download all referenced DataRef instances into the local data store as well. If true, all contained DataRef objects will point into local storage after the returned promise resolved, and are therefore guaranteed to instantly resolve in future download attempts.

Returns:

Promise to a local data ref instance which extends the interface by DataRef with direct access to the stored data. The contained Maybe will evaluate to nullptr if the given DataRef is unset.

Publication methods

template<typename T = capnp::Data>
LocalDataRef<T> publish(typename DataRefMetadata::Reader metaData, Array<const byte> backingArray, ArrayPtr<capnp::Capability::Client> capTable = nullptr)

Publishes binary data and capability table.

Creates a local data reference directly from a backing array and a capability table.

The interpretation of the backing array depends on the seleced data type. If the data type is capnp::Data, the array is interpreted as the raw data intended to be referenced. This is e.g. intended to be used for raw memory-mapped files. Currently, any other type leads to the backing array being interpreted as containing a CapNProto message (including its segment table) with a root of the specified data type (can also be capnp::AnyPointer, capnp::AnyList or capnp::AnyStruct or similar).

Parameters:
  • id – The global ID to publish this data ref under.

  • backingArray – The contents of the binary buffer. The LocalDataRef object will take ownership of this buffer.

  • capTable – A list of capabilities (usually the capability table of the passed Cap’n’Proto message) to be stored alongside the binary data.

Returns:

A LocalDataRef object which can be passed into all targets expecting abort DataRef::Client.

template<typename Reader, typename T = capnp::FromAny<Reader>>
LocalDataRef<T> publish(Reader reader)

Publishes Cap’n’proto message.

Creates a local data reference by copying the contents of a capnproto reader. If the reader is of type capnp::Data, the byte array it points to will be copied verbatim into the backing buffer. Currently, for any other type this method will create a message containing a deepcopy copy of the data referenced by this reader and store it into the backing array (including the message’s segment table). Capabilities contained in the reader’s message will be added into the capability table hosted by the DataRef.

LocalDataRef<capnp::Data> publish(kj::ArrayPtr<const byte> bytes)

Publish the contents of an array (copies and hashes the array)

LocalDataRef<capnp::Data> publish(kj::Array<const byte> bytes, kj::ArrayPtr<const kj::byte> hash = nullptr)

Take ownership of array and publish it, potentially with precomputed hash.

Archiving methods

template<typename Ref, typename T = References<Ref>> Promise< void > writeArchive (Ref reference, const kj::File &out) KJ_WARN_UNUSED_RESULT

Write DataRef to an archive file.

Downloads the target data and all its transitive dependencies and writes them into an archive file. This file can then be shared with other customers to provide them a deep copy of the stored data.

template<typename T>
LocalDataRef<T> publishArchive(const kj::ReadableFile &in, const capnp::ReaderOptions readerOpts = READ_UNLIMITED)

Publish contents of archive file as LocalDataRef.

Reads an archive file and publishes all data contained within. Returns a LocalDataRef to the root used when writing the archive.

template<typename T>
LocalDataRef<T> publishArchive(kj::Array<const byte> in, const capnp::ReaderOptions readerOpts = READ_UNLIMITED)
template<typename T>
LocalDataRef<T> publishConstant(kj::ArrayPtr<const byte> in)
LocalDataRef<capnp::Data> publishFile(const kj::ReadableFile &in, kj::ArrayPtr<const kj::byte> fileHash = nullptr, bool copy = false)

Publish the raw contents of a file as a data ref via mmap or copy.

LocalDataRef<capnp::Data> publishFile(const kj::ReadableFile &in, bool copy = false)

Shorthand for publishing without hash.

Flat representation

template<typename Client>
Promise<kj::Array<kj::Array<const byte>>> downloadFlat(Client src)
template<typename T>
Promise<kj::Array<kj::Array<const byte>>> downloadFlat(LocalDataRef<T> src)
template<typename T>
LocalDataRef<T> publishFlat(kj::Array<kj::Array<const byte>> data)

Raw data files

Promise<void> downloadIntoFile(DataRef<capnp::Data>::Client, Own<const kj::File> &&out)

Limit configuration

void setLimits(Limits limits)

Public Types

using Nursery = kj::Vector<kj::Own<void>>

Public Functions

void setChunkDebugMode()

Reduces chunk size to 1kB and throws error if chunks can’t be mapped.

operator DataService::Client()
LocalDataService(const LibraryHandle &hdl)

Constructs a new data service instance using the shared backing store.

LocalDataService(LocalDataService &other)
LocalDataService(LocalDataService &&other) = default
LocalDataService &operator=(LocalDataService &other)
LocalDataService &operator=(LocalDataService &&other) = default
LocalDataService() = delete
template<typename C>
Promise<kj::Array<kj::Array<const byte>>> downloadFlat(C ref)
struct Limits

Public Members

uint64_t maxRAMObjectSize = 500000000
Maybe<uint64_t> ramRemaining = nullptr
struct LocalNetworkInterface : public fsc::NetworkInterfaceBase

Network implementation based on the local network interface.

Public Functions

LocalNetworkInterface(Own<kj::Network> network)

Construct a network interface given a kj::Network (which can e.g. be used to restrict the address space)

LocalNetworkInterface()

Construct network interface using the process-wide network.

~LocalNetworkInterface()
virtual Promise<Own<kj::AsyncIoStream>> makeConnection(kj::StringPtr host, unsigned int port) override
virtual Promise<Own<kj::ConnectionReceiver>> listen(kj::StringPtr host, Maybe<unsigned int> port) override
kj::Network &getNetwork()
struct LocalVatHub

Exchange hub for local vat networks.

Whereas the LocalVatNetwork class represents the endpoints in the local network, the hub represents the network itself. Its join() method can be used to obtain new endpoints in the network with unique addresses. joins will be performed sequentially, and the first join() call is always guaranteed to have an ID of 0. Subsequent join() calls give no promises about the used IDs. After a network is deallocated, its ID will be reclaimed and might be used again. This inclused the initial 0 ID.

This class actually wraps a C interface struct which can be passed to other fusionsc instances without ABI incompatibility considerations.

Public Functions

LocalVatHub(fusionsc_LvnHub* = nullptr)
LocalVatHub(const LocalVatHub&)
LocalVatHub(LocalVatHub&&)
~LocalVatHub()
LocalVatHub &operator=(const LocalVatHub&)
LocalVatHub &operator=(LocalVatHub&&)
Own<LocalVatNetwork> join() const
fusionsc_LvnHub *incRef()
fusionsc_LvnHub *release()
struct LocalVatNetwork : public LocalVatNetworkBase

Local Vat network implementation

Local multi-point implementation of Cap’n’proto’s vat network protocol. All LocalVatNetwork instances connected to the same LocalVatHub instance can form connections with each other.

Note

An instance of LocalVatNetwork may not be simultaneously used from multiple threads. However, multiple threads can connect through the same LocalVatHub, and may form connections with each other. Additionally, it is also allowed to create a LocalVatNetwork instance in one thread but use it in another, as long as no method except getVatId() is called beforehand.

Public Functions

virtual lvn::VatId::Reader getVatId() const = 0
virtual Maybe<Own<LocalVatNetworkBase::Connection>> connect(lvn::VatId::Reader hostId) override = 0
virtual Promise<kj::Own<LocalVatNetworkBase::Connection>> accept() override = 0

Public Static Attributes

static lvn::VatId::Reader INITIAL_VAT_ID = lvn::INITIAL_VAT_ID.get()
struct LoopDevice : public fsc::CPUDeviceBase, public kj::Refcounted

Public Functions

LoopDevice(kj::Badge<LoopDevice>)
Own<DeviceBase> addRef() override

Public Static Functions

static Own<LoopDevice> create()

Public Static Attributes

static int BRAND = 0
struct MapNewMessage
struct MessageMappingBase : public fsc::DeviceMappingBase

Subclassed by fsc::DeviceMapping< Own< capnp::MessageBuilder > >, fsc::DeviceMapping< Own< capnp::MessageReader > >

Public Functions

MessageMappingBase(DeviceBase &device, bool allowAlias)
void updateStructureOnDevice()
template<typename T>
T getRoot()
template<typename T>
T getHostRoot()

Public Members

const bool allowAlias
struct MT19937

Implements the popular 32 bit Mersenne twister 19937 pseudo-random number generator.

Public Functions

inline CUPNP_FUNCTION MT19937(cu::MT19937State::Reader input)
inline CUPNP_FUNCTION void save (cu::MT19937State::Builder output)
inline CUPNP_FUNCTION void update ()
inline CUPNP_FUNCTION uint32_t operator() ()
inline CUPNP_FUNCTION double uniform ()
inline CUPNP_FUNCTION double exponential ()
inline CUPNP_FUNCTION void normalPair (double &n1, double &n2)

Public Members

uint32_t state[N]
uint16_t index = 0

Public Static Functions

static inline void seed(uint32_t seed, MT19937State::Builder state)

Public Static Attributes

static constexpr int N = 624
static constexpr int M = 397
struct MultiplexedOutputStream : public kj::AsyncOutputStream

A variant of kj::OutputStream where multiple write calls may be simultaneously active.

Public Functions

virtual Own<MultiplexedOutputStream> addRef() = 0
template<int nDims, typename Strategy, int iDim>
struct NDInterpEvaluator

Public Types

using Scalar = typename Strategy::Scalar

Public Static Functions

template<typename F, typename... Indices> static inline EIGEN_DEVICE_FUNC Scalar evaluate (Strategy &strategy, const F &f, const Vec< int, nDims > &base, const std::array< typename Strategy::Coeffs, nDims > &coeffs, Indices... indices)
template<typename F, typename... Indices> static inline EIGEN_DEVICE_FUNC Scalar evaluateCheckNan (Strategy &strategy, const F &f, const Vec< int, nDims > &base, const std::array< typename Strategy::Coeffs, nDims > &coeffs, Indices... indices)
template<int nDims, typename Strategy>
struct NDInterpEvaluator<nDims, Strategy, nDims>

Public Types

using Scalar = typename Strategy::Scalar

Public Static Functions

template<typename F, typename... Indices> static inline EIGEN_DEVICE_FUNC Scalar evaluate (Strategy &strategy, const F &f, const Vec< int, nDims > &base, const std::array< typename Strategy::Coeffs, nDims > &coeffs, Indices... indices)
template<typename F, typename... Indices> static inline EIGEN_DEVICE_FUNC Scalar evaluateCheckNan (Strategy &strategy, const F &f, const Vec< int, nDims > &base, const std::array< typename Strategy::Coeffs, nDims > &coeffs, Indices... indices)
template<int nDims, typename Strategy>
struct NDInterpolator

Multi-dimensional interpolator that runs based on a given 1-dimensional interpolation strategy

Public Types

using Scalar = typename Strategy::Scalar

Public Functions

inline EIGEN_DEVICE_FUNC NDInterpolator(const Strategy &strategy, const Axis axes[nDims])
inline EIGEN_DEVICE_FUNC NDInterpolator(const Strategy &strategy, std::initializer_list<Axis> axes)
template<typename F> inline EIGEN_DEVICE_FUNC Scalar operator() (const F &f, const Vec< Scalar, nDims > &x)

Public Members

Strategy strategy
Scalar scaleMultipliers[nDims]
Scalar offsets[nDims]
struct Axis

Public Functions

inline EIGEN_DEVICE_FUNC Axis(Scalar x1, Scalar x2, int nIntervals)

Public Members

Scalar x1
Scalar x2
int nIntervals
struct NetworkInterfaceBase : public virtual NetworkInterface::Server

This class provides the high-level networking services (SSH, RPC etc.) based on primitives for forming simple network connections.

Subclassed by fsc::LocalNetworkInterface

Public Functions

virtual Promise<Own<kj::AsyncIoStream>> makeConnection(kj::StringPtr host, unsigned int port) = 0
virtual Promise<Own<kj::ConnectionReceiver>> listen(kj::StringPtr host, Maybe<unsigned int> portHint = nullptr) = 0
Promise<void> sshConnect(SshConnectContext ctx) override
Promise<void> listen(ListenContext ctx) override
Promise<void> serve(ServeContext ctx) override
Promise<void> connect(ConnectContext ctx) override
struct NullErrorHandler : public kj::TaskSet::ErrorHandler

Public Functions

void taskFailed(kj::Exception &&e) override

Public Static Attributes

static NullErrorHandler instance
struct OrdinalChecker

Public Types

using DynamicValue = capnp::DynamicValue
using DynamicStruct = capnp::DynamicStruct
using StructSchema = capnp::StructSchema
using AnyStruct = capnp::AnyStruct
using SType = capnp::schema::Type

Public Functions

inline OrdinalChecker(DynamicStruct::Reader in, unsigned int maxOrdinal)
inline void allowPointer(unsigned int offset)
inline void allowBool(unsigned int offset)
inline void allowBytes(unsigned int size, unsigned int offsetInSizes)
inline bool checkField(DynamicStruct::Reader group, StructSchema::Field field, bool forbidden)
inline bool checkStruct(capnp::DynamicStruct::Reader in, bool forbidden)
inline bool checkRoot()
inline bool checkMask()
inline bool check()

Public Members

capnp::DynamicStruct::Reader in
unsigned int maxOrdinal
Array<byte> mask
Array<bool> ptrMask
struct RFLM

Public Functions

inline EIGEN_DEVICE_FUNC Vec3d unmap (double phi)

Computes the real-space coordinates of the last-mapped position projected to the given phi plane.

inline EIGEN_DEVICE_FUNC Vec3d unmap (double phi, double u, double v)

Computes the real-space coordinates of a phi-u-v coordinate in the current section.

inline EIGEN_DEVICE_FUNC double map (const Vec3d &x, bool goingCcw)

Captures a position for mapping using the closest mapping filament.

inline EIGEN_DEVICE_FUNC double mapInSection (uint64_t section, double phi, double z, double r)

Maps using a pre-selected section.

inline EIGEN_DEVICE_FUNC Vec3d advance (double newPhi, cupnp::List< cu::FLTKernelEvent >::Builder eventBuffer, uint32_t eventCount, uint32_t &newEventCount, uint32_t collisionLimit)

Advances to a new phi position, remapping if neccessary. Returns new real-space position.

inline EIGEN_DEVICE_FUNC Vec3d advance (double newPhi)
inline EIGEN_DEVICE_FUNC double getFieldlinePosition (double phi)
inline EIGEN_DEVICE_FUNC void setFieldlinePosition (double newValue)
inline EIGEN_DEVICE_FUNC RFLM(cu::ReversibleFieldlineMapping::Reader mapping)
inline EIGEN_DEVICE_FUNC RFLM(cu::ReversibleFieldlineMapping::Reader mapping, cu::GeometryMapping::MappingData::Reader)
inline EIGEN_DEVICE_FUNC RFLM(const RFLM &other) = default
inline EIGEN_DEVICE_FUNC void save (cu::ReversibleFieldlineMapping::State::Builder)
inline EIGEN_DEVICE_FUNC void load (cu::ReversibleFieldlineMapping::State::Reader)
inline void save(ReversibleFieldlineMapping::State::Builder)
inline void load(ReversibleFieldlineMapping::State::Reader)
inline void activateSection(uint64_t iSection)
inline cu::ReversibleFieldlineMapping::Section::Reader activeSection()
inline cu::GeometryMapping::SectionData::Reader activeGeoSection()

Public Members

cu::ReversibleFieldlineMapping::Reader mapping
cu::GeometryMapping::MappingData::Reader geoMapping
Vec2d uv
uint64_t currentSection
uint64_t currentSectionRaw
double phi
double lenOffset
uint32_t nPad
uint64_t nPhi
uint64_t nZ
uint64_t nR
double phi1
double phi2

Public Static Attributes

static constexpr double SECTION_TOL = 0.001
struct TensorField

Public Functions

inline TensorField(cu::Float64Tensor::Reader reader, RFLM &parent)
inline double operator()(int iPhi, int iZ, int iR) const

Public Members

cu::Float64Tensor::Reader reader
RFLM &parent
template<typename T>
struct Shared

Public Types

using Payload = T

Public Functions

template<typename ...Params>
inline Shared(Params&&... t)
inline Shared(const Shared<T> &other)
inline Shared(Shared<T> &other)
inline Shared<T> &operator=(const Shared<T> &other)
Shared(Shared<T> &&other) = default
Shared<T> &operator=(Shared<T> &&other) = default
inline ~Shared() noexcept
inline T &get()
inline T &operator*()
inline T *operator->()
template<typename ...Params>
inline void attach(Params&&... params)
inline Own<T> asOwn()
struct SimpleHttpServer : public kj::HttpService

Public Functions

SimpleHttpServer(Promise<Own<kj::NetworkAddress>> address, HttpRoot::Reader data)
inline Promise<unsigned int> getPort()
Promise<void> drain()
inline Promise<std::shared_ptr<kj::HttpServer>> getServer()
Promise<void> request(kj::HttpMethod method, kj::StringPtr url, const kj::HttpHeaders &headers, kj::AsyncInputStream &requestBody, Response &response)
inline Promise<void> listen()
template<typename Strategy>
struct SlabFieldInterpolator

Public Types

using Scalar = typename Strategy::Scalar
using Axis = typename NDInterpolator<3, Strategy>::Axis

Public Functions

inline EIGEN_DEVICE_FUNC SlabFieldInterpolator(const Strategy &strategy, cu::ToroidalGrid::Reader grid)
inline EIGEN_DEVICE_FUNC SlabFieldInterpolator(const Strategy &strategy, const ToroidalGridStruct &grid)
inline SlabFieldInterpolator(const Strategy &strategy, ToroidalGrid::Reader grid)
inline EIGEN_DEVICE_FUNC Vec< Scalar, 3 > operator() (const TensorMap< const Tensor< Scalar, 4 > > &fieldData, const Vec< Scalar, 3 > &xyz)
inline EIGEN_DEVICE_FUNC Vec< Scalar, 3 > inSlabOrientation (const TensorMap< const Tensor< Scalar, 4 > > &fieldData, const Vec< Scalar, 3 > &xyz)
inline EIGEN_DEVICE_FUNC Vec< Scalar, 3 > operator() (const TensorMap< Tensor< Scalar, 4 > > &fieldData, const Vec< Scalar, 3 > &xyz)
inline EIGEN_DEVICE_FUNC Vec< Scalar, 3 > inSlabOrientation (const TensorMap< Tensor< Scalar, 4 > > &fieldData, const Vec< Scalar, 3 > &xyz)

Public Members

NDInterpolator<3, Strategy> interpolator
struct SSHChannel

Public Functions

virtual ~SSHChannel()
virtual Own<SSHChannel> addRef() = 0
virtual Own<kj::AsyncIoStream> openStream(size_t id) = 0
virtual void close() = 0
virtual bool isOpen() = 0
struct SSHChannelListener

Public Functions

virtual ~SSHChannelListener()
virtual Promise<Own<SSHChannel>> accept() = 0
virtual int getPort() = 0
virtual Own<SSHChannelListener> addRef() = 0
virtual void close() = 0
virtual bool isOpen() = 0
struct SSHSession

Public Functions

virtual ~SSHSession()
virtual Own<SSHSession> addRef() = 0
virtual Promise<Own<SSHChannel>> connectRemote(kj::StringPtr remoteHost, size_t remotePort) = 0
virtual Promise<Own<SSHChannel>> connectRemote(kj::StringPtr remoteHost, size_t remotePort, kj::StringPtr srcHost, size_t srcPort) = 0
virtual Promise<Own<SSHChannelListener>> listen(kj::StringPtr host = "0.0.0.0"_kj, Maybe<int> port = nullptr) = 0
virtual Promise<bool> authenticatePassword(kj::StringPtr user, kj::StringPtr password) = 0
virtual Promise<bool> authenticatePubkeyFile(kj::StringPtr user, kj::StringPtr pubkeyFile, kj::StringPtr privkeyFile, kj::StringPtr passPhrase = nullptr) = 0
virtual Promise<bool> authenticatePubkeyData(kj::StringPtr user, kj::StringPtr pubkeyData, kj::StringPtr privkeyData, kj::StringPtr passPhrase) = 0
virtual bool isAuthenticated() = 0
virtual void close() = 0
virtual bool isOpen() = 0
virtual Promise<void> drain() = 0
struct StartupParameters

Public Members

Maybe<DataStore> dataStore
size_t numWorkerThreads = 0
struct StoreEntry

Public Functions

StoreEntry(fusionsc_DataStoreEntry*)
~StoreEntry()
StoreEntry(const StoreEntry&)
StoreEntry(StoreEntry&&)
StoreEntry &operator=(const StoreEntry&)
StoreEntry &operator=(StoreEntry&&)
fusionsc_DataStoreEntry *incRef()
fusionsc_DataStoreEntry *release()
kj::ArrayPtr<const byte> asPtr()
kj::Array<const byte> asArray()
struct StreamConverter

Public Functions

virtual ~StreamConverter() noexcept(false)
virtual RemoteInputStream::Client toRemote(Own<kj::AsyncInputStream>) = 0
virtual RemoteOutputStream::Client toRemote(Own<kj::AsyncOutputStream>) = 0
virtual Promise<Own<kj::AsyncInputStream>> fromRemote(RemoteInputStream::Client clt) = 0
virtual Promise<Own<kj::AsyncOutputStream>> fromRemote(RemoteOutputStream::Client clt) = 0
template<typename T>
struct Temporary : public T::Builder

Combined MessageBuilder and Struct::Builder.

This class holds a locally owned MessageBuilder and specifies the type of the message’s root. It directly derives from T::Builder, so the root struct / list can be directly accessed.

Template Parameters:

T – Data type of the contained message.

Public Types

using Builds = T

Public Functions

template<typename ...Params>
inline Temporary(Params... params)
inline Temporary(typename T::Reader reader)
inline Temporary(typename T::Builder builder)
inline Temporary(Own<capnp::MessageBuilder> holder)
Temporary(Temporary<T>&&) = default
Temporary<T> &operator=(Temporary<T> &&other) = default
inline Temporary<T> &operator=(typename T::Reader other)
inline Temporary<T> &operator=(std::nullptr_t)
inline T::Builder asBuilder()
inline operator capnp::MessageBuilder&()

Public Members

Own<capnp::MessageBuilder> holder
template<typename TensorType>
struct TensorMapping : public fsc::DeviceMapping<kj::Array<TensorType::Scalar>>

Subclassed by fsc::DeviceMapping< Own< TensorMap< T > > >, fsc::DeviceMapping< Tensor< TVal, tRank, tOpts, Index > >, fsc::DeviceMapping< TensorFixedSize< TVal, Dims, options, Index > >

Public Types

using Scalar = typename TensorType::Scalar

Public Functions

inline TensorMapping(Shared<TensorType> tensor, DeviceBase &device, bool allowAlias)
inline TensorMapping(Shared<TensorMap<TensorType>> tensor, DeviceBase &device, bool allowAlias)
inline TensorMap<TensorType> get()
inline TensorMap<TensorType> getHost()

Public Members

TensorMap<TensorType> hostMap
TensorMap<TensorType> deviceMap
struct ThreadContext

Subclassed by fsc::WorkerContext

Public Functions

ThreadContext(Library lh, Maybe<kj::EventPort&> = nullptr)
~ThreadContext()
inline const kj::Executor &executor() const

Access to executor from outside threads.

inline const Library &library() const
inline LocalDataService &dataService()
inline kj::AsyncIoContext &ioContext()
inline kj::WaitScope &waitScope()
inline kj::Timer &timer()
inline CSPRNG &rng()
inline kj::Network &network()
inline StreamConverter &streamConverter()
inline kj::Filesystem &filesystem()
inline DataStore &store() const
inline const kj::Executor &worker() const
inline kj::Array<const byte> randomID()
template<typename T>
Promise<T> uncancelable(Promise<T> p)
Promise<void> uncancelable(Promise<void> p)
void detach(Promise<void> p)
Promise<void> drain()
kj::Canceler &lifetimeScope()
struct ToroidalGridStruct

Public Functions

inline bool isValid() const
inline EIGEN_DEVICE_FUNC double phi (int i_phi) const
inline EIGEN_DEVICE_FUNC double r (int i_r) const
inline EIGEN_DEVICE_FUNC double z (int i_z) const
inline EIGEN_DEVICE_FUNC Vec3d xyz (int i_phi, int i_z, int i_r) const
inline EIGEN_DEVICE_FUNC Vec3d phizr (int i_phi, int i_z, int i_r) const

Public Members

double rMin
double rMax
unsigned int nR
double zMin
double zMax
unsigned int nZ
unsigned int nSym
unsigned int nPhi
struct UnbalancedIntervalSplit

Public Functions

inline UnbalancedIntervalSplit(size_t nTotal, size_t blockSize)
inline size_t blockCount()
inline size_t edge(size_t i)
inline size_t interval(size_t i)
template<typename T>
struct ValueExtractor

Helper that extracts the scalar value of an AutoDiff scalar

Public Types

using Scalar = T

Public Static Functions

static inline T extract(T in)
template<typename T>
struct ValueExtractor<Eigen::AutoDiffScalar<T>>

Public Types

using Scalar = typename T::Scalar

Public Static Functions

static inline Scalar extract(Eigen::AutoDiffScalar<T> in)
struct WorkerContext : public fsc::ThreadContext

Thread context that cancels all long-running tasks.

Public Functions

WorkerContext(Library l)
~WorkerContext()
template<typename T>
struct XThreadQueue

Cross-thread communication queue.

A queue that can asynchronously poll messages while allowing cross- thread synchronous pushes. Supports connection-like close semantics

Public Functions

bool push(T &&t) const

Push an item into the queue. Returns true if the queue is open, and false if it closed.

Promise<T> pop()

Retrieve item from queue.

Returns a promise that resolves once an entry is available in the queue. Only one such promise may be active at any time. Waiting promises will get cancelled if another wait is queued with pop().

void clear()

Removes all items currently in the queue.

void close(const kj::Exception &e = KJ_EXCEPTION(DISCONNECTED, "Queue closed"))

Close the queue

After closing the queue, no new messages can be pushed into the queue. Objects that are pushed after closing will be silently discarded. Objects pushed into the queue before calling close() will remain in the queue and can be read with pop(). Once the queue is cleared, the promise returned by pop() will contain the exception argument to close()

~XThreadQueue()
struct ZLib

Helper class for implementing ZLib-based compression and decompression.

Subclassed by fsc::Compressor, fsc::Decompressor

Public Types

enum State

Values:

enumerator NO_PROGRESS
enumerator PROGRESS

Indicates that no progress could be made because input or output buffer is full.

enumerator FINISHED

Indicates that compression / decompression progressed as planned.

Indicates that the stream is finished

Public Functions

inline void setInput(kj::ArrayPtr<const byte> newInput)

Sets the input buffer to read from.

inline void setOutput(kj::ArrayPtr<byte> newOutput)

Sets the output buffer to write to.

inline size_t remainingIn()

Number of bytes remaining in input buffer (is == 0 if input fully consumed)

inline size_t remainingOut()

Number of bytes remaining in output buffer.

namespace capi
namespace db

Enums

enum class TransactionType : uint8_t

Values:

enumerator UNKNOWN
enumerator READ_WRITE
enumerator READ_ONLY
enumerator READ_ONLY_DEFER

Functions

KJ_DECLARE_NON_POLYMORPHIC(Connection::BaseTransactionHook)
struct Connection

Public Functions

virtual Own<Connection> addRef() = 0
virtual Own<Connection> fork(bool readOnly) = 0
virtual Own<PreparedStatementHook> prepareHook(kj::StringPtr sql) = 0
virtual bool inTransaction() = 0
inline PreparedStatement prepare(kj::StringPtr sql)
inline int64_t exec(kj::StringPtr sql)
virtual Own<TransactionHook> beginTransaction(TransactionType) = 0
inline bool isSqliteLike()

Checks whether connection behaves like an SQLite connection.

If true, the connection has the following traits:

  • Serialization failure happens latest at the first write statement of a transaction.

  • It is strongly advisable to batch small write transactions into larger ones.

If these traits are true, clients can and should merge multiple write statements into super-transactions that will be released before the event loop goes to idle. If serialization failure can occur in a delayed fasion, this is not safe to perform as earlier successful writes can be invalidated by the later failure.

struct BaseTransactionHook : public fsc::db::Connection::TransactionHook, public kj::Refcounted

Public Functions

inline BaseTransactionHook(Connection &c)
inline ~BaseTransactionHook() noexcept
inline Own<Connection::BaseTransactionHook> addRef()
inline void deactivate() noexcept
inline bool active() noexcept override
inline void commit() override
inline void rollback() noexcept override
inline Own<SavepointTransactionHook> newSavepoint()

Public Members

kj::List<SavepointTransactionHook, &SavepointTransactionHook::listLink> savepoints
Own<Connection> connection
uint64_t savepointCounter = 0
struct TransactionHook

Subclassed by fsc::db::Connection::BaseTransactionHook

Public Functions

virtual ~TransactionHook()
virtual void commit() = 0
virtual bool active() noexcept = 0
virtual void rollback() noexcept = 0
struct PreparedStatement

Prepared statement object.

Public Functions

PreparedStatement() = default
PreparedStatement(Own<PreparedStatementHook> &&hook)
~PreparedStatement()
PreparedStatement(PreparedStatement&&) = default
PreparedStatement &operator=(PreparedStatement&&) = default
template<typename P>
void setParameter(size_t, P)

Set a statement parameter.

template<typename ...Params>
Query bind(Params... params)

Assigns all parameters from arguments.

inline void reset()

Reset the statement.

template<typename ...Params>
inline size_t operator()(Params... params)

Execute the statement directly (bind + step + reset). Returns no. of rows modified.

template<typename ...Params>
inline int64_t insert(Params... params)

Execute the statement directly (bind + step + reset). Returns last inserted rowid.

struct Column

Column of a statement row.

Public Functions

inline Column(PreparedStatement &parent, size_t idx)
inline kj::ArrayPtr<const byte> asBlob()
inline double asDouble()
inline int64_t asInt64()
inline kj::StringPtr asText()
inline bool isNull()
inline operator kj::ArrayPtr<const byte>()
inline operator kj::StringPtr()
inline operator double()
inline operator int64_t()
inline kj::String name()
inline bool operator==(const Column &other)
inline bool operator!=(const Column &other)
inline Column &operator++()
inline Column *operator->()
inline Column &operator*()

Public Members

PreparedStatement &parent
size_t idx
struct Query

Query object returned by bind() that can step through result rows and access columns.

Public Functions

inline Query(PreparedStatement &p)
inline ~Query()
inline Column operator[](size_t idx)
bool step()

Public Members

PreparedStatement &parent
struct PreparedStatementHook

Backend implementation class for prepared statements.

Public Functions

virtual void reset() = 0
virtual bool step() = 0
virtual int64_t lastInsertedRowid() = 0
virtual size_t nRowsModified() = 0
virtual void setParameter(size_t, double) = 0
virtual void setParameter(size_t, int64_t) = 0
virtual void setParameter(size_t, kj::ArrayPtr<const byte>) = 0
virtual void setParameter(size_t, kj::StringPtr) = 0
virtual void setParameter(size_t, decltype(nullptr)) = 0
virtual double getDouble(size_t) = 0
virtual int64_t getInt64(size_t) = 0
virtual kj::ArrayPtr<const byte> getBlob(size_t) = 0
virtual kj::StringPtr getText(size_t) = 0
virtual bool isNull(size_t) = 0
virtual kj::String getColumnName(size_t) = 0
virtual size_t size() = 0
struct Transaction

Public Functions

Transaction(Connection &parent, TransactionType type = TransactionType::UNKNOWN)
~Transaction() noexcept(false)
inline void commit()
inline void rollback() noexcept
inline bool active() noexcept
namespace devices
namespace jtext

Functions

TEST_CASE ("jtext-geo-resolver")
TEST_CASE ("jtext-field-resolver")
GeometryResolver::Client newGeometryResolver()
FieldResolver::Client newFieldResolver()
kj::StringPtr exampleGeqdsk()
ToroidalGrid::Reader defaultGrid()
CartesianGrid::Reader defaultGeometryGrid()
namespace w7x

Functions

TEST_CASE ("coilsdb")

This test cases sets up a dummy coilsDB and then queries the internal proxy for some coils from it. The test cases are defined in w7x-test.capnp

TEST_CASE ("compdb")
CoilsDB::Client newCoilsDBFromWebservice(kj::StringPtr address)

Constructs a new client for the W7-X coils DB that connects to the webservice on the given address.

ComponentsDB::Client newComponentsDBFromWebservice(kj::StringPtr address)
Provider::Client newProvider()
FieldResolver::Client newW7xFieldResolver()
GeometryResolver::Client newW7xGeometryResolver()
FieldResolver::Client newCoilsDBResolver(CoilsDB::Client coilsDB)
FieldResolver::Client newConfigDBResolver(CoilsDB::Client coilsDB)
GeometryResolver::Client newComponentsDBResolver(ComponentsDB::Client componentsDB)
void buildCoilFields(W7XCoilSet::Reader in, W7XCoilSet::Fields::Builder output)

Variables

static constexpr kj::StringPtr DEFAULT_COILSDB = "http://esb.ipp-hgw.mpg.de:8280/services/CoilsDBRest"_kj
static constexpr kj::StringPtr DEFAULT_COMPONENTSDB = "http://esb.ipp-hgw.mpg.de:8280/services/ComponentsDbRest"_kj
struct CoilsDBWebservice : public CoilsDB::Server

Public Functions

inline CoilsDBWebservice(kj::StringPtr address)
inline Promise<void> getCoil(GetCoilContext context) override
inline Promise<void> getConfig(GetConfigContext context) override

Public Members

kj::String address
Own<kj::HttpHeaderTable> headerTbl = kj::heap<kj::HttpHeaderTable>()
struct ComponentsDBWebservice : public ComponentsDB::Server

Public Functions

inline ComponentsDBWebservice(kj::StringPtr address)
inline Promise<void> getMesh(GetMeshContext context) override
inline Promise<void> getAssembly(GetAssemblyContext context) override

Public Members

kj::String address
Own<kj::HttpHeaderTable> headerTbl = kj::heap<kj::HttpHeaderTable>()
struct ProviderImpl : public Provider::Server

Public Functions

inline Promise<void> connectCoilsDb(ConnectCoilsDbContext ctx) override
inline Promise<void> connectComponentsDb(ConnectComponentsDbContext ctx) override
namespace kernels

Typedefs

using Field = Eigen::Tensor<double, 4>
using FieldRef = Eigen::TensorMap<Field>
using FieldValues = Eigen::Tensor<double, 2>
using FieldValuesRef = Eigen::TensorMap<FieldValues>
using MFilament = Eigen::Tensor<double, 2>
using FilamentRef = Eigen::TensorMap<MFilament>
using MagTransform = Eigen::Matrix<double, 3, 4>

Functions

FSC_DECLARE_KERNEL(addFieldInterpKernel, MagKernelContext, FieldRef, ToroidalGridStruct)
FSC_DECLARE_KERNEL(biotSavartKernel, MagKernelContext, FilamentRef, double, double)
FSC_DECLARE_KERNEL(dipoleFieldKernel, MagKernelContext, FieldValuesRef, FieldValuesRef, kj::ArrayPtr<double>, size_t, size_t)
FSC_DECLARE_KERNEL(eqFieldKernel, MagKernelContext, cu::AxisymmetricEquilibrium::Reader)
inline EIGEN_DEVICE_FUNC void dipoleFieldKernel (unsigned int idx, MagKernelContext ctx, FieldValuesRef dipolePoints, FieldValuesRef dipoleMoments, kj::ArrayPtr< double > radii, size_t start, size_t end)
struct MagKernelContext

Public Functions

inline MagKernelContext(FieldValuesRef pointsIn, FieldValuesRef fieldOut)
inline MagKernelContext(const MagKernelContext&) = default
inline MagKernelContext(MagKernelContext&&) = default
inline EIGEN_DEVICE_FUNC Vec3d getPosition (unsigned int idx) const
inline EIGEN_DEVICE_FUNC void addField (unsigned int idx, Vec3d fieldContrib) const
inline EIGEN_DEVICE_FUNC MagKernelContext scaleBy (double scale) const

Public Members

FieldValuesRef field
FieldValuesRef points
double scale = 1
Eigen::Matrix<double, 3, 4> transform = Eigen::Matrix<double, 3, 4>::Zero()
bool transformed = false
namespace kmath

Functions

template<typename Num> EIGEN_DEVICE_FUNC Num wrap (Num x)
template<typename Num> EIGEN_DEVICE_FUNC bool crossedPhi (Num phi1, Num phi2, Num phi0)
template<typename Num, int dim, typename F> EIGEN_DEVICE_FUNC void runge_kutta_4_step (Eigen::Vector< Num, dim > &x, Num t, Num h, const F &f)
template<typename Num, int dim, typename F> EIGEN_DEVICE_FUNC double runge_kutta_fehlberg_step (Eigen::Vector< Num, dim > &x, Num t, Num h, const F &f)
inline EIGEN_DEVICE_FUNC unsigned int modPlus (int i, int n)
namespace nudft

Functions

template<unsigned int xdim, unsigned int ydim>
void calculateModes(kj::ArrayPtr<const FourierPoint<xdim, ydim>>, kj::ArrayPtr<FourierMode<xdim, ydim>>)
template<unsigned int xdim, unsigned int ydim>
struct FourierMode

Public Members

int coeffs[xdim]
double cosCoeffs[ydim]
double sinCoeffs[ydim]
template<unsigned int xdim, unsigned int ydim>
struct FourierPoint

Public Members

double angles[xdim]
double y[ydim]
namespace structio

Typedefs

using ListInitializer = kj::Function<capnp::DynamicList::Builder(size_t)>

Functions

Own<Visitor> createVisitor(Node &n)
void save(Node&, Visitor&)

Streams loaded data into the target visitor.

void save(Node&&, Visitor&)

Streams loaded data into the target visitor, but deallocates no-longer-needed data.

Own<Visitor> createVisitor(YAML::Emitter &e)
Own<Visitor> createVisitor(DynamicStruct::Builder b)
Own<Visitor> createVisitor(capnp::ListSchema schema, ListInitializer initializer)
Own<Visitor> createDebugVisitor()
Own<Visitor> createVoidVisitor()
Own<Visitor> createVisitor(kj::BufferedOutputStream &os, const Dialect &dialect, const SaveOptions &opts)
void load(kj::ArrayPtr<const kj::byte> buf, Visitor &v, const Dialect &d)
void load(kj::BufferedInputStream &is, Visitor &visitor, const Dialect &dialect)
void save(DynamicValue::Reader reader, Visitor &v, const SaveOptions &opts, Maybe<kj::WaitScope&> ws)
void save(DynamicValue::Reader reader, kj::BufferedOutputStream &os, const Dialect &dialect, const SaveOptions &opts, Maybe<kj::WaitScope&> ws)
Array<kj::byte> saveToArray(DynamicValue::Reader reader, const Dialect &dialect, const SaveOptions &opts, Maybe<kj::WaitScope&> ws)
kj::String saveToString(DynamicValue::Reader reader, const Dialect &dialect, const SaveOptions &opts, Maybe<kj::WaitScope&> ws)
Own<Visitor> createVisitor(capnp::DynamicStruct::Builder)
void save(capnp::DynamicValue::Reader, Visitor&, const SaveOptions& = SaveOptions(), Maybe<kj::WaitScope&> = nullptr)
void save(capnp::DynamicValue::Reader, kj::BufferedOutputStream&, const Dialect&, const SaveOptions& = SaveOptions(), Maybe<kj::WaitScope&> = nullptr)
kj::Array<kj::byte> saveToArray(capnp::DynamicValue::Reader, const Dialect&, const SaveOptions& = SaveOptions(), Maybe<kj::WaitScope&> = nullptr)
kj::String saveToString(capnp::DynamicValue::Reader, const Dialect&, const SaveOptions& = SaveOptions(), Maybe<kj::WaitScope&> = nullptr)
struct Dialect

Public Types

enum Language

Values:

enumerator JSON
enumerator CBOR
enumerator BSON
enumerator YAML
enumerator MSGPACK
enumerator UBJSON

Public Functions

inline bool isBinary()
inline Dialect(Language l)

Public Members

Language language = JSON
bool quoteSpecialNums = true
kj::StringPtr jsonInf = "inf"
kj::StringPtr jsonNegInf = "-.inf"
kj::StringPtr jsonNan = ".nan"
struct Node

Public Types

using MapPayload = kj::Vector<kj::Tuple<Node, Node>>
using ListPayload = kj::Vector<Node>
using Payload = OneOf<MapPayload, ListPayload, kj::String, kj::Array<kj::byte>, double, uint64_t, int64_t, bool, NullValue>

Public Functions

Node() = default
Node(Node&&) = default
Node(const Node&) = delete

Public Members

Payload payload
struct NullValue
struct SaveOptions

Public Members

bool compact = false

Enable compact representation

Compact representation allows hiding default valued fields and substituting structures of the form { “onlyField” : defaultValue } with the field key (“onlyField” or the field ID).

bool integerKeys = false

Enable integer field keys

Some formats (YAML / CBOR) permit arbitrary objects to be used as keys. In such a case, we can save space and improve protcol migration by preferentially using the numeric IDs instead of names for a lot of objects (field keys, enumerants).

Since this eliminates the value of the saved data as self-describing structures, it is disabled by default.

CapabilityStrategy *capabilityStrategy = CapabilityStrategy::DEFAULT

Allows the override of capability storage

Custom viewers / editors might want to override how a capability is shown, e.g. by replacing them with a clickable link that opens the target in a GUI.

struct CapabilityStrategy

Public Functions

virtual void saveCapability(capnp::DynamicCapability::Client, Visitor&, const SaveOptions&, Maybe<kj::WaitScope&>) const = 0

Public Static Attributes

static CapabilityStrategy *const DEFAULT = &DEFAULT_CAP_INSTANCE
struct Visitor

Public Functions

inline virtual ~Visitor() noexcept(false)
virtual void beginObject(Maybe<size_t>) = 0
virtual void endObject() = 0
virtual void beginArray(Maybe<size_t>) = 0
virtual void endArray() = 0
virtual void acceptNull() = 0
virtual void acceptDouble(double) = 0
virtual void acceptInt(int64_t) = 0
virtual void acceptUInt(uint64_t) = 0
virtual void acceptString(kj::StringPtr) = 0
virtual void acceptData(ArrayPtr<const byte>) = 0
virtual void acceptBool(bool) = 0
virtual bool done() = 0

Public Members

bool supportsIntegerKeys = false

Whether this visitor allows integer map keys.