Skip to content

Commit 24a9666

Browse files
authored
updating official name and public url; use LLVM compile defs (#104)
* updating official name and public url; use LLVM compile defs * using older conda/build * adding sysroot to runtime deps * fixing out-of-bounds access in accumulate * fixing invalid conditions
1 parent e46af78 commit 24a9666

File tree

6 files changed

+26
-22
lines changed

6 files changed

+26
-22
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
bash $CPKG -u -b -f -p $CONDA_ROOT
4747
export PATH=$CONDA_ROOT/condabin:$CONDA_ROOT/bin:${PATH}
4848
eval "$($CONDA_ROOT/bin/python -m conda shell.bash hook)"
49-
conda install -c conda-forge --override-channels python git-lfs conda-build
49+
conda install -c conda-forge --override-channels python git-lfs 'conda-build<=24.1.2'
5050
# aahhhh bug in conda somewhere
5151
sed -i "s,\#\!/usr/bin/env python,#\!$CONDA_ROOT/bin/python," $CONDA_ROOT/*bin/conda
5252
conda clean --all -y

CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ message(STATUS "Expected IMEX sha: \"${EXPECTED_IMEX_SHA}\"")
4343
# find_package(ZLIB REQUIRED)
4444
find_library(LIBZ z NAMES libz.so libz.so.1 REQUIRED PATHS ${ZLIB_ROOT}/lib)
4545
message("FOUND zlib ${LIBZ}")
46+
set(ZLIB_LIBRARY ${LIBZ})
4647
find_package(TBB REQUIRED)
4748
find_package(Python3 COMPONENTS Interpreter Development.Module NumPy REQUIRED)
4849
find_package(pybind11 CONFIG REQUIRED)
@@ -64,9 +65,11 @@ list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
6465
#include(AddMLIR)
6566
#include(AddIMEX)
6667

68+
# LLVM defs, most impoprtatntly __STDC_FORMAT_MACROS for PRIxPTR et al
69+
message(STATUS "LLVM_DEFINITIONS: ${LLVM_DEFINITIONS}")
70+
add_definitions(${LLVM_DEFINITIONS})
6771
# macro for mlir/imex root directories
68-
# __STDC_FORMAT_MACROS for PRIxPTR et al
69-
add_compile_definitions(CMAKE_MLIR_ROOT="${MLIR_ROOT}" CMAKE_IMEX_ROOT="${IMEX_ROOT}" FORTIFY_SOURCE=2 __STDC_FORMAT_MACROS=1)
72+
add_compile_definitions(CMAKE_MLIR_ROOT="${MLIR_ROOT}" CMAKE_IMEX_ROOT="${IMEX_ROOT}" FORTIFY_SOURCE=2)
7073
add_compile_options(
7174
"-ftemplate-backtrace-limit=0"
7275
"$<$<STREQUAL:${CMAKE_CXX_COMPILER_ID},GNU>:-flarge-source-files>"

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
[![.github/workflows/ci.yml](https://github.com/intel-sandbox/sharpy/actions/workflows/ci.yml/badge.svg)](https://github.com/intel-sandbox/sharpy/actions/workflows/ci.yml)
1+
[![.github/workflows/ci.yml](https://github.com/IntelPython/sharded-array-for-python/actions/workflows/ci.yml/badge.svg)](https://github.com/IntelPython/sharded-array-for-python/actions/workflows/ci.yml)
22

33
***This software package is not ready for production use and and merely a proof of concept implementation.***
44

5-
# Distributed Python Array
5+
# Sharded Array For Python
66

77
A array implementation following the [array API as defined by the data-API consortium](https://data-apis.org/array-api/latest/index.html).
88
Parallel and distributed execution currently is MPI/CSP-like. In a later version support for a controller-worker execution model will be added.
99

1010
## Setting up build environment
1111

12-
Install MLIR/LLVM and IMEX (see https://github.com/intel-innersource/frameworks.ai.mlir.mlir-extensions).
12+
Install MLIR/LLVM and Intel® Extension for MLIR (IMEX, see https://github.com/intel/mlir-extensions).
1313

1414
```bash
15-
git clone --recurse-submodules https://github.com/intel-sandbox/sharpy
16-
cd sharpy
15+
git clone --recurse-submodules https://github.com/IntelPython/sharded-array-for-python
16+
cd sharded-array-for-python
1717
git checkout jit
1818
conda create --file conda-env.txt --name sharpy
1919
conda activate sharpy
@@ -22,7 +22,7 @@ export MLIRROOT=<your-MLIR-install-dir>
2222
export IMEXROOT=<your-IMEX-install-dir>
2323
```
2424

25-
## Building sharpy
25+
## Building Sharded Array For Python
2626

2727
```bash
2828
python -m pip install .
@@ -98,7 +98,7 @@ pre-commit autoupdate
9898

9999
### Deferred Execution
100100

101-
Typically, sharpy operations do not get executed immediately. Instead, the function returns a transparent object (a future) only.
101+
Typically, operations do not get executed immediately. Instead, the function returns a transparent object (a future) only.
102102
The actual computation gets deferred by creating a promise/deferred object and queuing it for later. This is not visible to users, they can use it as any other numpy-like library.
103103

104104
Only when actual data is needed, computation will happen; that is when
@@ -112,17 +112,17 @@ In the background a worker thread handles deferred objects. Until computation is
112112

113113
Arrays and operations on them get transparently distributed across multiple processes. Respective functionality is partly handled by this library and partly IMEX dist dialect.
114114
IMEX relies on a runtime library for complex communication tasks and for inspecting runtime configuration, such as number of processes and process id (MPI rank).
115-
sharpy provides this library functionality in a separate dynamic library "idtr".
115+
Sharded Array For Python provides this library functionality in a separate dynamic library "idtr".
116116

117117
Right now, data is split in the first dimension (only). Each process knows the partition it owns. For optimization partitions can actually overlap.
118118

119-
sharpy currently supports one execution mode: CSP/SPMD/explicitly-distributed execution, meaning all processes execute the same program, execution is replicated on all processes. Data is typically not replicated but distributed among processes. The distribution is handled automatically by sharpy, all operations on sharpy arrays can be viewed as collective operations.
119+
Sharded Array For Python currently supports one execution mode: CSP/SPMD/explicitly-distributed execution, meaning all processes execute the same program, execution is replicated on all processes. Data is typically not replicated but distributed among processes. The distribution is handled automatically, all operations on Sharded Arrays For Python can be viewed as collective operations.
120120

121121
Later, we'll add a Controller-Worker/implicitly-distributed execution mode, meaning only a single process executes the program and it distributes data and work to worker processes.
122122

123123
### Array API Coverage
124124

125-
Currently only a subset of the Array API is covered by sharpy
125+
Currently only a subset of the Array API is covered by Sharded Array For Python
126126

127127
- elementwise binary operations
128128
- elementwise unary operations
@@ -135,18 +135,18 @@ Currently only a subset of the Array API is covered by sharpy
135135

136136
### Other Functionality
137137

138-
- `sharpy.to_numpy` converts a sharpy array into a numpy array.
139-
- `sharpy.numpy.from_function` allows creating a sharpy array from a function (similar to numpy)
140-
- In addition to the Array API sharpy also provides functionality facilitating interacting with sharpy arrays in a distributed environment.
138+
- `sharpy.to_numpy` converts a sharded array into a numpy array.
139+
- `sharpy.numpy.from_function` allows creating a sharded array from a function (similar to numpy)
140+
- In addition to the Array API Sharded Array For Python also provides functionality facilitating interacting with sharded arrays in a distributed environment.
141141
- `sharpy.spmd.gather` gathers the distributed array and forms a single, local and contiguous copy of the data as a numpy array
142142
- `sharpy.spmd.get_locals` return the local part of the distributed array as a numpy array
143-
- sharpy allows providing a fallback array implementation. By setting SHARPY_FALLBACK to a python package it will call that package if a given function is not provided by sharpy. It will pass sharpy arrays as (gathered) numpy-arrays.
143+
- sharpy allows providing a fallback array implementation. By setting SHARPY_FALLBACK to a python package it will call that package if a given function is not provided. It will pass sharded arrays as (gathered) numpy-arrays.
144144

145145
## Environment variables
146146

147147
### Compile time variables
148148

149-
Required to compile `sharpy`:
149+
Required to compile Sharded Array For Python:
150150

151151
- `MLIRROOT`: Set path to MLIR install root.
152152
- `IMEXROOT`: Set path to Intel MLIR Extensions install root.

conda-recipe/meta.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ requirements:
3737
- tbb
3838
- impi_rt
3939
- mpi4py
40+
- sysroot_linux-64 >=2.28 # [linux]
4041

4142
build:
4243
number: 0

src/CollComm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ void gather_array(NDArray::ptr_type a_ptr, rank_type root, void *outPtr) {
4242
auto myoff = a_ptr->local_offsets()[0];
4343
auto nd = a_ptr->ndims();
4444
auto gshape = a_ptr->shape();
45-
auto myTileSz =
46-
std::accumulate(&gshape[1], &gshape[nd], 1, std::multiplies<int64_t>());
45+
auto myTileSz = std::accumulate(&gshape.data()[1], &gshape.data()[nd], 1,
46+
std::multiplies<int64_t>());
4747

4848
// allgather process local offset and sizes
4949
std::vector<int> displacements(nranks);

src/idtr.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ UHCache getMetaData(SHARPY::rank_type nworkers, int64_t ndims,
691691
// target is rightHalo
692692
if (cE._bufferizeSend) {
693693
cE._rSendOff[i] = i ? cE._rSendOff[i - 1] + cE._rSendSize[i - 1] : 0;
694-
if (cE._rSendOff[i] < cE._rSendOff[i - 1]) {
694+
if (i && cE._rSendOff[i] < cE._rSendOff[i - 1]) {
695695
throw std::overflow_error("Fatal: Integer overflow in getMetaData");
696696
}
697697
cE._rBufferStart[i * ndims] = localRowStart;
@@ -709,7 +709,7 @@ UHCache getMetaData(SHARPY::rank_type nworkers, int64_t ndims,
709709
// target is leftHalo
710710
if (cE._bufferizeSend) {
711711
cE._lSendOff[i] = i ? cE._lSendOff[i - 1] + cE._lSendSize[i - 1] : 0;
712-
if (cE._lSendOff[i] < cE._lSendOff[i - 1]) {
712+
if (i && cE._lSendOff[i] < cE._lSendOff[i - 1]) {
713713
throw std::overflow_error("Fatal: Integer overflow in getMetaData");
714714
}
715715
cE._lBufferStart[i * ndims] = localRowStart;

0 commit comments

Comments
 (0)