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

updated wrt latest darshan version (3.1.1) and added lustre module

parent 0d5c8e27
......@@ -15,23 +15,15 @@ VALUE mDarshanBGQ;
static VALUE Darshan3rb_bgq_get_rank(VALUE self)
{
struct darshan_bgq_record* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
if(c_record) return LL2NUM(c_record->rank);
else return Qnil;
}
static VALUE Darshan3rb_bgq_get_alignment(VALUE self)
{
struct darshan_bgq_record* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
if(c_record) return INT2NUM(c_record->alignment);
Data_Get_Struct(self,struct darshan_bgq_record,c_record);
if(c_record) return LL2NUM(c_record->base_rec.rank);
else return Qnil;
}
static VALUE Darshan3rb_bgq_get_counter(VALUE self, VALUE index)
{
struct darshan_bgq_record* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
Data_Get_Struct(self,struct darshan_bgq_record,c_record);
int i = NUM2INT(index);
if((i < 0) || (c_record == NULL)) return Qnil;
if(i < BGQ_NUM_INDICES) return LL2NUM(c_record->counters[i]);
......@@ -59,15 +51,14 @@ void Darshan3rb_init_bgq()
cDarshanBGQRecord = rb_define_class_under(mDarshanBGQ,"Record",cDarshanRecord);
rb_define_method(cDarshanBGQRecord,"rank",Darshan3rb_bgq_get_rank,0);
rb_define_method(cDarshanBGQRecord,"counter",Darshan3rb_bgq_get_counter,1);
rb_define_method(cDarshanBGQRecord,"alignment",Darshan3rb_bgq_get_alignment,0);
}
VALUE Darshan3rb_get_bgq_record(darshan_fd fd, darshan_record_id* rec_id)
{
struct darshan_bgq_record* c_record = (struct darshan_bgq_record*)malloc(sizeof(struct darshan_bgq_record));
int r = mod_logutils[DARSHAN_BGQ_MOD]->log_get_record(fd, (char*)c_record, rec_id);
struct darshan_bgq_record* c_record = NULL;
int r = mod_logutils[DARSHAN_BGQ_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(cDarshanBGQRecord, NULL , free, c_record);
return rb_record;
}
......@@ -27,7 +27,7 @@ static VALUE rb_darshan_open(VALUE self, VALUE name)
// get the job struct
struct darshan_job job;
int err = darshan_log_getjob(fd,&job);
int err = darshan_log_get_job(fd,&job);
if(err < 0) return Qnil;
......@@ -63,8 +63,9 @@ static VALUE rb_darshan_open(VALUE self, VALUE name)
rb_iv_set(res,"@metadata", metadata);
// set the executable name
char exe[DARSHAN_EXE_LEN+2];
err = darshan_log_getexe(fd, exe);
char exe[DARSHAN_EXE_LEN+1];
memset(exe,0,DARSHAN_EXE_LEN+1);
err = darshan_log_get_exe(fd, exe);
if(err < 0) return Qnil;
......@@ -75,10 +76,9 @@ static VALUE rb_darshan_open(VALUE self, VALUE name)
rb_iv_set(res,"@current_module", INT2NUM(-1));
// set the list of mount points
char** mnt_pts = NULL;
char** fs_types = NULL;
int count = 0;
err = darshan_log_getmounts(fd,&mnt_pts,&fs_types,&count);
struct darshan_mnt_info *mnt_info;
err = darshan_log_get_mounts(fd,&mnt_info,&count);
if(err < 0) {
return Qnil;
......@@ -90,22 +90,17 @@ static VALUE rb_darshan_open(VALUE self, VALUE name)
int i;
for(i=0; i<count; i++) {
VALUE hash = rb_hash_new();
rb_hash_aset(hash,path,rb_str_new2(mnt_pts[i]));
rb_hash_aset(hash,type,rb_str_new2(fs_types[i]));
rb_hash_aset(hash,path,rb_str_new2(mnt_info[i].mnt_path));
rb_hash_aset(hash,type,rb_str_new2(mnt_info[i].mnt_type));
rb_ary_store(mp,i,hash);
if(mnt_pts != NULL && mnt_pts[i] != NULL)
free(mnt_pts[i]);
if(fs_types != NULL && fs_types[i] != NULL)
free(fs_types[i]);
}
if(mnt_info) free(mnt_info);
if(mnt_pts != NULL) free(mnt_pts);
if(fs_types != NULL) free(fs_types);
rb_iv_set(res,"@mount_points", mp);
// get the hash
struct darshan_record_ref *rec_hash = NULL;
err = darshan_log_gethash(fd, &rec_hash);
struct darshan_name_record_ref *rec_hash = NULL;
err = darshan_log_get_namehash(fd, &rec_hash);
if(err < 0) {
return Qnil;
}
......@@ -185,8 +180,8 @@ static VALUE rb_darshan_next_record(VALUE self)
if(fd == NULL) return Qnil;
VALUE rbhash = rb_iv_get(rfd,"@hash");
struct darshan_record_ref* rec_hash = NULL;
Data_Get_Struct(rbhash,struct darshan_record_ref, rec_hash);
struct darshan_name_record_ref* rec_hash = NULL;
Data_Get_Struct(rbhash,struct darshan_name_record_ref, rec_hash);
if(rec_hash == NULL) return Qnil;
darshan_record_id rec_id;
......@@ -211,14 +206,17 @@ static VALUE rb_darshan_next_record(VALUE self)
case DARSHAN_BGQ_MOD:
res = Darshan3rb_get_bgq_record(fd,&rec_id);
break;
case DARSHAN_LUSTRE_MOD:
res = Darshan3rb_get_lustre_record(fd,&rec_id);
break;
}
if(res == Qnil) return Qnil;
struct darshan_record_ref* ref;
struct darshan_name_record_ref* ref;
HASH_FIND(hlink, rec_hash, &rec_id, sizeof(darshan_record_id), ref);
rb_iv_set(res,"@name",rb_str_new2(ref->rec.name));
rb_iv_set(res,"@name",rb_str_new2(ref->name_record->name));
return res;
}
......@@ -244,6 +242,7 @@ void Init_Darshan3rb() {
Darshan3rb_init_hdf5();
Darshan3rb_init_pnetcdf();
Darshan3rb_init_bgq();
Darshan3rb_init_lustre();
rb_define_method(cDarshanLogFile,"next_module",
rb_darshan_next_module,0);
......
......@@ -15,5 +15,6 @@
#include "hdf5-module.h"
#include "pnetcdf-module.h"
#include "bgq-module.h"
#include "lustre-module.h"
#endif
......@@ -15,15 +15,15 @@ VALUE mDarshanHDF5;
static VALUE Darshan3rb_hdf5_get_rank(VALUE self)
{
struct darshan_hdf5_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
if(c_record) return LL2NUM(c_record->rank);
Data_Get_Struct(self,struct darshan_hdf5_file,c_record);
if(c_record) return LL2NUM(c_record->base_rec.rank);
else return Qnil;
}
static VALUE Darshan3rb_hdf5_get_counter(VALUE self, VALUE index)
{
struct darshan_hdf5_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
Data_Get_Struct(self, struct darshan_hdf5_file, c_record);
int i = NUM2INT(index);
if((i < 0) || (c_record == NULL)) return Qnil;
if(i < HDF5_NUM_INDICES) return LL2NUM(c_record->counters[i]);
......@@ -55,10 +55,10 @@ void Darshan3rb_init_hdf5()
VALUE Darshan3rb_get_hdf5_record(darshan_fd fd, darshan_record_id* rec_id)
{
struct darshan_hdf5_file* c_record = (struct darshan_hdf5_file*)malloc(sizeof(struct darshan_hdf5_file));
int r = mod_logutils[DARSHAN_HDF5_MOD]->log_get_record(fd, (char*)c_record, rec_id);
struct darshan_hdf5_file* c_record = NULL;
int r = mod_logutils[DARSHAN_HDF5_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(cDarshanHDF5Record, NULL , free, c_record);
return rb_record;
}
......@@ -8,4 +8,4 @@
void Darshan3rb_init_hdf5();
VALUE Darshan3rb_get_hdf5_record(darshan_fd fd, darshan_record_id* rec_id);
VALUE Darshan3rb_get_hdf5_record(darshan_fd fd, darshan_record_id* id);
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#include "darshan-ruby.h"
extern VALUE cDarshanRecord;
extern VALUE mDarshan;
VALUE cDarshanLustreRecord;
VALUE mDarshanLustre;
static VALUE Darshan3rb_lustre_get_counter(VALUE self, VALUE index)
{
struct darshan_lustre_record* c_record = NULL;
Data_Get_Struct(self,struct darshan_lustre_record, c_record);
int i = NUM2INT(index);
if((i < 0) || (c_record == NULL)) return Qnil;
if(i < LUSTRE_NUM_INDICES) return LL2NUM(c_record->counters[i]);
else return Qnil;
}
void Darshan3rb_init_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,"NAMES",cnames);
cDarshanLustreRecord = rb_define_class_under(mDarshanLustre,"Record",cDarshanRecord);
rb_define_method(cDarshanLustreRecord,"counter",Darshan3rb_lustre_get_counter,1);
}
VALUE Darshan3rb_get_lustre_record(darshan_fd fd, darshan_record_id* rec_id)
{
struct darshan_lustre_record* c_record = NULL;
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);
return rb_record;
}
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#include <ruby.h>
void Darshan3rb_init_lustre();
VALUE Darshan3rb_get_lustre_record(darshan_fd fd, darshan_record_id* rec_id);
......@@ -15,15 +15,15 @@ VALUE mDarshanMPIIO;
static VALUE Darshan3rb_mpiio_get_rank(VALUE self)
{
struct darshan_mpiio_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
if(c_record) return LL2NUM(c_record->rank);
Data_Get_Struct(self,struct darshan_mpiio_file,c_record);
if(c_record) return LL2NUM(c_record->base_rec.rank);
else return Qnil;
}
static VALUE Darshan3rb_mpiio_get_counter(VALUE self, VALUE index)
{
struct darshan_mpiio_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
Data_Get_Struct(self,struct darshan_mpiio_file,c_record);
int i = NUM2INT(index);
if((i < 0) || (c_record == NULL)) return Qnil;
if(i < MPIIO_NUM_INDICES) return LL2NUM(c_record->counters[i]);
......@@ -55,10 +55,10 @@ void Darshan3rb_init_mpiio()
VALUE Darshan3rb_get_mpiio_record(darshan_fd fd, darshan_record_id* rec_id)
{
struct darshan_mpiio_file* c_record = (struct darshan_mpiio_file*)malloc(sizeof(struct darshan_mpiio_file));
int r = mod_logutils[DARSHAN_MPIIO_MOD]->log_get_record(fd, (char*)c_record, rec_id);
struct darshan_mpiio_file* c_record = NULL;
int r = mod_logutils[DARSHAN_MPIIO_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(cDarshanMPIIORecord, NULL , free, c_record);
return rb_record;
}
......@@ -15,15 +15,15 @@ VALUE mDarshanPNETCDF;
static VALUE Darshan3rb_pnetcdf_get_rank(VALUE self)
{
struct darshan_pnetcdf_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
if(c_record) return LL2NUM(c_record->rank);
Data_Get_Struct(self,struct darshan_pnetcdf_file,c_record);
if(c_record) return LL2NUM(c_record->base_rec.rank);
else return Qnil;
}
static VALUE Darshan3rb_pnetcdf_get_counter(VALUE self, VALUE index)
{
struct darshan_pnetcdf_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
Data_Get_Struct(self,struct darshan_pnetcdf_file,c_record);
int i = NUM2INT(index);
if((i < 0) || (c_record == NULL)) return Qnil;
if(i < PNETCDF_NUM_INDICES) return LL2NUM(c_record->counters[i]);
......@@ -55,10 +55,10 @@ void Darshan3rb_init_pnetcdf()
VALUE Darshan3rb_get_pnetcdf_record(darshan_fd fd, darshan_record_id* rec_id)
{
struct darshan_pnetcdf_file* c_record = (struct darshan_pnetcdf_file*)malloc(sizeof(struct darshan_pnetcdf_file));
int r = mod_logutils[DARSHAN_PNETCDF_MOD]->log_get_record(fd, (char*)c_record, rec_id);
struct darshan_pnetcdf_file* c_record = NULL;
int r = mod_logutils[DARSHAN_PNETCDF_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(cDarshanPNETCDFRecord, NULL , free, c_record);
return rb_record;
}
......@@ -15,15 +15,15 @@ VALUE mDarshanPOSIX;
static VALUE Darshan3rb_posix_get_rank(VALUE self)
{
struct darshan_posix_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
if(c_record) return LL2NUM(c_record->rank);
Data_Get_Struct(self, struct darshan_posix_file, c_record);
if(c_record) return LL2NUM(c_record->base_rec.rank);
else return Qnil;
}
static VALUE Darshan3rb_posix_get_counter(VALUE self, VALUE index)
{
struct darshan_posix_file* c_record = NULL;
Data_Get_Struct(self,struct darshan_fd_s,c_record);
Data_Get_Struct(self,struct darshan_posix_file, c_record);
int i = NUM2INT(index);
if((i < 0) || (c_record == NULL)) return Qnil;
if(i < POSIX_NUM_INDICES) return LL2NUM(c_record->counters[i]);
......@@ -55,10 +55,10 @@ void Darshan3rb_init_posix()
VALUE Darshan3rb_get_posix_record(darshan_fd fd, darshan_record_id* rec_id)
{
struct darshan_posix_file* c_record = (struct darshan_posix_file*)malloc(sizeof(struct darshan_posix_file));
int r = mod_logutils[DARSHAN_POSIX_MOD]->log_get_record(fd, (char*)c_record, rec_id);
struct darshan_posix_file* c_record = NULL;
int r = mod_logutils[DARSHAN_POSIX_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(cDarshanPOSIXRecord, NULL , free, c_record);
return rb_record;
}
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