| 1 | // Copyright (C) 2013 Altera Corporation, San Jose, California, USA. All rights reserved.
|
|---|
| 2 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|---|
| 3 | // software and associated documentation files (the "Software"), to deal in the Software
|
|---|
| 4 | // without restriction, including without limitation the rights to use, copy, modify, merge,
|
|---|
| 5 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to
|
|---|
| 6 | // whom the Software is furnished to do so, subject to the following conditions:
|
|---|
| 7 | // The above copyright notice and this permission notice shall be included in all copies or
|
|---|
| 8 | // substantial portions of the Software.
|
|---|
| 9 | //
|
|---|
| 10 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|---|
| 11 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|---|
| 12 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|---|
| 13 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|---|
| 14 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|---|
| 15 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|---|
| 16 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|---|
| 17 | // OTHER DEALINGS IN THE SOFTWARE.
|
|---|
| 18 | //
|
|---|
| 19 | // This agreement shall be governed in all respects by the laws of the State of California and
|
|---|
| 20 | // by the laws of the United States of America.
|
|---|
| 21 |
|
|---|
| 22 | // ACL kernel for adding two input vectors
|
|---|
| 23 | __kernel void vectorAdd(__global const float *x,
|
|---|
| 24 | __global const float *y,
|
|---|
| 25 | __global float *restrict z)
|
|---|
| 26 | {
|
|---|
| 27 | // get index of the work item
|
|---|
| 28 | int index = get_global_id(0);
|
|---|
| 29 |
|
|---|
| 30 | // add the vector elements
|
|---|
| 31 | z[index] = x[index] + y[index];
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|