]> gitweb.factorcode.org Git - factor.git/commitdiff
add SIMDS: ... ; and SPECIALIZED-ARRAYS: ... ; syntax
authorJoe Groff <arcata@gmail.com>
Fri, 9 Oct 2009 15:43:37 +0000 (10:43 -0500)
committerJoe Groff <arcata@gmail.com>
Fri, 9 Oct 2009 15:43:37 +0000 (10:43 -0500)
basis/math/vectors/simd/simd-docs.factor
basis/math/vectors/simd/simd-tests.factor
basis/math/vectors/simd/simd.factor
basis/specialized-arrays/specialized-arrays-docs.factor
basis/specialized-arrays/specialized-arrays-tests.factor
basis/specialized-arrays/specialized-arrays.factor

index c7adcbdd7da6111ce85f40e583b67d80c9d28114..97ff99cd28d67747248156c84e40254f598ac47a 100644 (file)
@@ -37,7 +37,10 @@ ARTICLE: "math.vectors.simd.types" "SIMD vector types"
 "Each SIMD vector type is named " { $snippet "scalar-count" } ", where " { $snippet "scalar" } " is a scalar C type and " { $snippet "count" } " is a vector dimension."
 $nl
 "To use a SIMD vector type, a parsing word is used to generate the relevant code and bring it into the vocabulary search path; this is the same idea as with " { $link "specialized-arrays" } ":"
-{ $subsections POSTPONE: SIMD: }
+{ $subsections
+    POSTPONE: SIMD:
+    POSTPONE: SIMDS:
+}
 "The following vector types are supported:"
 { $code
     "char-16"
@@ -205,4 +208,11 @@ HELP: SIMD:
 { $values { "type" "a scalar C type" } }
 { $description "Defines 128-bit and 256-bit SIMD arrays for holding elements of " { $snippet "type" } " into the vocabulary search path. The possible type/length combinations are listed in " { $link "math.vectors.simd.types" } " and the generated words are documented in " { $link "math.vectors.simd.words" } "." } ;
 
+HELP: SIMDS:
+{ $syntax "SIMDS: type type type ... ;" }
+{ $values { "type" "a scalar C type" } }
+{ $description "Defines 128-bit and 256-bit SIMD arrays for holding elements of each " { $snippet "type" } " into the vocabulary search path. The possible type/length combinations are listed in " { $link "math.vectors.simd.types" } " and the generated words are documented in " { $link "math.vectors.simd.words" } "." } ;
+
+{ POSTPONE: SIMD: POSTPONE: SIMDS: } related-words
+
 ABOUT: "math.vectors.simd"
index 78c938959112956defc8db4a4fbc57901c2f86cf..9e999ba9b705ab218e38aae57ebb6c058b1cc5ca 100644 (file)
@@ -11,15 +11,7 @@ quotations math.constants compiler.units ;
 QUALIFIED-WITH: alien.c-types c
 SPECIALIZED-ARRAY: c:float
 SIMD: c:char
-SIMD: c:uchar
-SIMD: c:short
-SIMD: c:ushort
-SIMD: c:int
-SIMD: c:uint
-SIMD: c:longlong
-SIMD: c:ulonglong
-SIMD: c:float
-SIMD: c:double
+SIMDS: c:uchar c:short c:ushort c:int c:uint c:longlong c:ulonglong c:float c:double ;
 IN: math.vectors.simd.tests
 
 ! Make sure the functor doesn't generate bogus vocabularies
index af04e283f0d48b586d03a8db8abc3d56747bf793..ffa6b5ba1876bad1d4fce40e62d88f059db80c4e 100644 (file)
@@ -37,3 +37,6 @@ PRIVATE>
 SYNTAX: SIMD:
     scan-word define-simd-vocab use-vocab ;
 
+SYNTAX: SIMDS:
+    \ ; parse-until [ define-simd-vocab use-vocab ] each ;
+
index 6c05324ec5a813c1a552593e89d1151b46b49a6e..50e94b65e9a3a675731f6d3fc5eb03b179c57229 100755 (executable)
@@ -6,8 +6,15 @@ HELP: SPECIALIZED-ARRAY:
 { $values { "type" "a C type" } }
 { $description "Brings a specialized array for holding values of " { $snippet "type" } " into the vocabulary search path. The generated words are documented in " { $link "specialized-array-words" } "." } ;
 
+HELP: SPECIALIZED-ARRAYS:
+{ $syntax "SPECIALIZED-ARRAYS: type type type ... ;" }
+{ $values { "type" "a C type" } }
+{ $description "Brings a set of specialized arrays for holding values of each " { $snippet "type" } " into the vocabulary search path. The generated words are documented in " { $link "specialized-array-words" } "." } ;
+
+{ POSTPONE: SPECIALIZED-ARRAY: POSTPONE: SPECIALIZED-ARRAYS: } related-words
+
 ARTICLE: "specialized-array-words" "Specialized array words"
-"The " { $link POSTPONE: SPECIALIZED-ARRAY: } " parsing word generates the specialized array type if it hasn't been generated already, and adds the following words to the vocabulary search path, where " { $snippet "T" } " is the C type in question:"
+"The " { $link POSTPONE: SPECIALIZED-ARRAY: } " and " { $link POSTPONE: SPECIALIZED-ARRAYS: } " parsing words generate specialized array types if they haven't been generated already and add the following words to the vocabulary search path, where " { $snippet "T" } " is the C type in question:"
 { $table
     { { $snippet "T-array" } { "The class of arrays with elements of type " { $snippet "T" } } }
     { { $snippet "<T-array>" } { "Constructor for arrays with elements of type " { $snippet "T" } "; stack effect " { $snippet "( len -- array )" } } }
@@ -18,7 +25,7 @@ ARTICLE: "specialized-array-words" "Specialized array words"
     { { $snippet ">T-array" } { "Converts a sequence into a specialized array of type " { $snippet "T" } "; stack effect " { $snippet "( seq -- array )" } } }
     { { $snippet "T-array{" } { "Literal syntax, consists of a series of values terminated by " { $snippet "}" } } }
 }
-"Behind the scenes, these words are placed in a vocabulary named " { $snippet "specialized-arrays.instances.T" } ", however this vocabulary should not be placed in a " { $link POSTPONE: USING: } " form directly. Instead, always use " { $link POSTPONE: SPECIALIZED-ARRAY: } ". This ensures that the vocabulary can get generated the first time it is needed." ;
+"Behind the scenes, these words are placed in a vocabulary named " { $snippet "specialized-arrays.instances.T" } ", however this vocabulary should not be placed in a " { $link POSTPONE: USING: } " form directly. Instead, always use " { $link POSTPONE: SPECIALIZED-ARRAY: } " or " { $link POSTPONE: SPECIALIZED-ARRAYS: } ". This ensures that the vocabulary can get generated the first time it is needed." ;
 
 ARTICLE: "specialized-array-c" "Passing specialized arrays to C functions"
 "If a C function is declared as taking a parameter with a pointer or an array type (for example, " { $snippet "float*" } " or " { $snippet "int[3]" } "), instances of the relevant specialized array can be passed in."
@@ -80,7 +87,10 @@ ARTICLE: "specialized-arrays" "Specialized arrays"
 "The " { $vocab-link "specialized-arrays" } " vocabulary implements fixed-length sequence types for storing machine values in a space-efficient manner without boxing."
 $nl
 "A specialized array type needs to be generated for each element type. This is done with a parsing word:"
-{ $subsections POSTPONE: SPECIALIZED-ARRAY: }
+{ $subsections
+    POSTPONE: SPECIALIZED-ARRAY:
+    POSTPONE: SPECIALIZED-ARRAYS:
+}
 "This parsing word adds new words to the search path, documented in the next section."
 { $subsections
     "specialized-array-words"
index b7d3371f45b5aaa499d1f68f874853672d34f88a..07a457db5c646d5873e2f20ac97102104055dfaa 100755 (executable)
@@ -8,12 +8,7 @@ assocs prettyprint alien.data math.vectors ;
 FROM: alien.c-types => float ;
 
 SPECIALIZED-ARRAY: int
-SPECIALIZED-ARRAY: bool
-SPECIALIZED-ARRAY: ushort
-SPECIALIZED-ARRAY: char
-SPECIALIZED-ARRAY: uint
-SPECIALIZED-ARRAY: float
-SPECIALIZED-ARRAY: ulonglong
+SPECIALIZED-ARRAYS: bool ushort char uint float ulonglong ;
 
 [ ulonglong ] [ ulonglong-array{ } element-type ] unit-test
 
index b8a3332600ecf340023a61c685e8544ddf2dca0b..a3d24c10c2454e01375cde9732c4c0973741d997 100755 (executable)
@@ -154,6 +154,9 @@ M: c-type-name c-direct-array-constructor
     dup [ "<direct-" "-array>" surround ] [ specialized-array-vocab ] bi lookup
     [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable
 
+SYNTAX: SPECIALIZED-ARRAYS:
+    ";" parse-tokens [ parse-c-type define-array-vocab use-vocab ] each ;
+
 SYNTAX: SPECIALIZED-ARRAY:
     scan-c-type define-array-vocab use-vocab ;