-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding ground work for cpp-zarr tests
- Loading branch information
1 parent
5e249bc
commit 10741c9
Showing
8 changed files
with
102 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.DS_Store | ||
zarr_libraries/example_data/* | ||
__pycache__/ | ||
.vscode/ | ||
.vscode/ | ||
example_data/ | ||
build/ | ||
test.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
project(cpp-zarr) | ||
cmake_policy(SET CMP0057 NEW) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
# finding the cppZarr lib | ||
find_library(cppZarrLib cppZarr REQUIRED) | ||
|
||
# setting include dir for dependencies | ||
include_directories(/usr/local/include) | ||
|
||
# pybind11 | ||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development) | ||
include_directories(${Python3_INCLUDE_DIRS}) | ||
|
||
find_package(pybind11 REQUIRED) | ||
include_directories(${pybind11_INCLUDE_DIR}) | ||
|
||
pybind11_add_module(pyCppZarr zarr_libraries/cpp_zarr/cpp_zarr.cpp) | ||
target_link_libraries(pyCppZarr PRIVATE ${cppZarrLib}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
from zarr_libraries.common import * | ||
from zarr_libraries.tensorstore.tensorstore_zarr import * | ||
from zarr_libraries.zarr_python.zarr_python import * | ||
from zarr_libraries.ome_ngff.ome_zarr import * | ||
from zarr_libraries.ome_ngff.ome_zarr import * | ||
# pybind11 | ||
import build.pyCppZarr | ||
from build.pyCppZarr import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <filesystem> | ||
#include <time.h> | ||
#include "zarr.h" | ||
#include "parallelwritezarr.h" | ||
#include <pybind11/pybind11.h> | ||
|
||
namespace py = pybind11; | ||
using namespace std; | ||
|
||
class Cpp_Zarr | ||
{ | ||
public: | ||
Cpp_Zarr() = default; | ||
|
||
int write_zarr() | ||
{ | ||
const vector<uint64_t> startCoords{0, 0, 0}; | ||
const vector<uint64_t> endCoords{64, 1920, 1920}; | ||
const vector<uint64_t> writeShape({endCoords[0] - startCoords[0], | ||
endCoords[1] - startCoords[1], | ||
endCoords[2] - startCoords[2]}); | ||
|
||
// random data | ||
size_t arrSize = writeShape[0] * writeShape[1] * writeShape[2]; | ||
void *zarrArr = malloc(arrSize * sizeof(uint8_t)); | ||
srand((unsigned int)time(NULL)); | ||
for (size_t i = 0; i < arrSize; i++) | ||
{ | ||
((uint8_t *)zarrArr)[i] = (uint8_t)(rand() % (UINT8_MAX + 1)); | ||
} | ||
|
||
// creat zarr object | ||
zarr zarrObject; | ||
|
||
zarrObject.set_fileName("/home/chris/code/zarr-writers-benchmark/test.zarr"); | ||
zarrObject.set_dtype("<u1"); | ||
zarrObject.set_shape(writeShape); | ||
zarrObject.set_chunks({64, 256, 256}); | ||
zarrObject.set_chunkInfo(startCoords, endCoords); | ||
zarrObject.set_fill_value(1); | ||
zarrObject.set_order("C"); | ||
zarrObject.set_dimension_separator("/"); | ||
zarrObject.write_zarray(); | ||
|
||
parallelWriteZarr(zarrObject, zarrArr, startCoords, endCoords, writeShape, 8, true, false); | ||
|
||
free(zarrArr); | ||
|
||
return 0; | ||
} | ||
}; | ||
|
||
PYBIND11_MODULE(pyCppZarr, handle) | ||
{ | ||
py::class_<Cpp_Zarr>( | ||
handle, "Cpp_Zarr") | ||
.def(py::init<>()) | ||
.def("write_zarr", &Cpp_Zarr::write_zarr); | ||
} |