Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Device and Type #5

Merged
merged 9 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading