visualize_helper 0.0.10.38 → 0.0.10.85
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/visualize_helper/extconf.rb +3 -0
- data/ext/visualize_helper/visualize_helper.c +148 -2
- data/lib/visualize_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c59eac56652287a7c49e6fbf2d7c830661f20686
|
4
|
+
data.tar.gz: dd3019d73e50651f6a7a680464cf659ed0e3889a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a555e4a18aa7d985de818a9551808c64ae2deda7aec36de139aa35419ba8018e4d9a8bd1b2e8b8398a36deeb2e284f802ae77a7e67e24219743e9238c3ecd0d
|
7
|
+
data.tar.gz: fa1f57811d326688452b05b7050015b91810b6df5ba1a5fe75b8bef77675f8682f14f4341c2b1d563ac4254a83468b087d727ef0f9773f45f3acb385d2ac4942
|
@@ -3,6 +3,7 @@
|
|
3
3
|
#include <string.h>
|
4
4
|
#include <stdio.h>
|
5
5
|
#include <math.h>
|
6
|
+
#include <omp.h>
|
6
7
|
|
7
8
|
void RemoveSpaces(char* source)
|
8
9
|
{
|
@@ -399,7 +400,6 @@ static VALUE iterate_over_trajectories(VALUE self, VALUE trajectories, VALUE min
|
|
399
400
|
}
|
400
401
|
|
401
402
|
value = rb_hash_aref(hash_v,trajectory);
|
402
|
-
//VALUE temp = rb_hash_aref(hash,key_t);
|
403
403
|
min_max_aggr = min_max_period(self,min,max,rb_hash_aref(hash_t,trajectory),intervals,aggr);
|
404
404
|
aggr = rb_ary_entry(min_max_aggr,4);
|
405
405
|
min = rb_ary_entry(min_max_aggr,0);
|
@@ -412,6 +412,146 @@ static VALUE iterate_over_trajectories(VALUE self, VALUE trajectories, VALUE min
|
|
412
412
|
return Qnil;
|
413
413
|
}
|
414
414
|
|
415
|
+
|
416
|
+
static VALUE openmp_test(VALUE self, VALUE string) {
|
417
|
+
|
418
|
+
FILE *f = fopen("/tmp/open_mp", "w");
|
419
|
+
|
420
|
+
int nthreads, tid;
|
421
|
+
|
422
|
+
/* Fork a team of threads giving them their own copies of variables */
|
423
|
+
#pragma omp parallel private(nthreads, tid)
|
424
|
+
{
|
425
|
+
|
426
|
+
/* Obtain thread number */
|
427
|
+
tid = omp_get_thread_num();
|
428
|
+
fprintf(f,"Hello World from thread = %d\n", tid);
|
429
|
+
|
430
|
+
/* Only master thread does this */
|
431
|
+
if (tid == 0)
|
432
|
+
{
|
433
|
+
nthreads = omp_get_num_threads();
|
434
|
+
fprintf(f,"Number of threads = %d\n", nthreads);
|
435
|
+
}
|
436
|
+
|
437
|
+
} /* All threads join master thread and disband */
|
438
|
+
|
439
|
+
fclose(f);
|
440
|
+
return string;
|
441
|
+
}
|
442
|
+
|
443
|
+
|
444
|
+
// Function callback to iterate in hash of boxes or links
|
445
|
+
static int update_boxes_links(VALUE key, VALUE value, VALUE parameters){
|
446
|
+
|
447
|
+
VALUE boxes_links_result = rb_ary_entry(parameters,0);
|
448
|
+
int index = FIX2INT(rb_ary_entry(parameters,1));
|
449
|
+
|
450
|
+
VALUE boxes_links_result_index = rb_ary_entry(boxes_links_result,index);
|
451
|
+
|
452
|
+
// if the key isnt already set on the boxes_result, create it
|
453
|
+
if (rb_hash_aref(boxes_links_result_index,key) == Qnil) {
|
454
|
+
rb_hash_aset(boxes_links_result_index,key,value);
|
455
|
+
}else{
|
456
|
+
// if the key is already on the boxes_result, sum the results
|
457
|
+
rb_hash_aset(boxes_links_result_index,key, FIX2INT(rb_hash_aref(boxes_links_result_index,key)) + FIX2INT(value));
|
458
|
+
}
|
459
|
+
|
460
|
+
return ST_CONTINUE;
|
461
|
+
}
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
// iterate over all the trajectories and create the boxes and links needed for the dashboard (Parallel)
|
467
|
+
//static VALUE iterate_over_trajectories_parallel(VALUE self, VALUE trajectories, VALUE min, VALUE max, VALUE hash_v, VALUE hash_t, VALUE intervals, VALUE dict, VALUE agrupamento, VALUE boxes, VALUE links) {
|
468
|
+
static VALUE iterate_over_trajectories_parallel() {
|
469
|
+
|
470
|
+
//VALUE trajectory;
|
471
|
+
VALUE aggr;
|
472
|
+
//VALUE value;
|
473
|
+
//VALUE min_max_aggr;
|
474
|
+
//VALUE boxes_result = rb_ary_new();
|
475
|
+
//VALUE links_result = rb_ary_new();
|
476
|
+
int i,j;
|
477
|
+
|
478
|
+
|
479
|
+
//initialize boxes_result and links_result
|
480
|
+
//for (j = 0; j < RARRAY_LEN(intervals) + 2; j++){
|
481
|
+
// rb_ary_push(boxes_result,rb_hash_new());
|
482
|
+
// if ( j != 0) {
|
483
|
+
// rb_ary_push(links_result,rb_hash_new());
|
484
|
+
// }
|
485
|
+
//}
|
486
|
+
|
487
|
+
//#pragma omp parallel firstprivate(boxes,links,i,j)
|
488
|
+
//#pragma omp parallel private(i,j,aggr,boxes,links)
|
489
|
+
//{
|
490
|
+
// //#pragma omp for nowait
|
491
|
+
// #pragma omp for firstprivate(min,max) nowait
|
492
|
+
// for (i = 0; i < RARRAY_LEN(trajectories); i++ ){
|
493
|
+
//
|
494
|
+
//
|
495
|
+
// trajectory = rb_ary_entry(trajectories,i);
|
496
|
+
|
497
|
+
#pragma omp parallel for private(i,aggr)
|
498
|
+
for (i = 0; i < 500; i++ ){
|
499
|
+
|
500
|
+
aggr = rb_ary_new();
|
501
|
+
//for (j = 0; j < RARRAY_LEN(intervals) + 2; j++){
|
502
|
+
// rb_ary_push(aggr,rb_ary_new());
|
503
|
+
//}
|
504
|
+
|
505
|
+
//value = rb_hash_aref(hash_v,trajectory);
|
506
|
+
//min_max_aggr = min_max_period(self,min,max,rb_hash_aref(hash_t,trajectory),intervals,aggr);
|
507
|
+
//aggr = rb_ary_entry(min_max_aggr,4);
|
508
|
+
//min = rb_ary_entry(min_max_aggr,0);
|
509
|
+
//max = rb_ary_entry(min_max_aggr,1);
|
510
|
+
|
511
|
+
//generate_boxes_and_links(self,aggr,boxes,links,dict,agrupamento,value);
|
512
|
+
|
513
|
+
// }// end pragma for
|
514
|
+
}
|
515
|
+
// // must aggregate the boxes from each thread into boxes_result
|
516
|
+
// #pragma omp critical
|
517
|
+
// {
|
518
|
+
// int i;
|
519
|
+
// VALUE parameters = rb_ary_new2(2);
|
520
|
+
// // iterate over the size of boxes
|
521
|
+
// for(i = 0; i < RARRAY_LEN(boxes); i++ ){
|
522
|
+
//
|
523
|
+
// rb_ary_store(parameters,0,boxes_result);
|
524
|
+
// rb_ary_store(parameters,1,INT2FIX(i));
|
525
|
+
// VALUE hash = rb_ary_entry(boxes,i);
|
526
|
+
// //iterate over each key of the hashmap
|
527
|
+
// rb_hash_foreach(hash,update_boxes_links,parameters);
|
528
|
+
// }
|
529
|
+
// }
|
530
|
+
|
531
|
+
// // must aggregate the links from each thread into links_result
|
532
|
+
// #pragma omp critical
|
533
|
+
// {
|
534
|
+
// int i;
|
535
|
+
// VALUE parameters = rb_ary_new2(2);
|
536
|
+
// for(i = 0; i < RARRAY_LEN(links); i++ ){
|
537
|
+
//
|
538
|
+
// rb_ary_store(parameters,0,links_result);
|
539
|
+
// rb_ary_store(parameters,1,INT2FIX(i));
|
540
|
+
// VALUE hash = rb_ary_entry(links,i);
|
541
|
+
// //iterate over each key of the hashmap
|
542
|
+
// rb_hash_foreach(hash,update_boxes_links,parameters);
|
543
|
+
// }
|
544
|
+
// }
|
545
|
+
|
546
|
+
//}// and pragma parallel
|
547
|
+
|
548
|
+
return Qnil;
|
549
|
+
}
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
|
415
555
|
// Main function called when the gem is loaded
|
416
556
|
void Init_visualize_helper(void) {
|
417
557
|
|
@@ -427,9 +567,15 @@ void Init_visualize_helper(void) {
|
|
427
567
|
// Register the method sort
|
428
568
|
rb_define_singleton_method(mVisualizeHelper, "sort_uniq", sort_uniq, 2 );
|
429
569
|
|
430
|
-
// Register the method that iterates
|
570
|
+
// Register the method that iterates on each trajectory
|
431
571
|
rb_define_singleton_method(mVisualizeHelper, "iterate_over_trajectories", iterate_over_trajectories, 10);
|
432
572
|
|
433
573
|
// Register the method sort
|
434
574
|
rb_define_singleton_method(mVisualizeHelper, "join_teste", join_teste, 1 );
|
575
|
+
|
576
|
+
// Register a test with openmp
|
577
|
+
rb_define_singleton_method(mVisualizeHelper, "openmp_test", openmp_test, 1 );
|
578
|
+
|
579
|
+
// Register the method that iterates on each trajectory using openmp
|
580
|
+
rb_define_singleton_method(mVisualizeHelper, "iterate_over_trajectories_parallel", iterate_over_trajectories_parallel, 0);
|
435
581
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visualize_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.10.
|
4
|
+
version: 0.0.10.85
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Ottoni Santiago Machado de Faria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|