Skip to content

Add multithreaded variant to ICU port - #15592

Merged
sbc100 merged 3 commits into
emscripten-core:mainfrom
GRAPHISOFT:pthread-icu
Nov 29, 2021
Merged

Add multithreaded variant to ICU port#15592
sbc100 merged 3 commits into
emscripten-core:mainfrom
GRAPHISOFT:pthread-icu

Conversation

@mmarczell-graphisoft

Copy link
Copy Markdown
Contributor

Fixes #14518

Comment thread tests/other/test_pthread_icu.cpp Outdated
ustr.toUTF8String(str);
std::cout << str << std::endl;
}).detach();
} No newline at end of file

Copy link
Copy Markdown
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

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm % comments

Comment thread tests/other/test_pthread_icu.cpp Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread tests/test_other.py Outdated
self.do_other_test('test_pthread_out_err.c')

@node_pthreads
def test_icu_mt(self):

Copy link
Copy Markdown
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?

Comment thread tests/test_other.py Outdated

@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
Copy Markdown
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.

Comment thread tests/other/test_pthread_icu.cpp Outdated
icu::UnicodeString ustr("Hello world!");
ustr.toUTF8String(str);
std::cout << str << std::endl;
}).detach();

Copy link
Copy Markdown
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

sbc100 commented Nov 22, 2021

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

tlively commented Nov 22, 2021

Copy link
Copy Markdown
Member

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 :(

Comment thread tests/other/test_pthread_icu.out Outdated
@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