Skip to content

Commit f6d9c56

Browse files
committed
starcluster instance changes
1 parent b688c4a commit f6d9c56

11 files changed

+570
-22
lines changed

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ collfs.o : collfs.c collfs.h libc-collfs.h
4141
main-nompi : main-nompi.o libcollfs-easy.so libminimal_thefunc.so
4242
${CC} -g3 -o $@ $< ${LDFLAGS}
4343

44-
#main : main.o libfoo.so libcollfs.so
45-
#main : main.o libfoo.so libcollfs.so libc-collfs.so
46-
# ${MPICC} -g3 -o $@ $^ ${LDFLAGS}
44+
test_collfs : test_collfs.o libfoo.so libcollfs.so libminimal_thefunc.so
45+
${MPICC} -g3 -o $@ $^ ${LDFLAGS}
4746
.c.o :
4847
${CC} ${CFLAGS} -fPIC -c $<
4948

@@ -52,8 +51,13 @@ libfoo.so : foo.o collfs.o
5251

5352
collfs.o : collfs.c collfs.h libc-collfs.h
5453
libc-collfs.o : libc-collfs.c libc-collfs.h libc-collfs-private.h
54+
5555
foo.o : foo.c foo.h errmacros.h collfs.h libc-collfs-private.h
56-
main.o : main.c errmacros.h
56+
${MPICC} -c -fPIC -g3 $<
57+
58+
test_collfs.o : test_collfs.c errmacros.h
59+
${MPICC} -c -fPIC -g3 $<
60+
5761
thefunc.o : thefunc.h collfs.h
5862

5963
clean :

foo.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "collfs.h"
1515
#include "libc-collfs-private.h" /* So that we can call the wrapped versions directly */
1616

17+
1718
extern int MPI_Comm_rank ( MPI_Comm comm, int *rank ) __attribute__ ((weak));
1819

1920
int foo(const char *path)
@@ -39,7 +40,7 @@ int foo(const char *path)
3940
pa = __collfs_mmap((void *)0,pagesize,PROT_READ,MAP_PRIVATE,fd,(off_t)0);
4041
if (pa == MAP_FAILED) ERR("[%d] mmap(%d,pagesize) failed",rank,fd);
4142

42-
while (__collfs_read(fd,&value,sizeof value) == sizeof value) {
43+
while (__collfs_libc_read(fd,&value,sizeof value) == sizeof value) {
4344
sum ^= value;
4445
}
4546

@@ -63,21 +64,21 @@ int foo2_inner(const char *path)
6364
off = __collfs_lseek(fd, 0, SEEK_SET);
6465
if (off != 0) ERR("lseek SET");
6566

66-
nc = __collfs_read(fd, buf, 2);
67+
nc = __collfs_libc_read(fd, buf, 2);
6768
if (nc != 2) ERR("read [%d] but expected 2\nbuf: %4.4s", nc, buf);
6869
if (strncmp(buf, "ab", 2)) ERR("wrong content");
6970

70-
if (__collfs_read(fd, buf, 3) != 3) ERR("read");
71+
if (__collfs_libc_read(fd, buf, 3) != 3) ERR("read");
7172
if (strncmp(buf, "cde", 3)) ERR("wrong repeat read");
7273

7374
off = __collfs_lseek(fd, 8, SEEK_CUR);
7475
if (off != 13) ERR("lseek CUR");
75-
if (__collfs_read(fd, buf, 3) != 3) ERR("read");
76+
if (__collfs_libc_read(fd, buf, 3) != 3) ERR("read");
7677
if (strncmp(buf, "nop", 3)) ERR("wrong content");
7778

7879
off = __collfs_lseek(fd, 5, SEEK_SET);
7980
if (off != 5) ERR("lseek SET");
80-
if (__collfs_read(fd, buf, 3) != 3) ERR("read");
81+
if (__collfs_libc_read(fd, buf, 3) != 3) ERR("read");
8182
if (strncmp(buf, "fgh", 3)) ERR("wrong content");
8283

8384
err = collfs_comm_pop();CHK(err);

libc-collfs-private.h

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,58 @@
66
#include <sys/types.h>
77
#include <unistd.h>
88

9-
int __collfs_fxstat64(int vers, int fd, struct stat64 *buf);
10-
int __collfs_xstat64(int vers, const char *file, struct stat64 *buf);
11-
void *__collfs_mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
12-
int __collfs_munmap(__ptr_t addr, size_t len);
13-
off_t __collfs_lseek(int fildes, off_t offset, int whence);
14-
int __collfs_open(const char *pathname, int flags, ...);
15-
int __collfs_close(int fd);
16-
ssize_t __collfs_read(int fd, void *buf, size_t count);
9+
struct libc_collfs_api {
10+
void (*fxstat64)(void);
11+
void (*xstat64)(void);
12+
void (*open)(void);
13+
void (*close)(void);
14+
void (*read)(void);
15+
void (*lseek)(void);
16+
void (*mmap)(void);
17+
void (*munmap)(void);
18+
};
19+
20+
extern struct libc_collfs_api _dl_collfs_api;
21+
22+
typedef int (*collfs_fxstat64_fp)(int vers, int fd, struct stat64 *buf);
23+
typedef int (*collfs_xstat64_fp)(int vers, const char *file, struct stat64 *buf);
24+
typedef int (*collfs_open_fp)(const char *pathname, int flags, mode_t mode);
25+
typedef int (*collfs_close_fp)(int fd);
26+
typedef ssize_t (*collfs_read_fp)(int fd, void *buf, size_t count);
27+
typedef off_t (*collfs_lseek_fp)(int fildes, off_t offset, int whence);
28+
typedef void *(*collfs_mmap_fp)(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
29+
typedef int (*collfs_munmap_fp)(__ptr_t addr, size_t len);
30+
31+
#define __collfs_open(pathname,flags) \
32+
((_dl_collfs_api.open != NULL) ? \
33+
((collfs_open_fp) _dl_collfs_api.open)(pathname,flags,O_RDONLY) : __open(pathname, flags))
34+
35+
#define __collfs_close(fd) \
36+
((_dl_collfs_api.close != NULL) ? \
37+
((collfs_close_fp) _dl_collfs_api.close)(fd) : __close(fd))
38+
39+
#define __collfs_lseek(fildes, offset, whence) \
40+
((_dl_collfs_api.lseek != NULL) ? \
41+
((collfs_lseek_fp) _dl_collfs_api.lseek)(fildes, offset, whence) : __lseek(fildes, offset, whence))
42+
43+
#define __collfs_fxstat64(vers, fd, buf) \
44+
((_dl_collfs_api.fxstat64 != NULL) ? \
45+
((collfs_fxstat64_fp) _dl_collfs_api.fxstat64)(vers, fd, buf) : __fxstat64(vers, fd, buf))
46+
47+
#define __collfs_xstat64(vers, file, buf) \
48+
((_dl_collfs_api.xstat64 != NULL) ? \
49+
((collfs_xstat64_fp) _dl_collfs_api.xstat64)(vers, file, buf) : __xstat64(vers, file, buf))
50+
51+
#define __collfs_libc_read(fd, buf, count) \
52+
((_dl_collfs_api.read != NULL) ? \
53+
((collfs_read_fp) _dl_collfs_api.read)(fd, buf, count) : read(fd, buf, count))
54+
55+
#define __collfs_mmap(addr, len, prot, flags, fildes, off) \
56+
((_dl_collfs_api.mmap != NULL) ? \
57+
((collfs_mmap_fp) _dl_collfs_api.mmap)(addr, len, prot, flags, fildes, off) : mmap(addr, len, prot, flags, fildes, off))
58+
59+
#define __collfs_munmap(addr, len) \
60+
((_dl_collfs_api.munmap != NULL) ? \
61+
((collfs_munmap_fp) _dl_collfs_api.munmap)(addr, len) : munmap(addr, len))
1762

1863
#endif

shaheen/extended_tests.ll

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
#
3+
# @ job_name = kslrun_job
4+
# @ job_type = bluegene
5+
# @ output = ./$(job_name)_$(jobid).out
6+
# @ error = ./$(job_name)_$(jobid).err
7+
# @ environment = COPY_ALL;
8+
# @ wall_clock_limit = 4:00:00,4:00:00
9+
# @ notification = always
10+
# @ bg_size = 2048
11+
# @ account_no = k01
12+
13+
# @ queue
14+
15+
projdir=/project/k01/pyclaw
16+
sandbox=${projdir}/sandbox
17+
builddir=${projdir}/opt/share
18+
srcdir=${builddir}/sources
19+
20+
pythondir=${builddir}/python/2.7.2/bgp
21+
ldpath=${pythondir}/lib
22+
numpy_path=${builddir}/numpy/1.6.2/bgp/lib/python
23+
nose_path=${builddir}/nose/1.1.2/bgp/lib/python
24+
clawpack_path=${builddir}/clawpack/dev/bgp/lib/python
25+
petsc4py_path=${builddir}/petsc4py/1.2/bgp/lib/python
26+
mpi_python_path=${builddir}/mpi4py/1.3/bgp/lib/python
27+
28+
bgp_python_path=${numpy_path}:${nose_path}:${clawpack_path}:${petsc4py_path}:${mpi_python_path}
29+
30+
bgp_python=${pythondir}/bin/python
31+
mpi_python=${builddir}/mpi4py/1.3/bgp/lib/python/mpi4py/bin/python-mpi
32+
33+
testdir=/gpfs/scratch/aron/sandbox/import/collfs/tests
34+
35+
cd $testdir
36+
logdir=${testdir}/runs
37+
mkdir -p ${logdir}
38+
39+
for np in 1 2 4 8 16 32 64 128 256 512 1024 2048 4096
40+
do
41+
mpirun -env LD_LIBRARY_PATH=${ldpath} -env PYTHONPATH=${bgp_python_path} \
42+
-mode VN -exp_env HOME -n 2 ${bgp_python} test_python_importer.py &> ${logdir}/python_${np}.txt
43+
mpirun -env LD_LIBRARY_PATH=${ldpath} -env PYTHONPATH=${bgp_python_path} \
44+
-mode VN -exp_env HOME -n 2 ${mpi_python} test_collfs_importer.py &> ${logdir}/collfs_${np}.txt
45+
mpirun -env LD_LIBRARY_PATH=${ldpath} -env PYTHONPATH=${bgp_python_path} \
46+
-mode VN -exp_env HOME -n 2 ${bgp_python} test_mpi4py_cached_importer.py &> ${logdir}/asher_${np}.txt
47+
mpirun -env LD_LIBRARY_PATH=${ldpath} -env PYTHONPATH=${bgp_python_path} \
48+
-mode VN -exp_env HOME -n 2 ${mpi_python} test_mpi4py_cached_importer.py &> ${logdir}/asher_collfs_${np}.txt
49+
done

shaheen/kslrun_job_submit.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
#
3+
# @ job_name = kslrun_job
4+
# @ job_type = bluegene
5+
# @ output = ./$(job_name)_$(jobid).out
6+
# @ error = ./$(job_name)_$(jobid).err
7+
# @ environment = COPY_ALL;
8+
# @ wall_clock_limit = 2:00:00,2:00:00
9+
# @ notification = always
10+
# @ bg_size = 128
11+
# @ account_no = k01
12+
13+
# @ queue
14+
15+
llx

shaheen/test_pyclaw.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
projdir=/project/k01/pyclaw
2+
sandbox=${projdir}/sandbox
3+
builddir=${projdir}/opt/share
4+
logdir=${builddir}/logs
5+
srcdir=${builddir}/sources
6+
7+
pythondir=${builddir}/python/2.7.2/bgp
8+
ldpath=${pythondir}/lib
9+
numpy_path=${builddir}/numpy/1.6.2/bgp/lib/python
10+
nose_path=${builddir}/nose/1.1.2/bgp/lib/python
11+
clawpack_path=${builddir}/clawpack/dev/bgp/lib/python
12+
petsc4py_path=${builddir}/petsc4py/1.2/bgp/lib/python
13+
mpi_python_path=${builddir}/mpi4py/1.3/bgp/lib/python
14+
15+
bgp_python_path=${numpy_path}:${nose_path}:${clawpack_path}:${petsc4py_path}:${mpi_python_path}
16+
17+
mpi_python=${builddir}/mpi4py/1.3/bgp/lib/python/mpi4py/bin/python-mpi
18+
19+
mpirun -env LD_LIBRARY_PATH=${ldpath} -env PYTHONPATH=${bgp_python_path} \
20+
-mode VN -exp_env HOME -n 2 ${mpi_python} -v test.py

main.c renamed to test_collfs.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515
extern int MPI_Init(int *argc, char ***argv) __attribute__ ((weak));
1616
extern int MPI_Finalize() __attribute__ ((weak));
1717

18+
struct libc_collfs_api {
19+
void (*fxstat64)(void);
20+
void (*xstat64)(void);
21+
void (*open)(void);
22+
void (*close)(void);
23+
void (*read)(void);
24+
void (*lseek)(void);
25+
void (*mmap)(void);
26+
void (*munmap)(void);
27+
};
28+
29+
struct libc_collfs_api _dl_collfs_api;
30+
1831
int run_tests(const char *soname, const char *path)
1932
{
2033
void *handle;
@@ -29,10 +42,6 @@ int run_tests(const char *soname, const char *path)
2942
if (!func) ERR("dlsym could not find symbol \"thefunc\" due to: %s", dlerror());
3043
err = (*func)();CHK(err);
3144

32-
test_fxstat64 = dlsym(handle,"thetest_fxstat64");
33-
if (!func) ERR("dlsym could not find symbol \"thetest_fxstat64\" due to: %s", dlerror());
34-
err = (*test_fxstat64)(path);CHK(err);
35-
3645
err = dlclose(handle);
3746
if (err) ERR("dlclose failed due to: %s", dlerror());
3847
return 0;
@@ -48,7 +57,7 @@ int main(int argc, char *argv[])
4857
MPI_Init(&argc,&argv);
4958
}
5059
if (!getcwd(path,sizeof path)) ERR("getcwd failed");
51-
strcat(path,"/libthefunc.so");
60+
strcat(path,"/libminimal_thefunc.so");
5261
err = run_tests(path, path);CHK(err);
5362
err = foo(path);CHK(err);
5463
err = foo2("alphabet.txt");CHK(err);

0 commit comments

Comments
 (0)