lundi 26 décembre 2016

different aligned pointers pointing to the same memory

This code returns always the same value for the double* pointers u and r. However, if I remove the attribute__((aligned(16))) it works correct. Is this usage of attribute_((algined(16))) invalid?

int main(void){
double* __restrict __attribute__((aligned(16))) u=(double*)aligned_alloc(16,1252*2502*sizeof(double));
std::cerr<<"u after alloc: "<<u<<std::endl;
memset(u,0,1252*2502*sizeof(double));
std::cerr<<"u after memset: "<<u<<std::endl;
double* __restrict __attribute__((aligned(16)))r=(double*)aligned_alloc(16,1252*2502*sizeof(double));
std::cerr<<"r after alloc: "<<r<<std::endl;
memset(r,0,1252*2502*sizeof(double));
std::cerr<<"r after memset:"<<r<<std::endl<<std::endl;

}

Aucun commentaire:

Enregistrer un commentaire