Commit 1fdd7a5f authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

added STDIO module

parent cec813b4
......@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
"ext/darshan/mpiio-module.c", "ext/darshan/mpiio-module.h",
"ext/darshan/pnetcdf-module.c", "ext/darshan/pnetcdf-module.h",
"ext/darshan/posix-module.c", "ext/darshan/posix-module.h",
"ext/darshan/stdio-module.c", "ext/darshan/stdio-module.h",
"ext/darshan/lustre-module.c", "ext/darshan/lustre-module.h",
"ext/darshan/extconf.rb"]
s.require_paths = [ 'lib', 'ext' ]
......
......@@ -206,6 +206,9 @@ static VALUE rb_darshan_next_record(VALUE self)
case DARSHAN_BGQ_MOD:
res = Darshan3rb_get_bgq_record(fd,&rec_id);
break;
case DARSHAN_STDIO_MOD:
res = Darshan3rb_get_stdio_record(fd,&rec_id);
break;
case DARSHAN_LUSTRE_MOD:
res = Darshan3rb_get_lustre_record(fd,&rec_id);
break;
......@@ -242,6 +245,7 @@ void Init_Darshan3rb() {
Darshan3rb_init_hdf5();
Darshan3rb_init_pnetcdf();
Darshan3rb_init_bgq();
Darshan3rb_init_stdio();
Darshan3rb_init_lustre();
rb_define_method(cDarshanLogFile,"next_module",
......
......@@ -16,5 +16,6 @@
#include "pnetcdf-module.h"
#include "bgq-module.h"
#include "lustre-module.h"
#include "stdio-module.h"
#endif
......@@ -9,8 +9,8 @@
extern VALUE cDarshanRecord;
extern VALUE mDarshan;
VALUE cDarshanLustreRecord;
VALUE mDarshanLustre;
VALUE cDarshanLUSTRERecord;
VALUE mDarshanLUSTRE;
static VALUE Darshan3rb_lustre_get_counter(VALUE self, VALUE index)
{
......@@ -37,19 +37,19 @@ static VALUE Darshan3rb_lustre_get_osts(VALUE self)
void Darshan3rb_init_lustre()
{
mDarshanLustre = rb_define_module_under(mDarshan,"Lustre");
mDarshanLUSTRE = rb_define_module_under(mDarshan,"LUSTRE");
VALUE cnames = rb_ary_new2(LUSTRE_NUM_INDICES);
int i;
for(i=0; i < LUSTRE_NUM_INDICES; i++) {
rb_ary_store(cnames,i,rb_str_new2(mpiio_counter_names[i]));
rb_define_const(mDarshanLustre,mpiio_counter_names[i],INT2NUM(i));
rb_define_const(mDarshanLUSTRE,mpiio_counter_names[i],INT2NUM(i));
}
rb_define_const(mDarshanLustre,"NAMES",cnames);
rb_define_const(mDarshanLUSTRE,"NAMES",cnames);
cDarshanLustreRecord = rb_define_class_under(mDarshanLustre,"Record",cDarshanRecord);
rb_define_method(cDarshanLustreRecord,"counter",Darshan3rb_lustre_get_counter,1);
rb_define_method(cDarshanLustreRecord,"osts",Darshan3rb_lustre_get_osts,0);
cDarshanLUSTRERecord = rb_define_class_under(mDarshanLUSTRE,"Record",cDarshanRecord);
rb_define_method(cDarshanLUSTRERecord,"counter",Darshan3rb_lustre_get_counter,1);
rb_define_method(cDarshanLUSTRERecord,"osts",Darshan3rb_lustre_get_osts,0);
}
VALUE Darshan3rb_get_lustre_record(darshan_fd fd, darshan_record_id* rec_id)
......@@ -58,6 +58,6 @@ VALUE Darshan3rb_get_lustre_record(darshan_fd fd, darshan_record_id* rec_id)
int r = mod_logutils[DARSHAN_LUSTRE_MOD]->log_get_record(fd, (void**)&c_record);
if(r != 1) return Qnil;
*rec_id = c_record->base_rec.id;
VALUE rb_record = Data_Wrap_Struct(cDarshanLustreRecord, NULL , free, c_record);
VALUE rb_record = Data_Wrap_Struct(cDarshanLUSTRERecord, NULL , free, c_record);
return rb_record;
}
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#include "darshan-ruby.h"
extern VALUE cDarshanRecord;
extern VALUE mDarshan;
VALUE cDarshanSTDIORecord;
VALUE mDarshanSTDIO;
static VALUE Darshan3rb_stdio_get_rank(VALUE self)
{
struct darshan_stdio_file* c_record = NULL;
Data_Get_Struct(self, struct darshan_stdio_file, c_record);
if(c_record) return LL2NUM(c_record->base_rec.rank);
else return Qnil;
}
static VALUE Darshan3rb_stdio_get_counter(VALUE self, VALUE index)
{
struct darshan_stdio_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_stdio_file, c_record);
int i = NUM2INT(index);
if((i < 0) || (c_record == NULL)) return Qnil;
if(i < STDIO_NUM_INDICES) return LL2NUM(c_record->counters[i]);
if(i < STDIO_NUM_INDICES+STDIO_F_NUM_INDICES) return rb_float_new(c_record->fcounters[i-STDIO_NUM_INDICES]);
else return Qnil;
}
void Darshan3rb_init_stdio()
{
mDarshanSTDIO = rb_define_module_under(mDarshan,"STDIO");
VALUE cnames = rb_ary_new2(STDIO_NUM_INDICES+STDIO_F_NUM_INDICES);
int i;
for(i=0; i < STDIO_NUM_INDICES; i++) {
rb_ary_store(cnames,i,rb_str_new2(stdio_counter_names[i]));
rb_define_const(mDarshanSTDIO,stdio_counter_names[i],INT2NUM(i));
}
for(i=0; i < STDIO_F_NUM_INDICES; i++) {
int j = i+STDIO_NUM_INDICES;
rb_ary_store(cnames,j,rb_str_new2(stdio_f_counter_names[i]));
rb_define_const(mDarshanSTDIO,stdio_f_counter_names[i],INT2NUM(j));
}
rb_define_const(mDarshanSTDIO,"NAMES",cnames);
cDarshanSTDIORecord = rb_define_class_under(mDarshanSTDIO,"Record",cDarshanRecord);
rb_define_method(cDarshanSTDIORecord,"rank",Darshan3rb_stdio_get_rank,0);
rb_define_method(cDarshanSTDIORecord,"counter",Darshan3rb_stdio_get_counter,1);
}
VALUE Darshan3rb_get_stdio_record(darshan_fd fd, darshan_record_id* rec_id)
{
struct darshan_stdio_file* c_record = NULL;
int r = mod_logutils[DARSHAN_STDIO_MOD]->log_get_record(fd, (void**)&c_record);
if(r != 1) return Qnil;
*rec_id = c_record->base_rec.id;
VALUE rb_record = Data_Wrap_Struct(cDarshanSTDIORecord, NULL , free, c_record);
return rb_record;
}
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#include <ruby.h>
void Darshan3rb_init_stdio();
VALUE Darshan3rb_get_stdio_record(darshan_fd fd, darshan_record_id* rec_id);
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