c*******d 发帖数: 353 | 1 I would like to hear your comments on my design of this array class. The
purpose is to provide a fast, easy to use multi-dimensional array container.
/*
* A C/C++ OO approach to use multi-dimenisional array in HPC environment.
*
* Goal: speed, ease of use, robustness
*
* Design advantage:
* By using 1D array as data container, CPU prefetching, caching, TLB
* features are used to make data access faster. By providing error checking
* in access methods, bounds check can be easily done. Access me | s*****c 发帖数: 753 | 2 Why not put ndim in template also?
template class array;
Too many constructor. Either use stl:vector for dimlen, or the constructor
parameter is size_t *. Same can be done for ele. You could use a stl:vector, or an array (correct size is ensured by your main program). You could also define another template class called pixel, or point, or vector:
template class pixel
{
T data[N]
...
...
}
【在 c*******d 的大作中提到】 : I would like to hear your comments on my design of this array class. The : purpose is to provide a fast, easy to use multi-dimensional array container. : /* : * A C/C++ OO approach to use multi-dimenisional array in HPC environment. : * : * Goal: speed, ease of use, robustness : * : * Design advantage: : * By using 1D array as data container, CPU prefetching, caching, TLB : * features are used to make data access faster. By providing error checking
| c*******d 发帖数: 353 | 3 the purpose of this class is for high performance computing, therefore
performance and ease of use is very important, especially for people
with a heavy fortran background.
for example, the declaration should be simple:
array a3d(3,3,3);
not array a3d(vector(3,3,3)); // also overhead of creating vector
class
, or an array (correct size is ensured by your main program). You could also
define another template class called pixel, or point, or vector:
【在 s*****c 的大作中提到】 : Why not put ndim in template also? : template class array; : Too many constructor. Either use stl:vector for dimlen, or the constructor : parameter is size_t *. Same can be done for ele. You could use a stl:vector, or an array (correct size is ensured by your main program). You could also define another template class called pixel, or point, or vector: : template class pixel : { : T data[N] : ... : ... : }
|
|