/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2010-2012, 2014, 2019, 2021 Université de Bordeaux 1
* Copyright (C) 2010-2014 Centre National de la Recherche Scientifique
*
* StarPU is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* StarPU is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU Lesser General Public License in COPYING.LGPL for more details.
*/
#include
#define NX 2048
/* This kernel takes a buffer and scales it by a constant factor */
void vector_scal_cpu(float *val, unsigned n, float factor)
{
unsigned i;
/* scale the vector */
for (i = 0; i < n; i++)
val[i] *= factor;
}
int main(void)
{
/* We consider a vector of float that is initialized just as any of C
* data */
float *vector;
unsigned i;
vector = malloc(sizeof(vector[0]) * NX);
for (i = 0; i < NX; i++)
vector[i] = 1.0f;
fprintf(stderr, "BEFORE : First element was %f\n", vector[0]);
float factor = 3.14;
vector_scal_cpu(vector, NX, factor);
fprintf(stderr, "AFTER First element is %f\n", vector[0]);
return 0;
}