Skip to content

Add multithreaded variant to ICU port #15592

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 3 commits into from
Nov 29, 2021

Conversation

mmarczell-graphisoft
Copy link
Contributor

Fixes #14518

ustr.toUTF8String(str);
std::cout << str << std::endl;
}).detach();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add newline and EOF

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

lgtm % comments


// Test that code using both pthread and icu compiles.
int main () {
std::thread([] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know we are not yet consistent, but we are trying to use a consistent style these days which involves 2-space indentation (we have a .clang-format file if you want to just use that)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Can I recommend mentioning the existence of a style convention in Contributing or Developer's Guide?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes we should do that.

@@ -11125,6 +11125,10 @@ def test_pthread_out_err(self):
self.set_setting('EXIT_RUNTIME')
self.do_other_test('test_pthread_out_err.c')

@node_pthreads
def test_icu_mt(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you name the test the same as the file, i.e def test_pthread_icu?

@@ -11125,6 +11125,10 @@ def test_pthread_out_err(self):
self.set_setting('EXIT_RUNTIME')
self.do_other_test('test_pthread_out_err.c')

@node_pthreads
def test_icu_mt(self):
self.do_smart_test(test_file('other/test_pthread_icu.cpp'), emcc_args=['-pthread', '-sUSE_ICU', '-sPTHREAD_POOL_SIZE_STRICT=4', '-sEXIT_RUNTIME'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like do_other_test (like the test above) should suffice.

icu::UnicodeString ustr("Hello world!");
ustr.toUTF8String(str);
std::cout << str << std::endl;
}).detach();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to .join here since emscripten doesn't handling the case where the main application thread exits while other threads are still running.

Probably best to use PROXY_TO_PTHREAD and drop PTHREAD_POOL_SIZE_STRICT

@sbc100
Copy link
Collaborator

sbc100 commented Nov 22, 2021

I wonder if we can perhaps just always build with pthread enabled since browser should accept atomic opcode in single-threaded programs these days. See WebAssembly/threads#144

@tlively WDTY?

@mmarczell-graphisoft
Copy link
Contributor Author

I wonder if we can perhaps just always build with pthread enabled since browser should accept atomic opcode in single-threaded programs these days. See WebAssembly/threads#144

Certain browsers do not support atomics: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics

@tlively
Copy link
Member

tlively commented Nov 22, 2021

Yeah, I think Safari still does not support atomics yet (according to https://webassembly.org/roadmap/), so it's probably best not to enable threads by default :(

@sbc100 sbc100 enabled auto-merge (squash) November 29, 2021 22:45
@sbc100 sbc100 merged commit 4b3db86 into emscripten-core:main Nov 29, 2021
kripken pushed a commit that referenced this pull request Jan 4, 2022
Adds notes discussed in #14354 and #15592 , specifically
about AUTHORS being optional, and linking to the code style docs.
mmarczell-graphisoft added a commit to GRAPHISOFT/emscripten that referenced this pull request Jan 5, 2022
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.

Cannot compile with both ICU and pthread
3 participants