Exemple #1
0
R_API int r_cons_grepbuf(char *buf, int len) {
	RCons *cons = r_cons_singleton ();
	char *tline, *tbuf, *p, *out, *in = buf;
	int ret, total_lines = 0, buffer_len = 0, l = 0, tl = 0;
	bool show = false;
	if (cons->filter) {
		cons->buffer_len = 0;
		R_FREE (cons->buffer);
		return 0;
	}

	if ((!len || !buf || buf[0] == '\0') &&
	    (cons->grep.json || cons->grep.less)) {
		cons->grep.json = 0;
		cons->grep.less = 0;
		return 0;
	}
	if (cons->grep.json) {
		if (cons->grep.json_path) {
			Rangstr rs = json_get (cons->buffer, cons->grep.json_path);
			char *u = rangstr_dup (&rs);
			if (u) {
				cons->buffer = u;
				cons->buffer_len = strlen (u);
				cons->buffer_sz = cons->buffer_len + 1;
				cons->grep.json = 0;
				r_cons_newline ();
			}
			R_FREE (cons->grep.json_path);
		} else {
			const char *palette[] = {
				cons->pal.graph_false, // f
				cons->pal.graph_true, // t
				cons->pal.num, // k
				cons->pal.comment, // v
				Color_RESET,
				NULL
			};
			char *out = r_print_json_indent (buf, I (use_color), "  ", palette);
			if (!out) {
				return 0;
			}
			free (cons->buffer);
			cons->buffer = out;
			cons->buffer_len = strlen (out);
			cons->buffer_sz = cons->buffer_len + 1;
			cons->grep.json = 0;
			if (cons->grep.less) {
				cons->grep.less = 0;
				r_cons_less_str (cons->buffer, NULL);
			}
		}
		return 3;
	}
	if (cons->grep.less) {
		int less = cons->grep.less;
		cons->grep.less = 0;
		if (less == 2) {
			char *res = r_cons_hud_string (buf);
			r_cons_println (res);
			free (res);
		} else {
			r_cons_less_str (buf, NULL);
			buf[0] = 0;
			cons->buffer_len = 0;
			if (cons->buffer) {
				cons->buffer[0] = 0;
			}
			R_FREE (cons->buffer);
		}
		return 0;
	}
	if (!cons->buffer) {
		cons->buffer_len = len + 20;
		cons->buffer = malloc (cons->buffer_len);
		cons->buffer[0] = 0;
	}
	out = tbuf = calloc (1, len);
	if (!out) {
		return 0;
	}
	tline = malloc (len);
	if (!tline) {
		free (out);
		return 0;
	}
	cons->lines = 0;
	// used to count lines and change negative grep.line values
	while ((int) (size_t) (in - buf) < len) {
		p = strchr (in, '\n');
		if (!p) {
			break;
		}
		l = p - in;
		if (l > 0) {
			in += l + 1;
		} else {
			in++;
		}
		total_lines++;
	}
	if (!cons->grep.range_line && cons->grep.line < 0) {
		cons->grep.line = total_lines + cons->grep.line;
	}
	if (cons->grep.range_line == 1) {
		if (cons->grep.f_line < 0) {
			cons->grep.f_line = total_lines + cons->grep.f_line;
		}
		if (cons->grep.l_line < 0) {
			cons->grep.l_line = total_lines + cons->grep.l_line;
		}
	}
	in = buf;
	while ((int) (size_t) (in - buf) < len) {
		p = strchr (in, '\n');
		if (!p) {
			free (tbuf);
			free (tline);
			return 0;
		}
		l = p - in;
		if (l > 0) {
			memcpy (tline, in, l);
			tl = r_str_ansi_filter (tline, NULL, NULL, l);
			if (tl < 0) {
				ret = -1;
			} else {
				ret = r_cons_grep_line (tline, tl);
				if (!cons->grep.range_line) {
					if (cons->grep.line == cons->lines) {
						show = true;
					}
				} else if (cons->grep.range_line == 1) {
					if (cons->grep.f_line == cons->lines) {
						show = true;
					}
					if (cons->grep.l_line == cons->lines) {
						show = false;
					}
				} else {
					show = true;
				}
			}
			if (ret > 0) {
				if (show) {
					memcpy (out, tline, ret);
					memcpy (out + ret, "\n", 1);
					out += ret + 1;
					buffer_len += ret + 1;
				}
				if (!cons->grep.range_line) {
					show = false;
				}
				cons->lines++;
			} else if (ret < 0) {
				free (tbuf);
				free (tline);
				return 0;
			}
			in += l + 1;
		} else {
			in++;
		}
	}
	memcpy (buf, tbuf, len);
	cons->buffer_len = buffer_len;
	free (tbuf);
	free (tline);
	if (cons->grep.counter) {
		int cnt = cons->grep.charCounter? strlen (cons->buffer): cons->lines;
		if (cons->buffer_len < 10) {
			cons->buffer_len = 10; // HACK
		}
		snprintf (cons->buffer, cons->buffer_len, "%d\n", cnt);
		cons->buffer_len = strlen (cons->buffer);
		cons->num->value = cons->lines;
	}
	if (cons->grep.sort != -1) {
#define INSERT_LINES(list)\
	do {\
		r_list_foreach (list, iter, str) {\
			int len = strlen (str);\
			memcpy (ptr, str, len);\
			memcpy (ptr + len, "\n", 2);\
			ptr += len + 1;\
			nl++;\
		}\
	}\
	while (false)

		RListIter *iter;
		int nl = 0;
		char *ptr = cons->buffer;
		char *str;
		sorted_column = cons->grep.sort;
		r_list_sort (sorted_lines, cmp);
		if (cons->grep.sort_invert) {
			r_list_reverse (sorted_lines);
		}
		INSERT_LINES (unsorted_lines);
		INSERT_LINES (sorted_lines);
		cons->lines = nl;
		r_list_free (sorted_lines);
		sorted_lines = NULL;
		r_list_free (unsorted_lines);
		unsorted_lines = NULL;
	}
	return cons->lines;
}
Exemple #2
0
int test_with_random_access_iterator() {
  GoodIter begin, end;
  Iter0 begin0, end0;
  #pragma omp simd
  for (GoodIter I = begin; I < end; ++I)
    ++I;
  // expected-error@+2 {{variable must be of integer or random access iterator type}}
  #pragma omp simd
  for (GoodIter &I = begin; I < end; ++I)
    ++I;
  #pragma omp simd
  for (GoodIter I = begin; I >= end; --I)
    ++I;
  // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
  #pragma omp simd
  for (GoodIter I(begin); I < end; ++I)
    ++I;
  // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
  #pragma omp simd
  for (GoodIter I(nullptr); I < end; ++I)
    ++I;
  // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
  #pragma omp simd
  for (GoodIter I(0); I < end; ++I)
    ++I;
  // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
  #pragma omp simd
  for (GoodIter I(1,2); I < end; ++I)
    ++I;
  #pragma omp simd
  for (begin = GoodIter(0); begin < end; ++begin)
    ++begin;
  #pragma omp simd
  for (begin = begin0; begin < end; ++begin)
    ++begin;
  // expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
  #pragma omp simd
  for (++begin; begin < end; ++begin)
    ++begin;
  #pragma omp simd
  for (begin = end; begin < end; ++begin)
    ++begin;
  // expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
  #pragma omp simd
  for (GoodIter I = begin; I - I; ++I)
    ++I;
  // expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
  #pragma omp simd
  for (GoodIter I = begin; begin < end; ++I)
    ++I;
  // expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
  #pragma omp simd
  for (GoodIter I = begin; !I; ++I)
    ++I;
  // expected-note@+3 {{loop step is expected to be negative due to this condition}}
  // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
  #pragma omp simd
  for (GoodIter I = begin; I >= end; I = I + 1)
    ++I;
  #pragma omp simd
  for (GoodIter I = begin; I >= end; I = I - 1)
    ++I;
  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
  #pragma omp simd
  for (GoodIter I = begin; I >= end; I = -I)
    ++I;
  // expected-note@+3 {{loop step is expected to be negative due to this condition}}
  // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
  #pragma omp simd
  for (GoodIter I = begin; I >= end; I = 2 + I)
    ++I;
  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
  #pragma omp simd
  for (GoodIter I = begin; I >= end; I = 2 - I)
    ++I;
  #pragma omp simd
  for (Iter0 I = begin0; I < end0; ++I)
    ++I;
  // Initializer is constructor without params.
  // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
  #pragma omp simd
  for (Iter0 I; I < end0; ++I)
    ++I;
  Iter1 begin1, end1;
  #pragma omp simd
  for (Iter1 I = begin1; I < end1; ++I)
    ++I;
  // expected-note@+3 {{loop step is expected to be negative due to this condition}}
  // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
  #pragma omp simd
  for (Iter1 I = begin1; I >= end1; ++I)
    ++I;
  // Initializer is constructor with all default params.
  // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
  #pragma omp simd
  for (Iter1 I; I < end1; ++I) {
  }
  return 0;
}
static int __init rk28_ts_ak4183_init(void)
{
	int ret;
	struct AK4183_TS_EVENT *ts_dev = NULL;

	GPIOSetPinDirection(GPIOPortE_Pin3,GPIO_IN);
	GPIOSetPinLevel(GPIOPortE_Pin3,GPIO_HIGH);

	ts_dev = kzalloc(sizeof(struct AK4183_TS_EVENT), GFP_KERNEL);
	if(ts_dev == NULL)
	{
		E("ts_dev kzalloc failed!\n");
		ret = -ENOMEM;
		goto err1;
	}

	ts_dev->input = input_allocate_device();
	if(ts_dev->input == NULL)
	{
		E("input_allocate_device err!\n"); 
		ret = -ENOMEM;

		goto err2;
	}	

	ts_dev->irq = 7;
	
	ts_dev->input->name = "ak4183";	
	ts_dev->input->phys = "ak4183_TS/input0";
	ts_dev->input->evbit[0] = BIT_MASK(EV_ABS)|BIT_MASK(EV_KEY);
	ts_dev->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
	input_set_abs_params(ts_dev->input, ABS_X, 0, LCD_MAX_LENGTH - 1, 0, 0);
	input_set_abs_params(ts_dev->input, ABS_Y, 0, LCD_MAX_WIDTH - 1, 0, 0);
	
	ret = input_register_device(ts_dev->input);
	if(ret < 0){
		goto err3;

	}
#ifdef CONFIG_ANDROID_POWER
	ts_early_suspend.suspend = ak4183_suspend;
    ts_early_suspend.resume = ak4183_resume;
    android_register_early_suspend(&ts_early_suspend);
#endif

    rockchip_mux_api_set(GPIOB_SPI0_MMC0_NAME, 0);
	rockchip_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME, IOMUXA_GPIO0_B4);
	GPIOSetPinDirection(GPIOPortB_Pin4,GPIO_IN);
	GPIOSetPinLevel(GPIOPortB_Pin4,GPIO_HIGH);
	GPIOSetPinDirection(GPIOPortB_Pin5,GPIO_IN);
	GPIOSetPinLevel(GPIOPortB_Pin5,GPIO_HIGH);
	GPIOSetPinDirection(GPIOPortB_Pin6,GPIO_IN);
	GPIOSetPinLevel(GPIOPortB_Pin6,GPIO_HIGH);
	GPIOSetPinDirection(GPIOPortB_Pin7,GPIO_IN);
	GPIOSetPinLevel(GPIOPortB_Pin7,GPIO_HIGH);

	INIT_DELAYED_WORK(&ts_dev->work, ak4183_delay_work);

	ret = request_gpio_irq(GPIOPortE_Pin3, (void *)ak4183_isr, GPIOEdgelFalling, ts_dev);
	if(ret < 0){
		E("ak4183 request irq err, ret = %d\n", ret);
		goto err4;
	}	

	ret =  i2c_add_driver(&ak4183_i2c_driver);
	if(ret < 0){
		E("i2c_add_driver err, ret = %d\n", ret);
		goto err5;
	}
	
	g_ts_dev = ts_dev;
	
	ret = driver_create_file(&ak4183_i2c_driver.driver, &driver_attr_touchcheck);
	ret += driver_create_file(&ak4183_i2c_driver.driver, &driver_attr_touchadc);
	ret += driver_create_file(&ak4183_i2c_driver.driver, &driver_attr_calistatus);
	ret += driver_create_file(&ak4183_i2c_driver.driver, &driver_attr_debug_ak4183);

	I("ak4183 init success!\n");

	return 0;

err5:
	free_irq(7, NULL);
err4:
	input_unregister_device(ts_dev->input);
err3:
	input_free_device(ts_dev->input);
err2:
	kfree(ts_dev);
err1:
	return ret;
Exemple #4
0
 /* Add identity matrix */
 Block<Type> addIdentity(){
   int n=A.rows();
   matrix<double> I(n,n);
   I.setIdentity();
   return Block( this->A + I );
 }
void Smoke::boundary( int type, std::vector<float>& arr )
{
	for (int i=1; i <= N; i++ ) {
        switch (type) {
            case (HORIZ):
                arr[I(0,i)] = -arr[I(1,i)];
                arr[I(N+1,i)] = -arr[I(N,i)];
                break;
            case (VERT):
                arr[I(i,0)] = -arr[I(i,1)];
                arr[I(i,N+1)] = -arr[I(i,N)];
                break;
            default:
                arr[I(0,i)] = arr[I(1,i)];
                arr[I(N+1,i)] = arr[I(N,i)];
                arr[I(i,0)] = arr[I(i,1)]; 
                arr[I(i,N+1)] = arr[I(i,N)];
                break;
        }
    }   
    arr[I(0,0)] = 0.5f * (arr[I(1,0)] + arr[I(0,1)]);   
    arr[I(0,N+1)] = 0.5f * (arr[I(1,N+1)] + arr[I(0,N)]);   
    arr[I(N+1,0)] = 0.5f * (arr[I(N,0)] + arr[I(N+1,1)]);   
    arr[I(N+1,N+1)] = 0.5f * (arr[I(N,N+1)] + arr[I(N+1,N)]); 
}
Exemple #6
0
void Tile::Refine(int block_size, float roughness) {
  int block_size_h = block_size/2;
  float offset_factor = roughness * block_size / size_;

  for (int y = block_size_h; y < size_; y += block_size) {
    for (int x = block_size_h; x < size_; x += block_size) {
      // Lookup der umliegenden Höhenwerte (-); o ist Position (x, y)
      // -   -
      //   o
      // -   -
      float nw = vertices_[I(x - block_size_h, y - block_size_h)].y;
      float ne = vertices_[I(x + block_size_h, y - block_size_h)].y;
      float sw = vertices_[I(x - block_size_h, y + block_size_h)].y;
      float se = vertices_[I(x + block_size_h, y + block_size_h)].y;
      
      // Berechnung der neuen Höhenwerte (+)
      // - + -
      // + +
      // -   -
      float center = (nw + ne + sw + se) / 4 + offset_factor * randf();
      vertices_[I(x, y)].y = center;
      
      float n = nw + ne + center;
      if (y > block_size_h) {
        n += vertices_[I(x, y - block_size)].y;
        n /= 4;
      } else {
        n /= 3;
      }
      vertices_[I(x, y - block_size_h)].y = n + offset_factor * randf();

      float w = nw + sw + center;
      if (x > block_size_h) {
        w += vertices_[I(x - block_size, y)].y;
        w /= 4;
      } else {
        w /= 3;
      }
      vertices_[I(x - block_size_h, y)].y = w + offset_factor * randf();

      // Edge cases: Berechnung neuer Höhenwerte am rechten bzw. unteren Rand
      // -   -
      //     +
      // - + - 
      if (x == size_ - 1 - block_size_h) {
        vertices_[I(x + block_size_h, y)].y =
            (ne + se + center) / 3 + offset_factor * randf();
      }
      if (y == size_ - 1 - block_size_h) {
        vertices_[I(x, y + block_size_h)].y =
            (sw + se + center) / 3 + offset_factor * randf();
      }
    }
  } 
}
Exemple #7
0
void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
			  int midsession, int protocol)
{
    struct controlset *s;
    union control *c;
    char *str;
    BOOL with_glass;

    if (!midsession) {
	/*
	 * Add the About and Help buttons to the standard panel.
	 */
	s = ctrl_getset(b, "", "", "");
	c = ctrl_pushbutton(s, "About", 'a', HELPCTX(no_help),
			    about_handler, P(hwndp));
	c->generic.column = 0;
	if (has_help) {
	    c = ctrl_pushbutton(s, "Help", 'h', HELPCTX(no_help),
				help_handler, P(hwndp));
	    c->generic.column = 1;
	}
    }

    /*
     * Full-screen mode is a Windows peculiarity; hence
     * scrollbar_in_fullscreen is as well.
     */
    s = ctrl_getset(b, "Window", "scrollback",
		    "Control the scrollback in the window");
    ctrl_checkbox(s, "Display scrollbar in full screen mode", 'i',
		  HELPCTX(window_scrollback),
		  dlg_stdcheckbox_handler,
		  I(offsetof(Config,scrollbar_in_fullscreen)));
    /*
     * Really this wants to go just after `Display scrollbar'. See
     * if we can find that control, and do some shuffling.
     */
    {
        int i;
        for (i = 0; i < s->ncontrols; i++) {
            c = s->ctrls[i];
            if (c->generic.type == CTRL_CHECKBOX &&
                c->generic.context.i == offsetof(Config,scrollbar)) {
                /*
                 * Control i is the scrollbar checkbox.
                 * Control s->ncontrols-1 is the scrollbar-in-FS one.
                 */
                if (i < s->ncontrols-2) {
                    c = s->ctrls[s->ncontrols-1];
                    memmove(s->ctrls+i+2, s->ctrls+i+1,
                            (s->ncontrols-i-2)*sizeof(union control *));
                    s->ctrls[i+1] = c;
                }
                break;
            }
        }
    }

    s = ctrl_getset(b, "Window/Appearance", "trans", "Transparency");
    with_glass = is_glass_available();
    ctrl_radiobuttons(s, NULL, NO_SHORTCUT, with_glass ? 5 : 4, 
		      HELPCTX(appearance_transparency), 
		      dlg_stdradiobutton_handler, 
		      I(offsetof(Config,transparency)),
		      "Off", NO_SHORTCUT, I(0),
		      "Low", NO_SHORTCUT, I(1),
		      with_glass ? "Med." : "Medium", NO_SHORTCUT, I(2),
		      "High", NO_SHORTCUT, I(3),
		      with_glass ? "Glass" : NULL, NO_SHORTCUT, I(-1), NULL);
    ctrl_checkbox(s, "Opaque when focused", NO_SHORTCUT, 
		  HELPCTX(appearance_opaquefocus),
		  dlg_stdcheckbox_handler, 
		  I(offsetof(Config,opaque_when_focused)));

    /*
     * Windows has the AltGr key, which has various Windows-
     * specific options.
     */
    s = ctrl_getset(b, "Terminal/Keyboard", "features",
		    "Enable extra keyboard features:");
    ctrl_checkbox(s, "AltGr acts as Compose key", 't',
		  HELPCTX(keyboard_compose),
		  dlg_stdcheckbox_handler, I(offsetof(Config,compose_key)));
    ctrl_checkbox(s, "Control-Alt is different from AltGr", 'd',
		  HELPCTX(keyboard_ctrlalt),
		  dlg_stdcheckbox_handler, I(offsetof(Config,ctrlaltkeys)));
    ctrl_checkbox(s, "Set meta bit on alt (instead of escape)", 'm',
		  HELPCTX(no_help),
		  dlg_stdcheckbox_handler, I(offsetof(Config,alt_metabit)));

    /*
     * Windows allows an arbitrary .WAV to be played as a bell, and
     * also the use of the PC speaker. For this we must search the
     * existing controlset for the radio-button set controlling the
     * `beep' option, and add extra buttons to it.
     * 
     * Note that although this _looks_ like a hideous hack, it's
     * actually all above board. The well-defined interface to the
     * per-platform dialog box code is the _data structures_ `union
     * control', `struct controlset' and so on; so code like this
     * that reaches into those data structures and changes bits of
     * them is perfectly legitimate and crosses no boundaries. All
     * the ctrl_* routines that create most of the controls are
     * convenient shortcuts provided on the cross-platform side of
     * the interface, and template creation code is under no actual
     * obligation to use them.
     */
    s = ctrl_getset(b, "Terminal/Bell", "style", "Set the style of bell");
    {
	int i;
	for (i = 0; i < s->ncontrols; i++) {
	    c = s->ctrls[i];
	    if (c->generic.type == CTRL_RADIO &&
		c->generic.context.i == offsetof(Config, beep)) {
		assert(c->generic.handler == dlg_stdradiobutton_handler);
		c->radio.nbuttons += 2;
		c->radio.buttons =
		    sresize(c->radio.buttons, c->radio.nbuttons, char *);
		c->radio.buttons[c->radio.nbuttons-1] =
		    dupstr("Play a custom sound file");
		c->radio.buttons[c->radio.nbuttons-2] =
		    dupstr("Beep using the PC speaker");
		c->radio.buttondata =
		    sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
		c->radio.buttondata[c->radio.nbuttons-1] = I(BELL_WAVEFILE);
		c->radio.buttondata[c->radio.nbuttons-2] = I(BELL_PCSPEAKER);
		if (c->radio.shortcuts) {
		    c->radio.shortcuts =
			sresize(c->radio.shortcuts, c->radio.nbuttons, char);
		    c->radio.shortcuts[c->radio.nbuttons-1] = NO_SHORTCUT;
		    c->radio.shortcuts[c->radio.nbuttons-2] = NO_SHORTCUT;
		}
		break;
	    }
	}
Exemple #8
0
	4, 4, 0,	/* int */
	8, 8, 1,	/* long */
	8 ,8, 1,	/* long long */
	4, 4, 1,	/* float */
	8, 8, 1,	/* double */
	16,16,1,	/* long double */
	4, 4, 0,	/* T* */
	0, 4, 0,	/* struct */
	1,		/* little_endian */
	0,		/* mulops_calls */
	0,		/* wants_callb */
	0,		/* wants_argb */
	1,		/* left_to_right */
	0,		/* wants_dag */
	0,		/* unsigned_char */
	I(address),
	I(blockbeg),
	I(blockend),
	I(defaddress),
	I(defconst),
	I(defstring),
	I(defsymbol),
	I(emit),
	I(export),
	I(function),
	I(gen),
	I(global),
	I(import),
	I(local),
	I(progbeg),
	I(progend),
void
MisesMat :: give3dLSMaterialStiffnessMatrix(FloatMatrix &answer, MatResponseMode mode, GaussPoint *gp, TimeStep *atTime)
{
    MisesMatStatus *status = static_cast< MisesMatStatus * >( this->giveStatus(gp) );
    // start from the elastic stiffness

    FloatMatrix I(6, 6);
    I.at(1, 1) = I.at(2, 2) = I.at(3, 3) = 1;
    I.at(4, 4) = I.at(5, 5) = I.at(6, 6) = 0.5;
    FloatArray delta(6);
    delta.at(1) = delta.at(2) = delta.at(3) = 1;

    FloatMatrix F, F_Tr;
    F.beMatrixForm( status->giveTempFVector() );
    double J;
    J = F.giveDeterminant();

    StressVector trialStressDev(_3dMat);
    double trialStressVol;
    status->giveTrialStressVol(trialStressVol);
    status->giveTrialStressDev(trialStressDev);
    double trialS = trialStressDev.computeStressNorm();
    FloatArray n(6);
    n = trialStressDev;
    if ( trialS == 0 ) {
        n.resize(6);
    } else {
        n.times(1 / trialS);
    }


    FloatMatrix Cdev(6, 6);
    FloatMatrix C(6, 6);
    FloatMatrix help(6, 6);
    help.beDyadicProductOf(delta, delta);
    C = help;
    help.times(-1. / 3.);
    FloatMatrix C1 = I;
    C1.add(help);
    C1.times(2 * trialStressVol);

    FloatMatrix n1(6, 6), n2(6, 6);
    n1.beDyadicProductOf(n, delta);
    n2.beDyadicProductOf(delta, n);
    help = n1;
    help.add(n2);
    help.times(-2. / 3. * trialS);
    C1.add(help);
    Cdev = C1;
    C.times(K * J * J);

    help = I;
    help.times( -K * ( J * J - 1 ) );
    C.add(help);
    FloatMatrix Cvol = C;
    C.add(C1);
    //////////////////////////////////////////////////////////////////////////////////////////////////////////

    FloatMatrix invF(3, 3);
    FloatMatrix T(6, 6), tT(6, 6);

    invF.beInverseOf(F);
    //////////////////////////////////////////////////
    //first row of pull back transformation matrix
    T.at(1, 1) = invF.at(1, 1) * invF.at(1, 1);
    T.at(1, 2) = invF.at(1, 2) * invF.at(1, 2);
    T.at(1, 3) = invF.at(1, 3) * invF.at(1, 3);
    T.at(1, 4) = 2. * invF.at(1, 2) * invF.at(1, 3);
    T.at(1, 5) = 2. * invF.at(1, 1) * invF.at(1, 3);
    T.at(1, 6) = 2. * invF.at(1, 1) * invF.at(1, 2);
    //second row of pull back transformation matrix
    T.at(2, 1) = invF.at(2, 1) * invF.at(2, 1);
    T.at(2, 2) = invF.at(2, 2) * invF.at(2, 2);
    T.at(2, 3) = invF.at(2, 3) * invF.at(2, 3);
    T.at(2, 4) = 2. * invF.at(2, 2) * invF.at(2, 3);
    T.at(2, 5) = 2. * invF.at(2, 1) * invF.at(2, 3);
    T.at(2, 6) = 2. * invF.at(2, 1) * invF.at(2, 2);
    //third row of pull back transformation matrix
    T.at(3, 1) = invF.at(3, 1) * invF.at(3, 1);
    T.at(3, 2) = invF.at(3, 2) * invF.at(3, 2);
    T.at(3, 3) = invF.at(3, 3) * invF.at(3, 3);
    T.at(3, 4) = 2. * invF.at(3, 2) * invF.at(3, 3);
    T.at(3, 5) = 2. * invF.at(3, 1) * invF.at(3, 3);
    T.at(3, 6) = 2. * invF.at(3, 1) * invF.at(3, 2);
    //fourth row of pull back transformation matrix
    T.at(4, 1) = invF.at(2, 1) * invF.at(3, 1);
    T.at(4, 2) = invF.at(2, 2) * invF.at(3, 2);
    T.at(4, 3) = invF.at(2, 3) * invF.at(3, 3);
    T.at(4, 4) = ( invF.at(2, 2) * invF.at(3, 3) + invF.at(2, 3) * invF.at(3, 2) );
    T.at(4, 5) = ( invF.at(2, 1) * invF.at(3, 3) + invF.at(2, 3) * invF.at(3, 1) );
    T.at(4, 6) = ( invF.at(2, 1) * invF.at(3, 2) + invF.at(2, 2) * invF.at(3, 1) );
    //fifth row of pull back transformation matrix
    T.at(5, 1) = invF.at(1, 1) * invF.at(3, 1);
    T.at(5, 2) = invF.at(1, 2) * invF.at(3, 2);
    T.at(5, 3) = invF.at(1, 3) * invF.at(3, 3);
    T.at(5, 4) = ( invF.at(1, 2) * invF.at(3, 3) + invF.at(1, 3) * invF.at(3, 2) );
    T.at(5, 5) = ( invF.at(1, 1) * invF.at(3, 3) + invF.at(1, 3) * invF.at(3, 1) );
    T.at(5, 6) = ( invF.at(1, 1) * invF.at(3, 2) + invF.at(1, 2) * invF.at(3, 1) );
    //sixth row of pull back transformation matrix
    T.at(6, 1) = invF.at(1, 1) * invF.at(2, 1);
    T.at(6, 2) = invF.at(1, 2) * invF.at(2, 2);
    T.at(6, 3) = invF.at(1, 3) * invF.at(2, 3);
    T.at(6, 4) = ( invF.at(1, 2) * invF.at(2, 3) + invF.at(1, 3) * invF.at(2, 2) );
    T.at(6, 5) = ( invF.at(1, 1) * invF.at(2, 3) + invF.at(1, 3) * invF.at(2, 1) );
    T.at(6, 6) = ( invF.at(1, 1) * invF.at(2, 2) + invF.at(1, 2) * invF.at(2, 1) );
    ///////////////////////////////////////////

    if ( mode != TangentStiffness ) {
        help.beProductTOf(C, T);
        answer.beProductOf(T, help);
        return;
    }


    //StructuralCrossSection *crossSection = ( StructuralCrossSection * ) ( gp->giveElement()->giveCrossSection() );
    double kappa = status->giveCumulativePlasticStrain();
    // increment of cumulative plastic strain as an indicator of plastic loading
    double dKappa = sqrt(3. / 2.) * ( status->giveTempCumulativePlasticStrain() - kappa );
    //double dKappa = ( status->giveTempCumulativePlasticStrain() - kappa);
    if ( dKappa <= 0.0 ) { // elastic loading - elastic stiffness plays the role of tangent stiffness
        help.beProductTOf(C, T);
        answer.beProductOf(T, help);
        return;
    }

    // === plastic loading ===
    //dKappa = dKappa*sqrt(3./2.);
    // trial deviatoric stress and its norm


    double beta0, beta1, beta2, beta3, beta4;
    if ( trialS == 0 ) {
        beta1 = 0;
    } else {
        beta1 = 2 * trialStressVol * dKappa / trialS;
    }

    if ( trialStressVol == 0 ) {
        beta0 = 0;
        beta2 = 0;
        beta3 = beta1;
        beta4 = 0;
    } else {
        beta0 = 1 + H / 3 / trialStressVol;
        beta2 = ( 1 - 1 / beta0 ) * 2. / 3. * trialS * dKappa / trialStressVol;
        beta3 = 1 / beta0 - beta1 + beta2;
        beta4 = ( 1 / beta0 - beta1 ) * trialS / trialStressVol;
    }

    FloatMatrix N;
    N.beDyadicProductOf(n, n);
    N.times(-2 * trialStressVol * beta3);
    answer.resize(6, 6);

    C1.times(-beta1);
    FloatMatrix mN(3, 3);
    mN.at(1, 1) = n.at(1);
    mN.at(1, 2) = n.at(6);
    mN.at(1, 3) = n.at(5);
    mN.at(2, 1) = n.at(6);
    mN.at(2, 2) = n.at(2);
    mN.at(2, 3) = n.at(4);
    mN.at(3, 1) = n.at(5);
    mN.at(3, 2) = n.at(4);
    mN.at(3, 3) = n.at(3);
    FloatMatrix mN2(3, 3);
    mN2.beProductOf(mN, mN);

    double volN2 = 1. / 3. * ( mN2.at(1, 1) + mN2.at(2, 2) + mN2.at(3, 3) );
    FloatArray devN2(6);
    devN2.at(1) = mN2.at(1, 1) - volN2;
    devN2.at(2) = mN2.at(2, 2) - volN2;

    devN2.at(3) = mN2.at(3, 3) - volN2;
    devN2.at(4) = mN2.at(2, 3);
    devN2.at(5) = mN2.at(1, 3);
    devN2.at(6) = mN2.at(1, 2);
    FloatMatrix nonSymPart;
    nonSymPart.beDyadicProductOf(n, devN2);
    //symP.beTranspositionOf(nonSymPart);
    //symP.add(nonSymPart);
    //symP.times(1./2.);
    nonSymPart.times(-2 * trialStressVol * beta4);

    C.add(C1);
    C.add(N);
    C.add(nonSymPart);
    help.beProductTOf(C, T);
    answer.beProductOf(T, help);
}
Exemple #10
0
void processorCore()
{
  const char *proc = SescConf->getCharPtr("","cpucore",0) ;
  fprintf(stderr,"proc = [%s]\n",proc);

  xcacti_flp xflp;

  //----------------------------------------------
  // Branch Predictor
  processBranch(proc);
  
  //----------------------------------------------
  // Register File
  int issueWidth= SescConf->getInt(proc,"issueWidth");
  int size    = SescConf->getInt(proc,"intRegs");
  int banks   = 1; 
  int rdPorts = 2*issueWidth;
  int wrPorts = issueWidth;
  int bits = 32;
  int bytes = 8;

  if(SescConf->checkInt(proc,"bits")) {
    bits = SescConf->getInt(proc,"bits");
    bytes = bits/8;
    if (bits*8 != bytes) {
      fprintf(stderr,"Not valid number of bits for the processor core [%d]\n",bits);
      exit(-2);
    }
  }

  if(SescConf->checkInt(proc,"intRegBanks"))
    banks = SescConf->getInt(proc,"intRegBanks");

  if(SescConf->checkInt(proc,"intRegRdPorts"))
    rdPorts = SescConf->getInt(proc,"intRegRdPorts");

  if(SescConf->checkInt(proc,"intRegWrPorts"))
    wrPorts = SescConf->getInt(proc,"intRegWrPorts");

  double regEnergy = getEnergy(size*bytes, bytes, 1, rdPorts, wrPorts, banks, 0, bits, &xflp);

  printf("\nRegister [%d bytes] banks[%d] ports[%d] Energy[%g]\n"
         ,size*bytes, banks, rdPorts+wrPorts, regEnergy);

#ifdef SESC_SESCTHERM2
  const char *blockName = SescConf->getCharPtr(proc,"IntRegBlockName");
  I(blockName);
  update_layout(blockName, &xflp);
  blockName = SescConf->getCharPtr(proc,"fpRegBlockName");
  I(blockName);
  update_layout(blockName , &xflp); // FIXME: different energy for FP register
#else
  SescConf->updateRecord(proc,"wrRegEnergy",regEnergy);
  SescConf->updateRecord(proc,"rdRegEnergy",regEnergy);
#endif


  //----------------------------------------------
  // Load/Store Queue
  size      = SescConf->getInt(proc,"maxLoads");
  banks     = 1; 
  rdPorts   = res_memport;
  wrPorts   = res_memport;

  if(SescConf->checkInt(proc,"lsqBanks"))
    banks = SescConf->getInt(proc,"lsqBanks");

  regEnergy = getEnergy(size*2*bytes,2*bytes,size,rdPorts,wrPorts,banks,1, 2*bits, &xflp);
#ifdef SESC_SESCTHERM2
  // FIXME: partition energies per structure
  blockName = SescConf->getCharPtr(proc,"LSQBlockName");
  I(blockName);
  update_layout(lsqBlockName, &xflp);
#else
  SescConf->updateRecord(proc,"ldqRdWrEnergy",regEnergy);
#endif
  printf("\nLoad Queue [%d bytes] banks[%d] ports[%d] Energy[%g]\n"
         ,size*2*bytes, banks, 2*res_memport, regEnergy);

  size      =  SescConf->getInt(proc,"maxStores");
 
  regEnergy = getEnergy(size*4*bytes,4*bytes,size,rdPorts,wrPorts,banks,1, 2*bits, &xflp);
#ifdef SESC_SESCTHERM2
  // FIXME: partition energies per structure
  blockName = SescConf->getCharPtr(proc,"LSQBlockName");
  I(blockName);
  update_layout(lsqBlockName, &xflp);
#else
  SescConf->updateRecord(proc,"stqRdWrEnergy",regEnergy);
#endif
  printf("\nStore Queue [%d bytes] banks[%d] ports[%d] Energy[%g]\n"
         ,size*4*bytes, banks, 2*res_memport, regEnergy);


#ifdef SESC_INORDER 
  size      =  size/4;
 
  regEnergy = getEnergy(size*4*bytes,4*bytes,size,rdPorts,wrPorts,banks,1, 2*bits, &xflp);

  printf("\nStore Inorder Queue [%d bytes] banks[%d] ports[%d] Energy[%g]\n"
         ,size*4*bytes, banks, 2*res_memport, regEnergy);

  SescConf->updateRecord(proc,"stqRdWrEnergyInOrder",regEnergy);

#ifdef SESC_SESCTHERM
  I(0);
  exit(-1); // Not supported
#endif

 #endif 
 
  //----------------------------------------------
  // Reorder Buffer
  size      = SescConf->getInt(proc,"robSize");
  banks     = size/64;
  if (banks == 0) {
    banks = 1;
  }else{
    banks = roundUpPower2(banks);
  }
  
  // Retirement should hit another bank
  rdPorts   = 1; // continuous possitions
  wrPorts   = 1;

  regEnergy = getEnergy(size*2,2*issueWidth,1,rdPorts,wrPorts,banks,0,16*issueWidth, &xflp);
#ifdef SESC_SESCTHERM2
  const char *blockName = SescConf->getCharPtr(proc,"robBlockName");
  I(blockName);
  update_layout(blockName, &xflp);
  // FIXME: partition energies per structure
#else
  SescConf->updateRecord(proc,"robEnergy",regEnergy);
#endif

  printf("\nROB [%d bytes] banks[%d] ports[%d] Energy[%g]\n",size*2, banks, 2*rdPorts, regEnergy);

  //----------------------------------------------
  // Rename Table
  {
    double bitsPerEntry = log(SescConf->getInt(proc,"intRegs"))/log(2);
    
    size      = roundUpPower2(static_cast<unsigned int>(32*bitsPerEntry/8));
    banks     = 1;
    rdPorts   = 2*issueWidth;
    wrPorts   = issueWidth;

    regEnergy = getEnergy(size,1,1,rdPorts,wrPorts,banks,0,1, &xflp);
#ifdef SESC_SESCTHERM2
    update_layout("IntRAT", &xflp); //FIXME: create a IntRATblockName
    // FIXME: partition energies per structure
#endif

    printf("\nrename [%d bytes] banks[%d] Energy[%g]\n",size, banks, regEnergy);

    regEnergy += getEnergy(size,1,1,rdPorts/2+1,wrPorts/2+1,banks,0,1, &xflp);
#ifdef SESC_SESCTHERM2
    update_layout("IntRAT", &xflp);
    // FIXME: partition energies per structure
#else
    // unified FP+Int RAT energy counter
    SescConf->updateRecord(proc,"renameEnergy",regEnergy);
#endif
  }

  //----------------------------------------------
  // Window Energy & Window + DDIS

  {
    int min = SescConf->getRecordMin(proc,"cluster") ;
    int max = SescConf->getRecordMax(proc,"cluster") ;
    I(min==0);

    for(int i = min ; i <= max ; i++) {
      const char *cluster = SescConf->getCharPtr(proc,"cluster",i) ;

      // TRADITIONAL COLLAPSING ISSUE LOGIC
      // Recalculate windowRdWrEnergy using CACTI (keep select and wake)
      
      size      = SescConf->getInt(cluster,"winSize");
      banks     = 1;
      rdPorts   = SescConf->getInt(cluster,"wakeUpNumPorts");
      wrPorts   = issueWidth;
      int robSize          = SescConf->getInt(proc,"robSize");
      float entryBits = 4*(log(robSize)/log(2)); // src1, src2, dest, instID
      entryBits += 7; // opcode
      entryBits += 1; // ready bit
      
      int tableBits = static_cast<int>(entryBits * size);
      int tableBytes;
      if (tableBits < 8) {
	tableBits  = 8;
	tableBytes = 1;
      }else{
	tableBytes = tableBits/8;
      }
      int assoc= roundUpPower2(static_cast<unsigned int>(entryBits/8));
      tableBytes = roundUpPower2(tableBytes);
      regEnergy = getEnergy(tableBytes,tableBytes/assoc,assoc,rdPorts,wrPorts,banks,1,static_cast<int>(entryBits), &xflp);
      
      printf("\nWindow [%d bytes] assoc[%d] banks[%d] ports[%d] Energy[%g]\n"
	     ,tableBytes, assoc, banks, rdPorts+wrPorts, regEnergy);
      
#ifdef SESC_SESCTHERM2
      const char *blockName = SescConf->getCharPtr(cluster,"blockName");
      I(blockName);
      update_layout(blockName, &xflp);
#else
      // unified FP+Int RAT energy counter
      SescConf->updateRecord(cluster,"windowRdWrEnergy" ,regEnergy,0);
#endif
    }
  }
}
Exemple #11
0
MemObj *MemorySystem::buildMemoryObj(const char *device_type, const char *dev_section, const char *dev_name)
  /* build the correct memory object {{{1 */
{
  // Returns new created MemoryObj or NULL in known-error mode 
  MemObj *mdev=0;
  uint32_t devtype = 0; //CCache

  std::string mystr("");
  // You may insert here the further specializations you may need
  if (!strcasecmp(device_type, "cache") || !strcasecmp(device_type, "icache")) {
    mdev = new CCache(this, dev_section, dev_name);
    devtype = 0;
  } else if (!strcasecmp(device_type, "nicecache")) {
    mdev = new NICECache(this, dev_section, dev_name);
    devtype = 1;
  } else if (!strcasecmp(device_type, "SL0")) {
    //mdev = new SL0Cache(this, dev_section, dev_name);
		I(0);
    devtype = 2;
  } else if (!strcasecmp(device_type, "VPC")) {
    //mdev = new VPC(this, dev_section, dev_name);
		I(0);
    devtype = 3;
  } else if (!strcasecmp(device_type, "ghb")) {
    //mdev = new GHB(this, dev_section, dev_name);
		I(0);
    devtype = 4;

  } else if (!strcasecmp(device_type, "stridePrefetcher")) {
    mdev = new StridePrefetcher(this, dev_section, dev_name);
    devtype = 5;
  } else if (!strcasecmp(device_type, "markovPrefetcher")) {
    mdev = new MarkovPrefetcher(this, dev_section, dev_name);
    devtype = 6;
/*
  } else if (!strcasecmp(device_type, "taggedPrefetcher")) {
    mdev = new TaggedPrefetcher(this, dev_section, dev_name);
    devtype = 7;
*/
  }  else if (!strcasecmp(device_type, "bus")) {
    mdev = new Bus(this, dev_section, dev_name);
    devtype = 8;
  } else if (!strcasecmp(device_type, "tlb")) {
    mdev = new TLB(this, dev_section, dev_name);
    devtype = 9;
  } else if (!strcasecmp(device_type, "splitter")) {
    //mdev = new Splitter(this, dev_section, dev_name);
		I(0);
    devtype = 10;
  } else if (!strcasecmp(device_type, "memxbar")) {
    mdev = new MemXBar(this, dev_section, dev_name);    
    devtype = 11;
  } else if (!strcasecmp(device_type, "unmemxbar")) {
    mdev = new UnMemXBar(this, dev_section, dev_name);    
    devtype = 12;
  }  else if (!strcasecmp(device_type, "memcontroller")) {
    mdev = new MemController(this, dev_section, dev_name);
    devtype = 13;
  } else if (!strcasecmp(device_type, "void")) {
    return NULL;
  } else {
    // Check the lower level because it may have it
    return GMemorySystem::buildMemoryObj(device_type, dev_section, dev_name);
  }


#if GOOGLE_GRAPH_API
#else
  mystr += "\n\"";
  mystr += mdev->getName();

  switch(devtype){
    case 0: //CCache
    case 1: //NiceCache
    case 2: //SL0
    case 3: //VPC
      mystr += "\"[shape=record,sides=5,peripheries=2,color=darkseagreen,style=filled]";
      //Fetch the CCache related parameters : Size, bsize, name, inclusive, ports
      break;
    case 4: //GHB
    case 5: //stridePrefetcher
    case 6: //markovPrefetcher
    case 7: //taggedPrefetcher
      mystr += "\"[shape=record,sides=5,peripheries=1,color=lightcoral,style=filled]";
      break;
    case 8://bus
      mystr += "\"[shape=record,sides=5,peripheries=1,color=lightpink,style=filled]";
      break;
    case 10: //Splitter
    case 11: //MemXBar
      mystr += "\"[shape=record,sides=5,peripheries=1,color=thistle,style=filled]";
      break;
    case 12: //memcontroller
      mystr += "\"[shape=record,sides=5,peripheries=1,color=skyblue,style=filled]";
      break;
    default:
      mystr += "\"[shape=record,sides=5,peripheries=3,color=white,style=filled]";
      break;
  }
  arch.addObj(mystr);
#endif

  I(mdev);
  addMemObjName(mdev->getName());
#ifdef DEBUG
  LOG("Added: %s", mdev->getName());
#endif

  return mdev;
}
Exemple #12
0
void processBranch(const char *proc)
{
  // FIXME: add thermal block to branch predictor

  // get the branch
  const char* bpred = SescConf->getCharPtr(proc,"bpred") ;

  // get the type
  const char* type = SescConf->getCharPtr(bpred,"type") ;

  xcacti_flp xflp;

  double bpred_power=0;
  // switch based on the type
  if(!strcmp(type,"Taken") || 
     !strcmp(type,"Oracle") || 
     !strcmp(type,"NotTaken") || 
     !strcmp(type,"Static")) {
    // No tables
    bpred_power= 0;
  }else if(!strcmp(type,"2bit")) {
	 int size = SescConf->getInt(bpred,"size") ;

    // 32 = 8bytes line * 4 predictions per byte (assume 2bit counter)
    bpred_power = getEnergy(size/32, 8, 1, 1, 0, 1, 0, 8, &xflp);
    bpred_power= 0;

  }else if(!strcmp(type,"2level")) {
	 int size = SescConf->getInt(bpred,"l2size") ;

    // 32 = 8bytes line * 4 predictions per byte (assume 2bit counter)
    bpred_power = getEnergy(size/32, 8, 1, 1, 0, 1, 0, 8, &xflp);

  }else if(!strcmp(type,"ogehl")) {
    int mTables = SescConf->getInt(bpred,"mtables") ;
    int size    = SescConf->getInt(bpred,"tsize") ;

    I(0);
    // 32 = 8bytes line * 4 predictions per byte (assume 2bit counter)
    bpred_power = getEnergy(size/32, 8, 1, 1, 0, 1, 0, 8, &xflp) * mTables;

  }else if(!strcmp(type,"hybrid")) {
	 int size = SescConf->getInt(bpred,"localSize") ;

    // 32 = 8bytes line * 4 predictions per byte (assume 2bit counter)
    bpred_power = getEnergy(size/32, 8, 1, 1, 0, 1, 0, 8, &xflp);
#ifdef SESC_SESCTHERM2
    // FIXME: update layout
#endif
    size = SescConf->getInt(bpred,"metaSize");

    // 32 = 8bytes line * 4 predictions per byte (assume 2bit counter)
    bpred_power += getEnergy(size/32, 8, 1, 1, 0, 1, 0, 8, &xflp);

  }else{
    MSG("Unknown energy for branch predictor type [%s]", type);
    exit(-1);
  }

#ifdef SESC_SESCTHERM2
  // FIXME: partition energies per structure
  const char *bpredBlockName = SescConf->getCharPtr(bpred, "blockName");
  update_layout(bpredBlockName, &xflp);
#else
  SescConf->updateRecord(proc,"bpredEnergy",bpred_power) ;
#endif

  int btbSize  = SescConf->getInt(bpred,"btbSize");
  int btbAssoc = SescConf->getInt(bpred,"btbAssoc");
  double btb_power = 0;

  if (btbSize) {
    btb_power = getEnergy(btbSize*8, 8, btbAssoc, 1, 0, 1, 1, 64, &xflp);
#ifdef SESC_SESCTHERM2
    // FIXME: partition energies per structure
    update_layout(bpredBlockName, &xflp);
#else
    SescConf->updateRecord(proc,"btbEnergy",btb_power) ;
#endif
  }else{
    SescConf->updateRecord(proc,"btbEnergy",0.0) ;
  }

  double ras_power =0;
  int ras_size = SescConf->getInt(bpred,"rasSize");
  if (ras_size) {
    ras_power = getEnergy(ras_size*8, 8, 1, 1, 0, 1, 0, 64, &xflp);
#ifdef SESC_SESCTHERM2
    // FIXME: partition energies per structure (all bpred may share a block)
    update_layout(bpredBlockName, &xflp);
#else
    SescConf->updateRecord(proc,"rasEnergy",ras_power) ;
#endif
  }else{
    SescConf->updateRecord(proc,"rasEnergy",0.0) ;
  }

}
Exemple #13
0
void PCM::updateCavity()
{
    //Cavities from expanded densities for SGA13 variant:
    if(fsp.pcmVariant == PCM_SGA13)
    {   ScalarField* shapeEx[2] = { &shape, &shapeVdw };
        for(int i=0; i<2; i++)
        {   ShapeFunction::expandDensity(wExpand[i], Rex[i], nCavity, nCavityEx[i]);
            ShapeFunction::compute(nCavityEx[i], *(shapeEx[i]), fsp.nc, fsp.sigma);
        }
    }
    else if(fsp.pcmVariant == PCM_CANDLE)
    {   nCavityEx[0] = fsp.Ztot * I(Sf[0] * J(nCavity));
        ShapeFunction::compute(nCavityEx[0], coulomb(Sf[0]*rhoExplicitTilde), shapeVdw,
                               fsp.nc, fsp.sigma, fsp.pCavity); //vdW cavity
        shape = I(wExpand[0] * J(shapeVdw)); //dielectric cavity
    }
    else if(isPCM_SCCS(fsp.pcmVariant))
        ShapeFunctionSCCS::compute(nCavity, shape, fsp.rhoMin, fsp.rhoMax, epsBulk);
    else //Compute directly from nCavity (which is a density product for SaLSA):
        ShapeFunction::compute(nCavity, shape, fsp.nc, fsp.sigma);

    //Compute and cache cavitation energy and gradients:
    const auto& solvent = fsp.solvents[0];
    switch(fsp.pcmVariant)
    {
    case PCM_SaLSA:
    case PCM_CANDLE:
    case PCM_SGA13:
    {   //Select relevant shape function:
        const ScalarFieldTilde sTilde = J(fsp.pcmVariant==PCM_SaLSA ? shape : shapeVdw);
        ScalarFieldTilde A_sTilde;
        //Cavitation:
        const double nlT = solvent->Nbulk * fsp.T;
        const double Gamma = log(nlT/solvent->Pvap) - 1.;
        const double Cp = 15. * (solvent->sigmaBulk/(2*solvent->Rvdw * nlT) - (1+Gamma)/6);
        const double coeff2 = 1. + Cp - 2.*Gamma;
        const double coeff3 = Gamma - 1. -2.*Cp;
        ScalarField sbar = I(wCavity*sTilde);
        Adiel["Cavitation"] = nlT * integral(sbar*(Gamma + sbar*(coeff2 + sbar*(coeff3 + sbar*Cp))));
        A_sTilde += wCavity*Idag(nlT * (Gamma + sbar*(2.*coeff2 + sbar*(3.*coeff3 + sbar*(4.*Cp)))));
        //Dispersion:
        ScalarFieldTildeArray Ntilde(Sf.size()), A_Ntilde(Sf.size()); //effective nuclear densities in spherical-averaged ansatz
        for(unsigned i=0; i<Sf.size(); i++)
            Ntilde[i] = solvent->Nbulk * (Sf[i] * sTilde);
        const double vdwScaleEff = (fsp.pcmVariant==PCM_CANDLE) ? fsp.sqrtC6eff : fsp.vdwScale;
        Adiel["Dispersion"] = e.vanDerWaals->energyAndGrad(atpos, Ntilde, atomicNumbers, vdwScaleEff, &A_Ntilde);
        A_vdwScale = Adiel["Dispersion"]/vdwScaleEff;
        for(unsigned i=0; i<Sf.size(); i++)
            if(A_Ntilde[i])
                A_sTilde += solvent->Nbulk * (Sf[i] * A_Ntilde[i]);
        //Propagate gradients to appropriate shape function:
        (fsp.pcmVariant==PCM_SaLSA ? Acavity_shape : Acavity_shapeVdw) = Jdag(A_sTilde);
        break;
    }
    case PCM_GLSSA13:
    {   VectorField Dshape = gradient(shape);
        ScalarField surfaceDensity = sqrt(lengthSquared(Dshape));
        ScalarField invSurfaceDensity = inv(surfaceDensity);
        A_tension = integral(surfaceDensity);
        Adiel["CavityTension"] = A_tension * fsp.cavityTension;
        Acavity_shape = (-fsp.cavityTension)*divergence(Dshape*invSurfaceDensity);
        break;
    }
    case PCM_LA12:
    case PCM_PRA05:
        break; //no contribution
case_PCM_SCCS_any:
        {   //Volume contribution:
            Adiel["CavityPressure"] = fsp.cavityPressure * (gInfo.detR - integral(shape));
            //Surface contribution:
            ScalarField shapePlus, shapeMinus;
            ShapeFunctionSCCS::compute(nCavity+(0.5*fsp.rhoDelta), shapePlus, fsp.rhoMin, fsp.rhoMax, epsBulk);
            ShapeFunctionSCCS::compute(nCavity-(0.5*fsp.rhoDelta), shapeMinus, fsp.rhoMin, fsp.rhoMax, epsBulk);
            ScalarField DnLength = sqrt(lengthSquared(gradient(nCavity)));
            Adiel["CavityTension"] = (fsp.cavityTension/fsp.rhoDelta) * integral(DnLength * (shapeMinus - shapePlus));
            break;
        }
    }
}
Exemple #14
0
 void pqueue<T,I>::append(const T & item)
 {
     push(item, I());
 } // pqueue<T,I>::append()
Exemple #15
0
/******************************************************************************
 * Example:
 * goal:    [active-goal Jim [watch-TV Jim]]
 * Returns: watch
 ******************************************************************************/
Obj *GoalObjectiveOf(Obj *goal)
{
  return(I(I(goal, 2), 0));
}
Exemple #16
0
// CHECK: define void @_Z1hv() nounwind {
void h() {
  I i;
  // CHECK: call void @llvm.memcpy.
  i = I();
  // CHECK-NEXT: ret void
}
Exemple #17
0
uint32_t do_syscall_arm(ProgramBase *prog, uint32_t num, uint32_t arg1,uint32_t
    arg2, uint32_t arg3,uint32_t arg4,uint32_t arg5, uint32_t arg6, FILE *syscallTrace)

{ 

#ifdef DEBUG2
  printf ("syscall %d \n", num);
#endif

  uint32_t ret;  
  void  *p;
#if defined (CONFIG_ESESC_system) || defined (CONFIG_ESESC_user)
  struct timespec startTime;
  clock_gettime(CLOCK_REALTIME,&startTime);
#endif

  char tmp_str[128];
  char pc[32];
  char systrace_syscall_num[32];
  char emul_syscall_num[32];
  int i, j, ret1; 
  regex_t re1;
  regmatch_t match[3];

  if (syscallTrace != NULL) {

    // Example trace file section
    //
    //----------
    //pc: 0x8174
    //syscall: 122
    //Linux
    //masca1
    //3.0.0-1205-omap4
    //#10-Ubuntu SMP PREEMPT Thu Sep 29 03:57:24 UTC 2011
    //armv7l
    //----------
    //pc: 0x8230
    //syscall: 4
    //----------

    //printf("Advance to the section \n");
    fgets(tmp_str, sizeof tmp_str, syscallTrace);
    tmp_str[strlen (tmp_str) - 1] = '\0';
    memset(tmp_str, '\0', 128);

    // read pc
    fgets(pc, sizeof pc, syscallTrace);
    pc[strlen (pc) - 1] = '\0';

    // read syscall number
    fgets(tmp_str, sizeof tmp_str, syscallTrace);
    tmp_str[strlen (tmp_str) - 1] = '\0';
    //printf("pc %s, syscall %s \n", pc, tmp_str);

    ret1 = regcomp(&re1, "syscall: ([0-9]+)", REG_EXTENDED);
    ret1 = regexec(&re1, tmp_str, 2, match, 0);
    if(!ret1) {
      j = 0;
      for(i = match[1].rm_so; i < match[1].rm_eo; i++) {
        systrace_syscall_num[j] = tmp_str[i];
        j++;
      }
      systrace_syscall_num[j] = '\0';
    }else{
      I(0);
    }

    sprintf(emul_syscall_num, "%d", num);

    // Sanity check for syscall number
    if (strcmp(systrace_syscall_num, emul_syscall_num) != 0) {
      printf("Emulator syscall trace and expected syscall trace are out of sync \n");
      printf("  syscall num - Expected: %s, Emulator: %s\n", systrace_syscall_num, emul_syscall_num);
      I(0);
      // exit(0);
    }
  }

  switch(num) {
    case TARGET_NR_exit:
      exit(arg1);
      return 0;
      break;
    case TARGET_NR_exit_group:
      exit(arg1);
      return 0;
      break;
    case TARGET_NR_write: 
      ret = write(arg1, prog->g2h(arg2), arg3);
      return ret;
      break;
    case TARGET_NR_read: 
      if (arg3 == 0) {
        ret = 0;
      }else{
        ret = read(arg1, prog->g2h(arg2), arg3);
      }
      return ret;
      break;
      /* case TARGET_NR_ioctl:
         do_ioctl(prog, arg1, arg2, arg3);
         return 0;
         break;*/
    case TARGET_NR_lseek:
      ret = lseek(arg1, arg2, arg3);
      return ret;
      break;
    case TARGET_NR_gettimeofday:
      {          
        // FIXME: Not correct
        struct timeval tv; 
        gettimeofday(&tv, NULL);
      }  
      return 0;
      break;
    case TARGET_NR_open:
      // FIXME: how to check if this is a open(a,b,c) or open(a,b)
      ret = open((const char *)prog->g2h(arg1), arg2);
      return ret;
      break;        
    case TARGET_NR_close:
      ret = close(arg1);
      return ret;
      break;
    case TARGET_NR_mkdir:
      p = lock_user_string(prog, arg1);
      ret = mkdir((const char *)p, arg2);
      return ret; 
      break;
    case TARGET_NR_rmdir:
      p = lock_user_string(prog, arg1);
      ret = rmdir((const char *)p);
      return ret;                
      break;
    case TARGET_NR_rename:
      {
        void *p2;
        p  = lock_user_string(prog, arg1);
        p2 = lock_user_string(prog, arg2);
        if (!p || !p2)
          ret = -TARGET_EFAULT;
        else
          rename((const char *)p, (const char *)p2);
      }
      return 0;
      break;

    case TARGET_NR_uname:
      // copy 390 bytes from syscalltrace to buf
      //Linux
      //masca1
      //3.0.0-1205-omap4
      //#10-Ubuntu SMP PREEMPT Thu Sep 29 03:57:24 UTC 2011
      {
        struct utsname *uts_buf = (struct utsname *)prog->g2h(arg1);

        if (syscallTrace != NULL) {

          for (i = 0; i < 5; i++) {
            memset(tmp_str, '\0', 65);
            fgets(tmp_str, sizeof tmp_str, syscallTrace);
            tmp_str[strlen (tmp_str) - 1] = '\0';
            if(i == 0)
              strcpy(uts_buf->sysname, tmp_str);
            else if(i == 1)
              strcpy(uts_buf->nodename, tmp_str);
            else if(i == 2)
              strcpy(uts_buf->release, tmp_str);
            else if(i == 3)
              strcpy(uts_buf->version, tmp_str);
            else if(i == 4)
              strcpy(uts_buf->machine, tmp_str);
          }
        } else {
          if (uname(uts_buf) < 0)
            return (-1);
        }
      }
      return 0;
      break;

    case TARGET_NR_brk:
      {

        if (!arg1) {
          return target_brk;
        } else if(arg1 < target_original_brk) { 
          return target_brk; 
        } else {

          if(arg1 < brk_page) {
            if(arg1 > target_brk) {
              // initialize as it may contain garbage due to a previous heap usage
              // (grown then shrunken)
              memset(prog->g2h(target_brk), 0, arg1 - target_brk);
            }
            // deallocate is handled automatically here.
            target_brk = arg1;
            return target_brk;
          } 

          // Need to allocate memory.
          // We can't call local host brk() system call which tends to change the 
          // simulator program's brk_addr.
          // What we need to adjust here is the simulated virtual memory data segment.
          // so simulate brk here by calling realloc to reallocate simulator data segment.

          uint32_t size_incr = PAGE_ALIGN_UP(arg1 - brk_page); 

          uint32_t old_size;
          uint32_t *data_ptr = NULL;
          data_ptr = prog->get_data_buffer(&old_size);

          uint8_t *new_data_ptr = (uint8_t *)realloc(data_ptr, (old_size + size_incr));

          if (new_data_ptr != NULL) {

            prog->set_data_buffer((old_size + size_incr), new_data_ptr);
            target_brk = arg1;
            brk_page = PAGE_ALIGN_UP(target_brk);

            return target_brk;
          } else {
            return (-1);
          }
        }
      }
      return target_brk;;
      break;

    case TARGET_NR_fstat64:
      {
        if (syscallTrace == NULL) {
          ret = fstat(arg1, (struct stat *)prog->g2h(arg2));
          return ret;
        } else {
          // copy 144 bytes (size of stat structure) from systrace file
          // number of lines in the file: total 144 bytes/8 bytes per line = 18 lines
          for (i=0; i < 18; i++) {
            memset(tmp_str, '\0', 128);
            fgets(tmp_str, 128, syscallTrace);
            long long int val = strtoull(tmp_str, NULL, 16);
            memcpy( (prog->g2h(arg2 + (i * 8) )), &val, 8);
          }
        }
      }
      return 0;
      break;

    case TARGET_NR_mmap2:
      {
        if (arg1 != 0x00000000) {
          // FIXME: This is the non-zero address case.
          // The address gives a hint to the kernel about where to map the file.
          // We might still do a malloc but need to remember a mapping of the native
          // address (i.e arg1) to pointer returned by malloc.
          printf("TARGET_NR_mmap2 map address not zero!!! This case is not handled \n");
          exit(-1);
        }
        uint8_t *p = (uint8_t *)malloc(arg2);
        if (p == MAP_FAILED)
          return -1;
        else {
          prog->set_mem_mapped_file_endpts((long)p, arg2);
          return (long)p;
        }
      }
      return 0;
      printf("return address 0x%08x \n", p);
      break;

    case TARGET_NR_getpid:
      getpid();
      return 0;
      break;
    case TARGET_NR_kill:
      kill(arg1, target_to_host_signal(arg2));
      return 0;                 
      break;
    case TARGET_NR_pause:
      pause();
      return 0;
      break;
#ifdef TARGET_NR_shutdown
    case TARGET_NR_shutdown:
      shutdown(arg1, arg2);
      return 0;
      break;
#endif
#ifdef TARGET_NR_semget
    case TARGET_NR_semget:
      semget(arg1, arg2, arg3);
      return 0;       
      break; 
#endif
    case TARGET_NR_setdomainname:
      p = lock_user_string(prog, arg1);
      setdomainname((const char *)p, arg2);
      return 0;      
      break;
    case TARGET_NR_getsid:
      getsid(arg1);
      return 0;
      break;
#if defined(TARGET_NR_fdatasync)
      /* Not on alpha (osf_datasync ?) */
    case TARGET_NR_fdatasync:
      fdatasync(arg1);
      return 0;
      break;
#endif
#ifdef TARGET_NR_getuid32
    case TARGET_NR_getuid32:
      getuid();
      return 0;
      break;
#endif 
    case TARGET_NR_ioctl:
      printf("ioctl syscall not implemented\n");
      return 0;
      break;
    default:
      printf("syscall %d is not implemented\n", num);
      exit(-1);
  }    

}
Error TextureAtlasResource::load(const ResourceFilename& filename, Bool async)
{
	XmlDocument doc;
	ANKI_CHECK(openFileParseXml(filename, doc));

	XmlElement rootel, el;

	//
	// <textureAtlas>
	//
	ANKI_CHECK(doc.getChildElement("textureAtlas", rootel));

	//
	// <texture>
	//
	ANKI_CHECK(rootel.getChildElement("texture", el));
	CString texFname;
	ANKI_CHECK(el.getText(texFname));
	ANKI_CHECK(getManager().loadResource<TextureResource>(texFname, m_tex, async));

	m_size[0] = m_tex->getWidth();
	m_size[1] = m_tex->getHeight();

	//
	// <subTextureMargin>
	//
	ANKI_CHECK(rootel.getChildElement("subTextureMargin", el));
	I64 margin = 0;
	ANKI_CHECK(el.getNumber(margin));
	if(margin >= I(m_tex->getWidth()) || margin >= I(m_tex->getHeight()) || margin < 0)
	{
		ANKI_RESOURCE_LOGE("Too big margin %d", U(margin));
		return Error::USER_DATA;
	}
	m_margin = margin;

	//
	// <subTextures>
	//

	// Get counts
	PtrSize namesSize = 0;
	PtrSize subTexesCount = 0;
	XmlElement subTexesEl, subTexEl;
	ANKI_CHECK(rootel.getChildElement("subTextures", subTexesEl));
	ANKI_CHECK(subTexesEl.getChildElement("subTexture", subTexEl));
	do
	{
		ANKI_CHECK(subTexEl.getChildElement("name", el));
		CString name;
		ANKI_CHECK(el.getText(name));

		if(name.getLength() < 1)
		{
			ANKI_RESOURCE_LOGE("Something wrong with the <name> tag. Probably empty");
			return Error::USER_DATA;
		}

		namesSize += name.getLength() + 1;
		++subTexesCount;

		ANKI_CHECK(subTexEl.getNextSiblingElement("subTexture", subTexEl));
	} while(subTexEl);

	// Allocate
	m_subTexNames.create(getAllocator(), namesSize);
	m_subTexes.create(getAllocator(), subTexesCount);

	// Iterate again and populate
	subTexesCount = 0;
	char* names = &m_subTexNames[0];
	ANKI_CHECK(subTexesEl.getChildElement("subTexture", subTexEl));
	do
	{
		ANKI_CHECK(subTexEl.getChildElement("name", el));
		CString name;
		ANKI_CHECK(el.getText(name));

		memcpy(names, &name[0], name.getLength() + 1);

		m_subTexes[subTexesCount].m_name = names;

		ANKI_CHECK(subTexEl.getChildElement("uv", el));
		Vec4 uv;
		ANKI_CHECK(el.getVec4(uv));
		m_subTexes[subTexesCount].m_uv = {{uv[0], uv[1], uv[2], uv[3]}};

		names += name.getLength() + 1;
		++subTexesCount;

		ANKI_CHECK(subTexEl.getNextSiblingElement("subTexture", subTexEl));
	} while(subTexEl);

	return Error::NONE;
}
Exemple #19
0
void SamplerGPUSim::queue(uint32_t insn, uint64_t pc, uint64_t addr, uint32_t fid, char op)
  /* main qemu/gpu/tracer/... entry point {{{1 */
{
  if(!execute(fid,icount))
    return; // QEMU can still send a few additional instructions (emul should stop soon)
  
  I(mode!=EmuInit);

  I(insn!=0);
  I(icount!=0);

  if (doPower){

    uint64_t ti = 0;
    bool callpwr = callPowerModel(ti, fid);

    if (callpwr){ 

      I(ti > 0);
      //printf("totalnInst:%ld, nPassedInst:%ld, interval:%ld\n", totalnInst, nPassedInst, interval);


      bool dummy = false;

      //std::cout<<"mode "<<mode<<" Timeinterval "<<ti<<" last time "<<lastTime<<"\n";  

      int simt = 0;
      if (ti > 0){
        setMode(EmuTiming, fid);
        simt =  BootLoader::pwrmodel.calcStats(ti, 
            !(mode == EmuTiming), static_cast<float>(freq), dummy, dummy, dummy, dummy); 

        endSimSiged = (simt==90)?1:0;
        BootLoader::pwrmodel.sescThermWrapper->sesctherm.updateMetrics();  
      }
    }
  }// doPower
  
  if (nInstMax < totalnInst || endSimSiged) {
    markDone();
    return;
  }
  if (nInstSkip>totalnInst) {
    I(mode==EmuRabbit);
    return;
  }
  I(nInstSkip<=totalnInst);
  if (mode == EmuRabbit) {
    stop();
    startTiming(fid);
  }

#if 0
  static std::set<AddrType> seenPC;
  static Time_t seenPC_last   = 0;
  static Time_t seenPC_active = 0;
  static Time_t seenPC_total  = 0;
  seenPC_total++;
  if (seenPC.find(pc^insn) == seenPC.end()) {
    seenPC.insert(pc^insn);
    seenPC_last = seenPC_total;
  }
  if ((seenPC_last+1000) > seenPC_total)
    seenPC_active++;
/*
  if ((seenPC_total & 1048575) == 1)
    MSG("%5.3f",(100.0*seenPC_active)/(1.0+seenPC_total)); */
#endif

  emul->queueInstruction(insn,pc,addr, (op&0x80) /* thumb */, fid);
}
Exemple #20
0
void DummyMemObj::doInvalidate(PAddr addr, ushort size)
{
  I(0);
}
Exemple #21
0
/* 
 * internal energy
 *  see Reynolds eqn (15) section 2
 *  u = (the integral from T to To of co(T)dT) +
 *         sum from i to N ([C(i) - T*Cprime(i)] + uo
 */
double Heptane::up() {
   double Tinverse = 1.0/T;   
   double T2inverse = pow(T, -2);
   double T3inverse = pow(T, -3);
   double T4inverse = pow(T, -4);
   double egrho = exp(-Gamma*Rho*Rho);

   double sum = 0.0;
   int i;
   for (i=1; i<=5; i++)
      sum += G[i]*(pow(T,i) - pow(To,i))/double(i);

   sum += G[0]*log(T/To);   

   for (i=0; i<=6; i++) {
      sum += (C(i, Tinverse, T2inverse, T3inverse, T4inverse) - T*Cprime(i,T2inverse, T3inverse, T4inverse))*I(i,egrho, Gamma);   
   }
    
   sum += u0;

   return sum + m_energy_offset;
 }
Exemple #22
0
void DummyMemObj::returnAccess(MemRequest *req) 
{
  I(0);
}
void Smoke::project( std::vector<float>& p, std::vector<float>& div )
{
	for (int i=1; i <= N; i++) {
		for (int j=1; j <= N; j++) {
			div[I(i,j)] = -0.5f * (u[I(i+1,j)] - u[I(i-1,j)] + 
								   v[I(i,j+1)] - v[I(i,j-1)]) / N;   
			p[I(i,j)] = 0;   
		}
	}  
    boundary( 0, div ); 
	boundary( 0, p );   
   
    linearSolver( 0, p, div, 1, 4 );   
   
    for (int i=1; i <= N; i++) {
		for (int j=1; j <= N; j++) {
			u[I(i,j)] -= 0.5f * N * (p[I(i+1,j)] - p[I(i-1,j)]);   
			v[I(i,j)] -= 0.5f * N * (p[I(i,j+1)] - p[I(i,j-1)]);   
		}
	}
    boundary( 1, u ); 
	boundary( 2, v ); 
}
int test_with_random_access_iterator() {
    GoodIter begin, end;
    Iter0 begin0, end0;
    #pragma omp parallel
    #pragma omp for
    for (GoodIter I = begin; I < end; ++I)
        ++I;
    #pragma omp parallel
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
    #pragma omp for
    for (GoodIter &I = begin; I < end; ++I)
        ++I;
    #pragma omp parallel
    #pragma omp for
    for (GoodIter I = begin; I >= end; --I)
        ++I;
    #pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
    #pragma omp for
    for (GoodIter I(begin); I < end; ++I)
        ++I;
    #pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
    #pragma omp for
    for (GoodIter I(nullptr); I < end; ++I)
        ++I;
    #pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
    #pragma omp for
    for (GoodIter I(0); I < end; ++I)
        ++I;
    #pragma omp parallel
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
    #pragma omp for
    for (GoodIter I(1, 2); I < end; ++I)
        ++I;
    #pragma omp parallel
    #pragma omp for
    for (begin = GoodIter(0); begin < end; ++begin)
        ++begin;
// expected-error@+4 {{invalid operands to binary expression ('GoodIter' and 'Iter0')}}
// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
    #pragma omp parallel
    #pragma omp for
    for (begin = begin0; begin < end; ++begin)
        ++begin;
    #pragma omp parallel
// expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
    #pragma omp for
    for (++begin; begin < end; ++begin)
        ++begin;
    #pragma omp parallel
    #pragma omp for
    for (begin = end; begin < end; ++begin)
        ++begin;
    #pragma omp parallel
// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
    #pragma omp for
    for (GoodIter I = begin; I - I; ++I)
        ++I;
    #pragma omp parallel
// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
    #pragma omp for
    for (GoodIter I = begin; begin < end; ++I)
        ++I;
    #pragma omp parallel
// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
    #pragma omp for
    for (GoodIter I = begin; !I; ++I)
        ++I;
    #pragma omp parallel
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
    #pragma omp for
    for (GoodIter I = begin; I >= end; I = I + 1)
        ++I;
    #pragma omp parallel
    #pragma omp for
    for (GoodIter I = begin; I >= end; I = I - 1)
        ++I;
    #pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
    #pragma omp for
    for (GoodIter I = begin; I >= end; I = -I)
        ++I;
    #pragma omp parallel
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
    #pragma omp for
    for (GoodIter I = begin; I >= end; I = 2 + I)
        ++I;
    #pragma omp parallel
// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
    #pragma omp for
    for (GoodIter I = begin; I >= end; I = 2 - I)
        ++I;
// In the following example, we cannot update the loop variable using '+='
// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
    #pragma omp parallel
    #pragma omp for
    for (Iter0 I = begin0; I < end0; ++I)
        ++I;
    #pragma omp parallel
// Initializer is constructor without params.
// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
    #pragma omp for
    for (Iter0 I; I < end0; ++I)
        ++I;
    Iter1 begin1, end1;
// expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
    #pragma omp parallel
    #pragma omp for
    for (Iter1 I = begin1; I < end1; ++I)
        ++I;
    #pragma omp parallel
// expected-note@+3 {{loop step is expected to be negative due to this condition}}
// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
    #pragma omp for
    for (Iter1 I = begin1; I >= end1; ++I)
        ++I;
    #pragma omp parallel
// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
// expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
// Initializer is constructor with all default params.
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
    #pragma omp for
    for (Iter1 I; I < end1; ++I) {
    }
    GoodIter1 I1, E1;
    #pragma omp for
    for (GoodIter1 I = I1; I < E1; I++)
        ;
    return 0;
}
Exemple #25
0
void FlatCodeGen::writeData()
{
	/* If there are any transtion functions then output the array. If there
	 * are none, don't bother emitting an empty array that won't be used. */
	if ( redFsm->anyActions() ) {
		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() );
		ACTIONS_ARRAY();
		CLOSE_ARRAY() <<
		"\n";
	}

	if ( redFsm->anyConditions() ) {
		OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
		COND_KEYS();
		CLOSE_ARRAY() <<
		"\n";

		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() );
		COND_KEY_SPANS();
		CLOSE_ARRAY() <<
		"\n";

		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() );
		CONDS();
		CLOSE_ARRAY() <<
		"\n";

		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() );
		COND_INDEX_OFFSET();
		CLOSE_ARRAY() <<
		"\n";
	}

	OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
	KEYS();
	CLOSE_ARRAY() <<
	"\n";

	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() );
	KEY_SPANS();
	CLOSE_ARRAY() <<
	"\n";

	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() );
	FLAT_INDEX_OFFSET();
	CLOSE_ARRAY() <<
	"\n";

	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() );
	INDICIES();
	CLOSE_ARRAY() <<
	"\n";

	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
	TRANS_TARGS();
	CLOSE_ARRAY() <<
	"\n";

	if ( redFsm->anyActions() ) {
		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() );
		TRANS_ACTIONS();
		CLOSE_ARRAY() <<
		"\n";
	}

	if ( redFsm->anyToStateActions() ) {
		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
		TO_STATE_ACTIONS();
		CLOSE_ARRAY() <<
		"\n";
	}

	if ( redFsm->anyFromStateActions() ) {
		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
		FROM_STATE_ACTIONS();
		CLOSE_ARRAY() <<
		"\n";
	}

	if ( redFsm->anyEofActions() ) {
		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() );
		EOF_ACTIONS();
		CLOSE_ARRAY() <<
		"\n";
	}

	if ( redFsm->anyEofTrans() ) {
		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() );
		EOF_TRANS();
		CLOSE_ARRAY() <<
		"\n";
	}

	STATE_IDS();
}
Exemple #26
0
arma::Mat<double> identity(int N)
{
  arma::Mat<double> I(N, N, arma::fill::eye);
  return I;
}
void ak4183_delay_work(struct work_struct *work)
{
	struct AK4183_TS_EVENT *ts_dev = g_ts_dev;
	int ak4183_irq_pin_level = 0;
	int ak4183_input_report_flag = 0;
	int raw_x[SAMPLE_TIMES] = {0}; /* x raw adc data */
	int raw_y[SAMPLE_TIMES] = {0}; /* y raw adc data */
    int filtered_x = 0;
	int filtered_y = 0;
    int xpos;
	int ypos;
	int ret = 0;	
	int i;
	
	D("enter!\n");

	ak4183_irq_pin_level = GPIOGetPinLevel(GPIOPortE_Pin3);

	/* touch */
	if(ak4183_irq_pin_level == 0){
		/* get raw data of x and y */
		for(i = 0; i < SAMPLE_TIMES; i++){
			ret |= ak4183_read_x(&raw_x[i]);
			ret |= ak4183_read_y(&raw_y[i]);
			if(ret != 0){
				E("an4183_read xpos or ypos err!\n");
				goto fake_touch;
			}
		}

		/* check raw data whether valid */
	    for (i = 0; i < SAMPLE_TIMES; i++)
	    {
	        if (raw_x[i] == 4095 || raw_x[i] == 0 ||
			    raw_y[i] == 4095 || raw_y[i] == 0){
			    I("raw data invalid\n");
	            goto fake_touch;
	        }
	    }

		/* filter raw data */
	    ret = tp_average_filter(raw_x, &filtered_x);
		if(ret < 0){
			I("x fake touch\n");
			goto fake_touch;
		}

		ret = tp_average_filter(raw_y, &filtered_y);
	    if (ret < 0){
			I("y fake touch\n");
	        goto fake_touch;
	    }

	    TouchPanelCalibrateAPoint(filtered_x, filtered_y, &xpos, &ypos);
		xpos = xpos / 4;
	    ypos = ypos / 4;

		if(tp_state == TP_STATE_IDLE){
			input_report_key(ts_dev->input, BTN_TOUCH, 1);
			ak4183_input_report_flag = 1;
			tp_state = TP_STATE_DOWN;
		}
		
		if(tp_state == TP_STATE_DOWN){
			I("xpos=%d, ypos=%d\n", xpos, ypos);
			I("gADPoint.x=%d, gADPoint.y=%d\n", gADPoint.x, gADPoint.y);
			gADPoint.x = filtered_x;
			gADPoint.y = filtered_y;
			
			input_report_abs(ts_dev->input, ABS_X, xpos);
			input_report_abs(ts_dev->input, ABS_Y, ypos);
			ak4183_input_report_flag = 1;
		}
	}

fake_touch:
	if(ak4183_irq_pin_level == 1 && tp_state == TP_STATE_DOWN){
		input_report_key(ts_dev->input, BTN_TOUCH, 0);
		ak4183_input_report_flag = 1;
		tp_state = TP_STATE_IDLE;
	}

	if(ak4183_input_report_flag != 0){
		input_sync(ts_dev->input);
	}

	/* still on touch */
	if(ak4183_irq_pin_level == 0){
		schedule_delayed_work(&ts_dev->work, TP_POLL_PERIOD);
	}
	/* untouch, open ts irq */
	else{
		gpio_irq_enable(GPIOPortE_Pin3);
	}
}
Exemple #28
0
Bool GetActorSpatial(Obj *con, Obj *actor, /* RESULTS */ Obj **from, Obj **to)
{
  if (actor != I(con, 1)) return(0);
  return(GetSpatial(con, from, to));
}
int
GradientProjectionSearchDirection::computeSearchDirection(int stepNumber, 
							  const Vector &u, 
							  double passed_g, 
							  const Vector &gradG)
{
  // Initial declarations
  int i,j;
  Vector u_new;
  double initialStepSize;
  Vector Direction;
  
  
  // Problem size 
  int nrv = u.Size();
  
  
  // Unit matrix
  Matrix I(nrv,nrv);
  for (i=0; i<nrv; i++) {
    for (j=0; j<nrv; j++) {
      if (i==j) {
	I(i,j) = 1.0;
      }
      else {
	I(i,j) = 0.0;
      }
    }
  }
  
  
  // Matrix of "outer" product of gradient vector
  Matrix dGdG(nrv,nrv);
  for (i=0; i<nrv; i++) {
    for (j=0; j<nrv; j++) {
      dGdG(i,j) = gradG(i)*gradG(j);
    }
  }
  
  // Get initial step size from the step size algorithm
  initialStepSize = theStepSizeRule->getInitialStepSize();
  
  
  // As long as it is not the first step; do the usual thing
  // (shouldn't happen if the user restarts the search...)
  if (stepNumber != 1) {
    
    // Compute the initial search direction vector
    Vector direction = (-1)* (I - (1.0/(gradG^gradG))*dGdG ) * u;
    
    // Initial step 
    u_new = u + initialStepSize*direction;
    
    // Set the direction of the Newton search
    Direction = gradG;
  }
  // If it's the first step; do the Newton thing from the
  // start point in the direction of the iHLRF search direction. 
  else {
    
    u_new = u;
    
    // Compute the alpha-vector
    Vector alpha = gradG * ( (-1) / gradG.Norm() );
    
    // Compute the direction vector
    double alpha_times_u = alpha ^ u ;
    Vector direction = alpha * ( passed_g / gradG.Norm() + alpha_times_u ) - u;
    
    // Set the direction of the Newton search
    Direction = (-1)*direction;
  }
  
  
  // Do the search to bring the trial point 'u_new' onto the lsf surface
  double tangent = gradG.Norm();
  Vector u_newest = theRootFindingAlgorithm->findLimitStateSurface(2,passed_g, Direction, u_new);
  
  
  // Return the final search direction
  // (remember to scale it so that u_new = u_old + lambda*d really brings us to u_new
  searchDirection = (1.0/initialStepSize)*(u_newest-u);
  
  return 0;
}
Exemple #30
0
static void Round4(unsigned int *a, unsigned int b, unsigned int c,
	unsigned int d, unsigned int k, unsigned int s, unsigned int i)
{
	*a = Round(*a, b, I(b, c, d), k, s, i);
}