Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector: add constructor taking an element reference #286

Merged
merged 3 commits into from Sep 1, 2021

Conversation

amyspark
Copy link
Contributor

@amyspark amyspark commented Jul 6, 2021

Hi again!

This MR fixes #256. Tested with the following example under MSVC 19.29.30038.1:

#include <Vc/Vc>
#include <iostream>

int main()
{
	Vc::float_v a;

	a[2] = 4.0f;

	Vc::float_v works = (float)a[2];
	Vc::float_v fails = a[2]; // error: cannot convert Vc::float_v::reference to float

	std::cout << works << fails << std::endl;

	return 0;
}
❯ .\build\Debug\main.exe
[4, 4, 4, 4][4, 4, 4, 4]

Copy link
Collaborator

@bernhardmgruber bernhardmgruber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I am still not sure however, if there could be any implications. Having this ctor seems so straight forward to me, that there might have been a reason to not include it. I would like to have a second opinion before merging this.

Vc/avx/vector.h Outdated Show resolved Hide resolved
@agheata
Copy link
Collaborator

agheata commented Jul 8, 2021

Shouldn't this come with a unit test before merging?

@bernhardmgruber
Copy link
Collaborator

Shouldn't this come with a unit test before merging?

Absolutely right! @amyspark could you please add a small unit test as well? Something similar to the snippet you present here. Thank you!

@amyspark
Copy link
Contributor Author

Shouldn't this come with a unit test before merging?

Absolutely right! @amyspark could you please add a small unit test as well? Something similar to the snippet you present here. Thank you!

Hey! I'm trying to find which unit test location fits this case, but I've not been able to yet.

tests/casts.cpp Outdated Show resolved Hide resolved
@amadio
Copy link
Collaborator

amadio commented Aug 13, 2021

I agree with Bernhard that there may have been a reason not to include the constructor, e.g. to avoid enabling automatic conversions that are detrimental to performance and/or ambiguities about which constructor to use. However, if it is added as explicit, it is probably ok.

@amyspark
Copy link
Contributor Author

I see only passes at http://cdash.cern.ch/index.php?project=Vc, anyone knows what's going on with CI?

@amadio
Copy link
Collaborator

amadio commented Aug 14, 2021

We are looking into why the CI is showing the builds as failed. We should get this sorted out next week.

@amyspark
Copy link
Contributor Author

@amadio any news as to CDash?

@amadio
Copy link
Collaborator

amadio commented Aug 26, 2021

We think it's an issue with GitHub Actions itself. Nothing has changed on the CI configuration on our side. If GitHub Actions shows failures but we know from CDash that the builds actually passed, we can go ahead and merge the changes. I restarted the jobs to see if it will make any difference.

@amyspark
Copy link
Contributor Author

It seems it's a known issue with CTest: https://gitlab.kitware.com/cmake/cmake/-/issues/20975

@amyspark
Copy link
Contributor Author

I've pushed a commit that should resolve those two warnings that appear on CDash.

Vc/avx/const.h Outdated Show resolved Hide resolved
Vc/common/subscript.h Outdated Show resolved Hide resolved
@bernhardmgruber
Copy link
Collaborator

I think I have sorted out the CI issues: #297. You can rebase once the fix is merged.

@bernhardmgruber
Copy link
Collaborator

@amyspark please rebase on 1.4 again.

cmake/msvc_version.c Outdated Show resolved Hide resolved
Vc/avx/const.h Outdated Show resolved Hide resolved
@bernhardmgruber
Copy link
Collaborator

@amyspark I think we might also need to add the new overload to SimdArray. Or at least add a unit test, that it also works with SimdArray please!

@@ -119,8 +119,7 @@ namespace AVX
{
#ifdef Vc_IMPL_AVX2
#if defined Vc_ICC || defined Vc_MSVC
__m256i allone;
allone = _mm256_cmpeq_epi8(allone, allone);
__m256i allone = _mm256_set1_epi64x(~0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we go with this for all compilers and remove the ifdefs? I think it should be optimal in all cases, no?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends. I read somewhere that sometimes generating the constant is faster than reading a value from static memory. So we would need to check the generated code whether ~0 is stored in the static data or computed. But then, you are the expert on such matter, so I take your recommendation ;)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's computed for the other compilers, and I think that's actually ok, because at most that takes a few cycles, so it's like loading from L1. Loading from memory can be fast, or not, depending on where you're loading from.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this implementation on all compilers now, but in a separate PR: #299.

@bernhardmgruber bernhardmgruber merged commit 811e2ee into VcDevel:1.4 Sep 1, 2021
@amyspark amyspark deleted the amyspark/256 branch September 2, 2021 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Construct Vector from other Vector's reference
4 participants