Skip to content

[wasm64] Fix and run all pthread browser tests #20527

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

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Oct 24, 2023

Split out from #20516

@sbc100 sbc100 force-pushed the browser64_pthreads branch 3 times, most recently from f3a32d7 to 18af054 Compare October 24, 2023 20:14
@sbc100 sbc100 requested a review from kripken October 24, 2023 22:03
@sbc100 sbc100 changed the title [wasm64] Fix and run run all pthread browser tests [wasm64] Fix and run all pthread browser tests Oct 24, 2023
@sbc100 sbc100 force-pushed the browser64_pthreads branch 2 times, most recently from 6bf7a50 to ceec2c0 Compare October 24, 2023 22:46
@sbc100 sbc100 requested a review from tlively October 24, 2023 22:46
@@ -57,7 +57,7 @@ void *WaitingThread(void *arg)

int main()
{
for(int i = 0; i < NUM_THREADS; ++i)
for(intptr_t i = 0; i < NUM_THREADS; ++i)
Copy link
Member

Choose a reason for hiding this comment

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

Surely the number of threads fits in an int? 😄

lgtm regardless, but I'm curious if this fixed a specific issue? Maybe that the higher bits were undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The specific issue here and elsewhere is that i is cast to a void* and passed to pthread_create as the argument to the thread start function.

Casting an int to void* is find on wasm32 but generates a warning on wasm64.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks.

@@ -129,7 +129,7 @@ int main()
fetch_and_and_data = HILO(65536 + (1<<(NUM_THREADS+1))-1, (1<<(NUM_THREADS+1))-1);
for(int i = 0; i < NUM_THREADS; ++i)
{
threadArg[i] = DUP(~(1UL<<i));
threadArg[i] = DUP(~(1u<<i));
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this change us from an unsigned long to plain unsigned? We seem to store this to uint64_t, so isn't the former better, if it makes any difference?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. DUP() here is supposed to take an i32 and use HILO() to construct an i64 where the low and high parts are the same.

The current code which uses UL works for wasm32 because UL is i32 but on wasm64 UL is i64 which breaks DUP / HILO macros.

I verified this was broken on 64-bit linux too... and this was the fix there.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks.

@sbc100 sbc100 force-pushed the browser64_pthreads branch from ceec2c0 to 608f5d2 Compare October 24, 2023 23:13
@@ -3875,6 +3877,7 @@ def test_pthread_gcc_atomic_fetch_and_op(self):
self.btest_exit('pthread/test_pthread_gcc_atomic_fetch_and_op.cpp', args=args + ['-sINITIAL_MEMORY=64MB', '-pthread', '-sPTHREAD_POOL_SIZE=8'])

# 64 bit version of the above test.
@no_wasm64("XXX")
Copy link
Member

Choose a reason for hiding this comment

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

Placeholder here and below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry bad merge..

@sbc100 sbc100 force-pushed the browser64_pthreads branch from 608f5d2 to d75f024 Compare October 24, 2023 23:22
@sbc100 sbc100 merged commit 34a46b3 into emscripten-core:main Oct 26, 2023
@sbc100 sbc100 deleted the browser64_pthreads branch October 26, 2023 19:18
sbc100 added a commit to sbc100/emscripten that referenced this pull request Nov 8, 2023
sbc100 added a commit that referenced this pull request Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants