Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-alugrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-alugrid
Commits
c2fe4e19
Commit
c2fe4e19
authored
9 years ago
by
Robert K
Browse files
Options
Downloads
Patches
Plain Diff
pthreads: add pthreads check mostly needed in downstream modules.
parent
d07de1bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmake/modules/CMakeLists.txt
+1
-0
1 addition, 0 deletions
cmake/modules/CMakeLists.txt
cmake/modules/DuneAlugridMacros.cmake
+2
-1
2 additions, 1 deletion
cmake/modules/DuneAlugridMacros.cmake
cmake/modules/FindPThreads.cmake
+70
-0
70 additions, 0 deletions
cmake/modules/FindPThreads.cmake
with
73 additions
and
1 deletion
cmake/modules/CMakeLists.txt
+
1
−
0
View file @
c2fe4e19
...
...
@@ -3,6 +3,7 @@ set(modules
CMakeLists.txt
DuneAlugridMacros.cmake
FindDLMalloc.cmake
FindPThreads.cmake
FindSIONlib.cmake
FindZOLTAN.cmake
)
...
...
This diff is collapsed.
Click to expand it.
cmake/modules/DuneAlugridMacros.cmake
+
2
−
1
View file @
c2fe4e19
...
...
@@ -51,4 +51,5 @@ find_package(SIONlib)
find_package
(
DLMalloc
)
find_package
(
ZOLTAN
)
message
(
AUTHOR_WARNING
"TODO: Improve module test."
)
# check for phtreads
include
(
FindPThreads
)
This diff is collapsed.
Click to expand it.
cmake/modules/FindPThreads.cmake
0 → 100644
+
70
−
0
View file @
c2fe4e19
########################
# pthreads....
########################
# we are using the cmake default implementation for threads at the moment
include
(
FindThreads
)
set
(
HAVE_PTHREAD 0
)
set
(
USE_PTHREADS OFF CACHE BOOL
"whether we are using pthreads."
)
if
(
CMAKE_USE_PTHREADS_INIT AND NOT HAVE_PTHREAD
)
set
(
HAVE_PTHREAD 1
)
set
(
CMAKE_THREAD_PREFER_PTHREAD 1
)
include
(
CMakePushCheckState
)
cmake_push_check_state
()
#new settings
set
(
CMAKE_REQUIRED_LIBS
"
${
CMAKE_REQUIRED_LIBRARIES
}
${
CMAKE_THREAD_LIBS_INIT
}
"
)
set
(
CMAKE_REQUIRED_FLAGS
"
${
CMAKE_REQUIRED_FLAGS
}
${
PTHREAD_CFLAGS
}
"
)
if
(
USE_PTHREADS
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DUSE_PTHREADS=1"
)
endif
(
USE_PTHREADS
)
check_cxx_source_compiles
(
"include <pthread.h>
static const int maxThreads = 2 ;
static int& threadNumber () {
static __thread int tn;
return tn;
}
static int threadnumber[ maxThreads ];
pthread_barrier_t barrier;
static void* setThreadNumber(void *number) {
const int num = *((int*) number);
threadNumber () = num ;
//sleep (1);
threadnumber[ num ] = threadNumber ();
pthread_barrier_wait( &barrier );
return 0;
}
int main () {
pthread_t thread[ maxThreads ];
int num[ maxThreads ];
for (int i=0; i<maxThreads; ++i )
{
num[ i ] = i;
threadnumber[ i ] = -1;
}
pthread_barrier_init( &barrier, 0, maxThreads );
for( int i=0; i<maxThreads; ++ i)
pthread_create (&thread[ i ], 0, &setThreadNumber, (void *) &num[ i ]);
for( int i=0; i<maxThreads; ++ i)
pthread_join (thread[ i ], 0);
int result = 0;
for( int i=0; i<maxThreads; ++i )
if( threadnumber[ i ] != i ) result = 1;
return result;
}"
DUNE_CV_PTHREAD_TLS_COMPILES
)
#message( "DUNE_CV_PTHREAD_TLS_COMPILES is set to ${DUNE_CV_PTHREAD_TLS_COMPILES}" )
if
(
DUNE_CV_PTHREAD_TLS_COMPILES
)
set
(
HAVE_PTHREAD_TLS 1
)
endif
(
DUNE_CV_PTHREAD_TLS_COMPILES
)
cmake_pop_check_state
()
endif
(
CMAKE_USE_PTHREADS_INIT AND NOT HAVE_PTHREAD
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment