Skip to content

Commit

Permalink
Add Device and Type (#5)
Browse files Browse the repository at this point in the history
* tmp

* fixed linking, binding module name

* update readme

* add type and device

* fix conflict template var with complex.h

* update loack

* clang

* remove lecary test
  • Loading branch information
kaihsin authored Dec 20, 2024
1 parent d73126e commit 0752c12
Show file tree
Hide file tree
Showing 20 changed files with 1,239 additions and 69 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ Running pytest:
$cd build
$cmake ../ -DCMAKE_INSTALL_PREFIX=<install destination>
```

## For DEV:

1. Please add corresponding .pyi for binded objects/modules to comply with linting.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ authors = [
{ name = "kaihsin", email = "[email protected]" }
]
requires-python = ">=3.10"
dependencies = []
dependencies = [
"numpy>=2.2.0",
]

[tool.scikit-build]
minimum-version = "build-system.requires"
Expand Down
46 changes: 46 additions & 0 deletions src/cpp/include/cytnx_core/Device.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef CYTNX_DEVICE_H_
#define CYTNX_DEVICE_H_

#include <string>
#include <vector>

namespace cytnx_core {

/// @cond
struct __device {
enum __pybind_device { cpu = -1, cuda = 0 };
};

class Device_class {
public:
enum : int { cpu = -1, cuda = 0 };
int Ngpus;
int Ncpus;
std::vector<std::vector<bool>> CanAccessPeer;
Device_class();
void print_property();
std::string getname(const int &device_id);
~Device_class();
// void cudaDeviceSynchronize();
};
/// @endcond

/**
* @brief data on which devices.
*
* @details This is the variable about the data on which devices .\n
* You can use it as following:
* \code
* int device = Device.cpu;
* \endcode
* The supported enumerations are as following:
*
* enumeration | description
* --------------|--------------------
* cpu | -1, on cpu
* cuda | 0, on cuda
*/
extern Device_class Device;
} // namespace cytnx_core

#endif // CYTNX_DEVICE_H_
Loading

0 comments on commit 0752c12

Please sign in to comment.