How Can i work with matrix inside a kernel?

Hi,

If i allocate a matrix outside kernel, how can i work with it inside of kernel, since i can’t work with pointer-to-pointer?

Thanks,

Hm… For example, I started using one-dimensional array. And the one-dimensional array uses less memory, because there are no pointers.

Even in Nvidia examples, uses one-dimensional array:


/*
 * Copyright 1993-2010 NVIDIA Corporation.  All rights reserved.
 *
 * Please refer to the NVIDIA end user license agreement (EULA) associated
 * with this source code for terms and conditions that govern your use of
 * this software. Any use, reproduction, disclosure, or distribution of
 * this software and related documentation outside the terms of the EULA
 * is strictly prohibited.
 *
 */

/* Matrix multiplication: C = A * B.
 * Device code.
 */

#define AS(i, j) As[j + i * BLOCK_SIZE]
#define BS(i, j) Bs[j + i * BLOCK_SIZE]