darshan 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/darshan/darshan.c +276 -0
- data/ext/darshan/extconf.rb +46 -0
- data/lib/darshan.rb +88 -0
- metadata +58 -0
@@ -0,0 +1,276 @@
|
|
1
|
+
// This program is free software: you can redistribute it and/or modify
|
2
|
+
// it under the terms of the GNU Lesser General Public License as published by
|
3
|
+
// the Free Software Foundation, either version 3 of the License, or
|
4
|
+
// (at your option) any later version.
|
5
|
+
//
|
6
|
+
// This program is distributed in the hope that it will be useful,
|
7
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
8
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
9
|
+
// GNU Lesser General Public License for more details.
|
10
|
+
//
|
11
|
+
// You should have received a copy of the GNU Lesser General Public License
|
12
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
13
|
+
//######################################################################
|
14
|
+
// Author: Matthieu Dorier
|
15
|
+
// Institution: ENS Cachan Brittany
|
16
|
+
// Mail: matthieu.dorier [at] irisa.fr
|
17
|
+
// Date: April 14th, 2013
|
18
|
+
//######################################################################
|
19
|
+
|
20
|
+
#include <ruby.h>
|
21
|
+
#define DARSHAN_CONFIG_H "darshan-util-config.h"
|
22
|
+
#include <darshan-logutils.h>
|
23
|
+
|
24
|
+
VALUE mDarshan; // Darshan module in Ruby
|
25
|
+
VALUE cDarshanException;// Darshan::Exception class
|
26
|
+
VALUE cDarshanLogFile; // Darshan::LogFile class
|
27
|
+
VALUE cDarshanFile; // Darshan::File class
|
28
|
+
|
29
|
+
/* Within: Darshan module
|
30
|
+
* Opens a log file using its name and mode.
|
31
|
+
* Returns an instance of Darshan::LogFile on sucess, nil on failure.
|
32
|
+
*/
|
33
|
+
static VALUE rb_darshan_open(VALUE self, VALUE name, VALUE mode)
|
34
|
+
{
|
35
|
+
const char* c_name = rb_string_value_cstr(&name);
|
36
|
+
const char* c_mode = rb_string_value_cstr(&mode);
|
37
|
+
darshan_fd fd = darshan_log_open(c_name, c_mode);
|
38
|
+
if(fd != NULL) {
|
39
|
+
VALUE res = Data_Wrap_Struct(cDarshanLogFile, NULL ,NULL, fd);
|
40
|
+
// set the name of the file
|
41
|
+
rb_iv_set(res, "@name", rb_str_new2(fd->name));
|
42
|
+
|
43
|
+
// get the job struct
|
44
|
+
struct darshan_job job;
|
45
|
+
darshan_log_getjob(fd,&job);
|
46
|
+
|
47
|
+
// set the version number
|
48
|
+
rb_iv_set(res,"@version", rb_str_new2(job.version_string));
|
49
|
+
// set the magic number
|
50
|
+
rb_iv_set(res,"@magic_number", LL2NUM(job.magic_nr));
|
51
|
+
// set the uid
|
52
|
+
rb_iv_set(res,"@uid", LL2NUM(job.uid));
|
53
|
+
// set the start time
|
54
|
+
rb_iv_set(res,"@start_time", LL2NUM(job.start_time));
|
55
|
+
// set the end time
|
56
|
+
rb_iv_set(res,"@end_time", LL2NUM(job.end_time));
|
57
|
+
// set the job id
|
58
|
+
rb_iv_set(res,"@job_id", LL2NUM(job.jobid));
|
59
|
+
// set the number of processes
|
60
|
+
rb_iv_set(res,"@size", LL2NUM(job.nprocs));
|
61
|
+
// set the metadata
|
62
|
+
rb_iv_set(res,"@metadata", rb_str_new2(job.metadata));
|
63
|
+
|
64
|
+
// set the executable name
|
65
|
+
char exe[CP_EXE_LEN+2];
|
66
|
+
darshan_log_getexe(fd, exe);
|
67
|
+
rb_iv_set(res,"@exe", rb_str_new2(exe));
|
68
|
+
|
69
|
+
// set the list of mount points
|
70
|
+
int64_t* devs;
|
71
|
+
char** mnt_pts;
|
72
|
+
char** fs_types;
|
73
|
+
int count;
|
74
|
+
int err = darshan_log_getmounts(fd,
|
75
|
+
&devs,&mnt_pts,&fs_types,&count);
|
76
|
+
VALUE dev = ID2SYM(rb_intern("dev"));
|
77
|
+
VALUE mount = ID2SYM(rb_intern("mount"));
|
78
|
+
VALUE type = ID2SYM(rb_intern("type"));
|
79
|
+
VALUE mp = rb_ary_new2(count);
|
80
|
+
int i;
|
81
|
+
for(i=0; i<count; i++) {
|
82
|
+
VALUE hash = rb_hash_new();
|
83
|
+
rb_hash_aset(hash,dev,INT2NUM(devs[i]));
|
84
|
+
rb_hash_aset(hash,mount,rb_str_new2(mnt_pts[i]));
|
85
|
+
rb_hash_aset(hash,type,rb_str_new2(fs_types[i]));
|
86
|
+
rb_ary_store(mp,i,hash);
|
87
|
+
free(mnt_pts[i]);
|
88
|
+
free(fs_types[i]);
|
89
|
+
}
|
90
|
+
free(devs);
|
91
|
+
free(mnt_pts);
|
92
|
+
free(fs_types);
|
93
|
+
rb_iv_set(res,"@mount_points", mp);
|
94
|
+
return res;
|
95
|
+
} else {
|
96
|
+
return Qnil;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
/* Within: Darshan module
|
101
|
+
* Closes a file (instance of Darshan::LogFile)
|
102
|
+
* Returns true on success, false on failure.
|
103
|
+
*/
|
104
|
+
static VALUE rb_darshan_close(VALUE self, VALUE fd)
|
105
|
+
{
|
106
|
+
darshan_fd c_fd = NULL;
|
107
|
+
Data_Get_Struct(fd,struct darshan_fd_s,c_fd);
|
108
|
+
if(c_fd != NULL) {
|
109
|
+
darshan_log_close(c_fd);
|
110
|
+
return Qtrue;
|
111
|
+
} else {
|
112
|
+
return Qfalse;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
/* Within: Darshan::LogFile class
|
117
|
+
* Returns the next Darshan::File entry from the log file,
|
118
|
+
* or nil if there is no more such an entry.
|
119
|
+
*/
|
120
|
+
static VALUE rb_darshan_next_file(VALUE self)
|
121
|
+
{
|
122
|
+
|
123
|
+
darshan_fd fd = NULL;
|
124
|
+
Data_Get_Struct(self,struct darshan_fd_s, fd);
|
125
|
+
if(fd == NULL) return Qnil;
|
126
|
+
struct darshan_file* file = NULL;
|
127
|
+
VALUE rb_file = Data_Make_Struct(cDarshanFile,
|
128
|
+
struct darshan_file,
|
129
|
+
NULL, free, file);
|
130
|
+
Data_Get_Struct(rb_file, struct darshan_file, file);
|
131
|
+
if(file == NULL) return Qnil;
|
132
|
+
// if Darshan starts using the 2nd argument of
|
133
|
+
// log_getfile, we'll have a problem
|
134
|
+
if(darshan_log_getfile(fd, NULL, file) != 1) {
|
135
|
+
return Qnil;
|
136
|
+
}
|
137
|
+
return rb_file;
|
138
|
+
}
|
139
|
+
|
140
|
+
/* Within: Darshan::File class
|
141
|
+
* Returns the value for a given counter, nil on failure.
|
142
|
+
*/
|
143
|
+
static VALUE rb_darshan_file_get_counter(VALUE self, VALUE counter)
|
144
|
+
{
|
145
|
+
int c = NUM2INT(counter);
|
146
|
+
struct darshan_file* file = NULL;
|
147
|
+
Data_Get_Struct(self, struct darshan_file, file);
|
148
|
+
if(file != NULL) {
|
149
|
+
int64_t cnt = file->counters[c];
|
150
|
+
if(cnt == -1) return Qnil;
|
151
|
+
else return LL2NUM(cnt);
|
152
|
+
} else {
|
153
|
+
return Qnil;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
/* Within: Darshan::File class
|
158
|
+
* Returns the value for a given fconter, nil on failure.
|
159
|
+
*/
|
160
|
+
static VALUE rb_darshan_file_get_fcounter(VALUE self, VALUE counter)
|
161
|
+
{
|
162
|
+
int c = NUM2INT(counter);
|
163
|
+
struct darshan_file* file = NULL;
|
164
|
+
Data_Get_Struct(self, struct darshan_file, file);
|
165
|
+
if(file != NULL) {
|
166
|
+
int64_t cnt = file->fcounters[c];
|
167
|
+
if(cnt == -1) return Qnil;
|
168
|
+
else return LL2NUM(cnt);
|
169
|
+
} else {
|
170
|
+
return Qnil;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
/* Within: Darshan::File class
|
175
|
+
* Returns the hash of the file, or nil on failure.
|
176
|
+
*/
|
177
|
+
static VALUE rb_darshan_file_get_hash(VALUE self)
|
178
|
+
{
|
179
|
+
struct darshan_file* file = NULL;
|
180
|
+
Data_Get_Struct(self, struct darshan_file, file);
|
181
|
+
if(file != NULL) {
|
182
|
+
return LL2NUM(file->hash);
|
183
|
+
} else {
|
184
|
+
return Qnil;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
/* Within: Darshan::File class
|
189
|
+
* Returns the rank that produced the file, or nil on failure.
|
190
|
+
*/
|
191
|
+
static VALUE rb_darshan_file_get_rank(VALUE self)
|
192
|
+
{
|
193
|
+
struct darshan_file* file = NULL;
|
194
|
+
Data_Get_Struct(self, struct darshan_file, file);
|
195
|
+
if(file != NULL) {
|
196
|
+
return LL2NUM(file->rank);
|
197
|
+
} else {
|
198
|
+
return Qnil;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
/* Within: Darshan::File class
|
203
|
+
* Returns true if the file was collectively accessed, false otherwise.
|
204
|
+
*/
|
205
|
+
static VALUE rb_darshan_file_collective(VALUE self)
|
206
|
+
{
|
207
|
+
struct darshan_file* file = NULL;
|
208
|
+
Data_Get_Struct(self, struct darshan_file, file);
|
209
|
+
if(file != NULL) {
|
210
|
+
if(file->rank == -1) return Qtrue;
|
211
|
+
else return Qfalse;
|
212
|
+
} else {
|
213
|
+
return Qfalse;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
/* Within: Darshan::File class
|
218
|
+
* Returns the suffix of the name of the file, nil on failure.
|
219
|
+
*/
|
220
|
+
static VALUE rb_darshan_file_get_name_suffix(VALUE self)
|
221
|
+
{
|
222
|
+
struct darshan_file* file = NULL;
|
223
|
+
Data_Get_Struct(self, struct darshan_file, file);
|
224
|
+
if(file != NULL) {
|
225
|
+
return rb_str_new2(file->name_suffix);
|
226
|
+
} else {
|
227
|
+
return Qnil;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
/* Initialize the Darshan Ruby library
|
232
|
+
*/
|
233
|
+
void Init_RBDarshan() {
|
234
|
+
mDarshan = rb_define_module("Darshan");
|
235
|
+
cDarshanLogFile =
|
236
|
+
rb_define_class_under(mDarshan,"LogFile",rb_cObject);
|
237
|
+
cDarshanException =
|
238
|
+
rb_define_class_under(mDarshan,"Exception",rb_cObject);
|
239
|
+
cDarshanFile =
|
240
|
+
rb_define_class_under(mDarshan,"File",rb_cObject);
|
241
|
+
|
242
|
+
rb_define_module_function(mDarshan,"open",rb_darshan_open,2);
|
243
|
+
rb_define_module_function(mDarshan,"close",rb_darshan_close,1);
|
244
|
+
|
245
|
+
// define all the counters as constants and their names
|
246
|
+
VALUE cnames = rb_ary_new2(CP_NUM_INDICES);
|
247
|
+
int i;
|
248
|
+
for(i=0; i < CP_NUM_INDICES; i++) {
|
249
|
+
rb_ary_store(cnames,i,rb_str_new2(darshan_names[i]));
|
250
|
+
rb_define_const(mDarshan,darshan_names[i],INT2NUM(i));
|
251
|
+
}
|
252
|
+
rb_define_const(mDarshan,"NAMES",cnames);
|
253
|
+
|
254
|
+
VALUE cfnames = rb_ary_new2(CP_F_NUM_INDICES);
|
255
|
+
for(i=0; i < CP_F_NUM_INDICES; i++) {
|
256
|
+
rb_ary_store(cfnames,i,rb_str_new2(darshan_f_names[i]));
|
257
|
+
rb_define_const(mDarshan,darshan_f_names[i],INT2NUM(i));
|
258
|
+
}
|
259
|
+
rb_define_const(mDarshan,"F_NAMES",cfnames);
|
260
|
+
|
261
|
+
rb_define_method(cDarshanLogFile,"next_file",
|
262
|
+
rb_darshan_next_file,0);
|
263
|
+
|
264
|
+
rb_define_method(cDarshanFile,"counter",
|
265
|
+
rb_darshan_file_get_counter,1);
|
266
|
+
rb_define_method(cDarshanFile,"fcounter",
|
267
|
+
rb_darshan_file_get_fcounter,1);
|
268
|
+
rb_define_method(cDarshanFile,"hash",
|
269
|
+
rb_darshan_file_get_hash,0);
|
270
|
+
rb_define_method(cDarshanFile,"rank",
|
271
|
+
rb_darshan_file_get_rank,0);
|
272
|
+
rb_define_method(cDarshanFile,"collective",
|
273
|
+
rb_darshan_file_collective,0);
|
274
|
+
rb_define_method(cDarshanFile,"name_suffix",
|
275
|
+
rb_darshan_file_get_name_suffix,0);
|
276
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# This program is free software: you can redistribute it and/or modify
|
2
|
+
# it under the terms of the GNU General Public License as published by
|
3
|
+
# the Free Software Foundation, either version 3 of the License, or
|
4
|
+
# (at your option) any later version.
|
5
|
+
#
|
6
|
+
# This program is distributed in the hope that it will be useful,
|
7
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
8
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
9
|
+
# GNU General Public License for more details.
|
10
|
+
#
|
11
|
+
# You should have received a copy of the GNU General Public License
|
12
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
13
|
+
#######################################################################
|
14
|
+
# Author: Matthieu Dorier
|
15
|
+
# Institution: ENS Cachan Brittany
|
16
|
+
# Mail: matthieu.dorier [at] irisa.fr
|
17
|
+
# Date: April 14th, 2013
|
18
|
+
#######################################################################
|
19
|
+
|
20
|
+
require 'mkmf'
|
21
|
+
|
22
|
+
dir_config('darshan')
|
23
|
+
|
24
|
+
if(not have_header('darshan-util-config.h'))
|
25
|
+
$stderr << "Error, could not find darshan-util-config.h\n"
|
26
|
+
$stderr << "Please use --with-darshan-dir=...\n"
|
27
|
+
abort "Missing darshan-util-config.h"
|
28
|
+
end
|
29
|
+
|
30
|
+
if(not have_library('z'))
|
31
|
+
$stderr << "Error, could not locate zlib.\n"
|
32
|
+
abort "Missing zlib"
|
33
|
+
end
|
34
|
+
|
35
|
+
if(not have_library('bz2'))
|
36
|
+
$stderr << "Error, could not locate libbz2.\n"
|
37
|
+
abort "Missing bz2"
|
38
|
+
end
|
39
|
+
|
40
|
+
if(not have_library('darshan-util'))
|
41
|
+
$stderr << "Error, could not locate libdarshan-util.\n"
|
42
|
+
$stderr << "Please use --with-darshan-dir=...\n"
|
43
|
+
abort "Missing libdarshan-util.a"
|
44
|
+
end
|
45
|
+
|
46
|
+
create_makefile("RBDarshan")
|
data/lib/darshan.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# This program is free software: you can redistribute it and/or modify
|
2
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
3
|
+
# the Free Software Foundation, either version 3 of the License, or
|
4
|
+
# (at your option) any later version.
|
5
|
+
#
|
6
|
+
# This program is distributed in the hope that it will be useful,
|
7
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
8
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
9
|
+
# GNU Lesser General Public License for more details.
|
10
|
+
#
|
11
|
+
# You should have received a copy of the GNU Lesser General Public License
|
12
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
13
|
+
#######################################################################
|
14
|
+
# Author: Matthieu Dorier
|
15
|
+
# Institution: ENS Cachan Brittany
|
16
|
+
# Mail: matthieu.dorier [at] irisa.fr
|
17
|
+
# Date: April 14th, 2013
|
18
|
+
#######################################################################
|
19
|
+
require "RBDarshan"
|
20
|
+
|
21
|
+
#=====================================================================#
|
22
|
+
# Darshan module, contains the functions to open and close a LogFile,
|
23
|
+
# as well as all the classes (LogFile, Job and File). Some of these
|
24
|
+
# classes are defined through the C code, and are thus not shown here.
|
25
|
+
#=====================================================================#
|
26
|
+
module Darshan
|
27
|
+
|
28
|
+
#=============================================================#
|
29
|
+
# LogFile class, represents a binary log file (compressed).
|
30
|
+
# Open it by using
|
31
|
+
# logfile = LogFile.open("filename")
|
32
|
+
# ...
|
33
|
+
# logfile.close
|
34
|
+
# or
|
35
|
+
# LogFile.open("filename") do | logfile |
|
36
|
+
# ...
|
37
|
+
# end
|
38
|
+
#=============================================================#
|
39
|
+
class LogFile
|
40
|
+
|
41
|
+
attr_reader :name
|
42
|
+
attr_reader :version
|
43
|
+
attr_reader :exe
|
44
|
+
attr_reader :magic_number
|
45
|
+
attr_reader :uid
|
46
|
+
attr_reader :start_time
|
47
|
+
attr_reader :end_time
|
48
|
+
attr_reader :job_id
|
49
|
+
attr_reader :size
|
50
|
+
attr_reader :metadata
|
51
|
+
attr_reader :mount_points
|
52
|
+
|
53
|
+
#=====================================================#
|
54
|
+
# Opens a logfile, calls the given block if present.
|
55
|
+
#=====================================================#
|
56
|
+
def self.open(filename,mode="r")
|
57
|
+
lf = Darshan.open(filename,mode)
|
58
|
+
if block_given? and lf != nil
|
59
|
+
yield lf
|
60
|
+
lf.close
|
61
|
+
lf = nil
|
62
|
+
end
|
63
|
+
return lf
|
64
|
+
end
|
65
|
+
|
66
|
+
#======================================================#
|
67
|
+
# Close the file.
|
68
|
+
#======================================================#
|
69
|
+
def close
|
70
|
+
Darshan.close(self)
|
71
|
+
end
|
72
|
+
|
73
|
+
#======================================================#
|
74
|
+
# Iterates through all the file entries described in
|
75
|
+
# the log file.
|
76
|
+
#======================================================#
|
77
|
+
def each_file
|
78
|
+
if not block_given?
|
79
|
+
return nil
|
80
|
+
end
|
81
|
+
file = nil
|
82
|
+
while((file = next_file()) != nil)
|
83
|
+
yield file
|
84
|
+
end
|
85
|
+
return nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: darshan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matthieu Dorier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2013-09-08 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Ruby binding to ANL's Darshan library for HPC I/O tracing and analysis
|
17
|
+
email: matthieu.dorier@irisa.fr
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/darshan/extconf.rb
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/darshan.rb
|
26
|
+
- ext/darshan/darshan.c
|
27
|
+
- ext/darshan/extconf.rb
|
28
|
+
has_rdoc: true
|
29
|
+
homepage: http://darshan-ruby.gforge.inria.fr/
|
30
|
+
licenses:
|
31
|
+
- LGPL
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
- ext
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
version:
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
requirements: []
|
51
|
+
|
52
|
+
rubyforge_project: nowarning
|
53
|
+
rubygems_version: 1.3.5
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Ruby binding to Darshan
|
57
|
+
test_files: []
|
58
|
+
|