Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
azure-cloud-mining-script
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
azure-cloud-mining-script
Commits
c897fc04
There was an error fetching the commit references. Please try again later.
Commit
c897fc04
authored
7 years ago
by
fireice-uk
Browse files
Options
Downloads
Patches
Plain Diff
cleanup and give a return from set_affinity
parent
b40f937b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xmrstak/backend/cpu/minethd.cpp
+10
-31
10 additions, 31 deletions
xmrstak/backend/cpu/minethd.cpp
xmrstak/backend/cpu/minethd.hpp
+1
-1
1 addition, 1 deletion
xmrstak/backend/cpu/minethd.hpp
with
11 additions
and
32 deletions
xmrstak/backend/cpu/minethd.cpp
+
10
−
31
View file @
c897fc04
...
...
@@ -50,22 +50,8 @@
#include
<thread>
#include
<bitset>
#ifdef _WIN32
#include
<windows.h>
namespace
xmrstak
{
namespace
cpu
{
void
minethd
::
thd_setaffinity
(
std
::
thread
::
native_handle_type
h
,
uint64_t
cpu_id
)
{
SetThreadAffinityMask
(
h
,
1ULL
<<
cpu_id
);
}
}
// namespace cpu
}
// namespace xmrstak
#else
#include
<pthread.h>
...
...
@@ -75,44 +61,37 @@ void minethd::thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id
#define SYSCTL_CORE_COUNT "machdep.cpu.core_count"
#elif defined(__FreeBSD__)
#include
<pthread_np.h>
#endif
#endif //__APPLE__
#endif //_WIN32
namespace
xmrstak
{
namespace
cpu
{
void
minethd
::
thd_setaffinity
(
std
::
thread
::
native_handle_type
h
,
uint64_t
cpu_id
)
bool
minethd
::
thd_setaffinity
(
std
::
thread
::
native_handle_type
h
,
uint64_t
cpu_id
)
{
#if defined(__APPLE__)
#if defined(_WIN32)
return
SetThreadAffinityMask
(
h
,
1ULL
<<
cpu_id
)
!=
0
;
#elif defined(__APPLE__)
thread_port_t
mach_thread
;
thread_affinity_policy_data_t
policy
=
{
static_cast
<
integer_t
>
(
cpu_id
)
};
mach_thread
=
pthread_mach_thread_np
(
h
);
thread_policy_set
(
mach_thread
,
THREAD_AFFINITY_POLICY
,
(
thread_policy_t
)
&
policy
,
1
);
return
thread_policy_set
(
mach_thread
,
THREAD_AFFINITY_POLICY
,
(
thread_policy_t
)
&
policy
,
1
)
==
KERN_SUCCESS
;
#elif defined(__FreeBSD__)
cpuset_t
mn
;
CPU_ZERO
(
&
mn
);
CPU_SET
(
cpu_id
,
&
mn
);
pthread_setaffinity_np
(
h
,
sizeof
(
cpuset_t
),
&
mn
);
return
pthread_setaffinity_np
(
h
,
sizeof
(
cpuset_t
),
&
mn
)
==
0
;
#else
cpu_set_t
mn
;
CPU_ZERO
(
&
mn
);
CPU_SET
(
cpu_id
,
&
mn
);
pthread_setaffinity_np
(
h
,
sizeof
(
cpu_set_t
),
&
mn
);
return
pthread_setaffinity_np
(
h
,
sizeof
(
cpu_set_t
),
&
mn
)
==
0
;
#endif
}
}
// namespace cpu
}
// namespace xmrstak
#endif // _WIN32
namespace
xmrstak
{
namespace
cpu
{
minethd
::
minethd
(
miner_work
&
pWork
,
size_t
iNo
,
bool
double_work
,
bool
no_prefetch
,
int64_t
affinity
)
{
oWork
=
pWork
;
...
...
This diff is collapsed.
Click to expand it.
xmrstak/backend/cpu/minethd.hpp
+
1
−
1
View file @
c897fc04
...
...
@@ -24,7 +24,7 @@ public:
typedef
void
(
*
cn_hash_fun
)(
const
void
*
,
size_t
,
void
*
,
cryptonight_ctx
*
);
static
cn_hash_fun
func_selector
(
bool
bHaveAes
,
bool
bNoPrefetch
);
static
void
thd_setaffinity
(
std
::
thread
::
native_handle_type
h
,
uint64_t
cpu_id
);
static
bool
thd_setaffinity
(
std
::
thread
::
native_handle_type
h
,
uint64_t
cpu_id
);
static
cryptonight_ctx
*
minethd_alloc_ctx
();
...
...
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