浏览代码

examples/spmv: fix datatypes for opencl kernel

Nathalie Furmento 13 年之前
父节点
当前提交
9f4255e6dc
共有 2 个文件被更改,包括 14 次插入16 次删除
  1. 8 8
      examples/spmv/spmv_kernels.c
  2. 6 8
      examples/spmv/spmv_opencl.cl

+ 8 - 8
examples/spmv/spmv_kernels.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009, 2010, 2011  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  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
@@ -28,18 +28,18 @@ void spmv_kernel_opencl(void *descr[], void *args)
 	cl_event event;
 	int id, devid, err, n;
 
-	uint32_t nnz = STARPU_CSR_GET_NNZ(descr[0]);
-	uint32_t nrow = STARPU_CSR_GET_NROW(descr[0]);
+	int nnz = (int) STARPU_CSR_GET_NNZ(descr[0]);
+	int nrow = (int) STARPU_CSR_GET_NROW(descr[0]);
 	cl_mem nzval = (cl_mem)STARPU_CSR_GET_NZVAL(descr[0]);
-	uint32_t *colind = STARPU_CSR_GET_COLIND(descr[0]);
-	uint32_t *rowptr = STARPU_CSR_GET_ROWPTR(descr[0]);
-	uint32_t firstentry = STARPU_CSR_GET_FIRSTENTRY(descr[0]);
+	cl_mem colind = (cl_mem)STARPU_CSR_GET_COLIND(descr[0]);
+	cl_mem rowptr = (cl_mem)STARPU_CSR_GET_ROWPTR(descr[0]);
+	int firstentry = STARPU_CSR_GET_FIRSTENTRY(descr[0]);
 
 	cl_mem vecin = (cl_mem)STARPU_VECTOR_GET_DEV_HANDLE(descr[1]);
-	uint32_t nx_in = STARPU_VECTOR_GET_NX(descr[1]);
+	int nx_in = (int)STARPU_VECTOR_GET_NX(descr[1]);
 
 	cl_mem vecout = (cl_mem)STARPU_VECTOR_GET_DEV_HANDLE(descr[2]);
-	uint32_t nx_out = STARPU_VECTOR_GET_NX(descr[2]);
+	int nx_out = (int)STARPU_VECTOR_GET_NX(descr[2]);
 
         id = starpu_worker_get_id();
         devid = starpu_worker_get_devid(id);

+ 6 - 8
examples/spmv/spmv_opencl.cl

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2012  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
@@ -14,15 +14,13 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-__kernel void spmv(unsigned nnz, unsigned nrow,
+__kernel void spmv(int nnz, int nrow,
                    __global float* nzval, __global unsigned* colind,
-                   __global unsigned* rowptr, unsigned firstentry,
-                   __global float *vecin, unsigned nx_in,
-                   __global float *vecout, unsigned nx_out)
+                   __global unsigned* rowptr, int firstentry,
+                   __global float *vecin, int nx_in,
+                   __global float *vecout, int nx_out)
 {
-	unsigned row;
-	// for (row = 0; row < nrow; row++)
-	row = get_global_id(0);
+	const int row = get_global_id(0);
 	if (row < nrow)
 	{
 		float tmp = 0.0f;