Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit deef030

Browse files
committed
no more xtensor, futures carying dtype and rank
1 parent efad090 commit deef030

23 files changed

+567
-105
lines changed

.gitmodules

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
[submodule "third_party/bitsery"]
22
path = third_party/bitsery
33
url = https://github.com/fraillt/bitsery
4-
[submodule "third_party/xtensor"]
5-
path = third_party/xtensor
6-
url = https://github.com/xtensor-stack/xtensor
7-
[submodule "third_party/xtensor-blas"]
8-
path = third_party/xtensor-blas
9-
url = https://github.com/xtensor-stack/xtensor-blas
10-
[submodule "third_party/xsimd"]
11-
path = third_party/xsimd
12-
url = https://github.com/xtensor-stack/xsimd
13-
[submodule "third_party/xtl"]
14-
path = third_party/xtl
15-
url = https://github.com/xtensor-stack/xtl
164
[submodule "third_party/mlir-extensions"]
175
path = third_party/mlir-extensions
186
url = https://github.com/intel/mlir-extensions
19-
[submodule "third_party/dpcomp"]
20-
path = third_party/dpcomp
21-
url = https://github.com/IntelPython/dpcomp.git

CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,10 @@ set(MyCppSources ${MyCppSources} ${PROJECT_SOURCE_DIR}/src/jit/mlir.cpp ${P2C_HP
8787

8888
pybind11_add_module(_ddptensor MODULE ${MyCppSources})
8989

90-
target_compile_definitions(_ddptensor PRIVATE XTENSOR_USE_XSIMD=1 XTENSOR_USE_TBB=1 USE_MKL=1 DDPT_2TYPES=1)
90+
target_compile_definitions(_ddptensor PRIVATE USE_MKL=1 DDPT_2TYPES=1)
9191
target_compile_options(_ddptensor PRIVATE "-ftemplate-backtrace-limit=0")
9292
target_include_directories(_ddptensor PRIVATE
9393
${PROJECT_SOURCE_DIR}/src/include
94-
${PROJECT_SOURCE_DIR}/third_party/xtl/include
95-
${PROJECT_SOURCE_DIR}/third_party/xsimd/include
96-
${PROJECT_SOURCE_DIR}/third_party/xtensor-blas/include
97-
${PROJECT_SOURCE_DIR}/third_party/xtensor/include
9894
${PROJECT_SOURCE_DIR}/third_party/bitsery/include
9995
${MPI_INCLUDE_PATH}
10096
$ENV{MKLROOT}/include

src/Creator.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include "ddptensor/Creator.hpp"
22
#include "ddptensor/TypeDispatch.hpp"
3-
#include "ddptensor/x.hpp"
43
#include "ddptensor/Deferred.hpp"
54
#include "ddptensor/Factory.hpp"
5+
#include "ddptensor/DDPTensorImpl.hpp"
66

77
#include <imex/Dialect/PTensor/IR/PTensorOps.h>
88
#include <mlir/IR/Builders.h>
99

10+
#if 0
1011
namespace x {
1112

1213
template<typename T>
@@ -63,6 +64,7 @@ namespace x {
6364
}
6465
}; // class creatorx
6566
} // namespace x
67+
#endif // if 0
6668

6769
struct DeferredFromShape : public Deferred
6870
{
@@ -72,14 +74,17 @@ struct DeferredFromShape : public Deferred
7274

7375
DeferredFromShape() = default;
7476
DeferredFromShape(CreatorId op, const shape_type & shape, DTypeId dtype)
75-
: _shape(shape), _dtype(dtype), _op(op)
77+
: Deferred(dtype, shape.size()),
78+
_shape(shape), _dtype(dtype), _op(op)
7679
{}
7780

7881
void run()
7982
{
80-
set_value(std::move(TypeDispatch<x::Creator>(_dtype, _op, _shape)));
83+
// set_value(std::move(TypeDispatch<x::Creator>(_dtype, _op, _shape)));
8184
}
8285

86+
// FIXME mlir
87+
8388
FactoryId factory() const
8489
{
8590
return F_FROMSHAPE;
@@ -107,15 +112,18 @@ struct DeferredFull : public Deferred
107112

108113
DeferredFull() = default;
109114
DeferredFull(const shape_type & shape, PyScalar val, DTypeId dtype)
110-
: _shape(shape), _val(val), _dtype(dtype)
115+
: Deferred(dtype, shape.size()),
116+
_shape(shape), _val(val), _dtype(dtype)
111117
{}
112118

113119
void run()
114120
{
115-
auto op = FULL;
116-
set_value(std::move(TypeDispatch<x::Creator>(_dtype, op, _shape, _val)));
121+
// auto op = FULL;
122+
// set_value(std::move(TypeDispatch<x::Creator>(_dtype, op, _shape, _val)));
117123
}
118124

125+
// FIXME mlir
126+
119127
FactoryId factory() const
120128
{
121129
return F_FULL;
@@ -139,11 +147,11 @@ ddptensor * Creator::full(const shape_type & shape, const py::object & val, DTyp
139147
struct DeferredArange : public Deferred
140148
{
141149
uint64_t _start, _end, _step;
142-
DTypeId _dtype;
143150

144151
DeferredArange() = default;
145152
DeferredArange(uint64_t start, uint64_t end, uint64_t step, DTypeId dtype)
146-
: _start(start), _end(end), _step(step), _dtype(dtype)
153+
: Deferred(dtype, 1),
154+
_start(start), _end(end), _step(step)
147155
{}
148156

149157
void run() override
@@ -153,21 +161,20 @@ struct DeferredArange : public Deferred
153161

154162
::mlir::Value generate_mlir(::mlir::OpBuilder & builder, ::mlir::Location loc, jit::IdValueMap & ivm) override
155163
{
156-
// FIXME the type of the result is hard-coded to uint64_t
157164
// create start, stop and step
158165
auto start = jit::createI64(loc, builder, _start);
159166
auto end = jit::createI64(loc, builder, _end);
160167
auto step = jit::createI64(loc, builder, _step);
161168
// create arange
162169
auto dtype = builder.getI64Type();
170+
assert(_dtype == INT64 || _dtype == UINT64); // FIXME
163171
llvm::SmallVector<int64_t> shape(1, -1); //::mlir::ShapedType::kDynamicSize);
164172
auto artype = ::imex::ptensor::PTensorType::get(builder.getContext(), ::mlir::RankedTensorType::get(shape, dtype), true);
165173
auto ar = builder.create<::imex::ptensor::ARangeOp>(loc, artype, start, end, step, true);
166174
auto setter = [this](uint64_t rank, void *allocated, void *aligned, intptr_t offset, const intptr_t * sizes, const intptr_t * strides) {
167-
// FIXME GC assert(allocated == aligned);
168175
assert(rank == 1);
169176
assert(strides[0] == 1);
170-
this->set_value(std::move(x::operatorx<uint64_t>::mk_tx(rank, allocated, aligned, offset, sizes, strides)));
177+
this->set_value(std::move(mk_tnsr(_dtype, rank, allocated, aligned, offset, sizes, strides)));
171178
};
172179
ivm[_guid] = {ar, setter};
173180
return ar;

src/Deferred.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <mlir/Dialect/LLVMIR/LLVMDialect.h>
1212

1313
#include <iostream>
14+
#include <unordered_set>
1415

1516
static tbb::concurrent_bounded_queue<Runable::ptr_type> _deferred;
1617

@@ -27,7 +28,7 @@ void _dist(const Runable * p)
2728

2829
Deferred::future_type Deferred::get_future()
2930
{
30-
return {std::move(tensor_i::promise_type::get_future().share()), _guid};
31+
return {std::move(promise_type::get_future().share()), _guid, _dtype, _rank};
3132
}
3233

3334
Deferred::future_type defer_tensor(Runable::ptr_type && _d, bool is_global)
@@ -36,7 +37,7 @@ Deferred::future_type defer_tensor(Runable::ptr_type && _d, bool is_global)
3637
if(!d) throw std::runtime_error("Expected Deferred Tensor promise");
3738
if(is_global) {
3839
_dist(d);
39-
d->_guid = Registry::get_guid();
40+
d->set_guid(Registry::get_guid());
4041
}
4142
auto f = d->get_future();
4243
Registry::put(f);
@@ -59,6 +60,25 @@ void Runable::fini()
5960
_deferred.clear();
6061
}
6162

63+
#if 0
64+
class DepManager
65+
{
66+
private:
67+
IdValueMap _ivm;
68+
std::unordered_set<id_type> _args;
69+
public:
70+
::mlir::Value getDependent(i::mlir::OpBuilder & builder, d_type guid)
71+
{
72+
if(auto d = _ivm.find(guid); d == _ivm.end()) {
73+
_func.insertArg
74+
_ivm[guid] = {val, {}}
75+
} else {
76+
return d->second.first;
77+
}
78+
}
79+
};
80+
#endif
81+
6282
void process_promises()
6383
{
6484
jit::JIT jit;

src/EWBinOp.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
// SPDX-License-Identifier: BSD-3-Clause
22

3-
#include <xtensor/xview.hpp>
4-
using namespace xt::placeholders;
53
#include "ddptensor/EWBinOp.hpp"
64
#include "ddptensor/LinAlgOp.hpp"
75
#include "ddptensor/TypeDispatch.hpp"
8-
#include "ddptensor/x.hpp"
96
#include "ddptensor/Factory.hpp"
107
#include "ddptensor/Registry.hpp"
118
#include "ddptensor/Creator.hpp"
129
#include "ddptensor/TypePromotion.hpp"
1310
#include "ddptensor/CollComm.hpp"
1411
#include "ddptensor/Chunker.hpp"
12+
#include "ddptensor/DDPTensorImpl.hpp"
1513

1614
#include <imex/Dialect/PTensor/IR/PTensorOps.h>
1715
#include <mlir/IR/Builders.h>
@@ -45,6 +43,7 @@ using namespace xt::placeholders;
4543
// above regions and apply the op. All buffers/views get linearized/flattened.
4644
// #######################################################################################
4745

46+
#if 0
4847
namespace x {
4948

5049
// @return true if operation returs bool, false otherwise
@@ -371,6 +370,7 @@ namespace x {
371370
}
372371
};
373372
} // namespace x
373+
#endif // if 0
374374

375375
// convert id of our binop to id of imex::ptensor binop
376376
static ::imex::ptensor::EWBinOpId ddpt2mlir(const EWBinOpId bop)
@@ -443,7 +443,8 @@ struct DeferredEWBinOp : public Deferred
443443

444444
DeferredEWBinOp() = default;
445445
DeferredEWBinOp(EWBinOpId op, const tensor_i::future_type & a, const tensor_i::future_type & b)
446-
: _a(a.id()), _b(b.id()), _op(op)
446+
: Deferred(a.dtype(), a.rank()),
447+
_a(a.id()), _b(b.id()), _op(op)
447448
{}
448449

449450
void run() override
@@ -457,12 +458,11 @@ struct DeferredEWBinOp : public Deferred
457458

458459
::mlir::Value generate_mlir(::mlir::OpBuilder & builder, ::mlir::Location loc, jit::IdValueMap & ivm) override
459460
{
460-
// FIXME the type of the result is hard-coded to uint64_t
461+
// FIXME the type of the result is based on a only
461462
auto rtyp = ivm[_a].first.getType();
462463
auto ewbo = builder.create<::imex::ptensor::EWBinOp>(loc, rtyp, builder.getI32IntegerAttr(ddpt2mlir(_op)), ivm[_a].first, ivm[_b].first);
463464
auto setter = [this](uint64_t rank, void *allocated, void *aligned, intptr_t offset, const intptr_t * sizes, const intptr_t * strides) {
464-
// FIXME GC assert(allocated == aligned);
465-
this->set_value(std::move(x::operatorx<uint64_t>::mk_tx(rank, allocated, aligned, offset, sizes, strides)));
465+
this->set_value(std::move(mk_tnsr(_dtype, rank, allocated, aligned, offset, sizes, strides)));
466466
};
467467
ivm[_guid] = {ewbo, setter};
468468
return ewbo;

src/EWUnyOp.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "ddptensor/EWUnyOp.hpp"
22
#include "ddptensor/TypeDispatch.hpp"
3-
#include "ddptensor/x.hpp"
3+
#include "ddptensor/DDPTensorImpl.hpp"
44
#include "ddptensor/Factory.hpp"
55

6+
#if 0
67
namespace x {
78

89
class EWUnyOp
@@ -108,6 +109,7 @@ namespace x {
108109

109110
};
110111
} //namespace x
112+
#endif // if 0
111113

112114
struct DeferredEWUnyOp : public Deferred
113115
{
@@ -121,8 +123,8 @@ struct DeferredEWUnyOp : public Deferred
121123

122124
void run()
123125
{
124-
const auto a = std::move(Registry::get(_a).get());
125-
set_value(std::move(TypeDispatch<x::EWUnyOp>(a, _op)));
126+
// const auto a = std::move(Registry::get(_a).get());
127+
// set_value(std::move(TypeDispatch<x::EWUnyOp>(a, _op)));
126128
}
127129

128130
FactoryId factory() const

src/IEWBinOp.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#include "ddptensor/IEWBinOp.hpp"
22
#include "ddptensor/TypeDispatch.hpp"
3-
#include "ddptensor/x.hpp"
3+
#include "ddptensor/DDPTensorImpl.hpp"
44
#include "ddptensor/Factory.hpp"
55
#include "ddptensor/Creator.hpp"
66

7+
#if 0
78
namespace x {
89

910
class IEWBinOp
@@ -74,6 +75,7 @@ namespace x {
7475

7576
};
7677
} // namespace x
78+
#endif // if 0
7779

7880
struct DeferredIEWBinOp : public Deferred
7981
{
@@ -88,9 +90,9 @@ struct DeferredIEWBinOp : public Deferred
8890

8991
void run()
9092
{
91-
const auto a = std::move(Registry::get(_a).get());
92-
const auto b = std::move(Registry::get(_b).get());
93-
set_value(std::move(TypeDispatch<x::IEWBinOp>(a, b, _op)));
93+
// const auto a = std::move(Registry::get(_a).get());
94+
// const auto b = std::move(Registry::get(_b).get());
95+
// set_value(std::move(TypeDispatch<x::IEWBinOp>(a, b, _op)));
9496
}
9597

9698
FactoryId factory() const

src/IO.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "ddptensor/SetGetItem.hpp"
33
#include "ddptensor/TypeDispatch.hpp"
44
#include "ddptensor/Factory.hpp"
5+
#include "ddptensor/Transceiver.hpp"
56

67
using promise_type = std::promise<py::object>;
78
using future_type = std::shared_future<py::object>;

src/LinAlgOp.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
//#include <mkl.h>
33
#include "ddptensor/LinAlgOp.hpp"
44
#include "ddptensor/TypeDispatch.hpp"
5-
#include "ddptensor/x.hpp"
5+
#include "ddptensor/DDPTensorImpl.hpp"
66
#include "ddptensor/Factory.hpp"
7-
#include "xtensor-blas/xlinalg.hpp"
87

8+
#if 0
99
namespace x {
1010

1111
template<typename T> struct TGEMM;
@@ -109,6 +109,7 @@ namespace x {
109109
}
110110
};
111111
}
112+
#endif // if 0
112113

113114
struct DeferredLinAlgOp : public Deferred
114115
{
@@ -123,9 +124,9 @@ struct DeferredLinAlgOp : public Deferred
123124

124125
void run()
125126
{
126-
const auto a = std::move(Registry::get(_a).get());
127-
const auto b = std::move(Registry::get(_b).get());
128-
set_value(std::move(TypeDispatch<x::LinAlgOp>(a, b, _axis)));
127+
//const auto a = std::move(Registry::get(_a).get());
128+
//const auto b = std::move(Registry::get(_b).get());
129+
//set_value(std::move(TypeDispatch<x::LinAlgOp>(a, b, _axis)));
129130
}
130131

131132
FactoryId factory() const

src/ManipOp.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#include <mpi.h>
22
#include "ddptensor/ManipOp.hpp"
33
#include "ddptensor/TypeDispatch.hpp"
4-
#include "ddptensor/x.hpp"
4+
#include "ddptensor/DDPTensorImpl.hpp"
55
#include "ddptensor/CollComm.hpp"
66
#include "ddptensor/Factory.hpp"
77

8+
#if 0
89
namespace x {
910

1011
class ManipOp
@@ -23,6 +24,7 @@ namespace x {
2324
}
2425
};
2526
}
27+
#endif // if 0
2628

2729
struct DeferredManipOp : public Deferred
2830
{
@@ -36,8 +38,8 @@ struct DeferredManipOp : public Deferred
3638

3739
void run()
3840
{
39-
const auto a = std::move(Registry::get(_a).get());
40-
set_value(std::move(TypeDispatch<x::ManipOp>(a, _shape)));
41+
//const auto a = std::move(Registry::get(_a).get());
42+
//set_value(std::move(TypeDispatch<x::ManipOp>(a, _shape)));
4143
}
4244

4345
FactoryId factory() const

0 commit comments

Comments
 (0)