[eigen] No vectorization in presence of .cast<T>() calls |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: Eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] No vectorization in presence of .cast<T>() calls
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Fri, 17 Dec 2010 09:40:59 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=b2Ak9ZyEgmjo03VQIDmV1ZVka6z/t/cd1D1SpFcAeFs=; b=oGwJXP5kpauf2dU8oSMaEmhVOPsh+/pIoapDhdWxD4l4kdAOLJ7TQX0V6LrCk7pqlP H5PHLSmt3HCR2HcT/4GACIlyatd1anbBClwDm4rfxyPB9Ef0flbWeeMZSxw6+IvUPyLL +flAKCx1qvW8U6DwuWRGi9nL25IBD6/ylVc1c=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=gGvhW4oWGiMFrN0eJClze0bY+E82djqCMtKHoQ6ZPr0KDrxKzEfk6WaX/0ojtLQLmE uLVLEU8vYEFX0fAO/vKcJsOqvaheI89NUBJvWzWl35amtEIDavEtcwC918jqHRd5kpJl NFG/PvMBvawq6T2hfoAE7nP806+tjZxY+kWUE=
Hi,
I have the following piece of code
MatrixXf od_full = - std::log( img_mat.cast<float>() / 255.0f + std::numeric_limits<float>::epsilon() );
where img_mat is of type
Map< Array<unsigned char,Dynamic,Dynamic,ColMajor> >.
The issue is now that I recognized that the code is not vectorized at all.. As soon as I introduce a temporary
ArrayXXf tmp = img_mat.cast<float>();
MatrixXf od_full = - std::log( tmp / 255.0f + std::numeric_limits<float>::epsilon() );
the vectorization works again as expected. Right now, I don't see, why the cast should prevent vectorization, though I admit that this might be a little bit tricky.
My use case is that I am "abusing" Eigen for some image processing algorithms and most often, images come as "unsigned char" arrays. For numerical procedures I want to convert these values to float while trying to prevent the introduction of unnecessary temporaries since sometimes my images are rather large.
Do you have any information or ideas about this issue?
- Hauke