| … | … | @@ -60,7 +60,7 @@ that accepts (recognizes) `(Plus a b)` and turns it into |
| 60 | 60 | (Section (Item "vec_add") |
| 61 | 61 | (FloatValue rslt) (FloatValue a) (FloatValue b)) |
| 62 | 62 | ---- |
| 63 | Well, not that literally, because we'd have to wire `rslt` into | |
| 63 | Well, not quite that literally, because we'd have to wire `rslt` into | |
| 64 | 64 | something; its more complicated. Also `Plus` is unbounded, so it would |
| 65 | 65 | need to be some arithmetic fold. But you get the idea... |
| 66 | 66 | |
| … | … | @@ -122,3 +122,7 @@ bottom (i.e. depth-first), are some multi-pass width-first appreach. |
| 122 | 122 | Width-first is a bit more compatible with lazy evaluation. But |
| 123 | 123 | width-first algos are notoriously more complicated than |
| 124 | 124 | recursive-descent, depth-first algos. Hmmm. |
| 125 | ||
| 126 | Realistic Examples | |
| 127 | ------------------ | |
| 128 | Some realistic examples, illustrating the problems above, are needed... |
| … | … | @@ -1,7 +1,11 @@ |
| 1 | 1 | OpenCL Examples |
| 2 | 2 | =============== |
| 3 | 3 | |
| 4 | Two example: | |
| 4 | Four examples: | |
| 5 | * `vec-kernel.cl`: two very simple OpenCL kernels, used for the Atomese | |
| 6 | examples, below. These implement vector addition and vector | |
| 7 | multiplicattion. | |
| 8 | ||
| 5 | 9 | * `atomese-kernel.scm` demonstrates how to use Atomese to open a channel |
| 6 | 10 | to an OpenCL device, and then send a compute kernel and some floating- |
| 7 | 11 | point vector data to it. The results from the computation are pulled |
| … | … | @@ -12,3 +16,6 @@ Two example: |
| 12 | 16 | AtomSpace which shadows a vector held on the GPU. That is, the vector |
| 13 | 17 | "lives" on the GPU, and is downloaded back to to the system when |
| 14 | 18 | it is "examined", e.g. to be printed to stdout. |
| 19 | ||
| 20 | * `dot-product-bad.scm` under development; eventually meant to be a | |
| 21 | "realistic" example of a dot product. Doesn't work right now. |
| … | … | @@ -0,0 +1,18 @@ |
| 1 | ; | |
| 2 | ; dot-product-bad.scm | |
| 3 | ; | |
| 4 | ; An example of taking dot products between a pair of vectors. | |
| 5 | ; Its "bad" in that this example does not quite work yet, at least, | |
| 6 | ; not in the way in which it's desired to work. | |
| 7 | ; | |
| 8 | (use-modules (opencog) (opencog exec)) | |
| 9 | ||
| 10 | (cog-set-value! (Anchor "location") (Predicate "vetor-pairs") | |
| 11 | (LinkValue | |
| 12 | (FloatValue 1 2 3 4 5) | |
| 13 | (FloatValue 1 1 1 2 2))) | |
| 14 | ||
| 15 | (define pair-location | |
| 16 | (FloatValueOf (Anchor "location") (Predicate "vetor-pairs"))) | |
| 17 | ||
| 18 | (cog-execute! (Plus pair-location)) |