Cyclops is a parallel (distributed-memory) numerical library for multidimensional arrays (tensors) in C++ and Python.
Quick documentation links: C++ and Python.
Broadly, Cyclops provides tensor objects that are stored and operated on by all processes executing the program, coordinating via MPI communication.
Cyclops supports a multitude of tensor attributes, including sparsity, symmetries, and user-defined element types.
The library is interoperable with ScaLAPACK at the C++ level and with numpy at the Python level. In Python, the library provides a parallel/sparse implementation of numpy.ndarray functionality.
See the Github Wiki for more details on this. It is possible to build static and dynamic C++ libraries, the Python CTF library, as well as examples and tests for both via this repository. Cyclops follows the basic installation con,
(where the last command should usually be executed as superuser, i.e. requires sudo) below we give more details on how the build can be customized.
First, its necessary to run the configure script, which can be set to the appropriate type of build and is responsible for obtaining and checking for any necessary dependencies. For options and documentation on how to execute configure, run
then execute ./configure with the appropriate options. Successful execution of this script, will generate a config.mk file and a setup.py file, needed for C++ and Python builds, respectively, as well as a how-did-i-configure file with info on how the build was configured. You may modify the config.mk and setup.py files thereafter, subsequent executions of configure will prompt to o these files.
Note: there is a (now-fixed) bug in recent of MPICH that causes a segmentation fault in CTF when executing with 2 or more processors.
The bug can be remedied without rebuilding CTF by setting an en as follows,
The strict library dependencies of Cyclops are MPI and BLAS libraries.
Some functionality in Cyclops requires LAPACK and ScaLAPACK. A standard build of the latter can be constructed automatically by running configure with --build-scalapack (requires cmake to build ScaLAPACK, manual build can also be provided along by pro the library path).
Faster transposition in Cyclops is made possible by the HPTT library. To obtain a build of HPTT automatically run configure with --build-hptt.
Efficient sparse matrix multiplication primitives and efficient batched BLAS primitives are a via the Intel MKL library, which is automatically detected for standard Intel compiler configurations or when appropriately supplied as a library.
Once configured, you may install both the shared and dynamic libraries, by running make. Parallel make is supported.
To build exclusively the static library, run make libctf, to build exclusively the shared library, run make shared.
To install the C++ libraries to the prespecified build destination directory (--build-dir for ./configure, /usr/local/ by default), run make install (as superuser if necessary). If the CTF configure script built the ScaLAPACK and/or HPTT libraries automatically, the libraries for these will need to be installed system-wide manually.
To build the Python CTF library, execute make python.
To install the Python CTF library via pip, execute make python_install (as superuser if not in a en).
To uninstall, use make uninstall and make python_uninstall.
To test the C++ library with a sequential suite of tests, run make test. To test the library using 2 processors, execute make test2. To test the library using some number N processors, run make testN.
To test the Python library, run make python_test to do so sequentially and make python_testN to do so with N processors.
To debug issues with custom code execution correctness, build CTF libraries with -DDEBUG=1 -D=1 (more info in config.mk).
To debug issues with custom code performance, build CTF libraries with -DPROFILE -DPMPI (more info in config.mk), which should lead to a performance log dump at the end of an execution of a code using CTF.
A simple Jacobi iteration code using CTF is gi, also found in this example.
The abo function accepts n-by-n matrix A and n-dimensional b containing double precision floating point elements and solves Ax=b using Jacobi iteration. The matrix R is defined to be a copy of the data in A. Its diagonal is subsequently set to 0, while the diagonal of A is extracted into d and in. A while loop then computes the jacobi iteration by use of matrix multiplication, addition, and Hadamard products.
This Jacobi code uses and Matrix objects which are specializations of the Tensor object. Each of these is a distributed data structure, which is partitioned across an MPI communicator.
The key illustrative part of the abo is
to e this expression, CTF would execute the following set of loops, each in parallel,
This parallelization is done with any programming language constructs outside of basic C++. Operator o is used to interpret the indexing strings and build an expression tree. Each operation is then e by an appropriate parallelization. Locally, BLAS kernels are used when possible.
Its also worth noting the different ways indices are employed in the abo. In the matrix- multiplication,
the index j is contracted (summed) over, as it does not appear in the output, while the index i appears in one of the operand and the output. Note, that a different semantic occurs if an index appears in two operands the result
This is most often referred to as a Hadamard product. In general, CTF can execute any operation of the form,
so long as the length of each of the three strings matches the order of the tensors. The operation can be interpreted by looping over all unique characters that appear in the union of the three strings, and putting the specified multiply-add operation in the innermost loop.
Another piece of functionality employed in the Jacobi example is the Function object and its application,
the same code could have been written even more concisely,
This syntax defines and employs an elementwise function that inverts each element of A to which it is applied. The operation is executing the following loop,
In this way, arbitrary functions can be applied to elements of the tensors. There are additional 'algebraic structure' constructs that allow a redefinition of addition and multiplication for any gi. Finally, there is a Transform object, which acts in a similar way as Function, but takes the output element by reference. The Transform construct is more powerful than Function, but limits the transformations that can be applied internally for efficiency. Both Function and Transform can operate on one or two tensors with different element types, and output another element type.
An example of basic CTF functionality as a numpy.ndarray back-end is shown in this Jupyter notebook. The full notebook is included inside the doc folder.
Detailed documentation of all functionality and the organization of the source code can be found in the Doxygen page. Much of the C++ functionality is expressed through the Tensor object. Documentation for hte Python functionality is also a.
The examples and aforementioned papers can be used to gain further insight. If you have any questions regarding usage, do not hesitate to contact us! Please do so by creating an issue on this github webpage. You can also email questions to .
Please see the aforementioned papers for applications and benchmarks, which are also summarized in this recent presentation. Generally, the distributed-memory dense and sparse matrix multiplication performance should be very good. Similar performance is achieved for many types of contractions. CTF can le threading, but is fastest with pure MPI or hybrid MPI+OpenMP. The code aims at scalability to a large number of processors by minimizing communication cost, rather than necessarily achieving perfect absolute performance. User-defined functions naturally inhibit the sequential kernel performance. Algorithms that have a low flop-to-byte ratio may not achie peak as some copying/transposition may take place. Absolute performance of operations that ha indices is relatively low for the time being, but will be improved.
The CTF library enables general-purpose programming, but is particularly useful in some specific application domains.
The framework provides a powerful domain specific language for computational chemistry and physics codes that work on higher order tensors (e.g. coupled cluster, lattice QCD, quantum informatics). See the CCSD and sparse MP3 examples, or the Aquarius application. This domain was the initial moti for the de of CTF. An exemplary paper for this type of applications is
Edgar Solomonik, De, Jeff R. Hammond, John F. Stanton, and James Demmel; A massively parallel tensor contraction framework for coupled-cluster computations; Journal of Parallel and Distributed Computing, June 2014.
Much like the CombBLAS library, CTF provides sparse matrix primitives that enable de of parallel graph algorithms. Matrices and can be defined on a user-defined semiring or monoid. Multiplication of sparse matrices with sparse or other sparse matrices is parallelized automatically. The library includes example code for Bellman-Ford and betweenness centrality. An paper describing and analyzing the betweenness centrality code is
Edgar Solomonik, Maciej Besta, Fla, and Torsten Hoefler Scaling betweenness centrality using communication-efficient sparse matrix multiplication ACM/IEEE Supercomputing Conference, Denver, Colorado, No 2017.
The high-le for , matrices, and order 3+ tensors allow CTF to be a useful tool for de many numerical algorithms. Interface hook-ups for ScaLAPACK make coordination with distributed-memory solvers easy. Algorithms like algebraic multigrid, which require sparse matrix multiplication can be rapidly implemented with CTF. Further, higher order tensors can be used to express recursi like parallel scans and FFT. Some basic examples of numerical codes using CTF are presented in
[Edgar Solomonik and Torsten Hoefler; Sparse tensor algebra as a parallel programming model arXi, arXiv:1512.00066 [cs.MS], No 2015.]()
CTF has been recently used to do the largest-e circuit simulation,
[ Edwin Pednault, John A. Gunnels, Giacomo Nannicini, Lior Horesh, Thomas Magerlein, Edgar Solomonik, and Robert Wisnieff Breaking the 49-qubit barrier in the simulation of quantum circuits arXiv:1710.05867 [quant-ph], October 2017.]( )
Elemental and ScaLAPACK provide distributed-memory support for dense matrix operations in addition to a powerful suite of sol. It is also possible to interface them with CTF, in particular, we provide routines for retrieving a ScaLAPACK descriptor.
A faster library for dense tensor contractions in shared memory is Libtensor.
An excellent distributed-memory library with nati for block-sparse tensors is TiledArray.
The library and source code is a to e. If you would like to acknowledge the usage of the library, please cite one of our papers. The follow reference details dense tensor functionality in CTF,
Edgar Solomonik, De, Jeff R. Hammond, John F. Stanton, and James Demmel; A massively parallel tensor contraction framework for coupled-cluster computations; Journal of Parallel and Distributed Computing, June 2014.
here is the bibtex.
We hope you enjoy writing your parallel program with algebra!
开发语言:C++
Star 数:216
该项目属于CTF思路方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕Cyclops Tensor Framework: parallel arithmetic on multidimensional arrays展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | ctf - Cyclops Tensor Framework: parallel arithmetic on m |
| 所属分类 | CTF思路 |
| 发布作者 | admin |
| 发布时间 | 2026-10-05 23:46:24 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 88 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |