Skip to content
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

** use __cpu_mask for cpu_mask, support > 32 cores #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/hashpipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sched.h>
#include <signal.h>
#include <poll.h>
#include <getopt.h>
Expand Down Expand Up @@ -63,15 +62,14 @@ static void set_exit_status(hashpipe_thread_args_t *args) {

// Function to set cpu affinity
int
set_cpu_affinity(unsigned int mask)
set_cpu_affinity(__cpu_mask mask)
{
int i, rv;

if(mask != 0) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
// Only handle 32 cores (for now)
for(i=0; i<32; i++) {
for(i=0; i<__NCPUBITS; i++) {
if(mask&1) {
CPU_SET(i, &cpuset);
}
Expand Down Expand Up @@ -456,7 +454,7 @@ int main(int argc, char *argv[])

case 'c': // CPU number
i = strtol(optarg, NULL, 0);
args[num_threads].cpu_mask = (1<<i);
args[num_threads].cpu_mask = (((__cpu_mask) 1)<<i);
break;

case 'p': // Load plugin
Expand Down
3 changes: 2 additions & 1 deletion src/hashpipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _HASHPIPE_H

#include <stdio.h>
#include <sched.h>

#include "hashpipe_error.h"
#include "hashpipe_databuf.h"
Expand Down Expand Up @@ -139,7 +140,7 @@ struct hashpipe_thread_args {
int instance_id;
int input_buffer;
int output_buffer;
unsigned int cpu_mask; // 0 means use inherited
__cpu_mask cpu_mask; // 0 means use inherited
int finished;
pthread_cond_t finished_c;
pthread_mutex_t finished_m;
Expand Down