= SEP 2: Parallelization Plans For SAGE =12This is a SAGE enhancement proposal.34AUTHOR: William Stein5COPYRIGHT: GNU Free Documentation License, 2007.67The core SAGE library is a collection of Python and sagex files.89== Basic Principles ==1011Many of these are motivated by my (Stein's) perspective as the '''maintainer''' and integrated of SAGE, and recruiter of new developers...12131. Parallel methods should always be viewed as a means to an end -- speedups. Never parallelize any computation except to speed up a calculation beyond what can be done using sequential techniques.142. Parallel methods should never completely replace sequential implementations. Parallel algorithms are often very complicated to understand and test, so we need to at a ''minimum'' have a randomized test function that compares with that output of purely sequential code.153. Do not write insanely complicated parallel code that nobody can understand or maintain. Because SAGE is an open source system that is widely developed, it is ''crucial'' that it be readable.164. It is *crucial* that implementation of parallel methods in SAGE have the following properties:17* It can be done incrementally. One must be able to start with almost any specific operation or algorithm in SAGE and make a parallel version without having to drastically change code all over SAGE. Any proposed solutions that violate this fail our needs.18* It doesn't depend on any libraries or tools that are not open source and free, and all dependencies must work on the SAGE target platforms: Linux, OS X, Windows, (and soon Solaris).19* For any core tools that are needed must be made part of SAGE.2021== Architecture ==2223There are three levels to consider.2425=== 1. Low -- shared memory (mostly multicore desktop/laptop) ===2627Proposed tool: pthread2829Justification:30* pthread is available on all target platforms and is well supported31* mature32* with some thought I think we can make it usable from sagex3334Design issues:35* Have a global variable nthreads3637Alternative tool: multiple processes and a shared memory segment38* via UPC -- heavy and hard to build (??) maybe not right for us, because it's mainly for rather uniform computations.39* via shared pages -- might not be fast enough.404142=== 2. Middle -- homogeneous trusted cluster ===4344Proposed tool: ipython1 (with mpi)4546Justification:47* This is the hardware that the ipython developers use.48* It's written in Python, well tested, and will be included in SAGE anyways.4950=== 3. High -- heterogenous task farm (both trusted and untrusted) ===5152Proposed tool: dsage5354Justification:55* Written in Python to address specific problems we have.5657585960