GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
lfsr113.h
Go to the documentation of this file.
1 
2  /*
3  ***********************************************************************
4  Copyright (c) 2015 Advanced Micro Devices, Inc.
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without
8  modification, are permitted provided that the following conditions
9  are met:
10 
11  1. Redistributions of source code must retain the above copyright
12  notice, this list of conditions and the following disclaimer.
13 
14  2. Redistributions in binary form must reproduce the above copyright
15  notice, this list of conditions and the following disclaimer in the
16  documentation and/or other materials provided with the distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30  ***********************************************************************
31  */
32 
33 /* @file Lfsr113.h
34 * @brief Specific interface for the Lfsr113 generator
35 * @see clRNG_template.h
36 */
37 
38 #pragma once
39 #ifndef LFSR113_H
40 #define LFSR113_H
41 
42 #include <clRNG/clRNG.h>
43 #include <stdio.h>
44 
45 
46 /* @brief State type of a Lfsr113 stream
47 *
48 * The state is a seed consisting of six unsigned 32-bit integers.
49 *
50 * @see clrngStreamState
51 */
52 typedef struct {
55  cl_uint g[4];
57 
58 
60  union {
61  struct {
63  };
64  struct {
68  };
69  };
70 };
71 
76 
82 
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 
92 
97 
102 
107 
112 
116  CLRNGAPI clrngLfsr113Stream* clrngLfsr113AllocStreams(size_t count, size_t* bufSize, clrngStatus* err);
117 
122 
127 
131  CLRNGAPI clrngLfsr113Stream* clrngLfsr113CreateStreams(clrngLfsr113StreamCreator* creator, size_t count, size_t* bufSize, clrngStatus* err);
132 
136  CLRNGAPI clrngStatus clrngLfsr113CopyOverStreams(size_t count, clrngLfsr113Stream* destStreams, const clrngLfsr113Stream* srcStreams);
137 
142 
143 #define clrngLfsr113RandomU01 _CLRNG_TAG_FPTYPE(clrngLfsr113RandomU01)
144 #define clrngLfsr113RandomInteger _CLRNG_TAG_FPTYPE(clrngLfsr113RandomInteger)
145 #define clrngLfsr113RandomU01Array _CLRNG_TAG_FPTYPE(clrngLfsr113RandomU01Array)
146 #define clrngLfsr113RandomIntegerArray _CLRNG_TAG_FPTYPE(clrngLfsr113RandomIntegerArray)
147 
154 
158  CLRNGAPI cl_int clrngLfsr113RandomInteger(clrngLfsr113Stream* stream, cl_int i, cl_int j);
159  CLRNGAPI cl_int clrngLfsr113RandomInteger_cl_float (clrngLfsr113Stream* stream, cl_int i, cl_int j);
160  CLRNGAPI cl_int clrngLfsr113RandomInteger_cl_double(clrngLfsr113Stream* stream, cl_int i, cl_int j);
161 
166  CLRNGAPI clrngStatus clrngLfsr113RandomU01Array_cl_float (clrngLfsr113Stream* stream, size_t count, cl_float * buffer);
167  CLRNGAPI clrngStatus clrngLfsr113RandomU01Array_cl_double(clrngLfsr113Stream* stream, size_t count, cl_double* buffer);
168 
172  CLRNGAPI clrngStatus clrngLfsr113RandomIntegerArray(clrngLfsr113Stream* stream, cl_int i, cl_int j, size_t count, cl_int* buffer);
173  CLRNGAPI clrngStatus clrngLfsr113RandomIntegerArray_cl_float (clrngLfsr113Stream* stream, cl_int i, cl_int j, size_t count, cl_int* buffer);
174  CLRNGAPI clrngStatus clrngLfsr113RandomIntegerArray_cl_double(clrngLfsr113Stream* stream, cl_int i, cl_int j, size_t count, cl_int* buffer);
175 
180 
185 
190 
194  CLRNGAPI clrngLfsr113Stream* clrngLfsr113MakeSubstreams(clrngLfsr113Stream* stream, size_t count, size_t* bufSize, clrngStatus* err);
195 
200 
204  CLRNGAPI clrngStatus clrngLfsr113AdvanceStreams(size_t count, clrngLfsr113Stream* streams, cl_int e, cl_int c);
205 
209 #ifdef CLRNG_SINGLE_PRECISION
210 #define clrngLfsr113DeviceRandomU01Array(...) clrngLfsr113DeviceRandomU01Array_(__VA_ARGS__, CL_TRUE)
211 #else
212 #define clrngLfsr113DeviceRandomU01Array(...) clrngLfsr113DeviceRandomU01Array_(__VA_ARGS__, CL_FALSE)
213 #endif
214 
218  CLRNGAPI clrngStatus clrngLfsr113DeviceRandomU01Array_(size_t streamCount, cl_mem streams,
219  size_t numberCount, cl_mem outBuffer, cl_uint numQueuesAndEvents,
220  cl_command_queue* commQueues, cl_uint numWaitEvents,
221  const cl_event* waitEvents, cl_event* outEvents, cl_bool singlePrecision);
229 
230 
231 #if 0
232  CLRNGAPI clrngLfsr113Stream* clrngLfsr113GetStreamByIndex(clrngLfsr113Stream* stream, cl_uint index);
233 #endif
234 
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 
241 
242 #endif
CLRNGAPI clrngStatus clrngLfsr113RewindStreamCreator(clrngLfsr113StreamCreator *creator)
Definition: lfsr113.c:121
Library definitions common to all RNG&#39;s.
CLRNGAPI clrngLfsr113StreamCreator * clrngLfsr113CopyStreamCreator(const clrngLfsr113StreamCreator *creator, clrngStatus *err)
Definition: lfsr113.c:90
CLRNGAPI clrngStatus clrngLfsr113SetBaseCreatorState(clrngLfsr113StreamCreator *creator, const clrngLfsr113StreamState *baseState)
Definition: lfsr113.c:129
CLRNGAPI cl_double clrngLfsr113RandomU01_cl_double(clrngLfsr113Stream *stream)
CLRNGAPI clrngStatus clrngLfsr113CreateOverStreams(clrngLfsr113StreamCreator *creator, size_t count, clrngLfsr113Stream *streams)
Definition: lfsr113.c:259
CLRNGAPI clrngLfsr113Stream * clrngLfsr113CreateStreams(clrngLfsr113StreamCreator *creator, size_t count, size_t *bufSize, clrngStatus *err)
Definition: lfsr113.c:274
enum clrngStatus_ clrngStatus
Error codes.
Definition: lfsr113.h:59
clrngLfsr113StreamState states[3]
Definition: lfsr113.h:62
CLRNGAPI clrngStatus clrngLfsr113MakeOverSubstreams(clrngLfsr113Stream *stream, size_t count, clrngLfsr113Stream *substreams)
Definition: device/lfsr113.c.h:259
Definition: lfsr113.h:52
CLRNGAPI clrngStatus clrngLfsr113ForwardToNextSubstreams(size_t count, clrngLfsr113Stream *streams)
Definition: device/lfsr113.c.h:245
#define clrngLfsr113RandomIntegerArray
Definition: lfsr113.h:146
CLRNGAPI clrngStatus clrngLfsr113WriteStreamInfo(const clrngLfsr113Stream *stream, FILE *file)
Definition: lfsr113.c:336
#define clrngLfsr113RandomInteger
Definition: lfsr113.h:144
#define clrngLfsr113RandomU01Array
Definition: lfsr113.h:145
CLRNGAPI clrngStatus clrngLfsr113RandomU01Array_cl_double(clrngLfsr113Stream *stream, size_t count, cl_double *buffer)
CLRNGAPI clrngStatus clrngLfsr113RewindStreams(size_t count, clrngLfsr113Stream *streams)
Definition: device/lfsr113.c.h:129
CLRNGAPI cl_float clrngLfsr113RandomU01_cl_float(clrngLfsr113Stream *stream)
CLRNGAPI clrngLfsr113Stream * clrngLfsr113MakeSubstreams(clrngLfsr113Stream *stream, size_t count, size_t *bufSize, clrngStatus *err)
Definition: lfsr113.c:313
CLRNGAPI clrngStatus clrngLfsr113DestroyStreams(clrngLfsr113Stream *streams)
Definition: lfsr113.c:177
CLRNGAPI cl_int clrngLfsr113RandomInteger_cl_double(clrngLfsr113Stream *stream, cl_int i, cl_int j)
CLRNGAPI clrngStatus clrngLfsr113DestroyStreamCreator(clrngLfsr113StreamCreator *creator)
Definition: lfsr113.c:114
clrngLfsr113StreamState initial
Definition: lfsr113.h:66
CLRNGAPI clrngLfsr113Stream * clrngLfsr113CopyStreams(size_t count, const clrngLfsr113Stream *streams, clrngStatus *err)
Definition: lfsr113.c:292
CLRNGAPI clrngLfsr113Stream * clrngLfsr113AllocStreams(size_t count, size_t *bufSize, clrngStatus *err)
Definition: lfsr113.c:152
#define clrngLfsr113RandomU01
Definition: lfsr113.h:143
#define _CLRNG_FPTYPE
Definition: clRNG.h:314
CLRNGAPI clrngStatus clrngLfsr113RewindSubstreams(size_t count, clrngLfsr113Stream *streams)
Definition: device/lfsr113.c.h:151
CLRNGAPI clrngStatus clrngLfsr113DeviceRandomU01Array_(size_t streamCount, cl_mem streams, size_t numberCount, cl_mem outBuffer, cl_uint numQueuesAndEvents, cl_command_queue *commQueues, cl_uint numWaitEvents, const cl_event *waitEvents, cl_event *outEvents, cl_bool singlePrecision)
Definition: lfsr113.c:361
CLRNGAPI clrngStatus clrngLfsr113RandomU01Array_cl_float(clrngLfsr113Stream *stream, size_t count, cl_float *buffer)
CLRNGAPI clrngStatus clrngLfsr113ChangeStreamsSpacing(clrngLfsr113StreamCreator *creator, cl_int e, cl_int c)
Definition: lfsr113.c:147
CLRNGAPI clrngStatus clrngLfsr113RandomIntegerArray_cl_float(clrngLfsr113Stream *stream, cl_int i, cl_int j, size_t count, cl_int *buffer)
#define CLRNGAPI
Definition: clRNG.h:326
CLRNGAPI clrngStatus clrngLfsr113CopyOverStreams(size_t count, clrngLfsr113Stream *destStreams, const clrngLfsr113Stream *srcStreams)
Definition: device/lfsr113.c.h:45
clrngLfsr113StreamState substream
Definition: lfsr113.h:67
CLRNGAPI clrngStatus clrngLfsr113RandomIntegerArray_cl_double(clrngLfsr113Stream *stream, cl_int i, cl_int j, size_t count, cl_int *buffer)
CLRNGAPI cl_int clrngLfsr113RandomInteger_cl_float(clrngLfsr113Stream *stream, cl_int i, cl_int j)
Definition: lfsr113.c:44
clrngLfsr113StreamState current
Definition: lfsr113.h:65
CLRNGAPI clrngStatus clrngLfsr113AdvanceStreams(size_t count, clrngLfsr113Stream *streams, cl_int e, cl_int c)
Definition: lfsr113.c:331