Changeset 121
- Timestamp:
- 02/01/08 09:16:39 (7 months ago)
- Files:
-
- incubator/mpi_ruby/src/mpi.c (modified) (5 diffs)
- incubator/mpi_ruby/src/mpi_comm.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
incubator/mpi_ruby/src/mpi.c
r120 r121 26 26 { 27 27 int rv, flag; 28 28 29 29 rv = MPI_Initialized(&flag); 30 30 mpi_exception(rv); 31 31 32 32 return flag ? Qtrue : Qfalse; 33 33 } … … 37 37 int rv, len; 38 38 char buf[MPI_MAX_PROCESSOR_NAME]; 39 39 40 40 rv = MPI_Get_processor_name(buf, &len); 41 41 mpi_exception(rv); 42 42 43 43 return rb_str_new(buf, len); 44 44 } … … 51 51 Check_Type(rnnodes, T_FIXNUM); 52 52 nnodes = FIX2INT(rnnodes); 53 53 54 54 ndims = RARRAY(rdims)->len; 55 55 56 56 dims = ALLOCA_N(int, ndims); 57 57 for (i = 0; i < ndims; i++) 58 58 dims[i] = FIX2INT(rb_ary_entry(rdims, i)); 59 59 60 60 rv = MPI_Dims_create(nnodes, ndims, dims); 61 61 mpi_exception(rv); 62 62 63 63 ary = rb_ary_new2(ndims); 64 64 for (i = 0; i < ndims; i++) 65 65 rb_ary_store(ary, i, dims[i]); 66 66 67 67 return ary; 68 68 } … … 83 83 } 84 84 85 mMPI = rb_define_module("MPI");85 mMPI = rb_define_module("MPI"); 86 86 rb_define_module_function(mMPI, "wtime", mpi_wtime, 0); 87 87 rb_define_module_function(mMPI, "wtick", mpi_wtick, 0); … … 89 89 rb_define_module_function(mMPI, "processor_name", mpi_processor_name, 0); 90 90 rb_define_module_function(mMPI, "dims_create", mpi_dims_create, 2); 91 91 92 92 UNDEFINED = rb_obj_alloc(rb_cObject); 93 93 rb_define_singleton_method(UNDEFINED, "to_s", undefined_to_s, 0); 94 94 rb_define_const(mMPI, "UNDEFINED", UNDEFINED); 95 95 96 mMarshal = rb_const_get(rb_cObject, rb_intern("Marshal"));97 id_dump = rb_intern("dump");98 id_load = rb_intern("load");99 id_map_bang = rb_intern("map!");96 mMarshal = rb_const_get(rb_cObject, rb_intern("Marshal")); 97 id_dump = rb_intern("dump"); 98 id_load = rb_intern("load"); 99 id_map_bang = rb_intern("map!"); 100 100 Init_Comm(); 101 101 Init_Group(); incubator/mpi_ruby/src/mpi_comm.c
r120 r121 24 24 { 25 25 VALUE tdata; 26 26 27 27 tdata = Data_Wrap_Struct(cComm, NULL, comm_free, comm); 28 28 rb_obj_call_init(tdata, 0, NULL); 29 29 30 30 return tdata; 31 31 } … … 34 34 { 35 35 VALUE tdata; 36 36 37 37 tdata = Data_Wrap_Struct(cIntraComm, NULL, comm_free, comm); 38 38 rb_obj_call_init(tdata, 0, NULL); 39 39 40 40 return tdata; 41 41 } … … 251 251 252 252 switch (status) { 253 case MPI_GRAPH:254 return GRAPH;255 case MPI_CART:256 return CART;257 case MPI_UNDEFINED:258 default:259 return UNDEFINED;253 case MPI_GRAPH: 254 return GRAPH; 255 case MPI_CART: 256 return CART; 257 case MPI_UNDEFINED: 258 default: 259 return UNDEFINED; 260 260 } 261 261 }
