Redian新闻
>
C++ OO approach to use multi-dim array for HPC
avatar
C++ OO approach to use multi-dim array for HPC# Programming - 葵花宝典
c*d
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
avatar
s*c
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

avatar
c*d
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]
: ...
: ...
: }

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。