OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomese-simd commits / b616217

Start work on a more challenging example
b616217577888fd37b056a19bc9f245293a391aa
by Linas Vepštas <linasvepstas@gmail.com> · 2025-09-12T16:34:45.000Z

Changed files (3) +31 -2

Design-E.md +5 -1
……@@ -60,7 +60,7 @@ that accepts (recognizes) `(Plus a b)` and turns it into
6060 (Section (Item "vec_add")
6161 (FloatValue rslt) (FloatValue a) (FloatValue b))
6262----
63Well, not that literally, because we'd have to wire `rslt` into
63Well, not quite that literally, because we'd have to wire `rslt` into
6464something; its more complicated. Also `Plus` is unbounded, so it would
6565need to be some arithmetic fold. But you get the idea...
6666
……@@ -122,3 +122,7 @@ bottom (i.e. depth-first), are some multi-pass width-first appreach.
122122Width-first is a bit more compatible with lazy evaluation. But
123123width-first algos are notoriously more complicated than
124124recursive-descent, depth-first algos. Hmmm.
125
126Realistic Examples
127------------------
128Some realistic examples, illustrating the problems above, are needed...
examples/README.md +8 -1
……@@ -1,7 +1,11 @@
11OpenCL Examples
22===============
33
4Two example:
4Four 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
59* `atomese-kernel.scm` demonstrates how to use Atomese to open a channel
610 to an OpenCL device, and then send a compute kernel and some floating-
711 point vector data to it. The results from the computation are pulled
……@@ -12,3 +16,6 @@ Two example:
1216 AtomSpace which shadows a vector held on the GPU. That is, the vector
1317 "lives" on the GPU, and is downloaded back to to the system when
1418 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.
examples/dot-product-bad.scm +18 -0
……@@ -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))