Skip to content

Commit

Permalink
initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
fangdingjun committed Jul 16, 2011
0 parents commit daac7fd
Show file tree
Hide file tree
Showing 15 changed files with 834 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
*~
*.o
COPYING
INSTALL
Makefile.in
aclocal.m4
autom4te.cache
autoscan-2.68.log
compile
config.*
configure
depcomp
install-sh
missing
Makefile
src/.deps
src/qpi_stress
stamp-h1
cscope*

1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fangdingjun <[email protected]>
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

2011-7-16:
initial project
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBDIRS = src
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

2011-7-16
initial projects
30 changes: 30 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

1.overview

this is a tool to test CPU's QPI channel:

start a process A and bind to cpu0, then request a share memory
start a process B and bind to cpu1, then attach to process A's share memory
process A write to the share memory, process B read from then share memory via QPI channel
process A read the process B's share memory via QPI channel

procA procB
|| ||
+------+ +--------+
|cpu0 | QPI channel | cpu1 |
+------+ +--------+
|| ||
+-----+ +-----+
|memA | |memB |
+-----+ +-----+

2. install
unpack the source and enter the source directory, type
./configure
make
make install

3.usage
type
qpi_stress -h
for help
2 changes: 2 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
aclocal && autoheader && autoconf && automake -a && ./configure
28 changes: 28 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.68])
AC_INIT([qpi-stress], [0.1], [[email protected]])
AC_CONFIG_SRCDIR([src/worker.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(1.0)

# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_FORK
AC_CHECK_FUNCS([alarm gettimeofday memset])
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
4 changes: 4 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin_PROGRAMS = qpi_stress
qpi_stress_SOURCES = main.c cpu.c shm.c report.c worker.c
qpi_stress_CFLAGS = -Wall -Werror -D_GNU_SOURCE
qpi_stress_LDFLAGS = -lpthread
47 changes: 47 additions & 0 deletions src/cpu.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Filename: cpu.c
* Author: [email protected]
* License: GPLv2
* Date: 2011-7-10
*
*/

#include<stdio.h>
#include<unistd.h>
#include<sched.h>
//#include "qpi.h"

int bind_to_cpu(int cpunum)
{
int num = sysconf(_SC_NPROCESSORS_CONF);
int i;

cpu_set_t mask;

CPU_ZERO(&mask);
CPU_SET(cpunum, &mask);

if (sched_setaffinity(0, sizeof(mask), &mask) == -1) {
perror("set cpu affinity failed");
return -1;
}

CPU_ZERO(&mask);
if (sched_getaffinity(0, sizeof(mask), &mask) == -1) {
perror("get cpu affinity failed");
return -1;
}
for (i = 0; i < num; i++) {
if (CPU_ISSET(i, &mask)) {
break;
}
}
if (i != cpunum) {
fprintf(stderr,
"set cpu affinity failed: process not running on cpu %d\n",
cpunum);
return -1;
}
return 0;
}

Loading

0 comments on commit daac7fd

Please sign in to comment.