Skip to content

Commit 4487a6d

Browse files
authored
Merge pull request #3 from daphne-eu/main
update fork repository
2 parents 01cc9ec + ec01933 commit 4487a6d

File tree

77 files changed

+853
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+853
-363
lines changed

containers/daphne-dev.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ RUN apt-get -qq -y update && apt-get -y upgrade && apt-get -y --no-install-recom
3434
vim nano rsync sudo iputils-ping virtualenv openssh-server iproute2 git htop gdb lldb lld gpg-agent net-tools \
3535
software-properties-common ca-certificates file unzip wget tar zstd \
3636
ccache python3-pip python3-networkx python3-dev graphviz-dev clang-format \
37+
libbz2-dev libnsl-dev libncurses5-dev libncursesw5-dev \
3738
&& apt-get clean && rm -rf /var/lib/apt/lists/*
3839

3940
COPY --from=daphneeu/daphne-deps /usr/local/bin/ /usr/local/bin/

doc/DaphneLib/Overview.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ More precisely, DAPHNE matrices and frames can be obtained in the following ways
131131
- generating data in DAPHNE (e.g., random data, constants, or sequences)
132132
- reading files using DAPHNE's readers (e.g., CSV, Matrix Market, Parquet, DAPHNE binary format)
133133

134-
A comprehensive list can be found in the [DaphneLib API reference](/doc/DaphneLib/APIRef.md#daphnecontext).
134+
A comprehensive list can be found in the [DaphneLib API reference](/doc/DaphneLib/APIRef.md#daphnecontext-api-reference).
135135

136136
## Building Complex Computations
137137

@@ -241,6 +241,10 @@ If the result of the computation in DAPHNE is a matrix, `compute()` returns a `n
241241
242242
So far, DaphneLib can exchange data with numpy, pandas, TensorFlow, and PyTorch.
243243
By default, the data transfer is via shared memory (and in many cases zero-copy).
244+
Numpy and pandas are *required* dependencies for DaphneLib, so they should anyway be installed.
245+
TensorFlow and PyTorch are *optional* for DaphneLib; if these libraries are not installed, DaphneLib cannot exchange data with them, but all remaining features still work.
246+
In case you run DAPHNE inside the [`daphne-dev` container](/doc/GettingStarted.md), please note that TensorFlow and PyTorch are *not* included in the `daphne-dev` container due to their large footprint.
247+
Please follow the [instructions](/doc/development/InstallPythonLibsInContainer.md) on installing Python libraries in the `daphne-dev` container if you need them.
244248
245249
### Data Exchange with numpy
246250

doc/Extensions.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ make
173173
### Step 3: Using a Kernel Extension
174174

175175
The kernels in a kernel extension can be used either automatically by DAPHNE or manually by the user.
176-
Automatic use is currently restricted to the selection of the kernel based on result/argument data/value types, but in the future we plan to support custom cost models as well.
177-
Besides that, the manual employment of custom kernels is very useful for experimentation, e.g., to see the impact of the kernel in the context of a larger integrated data analysis pipeline.
178-
To this end, DaphneDSL [compiler hints](/doc/DaphneDSL/LanguageRef.md#compiler-hints) tell DAPHNE to use a specific kernel, even though DAPHNE's optimizing compiler may not choose the kernel, otherwise.
176+
The manual use has precedence over the automatic use.
177+
178+
#### Manual Use of Custom Kernels
179+
180+
The manual employment of custom kernels is very useful for experimentation, e.g., to see the impact of a particular kernel at a certain point of a larger integrated data analysis pipeline.
181+
To this end, DaphneDSL [compiler hints](/doc/DaphneDSL/LanguageRef.md#compiler-hints) tell DAPHNE to use a specific kernel in a specific place, even though DAPHNE's optimizing compiler may not choose the kernel, otherwise.
179182

180183
*Running example:*
181184

@@ -205,7 +208,7 @@ s = sum::mySumSeq(X);
205208
print(s);
206209
```
207210

208-
We execute this script with the following command, whereby the argument `--kernel-ext` specified the kernel catalog JSON file of the extension to use:
211+
We execute this script with the following command, whereby the argument `--kernel-ext` specifies the kernel catalog JSON file of the extension to use:
209212
```bash
210213
bin/daphne --kernel-ext scripts/examples/extensions/myKernels/myKernels.json scripts/examples/extensions/myKernels/demoSeq.daphne
211214
```
@@ -222,4 +225,27 @@ print(s);
222225
We execute this script by:
223226
```bash
224227
bin/daphne --kernel-ext scripts/examples/extensions/myKernels/myKernels.json scripts/examples/extensions/myKernels/demoSIMD.daphne
228+
```
229+
230+
#### Automatic Use of Custom Kernels
231+
232+
The automatic use of custom kernels is currently restricted to the selection of a kernel based on its result/argument data/value types and its priority level.
233+
In the future we plan to support custom cost models as well.
234+
235+
*Running example:*
236+
237+
Continuing the running example from above, we can make DAPHNE use the custom kernels `mySumSeq()` or `mySumSIMD()` even without a manual kernel hint by specifying a suitable *priority* when registering the `myKernels` extension with DAPHNE.
238+
239+
Priority levels can optionally be specified with the `--kernel-ext` command line argument by appending a colon (`:`) followed by the priority as an integer.
240+
The default priority of `0` is used for all built-in kernels and for extension kernels in case no priority is specified.
241+
When registering a kernel extension, the given priority is assigned to *all* kernels provided by the extension.
242+
When multiple kernels are applicable for an operation based on the combination of argument/result data/value types as well as the backend, DAPHNE chooses the kernel with the highest priority.
243+
If there are multiple kernels with the highest priority, it is not specified which of them is used.
244+
245+
By registering a kernel extension with a priority greater than zero, one can enforce that the kernels provided by the extension are always preferred over the built-in ones whenever they are applicable.
246+
For instance, the following command registers the `myKernels` extension with a priority of `1`.
247+
As the `myKernels` extension provides two kernels for the same operation, argument/result types, and backend, we cannot tell, based on priorities, which of these kernels will be used, but we can be sure that the built-in kernel will not be employed.
248+
249+
```bash
250+
bin/daphne --kernel-ext scripts/examples/extensions/myKernels/myKernels.json:1 scripts/examples/extensions/myKernels/demo.daphne
225251
```

doc/GettingStarted.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ git clone https://github.com/daphne-eu/daphne.git
125125

126126
<!-- TODO assumes X86-64 is correct -->
127127

128-
The development container image already contains all necessary dependencies of a DAPHNE development environment as well as a useful initialization of environment variables etc., such that you don't need to worry about these things and can have a productive start.
128+
The development container image already contains all necessary (¹) dependencies of a DAPHNE development environment as well as a useful initialization of environment variables etc., such that you don't need to worry about these things and can have a productive start.
129129

130130
**Get the container image**
131131

@@ -136,6 +136,8 @@ docker pull daphneeu/daphne-dev:latest_X86-64_BASE
136136

137137
***Hint:** You may want to choose another image tag based on your platform and needs, e.g., `latest_X86-64_CUDA` (for GPU support) or `latest_ARMV8_BASE` (for ARM support).*
138138

139+
***Hint:** (¹) TensorFlow and PyTorch are *optional* for DaphneLib and *not included* in the `daphne-dev`container due to their footprint of several gigabytes. Please follow the [instructions](/doc/development/InstallPythonLibsInContainer.md) on installing Python libraries in the `daphne-dev` container if you need these libraries.*
140+
139141
**Enter the container**, which should finally print something like the following (where `xyz` is your user name on your system, and the password and IP address may vary):
140142

141143
```bash

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- [Logging in DAPHNE](/doc/development/Logging.md)
3737
- [Profiling in DAPHNE](/doc/development/Profiling.md)
3838
- [Testing](/doc/development/Testing.md)
39+
- [Installing Python Libraries in the `daphne-dev` Container](/doc/development/InstallPythonLibsInContainer.md)
3940

4041
### Source Code Documentation
4142

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!--
2+
Copyright 2025 The DAPHNE Consortium
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
# Installing Python Libraries in the `daphne-dev` Container
18+
19+
The `daphne-dev` container (see [GettingStarted](/doc/GettingStarted.md)) already contains all *required* dependencies for running DAPHNE. However, there can be reasons to install additional Python libraries inside the container, e.g.:
20+
21+
1. **To use/test DaphneLib's data exchange with TensorFlow and PyTorch.**
22+
DaphneLib, DAPHNE's Python API, supports the efficient data exchange with widely-used Python libraries like numpy, pandas, TensorFlow, and PyTorch.
23+
Numpy and pandas are required for DaphneLib.
24+
Thus, they are already installed in the `daphne-dev` container.
25+
In contrast to that, TensorFlow and PyTorch are optional for DaphneLib; if these libraries are not installed on the system, DaphneLib cannot exchange data with them, but all remaining features still work.
26+
Likewise, the test cases related to the data exchange with TensorFlow and PyTorch will only run if these libraries are installed.
27+
As TensorFlow and PyTorch would increase the `daphne-dev` container size by several gigabytes, they are *not* included in the container.
28+
1. **To add support for additional Python libraries in DaphneLib.**
29+
For instance, while implementing efficient data exchange with these additional libraries.
30+
1. **To build integrated data analysis pipelines involving additional Python libraries.**
31+
For instance, for experiments.
32+
33+
## Installing Additional Python Libraries
34+
35+
Additional Python libraries are best installed in a *Python virtual environment* inside the `daphne-dev` container.
36+
To that end, execute the following commands inside the container:
37+
38+
**Create a Python virtual environment and activate it:**
39+
40+
```bash
41+
sudo apt update
42+
sudo apt install python3.12-venv
43+
python3 -m venv daphne-venv
44+
source daphne-venv/bin/activate
45+
```
46+
47+
Here, we call the virtual environment `daphne-venv`.
48+
Feel free to choose a different name.
49+
50+
**Install the desired Python libraries using `pip`:**
51+
52+
For instance, if you want to use/test DaphneLib's efficient data transfer with widely-used Python libraries like numpy, pandas, TensorFlow, and PyTorch, install the following libraries.
53+
Feel free to install any library you like.
54+
55+
```bash
56+
pip install numpy pandas tensorflow torch
57+
```
58+
59+
The libraries you install that way will be stored in the `daphne-venv` directory on the host and, thus, keep existing after you shut down the container.
60+
61+
## Don't Forget
62+
63+
Every time you enter the `daphne-dev` container, make sure to activate the Python virtual environment again:
64+
65+
```bash
66+
source daphne-venv/bin/activate
67+
```

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ nav:
6565
- FPGAconfiguration.md
6666
- MPI-Usage.md
6767
- Profiling.md
68+
- 'Custom Extensions': Extensions.md
6869
- 'Developers':
6970
- development/Contributing.md
7071
- development/BuildingDaphne.md
@@ -79,3 +80,4 @@ nav:
7980
- development/Profiling.md
8081
- development/WriteDocs.md
8182
- development/Testing.md
83+
- development/InstallPythonLibsInContainer.md

scripts/examples/dnn-conv2d.daph

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ ema_var = rand(F, 1, 1.0, 1.0, 1.0, seed);
5959
eps = 0.00001;
6060

6161
t_start_conv = now();
62-
X_conv, Hout, Wout = conv2d(X, W, N, F, Isize, Isize, Fsize, Fsize, 1, 1, 1, 1, b);
62+
X_conv, Hout, Wout = conv2d(X, W, N, C, Isize, Isize, Fsize, Fsize, 1, 1, 1, 1, b);
6363
t_end_conv = now();
6464
X_bn = batch_norm2d(X_conv, gamma, beta, ema_mean, ema_var, eps);
6565
t_end_bn = now();

src/api/cli/DaphneUserConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct DaphneUserConfig {
7777
bool explain_mlir_codegen_sparsity_exploiting_op_fusion = false;
7878
bool explain_mlir_codegen_daphneir_to_mlir = false;
7979
bool explain_mlir_codegen_mlir_specific = false;
80-
bool statistics = false;
80+
bool enable_statistics = false;
8181

8282
bool force_cuda = false;
8383

src/api/internal/daphne_internal.cpp

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ int startDAPHNE(int argc, const char **argv, DaphneLibResult *daphneLibRes, int
499499
}
500500
}
501501

502-
user_config.statistics = enableStatistics;
502+
user_config.enable_statistics = enableStatistics;
503503

504504
if (user_config.use_distributed && distributedBackEndSetup == ALLOCATION_TYPE::DIST_MPI) {
505505
#ifndef USE_MPI
@@ -571,14 +571,48 @@ int startDAPHNE(int argc, const char **argv, DaphneLibResult *daphneLibRes, int
571571
// ************************************************************************
572572

573573
KernelCatalog &kc = executor.getUserConfig().kernelCatalog;
574-
// kc.dump();
575-
KernelCatalogParser kcp(mctx);
576-
kcp.parseKernelCatalog(user_config.libdir + "/catalog.json", kc);
577-
if (user_config.use_cuda)
578-
kcp.parseKernelCatalog(user_config.libdir + "/CUDAcatalog.json", kc);
579-
// kc.dump();
580-
if (!kernelExt.empty())
581-
kcp.parseKernelCatalog(kernelExt, kc);
574+
try {
575+
// kc.dump();
576+
KernelCatalogParser kcp(mctx);
577+
kcp.parseKernelCatalog(user_config.libdir + "/catalog.json", kc, 0);
578+
if (user_config.use_cuda)
579+
kcp.parseKernelCatalog(user_config.libdir + "/CUDAcatalog.json", kc, 0);
580+
// kc.dump();
581+
if (!kernelExt.empty()) {
582+
std::string extCatalogFile;
583+
int64_t extPriority;
584+
585+
const std::string prioritySep = ":";
586+
const size_t pos = kernelExt.rfind(prioritySep);
587+
if (pos != std::string::npos) { // a priority was specified for the extension
588+
extCatalogFile = kernelExt.substr(0, pos);
589+
const std::string extPriorityStr(kernelExt.substr(pos + prioritySep.size()));
590+
try {
591+
size_t idx;
592+
extPriority = std::stoll(extPriorityStr, &idx);
593+
if (idx != extPriorityStr.size())
594+
// stoll() did not consume all characters in extPriorityStr, there is some non-integer part at
595+
// the end of the string.
596+
throw std::runtime_error(""); // the error message is generated in the catch-block below
597+
} catch (std::exception &e) {
598+
throw std::runtime_error("invalid priority for kernel extension, expected an integer after the '" +
599+
prioritySep + "', but found '" + extPriorityStr + "': '" + kernelExt +
600+
"'");
601+
}
602+
} else { // no priority was specified for the extension
603+
extCatalogFile = kernelExt;
604+
extPriority = 0;
605+
}
606+
607+
kcp.parseKernelCatalog(extCatalogFile, kc, extPriority);
608+
}
609+
} catch (std::exception &e) {
610+
logErrorDaphneLibAware(daphneLibRes, "Parser error: " + std::string(e.what()));
611+
return StatusCode::PARSER_ERROR;
612+
} catch (...) {
613+
logErrorDaphneLibAware(daphneLibRes, "Parser error: Unknown exception");
614+
return StatusCode::PARSER_ERROR;
615+
}
582616

583617
// ************************************************************************
584618
// Parse, compile and execute DaphneDSL script
@@ -671,7 +705,7 @@ int startDAPHNE(int argc, const char **argv, DaphneLibResult *daphneLibRes, int
671705
std::cerr << "}" << std::endl;
672706
}
673707

674-
if (user_config.statistics)
708+
if (user_config.enable_statistics)
675709
Statistics::instance().dumpStatistics(KernelDispatchMapping::instance());
676710

677711
// explicitly destroying the moduleOp here due to valgrind complaining about

0 commit comments

Comments
 (0)