Csound Csound-dev Csound-tekno Search About

[Csnd-dev] Making Pthreads optional

Date2017-02-23 17:56
FromSteven Yi
Subject[Csnd-dev] Making Pthreads optional
Hi All,

I was emailing with Stephen Kyne about MSVC and I mentioned that we
should work on removing pthread as a requirement first before the rest
of the MSVC stuff.  To that end, I've made a no-pthread branch and
pushed that to github.  So far, it's only got a change to CMake that
makes pthreads only required when not on Windows.

The goal is to restore the older Csound thread functions that use
native Windows API calls.  I found a version of these functions going
back to Csound 5.07:

https://github.com/csound/csound/blob/csound5.07/Top/threads.c

The rationale for this work is:

1. On Windows, using pthreads complicates the build and requires we do
static linking of pthreads and everything else that we can link. The
pthreads dependency has been worked around by this static linking in
building with mingw, but it causes issues when trying to build with
CMake and Visual Studio.  Restoring the Windows thread wrappers should
mitigate all of these.

2. The no-op version of the threads functions would be useful for
non-threaded builds.  This would target Emscripten as well as Bela.
As it is today, the work to get the Emscripten build required some
platform-specific #ifdefs and other changes that are a bit untidy, and
making a non-thread build would be a more generic solution.


The plan is to get the no-pthread build working, double-check it works
on other platforms, then merge back into develop once complete.

Thanks!

Date2017-02-23 17:58
FromSteven Yi
SubjectRe: [Csnd-dev] Making Pthreads optional
BTW: in terms of work to do, I think the codebase is not too far off.
Restoring the functions in threads.c is one step, the other is
removing references to pthread.h from the code base outside of
threads.c.  The changes are mostly going to be in the header files in
include/ and H/.

On Thu, Feb 23, 2017 at 12:56 PM, Steven Yi  wrote:
> Hi All,
>
> I was emailing with Stephen Kyne about MSVC and I mentioned that we
> should work on removing pthread as a requirement first before the rest
> of the MSVC stuff.  To that end, I've made a no-pthread branch and
> pushed that to github.  So far, it's only got a change to CMake that
> makes pthreads only required when not on Windows.
>
> The goal is to restore the older Csound thread functions that use
> native Windows API calls.  I found a version of these functions going
> back to Csound 5.07:
>
> https://github.com/csound/csound/blob/csound5.07/Top/threads.c
>
> The rationale for this work is:
>
> 1. On Windows, using pthreads complicates the build and requires we do
> static linking of pthreads and everything else that we can link. The
> pthreads dependency has been worked around by this static linking in
> building with mingw, but it causes issues when trying to build with
> CMake and Visual Studio.  Restoring the Windows thread wrappers should
> mitigate all of these.
>
> 2. The no-op version of the threads functions would be useful for
> non-threaded builds.  This would target Emscripten as well as Bela.
> As it is today, the work to get the Emscripten build required some
> platform-specific #ifdefs and other changes that are a bit untidy, and
> making a non-thread build would be a more generic solution.
>
>
> The plan is to get the no-pthread build working, double-check it works
> on other platforms, then merge back into develop once complete.
>
> Thanks!

Date2017-02-23 19:08
FromRory Walsh
SubjectRe: [Csnd-dev] Making Pthreads optional
Thanks for the update Steven. Is the new branch on github building already with Visual Studio?  

On 23 February 2017 at 17:58, Steven Yi <stevenyi@gmail.com> wrote:
BTW: in terms of work to do, I think the codebase is not too far off.
Restoring the functions in threads.c is one step, the other is
removing references to pthread.h from the code base outside of
threads.c.  The changes are mostly going to be in the header files in
include/ and H/.

On Thu, Feb 23, 2017 at 12:56 PM, Steven Yi <stevenyi@gmail.com> wrote:
> Hi All,
>
> I was emailing with Stephen Kyne about MSVC and I mentioned that we
> should work on removing pthread as a requirement first before the rest
> of the MSVC stuff.  To that end, I've made a no-pthread branch and
> pushed that to github.  So far, it's only got a change to CMake that
> makes pthreads only required when not on Windows.
>
> The goal is to restore the older Csound thread functions that use
> native Windows API calls.  I found a version of these functions going
> back to Csound 5.07:
>
> https://github.com/csound/csound/blob/csound5.07/Top/threads.c
>
> The rationale for this work is:
>
> 1. On Windows, using pthreads complicates the build and requires we do
> static linking of pthreads and everything else that we can link. The
> pthreads dependency has been worked around by this static linking in
> building with mingw, but it causes issues when trying to build with
> CMake and Visual Studio.  Restoring the Windows thread wrappers should
> mitigate all of these.
>
> 2. The no-op version of the threads functions would be useful for
> non-threaded builds.  This would target Emscripten as well as Bela.
> As it is today, the work to get the Emscripten build required some
> platform-specific #ifdefs and other changes that are a bit untidy, and
> making a non-thread build would be a more generic solution.
>
>
> The plan is to get the no-pthread build working, double-check it works
> on other platforms, then merge back into develop once complete.
>
> Thanks!
> steven


Date2017-02-23 19:30
FromSteven Yi
SubjectRe: [Csnd-dev] Making Pthreads optional
No, the pthread work comes first, then the VS work.  It's simpler
going this route, IMO.

On Thu, Feb 23, 2017 at 2:08 PM, Rory Walsh  wrote:
> Thanks for the update Steven. Is the new branch on github building already
> with Visual Studio?
>
> On 23 February 2017 at 17:58, Steven Yi  wrote:
>>
>> BTW: in terms of work to do, I think the codebase is not too far off.
>> Restoring the functions in threads.c is one step, the other is
>> removing references to pthread.h from the code base outside of
>> threads.c.  The changes are mostly going to be in the header files in
>> include/ and H/.
>>
>> On Thu, Feb 23, 2017 at 12:56 PM, Steven Yi  wrote:
>> > Hi All,
>> >
>> > I was emailing with Stephen Kyne about MSVC and I mentioned that we
>> > should work on removing pthread as a requirement first before the rest
>> > of the MSVC stuff.  To that end, I've made a no-pthread branch and
>> > pushed that to github.  So far, it's only got a change to CMake that
>> > makes pthreads only required when not on Windows.
>> >
>> > The goal is to restore the older Csound thread functions that use
>> > native Windows API calls.  I found a version of these functions going
>> > back to Csound 5.07:
>> >
>> > https://github.com/csound/csound/blob/csound5.07/Top/threads.c
>> >
>> > The rationale for this work is:
>> >
>> > 1. On Windows, using pthreads complicates the build and requires we do
>> > static linking of pthreads and everything else that we can link. The
>> > pthreads dependency has been worked around by this static linking in
>> > building with mingw, but it causes issues when trying to build with
>> > CMake and Visual Studio.  Restoring the Windows thread wrappers should
>> > mitigate all of these.
>> >
>> > 2. The no-op version of the threads functions would be useful for
>> > non-threaded builds.  This would target Emscripten as well as Bela.
>> > As it is today, the work to get the Emscripten build required some
>> > platform-specific #ifdefs and other changes that are a bit untidy, and
>> > making a non-thread build would be a more generic solution.
>> >
>> >
>> > The plan is to get the no-pthread build working, double-check it works
>> > on other platforms, then merge back into develop once complete.
>> >
>> > Thanks!
>> > steven
>

Date2017-02-23 19:43
FromRory Walsh
SubjectRe: [Csnd-dev] Making Pthreads optional
You won't hear me complaining ;) 

On 23 February 2017 at 19:30, Steven Yi <stevenyi@gmail.com> wrote:
No, the pthread work comes first, then the VS work.  It's simpler
going this route, IMO.

On Thu, Feb 23, 2017 at 2:08 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
> Thanks for the update Steven. Is the new branch on github building already
> with Visual Studio?
>
> On 23 February 2017 at 17:58, Steven Yi <stevenyi@gmail.com> wrote:
>>
>> BTW: in terms of work to do, I think the codebase is not too far off.
>> Restoring the functions in threads.c is one step, the other is
>> removing references to pthread.h from the code base outside of
>> threads.c.  The changes are mostly going to be in the header files in
>> include/ and H/.
>>
>> On Thu, Feb 23, 2017 at 12:56 PM, Steven Yi <stevenyi@gmail.com> wrote:
>> > Hi All,
>> >
>> > I was emailing with Stephen Kyne about MSVC and I mentioned that we
>> > should work on removing pthread as a requirement first before the rest
>> > of the MSVC stuff.  To that end, I've made a no-pthread branch and
>> > pushed that to github.  So far, it's only got a change to CMake that
>> > makes pthreads only required when not on Windows.
>> >
>> > The goal is to restore the older Csound thread functions that use
>> > native Windows API calls.  I found a version of these functions going
>> > back to Csound 5.07:
>> >
>> > https://github.com/csound/csound/blob/csound5.07/Top/threads.c
>> >
>> > The rationale for this work is:
>> >
>> > 1. On Windows, using pthreads complicates the build and requires we do
>> > static linking of pthreads and everything else that we can link. The
>> > pthreads dependency has been worked around by this static linking in
>> > building with mingw, but it causes issues when trying to build with
>> > CMake and Visual Studio.  Restoring the Windows thread wrappers should
>> > mitigate all of these.
>> >
>> > 2. The no-op version of the threads functions would be useful for
>> > non-threaded builds.  This would target Emscripten as well as Bela.
>> > As it is today, the work to get the Emscripten build required some
>> > platform-specific #ifdefs and other changes that are a bit untidy, and
>> > making a non-thread build would be a more generic solution.
>> >
>> >
>> > The plan is to get the no-pthread build working, double-check it works
>> > on other platforms, then merge back into develop once complete.
>> >
>> > Thanks!
>> > steven
>
>