Browse Source

Basic Structure

Adam Kelly 6 years ago
commit
ba23073a79
8 changed files with 56 additions and 0 deletions
  1. 3 0
      .gitignore
  2. 6 0
      Cargo.toml
  3. 0 0
      README.md
  4. 3 0
      src/backends/mod.rs
  5. 26 0
      src/backends/opencl/mod.rs
  6. 2 0
      src/gate.rs
  7. 7 0
      src/lib.rs
  8. 9 0
      src/traits.rs

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+/target
+**/*.rs.bk
+Cargo.lock

+ 6 - 0
Cargo.toml

@@ -0,0 +1,6 @@
+[package]
+name = "qcgpu"
+version = "1.0.0"
+authors = ["Adam Kelly <adamkelly2201@gmail.com>"]
+
+[dependencies]

+ 0 - 0
README.md


+ 3 - 0
src/backends/mod.rs

@@ -0,0 +1,3 @@
+mod opencl;
+
+pub use self::opencl::OpenCL;

+ 26 - 0
src/backends/opencl/mod.rs

@@ -0,0 +1,26 @@
+use traits::Backend;
+use gate::Gate;
+
+use std::collections::HashMap;
+
+pub struct OpenCL {
+
+}
+
+impl Backend for OpenCL {
+  fn apply_gate(&mut self, gate: Gate, target: u8) {
+
+  }
+
+  fn apply_controlled_gate(&mut self, gate: Gate, control: u8, target: u8) {
+
+  } 
+
+  fn measure(&mut self) -> u8 {
+    1
+  }
+
+  fn measure_many(&mut self, iters: u64) -> HashMap<u8, u64> {
+    HashMap::new()
+  }
+}

+ 2 - 0
src/gate.rs

@@ -0,0 +1,2 @@
+pub struct Gate { 
+}

+ 7 - 0
src/lib.rs

@@ -0,0 +1,7 @@
+pub mod gate;
+pub mod traits;
+pub mod backends;
+
+pub struct Simulator {
+    backend: Box<traits::Backend>
+}

+ 9 - 0
src/traits.rs

@@ -0,0 +1,9 @@
+use gate::Gate;
+use std::collections::HashMap;
+
+pub trait Backend {
+    fn apply_gate(&mut self, gate: Gate, target: u8);
+    fn apply_controlled_gate(&mut self, gate: Gate, control: u8, target: u8);
+    fn measure(&mut self) -> u8;
+    fn measure_many(&mut self, iters: u64) -> HashMap<u8, u64>;
+}