Commit 6e76df11 authored by John Esmet's avatar John Esmet

refs #184 Remove non-production code

parent 3b85f796
default: build
TARGETS = get.parallel get.serial
CPPFLAGS = -I../../../include -I../../../toku_include -I../../../linux
CFLAGS = -Wall -W -Werror -g $(OPTFLAGS)
LOADLIBES = -L../../../lib -ltokuportability -ltokudb
LDFLAGS = -Wl,-rpath,../../../lib
build: $(TARGETS)
CILKPP=/home/bradley/cilkarts/8503/cilk/bin/cilk++
CXX=/home/bradley/cilkarts/8503/cilk/bin/c++
CILKSCREEN=/home/bradley/cilkarts/8503/cilk/bin/cilkscreen
%.parallel: %.cilk
$(CILKPP) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LOADLIBES)
%.serial: %.cilk
$(CILKPP) -fcilk-stub $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LOADLIBES)
check: check_get.parallel check_get.serial
check_%.parallel: %.parallel
$(CILKSCREEN) ./$<
check_%.serial: %.serial
valgrind ./$<
foo.serial foo.parallel: CPPFLAGS=
foo.serial foo.parallel: LOADLIBES=
foo.serial foo.parallel: LDFLAGS=
foo.serial: CFLAGS=-lpthread
%.o: %.cilk
$(CILKPP) $(CPPFLAGS) $(CFLAGS) $< -c -o $@
foo2: foo2.o bar2.o
$(CILKPP) foo2.o bar2.o -o $@ -lpthread -L/home/bradley/cilkarts/8503/cilk/lib64 -lcilkrts -Wl,-rpath=/home/bradley/cilkarts/8503/cilk/lib64
broken:
$(CXX) foo2.o bar2.o -o $@ -lpthread -L/home/bradley/cilkarts/8503/cilk/lib64 -lcilkrts -Wl,-rpath=/home/bradley/cilkarts/8503/cilk/lib64
measurecilkrun.parallel: OPTFLAGS=-O2
measurecilkrun.parallel: LDFLAGS=
measurecilkrun.parallel: LOADLIBES=
measurecilkrun.parallel: CPPFLAGS=
check_measurecilkrun.parallel: CILKSCREEN=
#include <cilk.h>
#include <stdio.h>
#include "foo2.h"
extern "Cilk++"
int foo2 (int i) {
return i+1;
}
int foo (int i) {
int r;
r = cilk_spawn foo2 (i+1);
cilk_sync;
return r+1;
}
extern "C++"
void do_foo (void) {
printf("Running cilk\n");
int r = cilk::run(&foo, 3);
printf("Done r =%d\n", r);
}
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
pthread_t pt[2];
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
extern "C" void* start (void *extra __attribute__((__unused__))) {
{ int r = pthread_mutex_lock(&mutex); assert(r==0); }
printf("T%lx got lock\n", pthread_self());
sleep(1);
printf("T%lx releasing lock\n", pthread_self());
{ int r = pthread_mutex_unlock(&mutex); assert(r==0); }
return 0;
}
void create_pthread(void) {
for (int i=0; i<2; i++) {
int r = pthread_create(&pt[i], 0, start, NULL);
assert(r==0);
}
}
void join_pthread (void) {
for (int i=0; i<2; i++) {
int r = pthread_join(pt[i], NULL);
assert(r==0);
}
}
void foo (void) {
}
int cilk_main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
create_pthread();
cilk_spawn foo();
cilk_sync;
join_pthread();
return 0;
}
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#include "foo2.h"
#include "cilk.h"
pthread_t pt[2];
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
extern "C" void* start (void *extra __attribute__((__unused__))) {
{ int r = pthread_mutex_lock(&mutex); assert(r==0); }
printf("T%lx got lock\n", pthread_self());
sleep(1);
printf("T%lx releasing lock\n", pthread_self());
{ int r = pthread_mutex_unlock(&mutex); assert(r==0); }
return 0;
}
void create_pthread(void) {
for (int i=0; i<2; i++) {
int r = pthread_create(&pt[i], 0, start, NULL);
assert(r==0);
}
}
void join_pthread (void) {
for (int i=0; i<2; i++) {
int r = pthread_join(pt[i], NULL);
assert(r==0);
}
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
__cilkscreen_disable_instrumentation();
create_pthread();
__cilkscreen_enable_instrumentation();
do_foo();
join_pthread();
return 0;
}
/* Perform a DB->get in a cilk thread */
#include <assert.h>
#include <db.h>
#include <stdlib.h>
#include <toku_os.h>
#define DIR __FILE__ ".dir"
DB_ENV *env;
void foo (void) {
printf("foo\n");
}
const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_PRIVATE;
int cilk_main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
{ int r = db_env_create(&env, 0); assert(r==0); }
{ int r = env->open(env, DIR, envflags,S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); }
cilk_spawn foo();
cilk_sync;
{ int r = env->close(env, 0); assert(r==0); }
return 0;
}
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#include "cilk.h"
#include <sys/time.h>
int foo (int i) {
return i+1;
}
int fooi (void* iv) {
int *ip=(int*)iv;
return foo(*ip);
}
extern "C++" {
int N = 1000;
double tdiff (struct timeval *after, struct timeval *before)
{
return after->tv_sec - before->tv_sec + (1e-6)*(after->tv_usec - before->tv_usec);
}
void do_cilkrun (void) {
cilk::run(&foo, 0);
}
static cilk::context *ctx;
void do_cilkcxt (void) {
int i = 0;
int j __attribute__((__unused__)) = ctx->run(&fooi, (void*)&i);
}
void do_N_cilkcxt (void) {
struct timeval start,end;
gettimeofday(&start, 0);
cilk::context ctx;
int r=0;
for (int i=0; i<N; i++) {
int j=ctx.run(&fooi, (void*)&i);
r+=j;
}
gettimeofday(&end, 0);
printf("%.3fus per ctx.run (tot=%d)\n", 1e6*tdiff(&end, &start)/N, 0);
}
extern "Cilk++" int cilk_in_pt (int i) {
assert(i==0);
return 0;
}
pthread_t pt_for_cilk;
extern void* do_pt_for_cilk(void *extra __attribute__((__unused__))) {
cilk::run(&cilk_in_pt, 0);
return 0;
}
void setup_cilk_in_pthread (void) {
int r = pthread_create(&pt_for_cilk, 0, do_pt_for_cilk, NULL);
assert(r==0);
}
void do_cilk_in_pthread (void) {
}
void* do_something (void *extra __attribute__((__unused__))) {
return 0;
}
void do_pthread(void) {
pthread_t pt;
{int r = pthread_create(&pt, 0, do_something, NULL); assert(r==0);}
{int r = pthread_join(pt, NULL); assert(r==0);}
}
void measure(void (*f)(void), const char *string) {
const int maxiter=4;
for (int j=0; j<maxiter; j++) {
int M = (j+1==maxiter) ? N : 1<<j;
struct timeval start,end;
gettimeofday(&start, 0);
for (int i=0; i<M; i++) {
f();
}
gettimeofday(&end, 0);
printf("%9.3fus per call (%d calls) for %s\n", 1e6*tdiff(&end, &start)/M, M, string);
}
printf("\n");
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
measure(do_pthread, "pthread");
measure(do_cilkrun, "cilkrun");
ctx = new cilk::context;
measure(do_cilkcxt, "cilkcxt");
delete ctx;
return 0;
}
} /* end extern "C" */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment