Exemple #1
0
/**
 * \brief Example 1: Implements an abstract surface code using an 8-step cycle.   
 * 
 * \param[in] argc The number of command line arguments
 * \param[in] argv An array of the command line arguments 
 *
 * \return 0
 */
int main(int argc, char **argv) {
	RECIPE *recipe;

	// Initialise, then load the args
	ARGS *args = init_args();
	load_args(args, argc, argv);

	// Create the recipe for an infinite simulation
	recipe = qc_create_recipe(RECIPE_INFINITE, 1, 2*args->d-1, 2*args->d-1);
	
	// Generate the recipe 
	generate_recipe(args, recipe);

	// Boot up process, calculate optimal t_check
	if (args->boot == 1) {
		calculate_t_check(args, recipe);
	}

	// Run the simulation
	simulate_recipe(args, recipe);
	
	// Free the recipe
	qc_free_recipe(recipe);
	
	// If we opened a file for the output, it needs to be closed
	if (args->out_raw != stdout) { 
		fclose(args->out_raw);
	}

	free(args);

	return 0;
}
Exemple #2
0
static void
level_grains(GwyContainer *data,
             GwyRunType run)
{
    GwyDataField *dfield;
    GwyDataField *mfield;
    LevelGrainsArgs args;
    gboolean ok;
    GQuark quark;
    gint id;

    g_return_if_fail(run & LEVEL_GRAINS_RUN_MODES);
    gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD_KEY, &quark,
                                     GWY_APP_DATA_FIELD_ID, &id,
                                     GWY_APP_DATA_FIELD, &dfield,
                                     GWY_APP_MASK_FIELD, &mfield,
                                     0);
    g_return_if_fail(dfield && quark);

    load_args(gwy_app_settings_get(), &args);
    if (run != GWY_RUN_IMMEDIATE) {
        ok = level_grains_dialog(&args);
        save_args(gwy_app_settings_get(), &args);
        if (!ok)
            return;
    }

    level_grains_do(&args, data, quark, id, dfield, mfield);
    gwy_app_channel_log_add_proc(data, id, id);
}
Exemple #3
0
static int lconn_command(lua_State * L)
{
  redisContext * pContext = check_connection(L, 1);

  const char * argv[LUAHIREDIS_MAXARGS];
  size_t argvlen[LUAHIREDIS_MAXARGS];
  int nargs = load_args(L, pContext, 2, argv, argvlen);

  int nret = 0;

  redisReply * pReply = (redisReply *)redisCommandArgv(
      pContext, nargs, argv, argvlen
    );
  if (pReply == NULL)
  {
    /* TODO: Shouldn't we clear the context error state somehow after this? */
    return push_error(L, pContext);
  }

  nret = push_reply(L, pReply);

  /*
  * TODO: Not entirely safe: if above code throws error, reply object is leaked.
  */
  freeReplyObject(pReply);
  pReply = NULL;

  return nret;
}
Exemple #4
0
static void
fit(GwyGraph *graph)
{
    GwyContainer *settings;
    FitArgs args;

    memset(&args, 0, sizeof(FitArgs));

    args.auto_estimate = TRUE;
    args.auto_plot = TRUE;
    args.parent_graph = graph;
    args.xdata = gwy_data_line_new(1, 1.0, FALSE);
    args.ydata = gwy_data_line_new(1, 1.0, FALSE);
    args.param = g_array_new(FALSE, TRUE, sizeof(FitParamArg));

    settings = gwy_app_settings_get();
    load_args(settings, &args);
    fit_dialog(&args);
    save_args(settings, &args);

    g_object_unref(args.xdata);
    g_object_unref(args.ydata);
    g_array_free(args.param, TRUE);
    if (args.fitter)
        gwy_math_nlfit_free(args.fitter);
    if (args.abscissa_vf)
        gwy_si_unit_value_format_free(args.abscissa_vf);
}
Exemple #5
0
static void
poly_level(GwyContainer *data, GwyRunType run)
{
    GwyDataField *dfield, *mfield;
    GQuark quark;
    PolyLevelArgs args;
    gboolean ok;
    gint id;

    g_return_if_fail(run & POLYLEVEL_RUN_MODES);
    gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD_KEY, &quark,
                                     GWY_APP_DATA_FIELD, &dfield,
                                     GWY_APP_MASK_FIELD, &mfield,
                                     GWY_APP_DATA_FIELD_ID, &id,
                                     0);
    g_return_if_fail(dfield && quark);

    load_args(gwy_app_settings_get(), &args);
    if (run == GWY_RUN_INTERACTIVE) {
        ok = poly_level_dialog(&args, data, dfield, mfield, id);
        save_args(gwy_app_settings_get(), &args);
        if (!ok)
            return;
    }
    poly_level_do(data, dfield, mfield, quark, id, &args);
}
Exemple #6
0
void c_main(void)
{
//	test_load_args();

    load_args();

    __cpm_start_dmac();
    __cpm_start_ddr();
    /* enable mdmac's clock */
    REG_MDMAC_DMACKES = 0x3;
//	__cpm_set_bchdiv(3);
    __cpm_start_bch();

    gpio_init_4770();
    serial_init();

    serial_puts("pll init\n");
    pll_init_4770();
    sdram_init_4770();

    serial_puts("Setup fw args finish!\n");

    __asm__ (
        "li  $31, 0xbfc0130c \n\t"
        "jr  $31 \n\t "
    );
}
Exemple #7
0
static void
entropy(G_GNUC_UNUSED GwyContainer *data, GwyRunType run)
{
    GwyDataField *dfield, *mfield;
    EntropyArgs args;
    gboolean ok, same_units;

    g_return_if_fail(run & ENTROPY_RUN_MODES);
    gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD, &dfield,
                                     GWY_APP_MASK_FIELD, &mfield,
                                     0);
    g_return_if_fail(dfield);
    load_args(gwy_app_settings_get(), &args);
    same_units = gwy_si_unit_equal(gwy_data_field_get_si_unit_xy(dfield),
                                   gwy_data_field_get_si_unit_z(dfield));

    if (run == GWY_RUN_INTERACTIVE) {
        if (!same_units && args.mode == ENTROPY_ANGLES)
           args.mode = ENTROPY_SLOPES;
        ok = entropy_dialog(&args, dfield, mfield);
        save_args(gwy_app_settings_get(), &args);
        if (!ok)
            return;
    }
}
/* Step 3: Work forwards once again.  Perform register allocations,
 * taking into account instructions like TEX which require contiguous
 * result registers.  Where necessary spill registers to scratch space
 * and reload later.
 */
void brw_wm_pass2( struct brw_wm_compile *c )
{
   GLuint insn;
   GLuint i;

   init_registers(c);

   for (insn = 0; insn < c->nr_insns; insn++) {
      struct brw_wm_instruction *inst = &c->instruction[insn];

      /* Update registers' nextuse values:
       */
      update_register_usage(c, insn);

      /* May need to unspill some args.
       */
      load_args(c, inst);

      /* Allocate registers to hold results:
       */
      switch (inst->opcode) {
      case TGSI_OPCODE_TEX:
      case TGSI_OPCODE_TXB:
      case TGSI_OPCODE_TXP:
	 alloc_contiguous_dest(c, inst->dst, 4, insn);
	 break;

      default:
	 for (i = 0; i < 4; i++) {
	    if (inst->writemask & (1<<i)) {
	       assert(inst->dst[i]);
	       alloc_contiguous_dest(c, &inst->dst[i], 1, insn);
	    }
	 }
	 break;
      }

      if (TEST_DST_SPILLS && inst->opcode != WM_PIXELXY) {
	 for (i = 0; i < 4; i++)	
	    if (inst->dst[i])
	       spill_value(c, inst->dst[i]);
      }
   }

   if (BRW_DEBUG & DEBUG_WM) {
      brw_wm_print_program(c, "pass2");
   }

   c->state = PASS2_DONE;

   if (BRW_DEBUG & DEBUG_WM) {
       brw_wm_print_program(c, "pass2/done");
   }
}
Exemple #9
0
static int lconn_append_command(lua_State * L)
{
  redisContext * pContext = check_connection(L, 1);

  const char * argv[LUAHIREDIS_MAXARGS];
  size_t argvlen[LUAHIREDIS_MAXARGS];
  int nargs = load_args(L, pContext, 2, argv, argvlen);

  redisAppendCommandArgv(pContext, nargs, argv, argvlen);

  return 0;
}
int main(int argc, char *argv[]) {
	ServerConfig config;

	if (!load_args(argc, argv, config))
		return -1;

	ServerStart(config);

	while (1) {
		ServerUpdate();
	}
}
Exemple #11
0
void c_main(void)
{
	load_args();

	if (fw_args->debug_ops > 0) {
		do_debug();
		return ;
	}

	switch (CPU_ID) {
	case 0x4740:
		gpio_init_4740();
		pll_init_4740();
		serial_init();
		sdram_init_4740();
		break;
	case 0x4760:
		gpio_init_4760();
		cpm_start_all_4760();
		serial_init();
		pll_init_4760();
		sdram_init_4760();
		break;
	default:
		return;
	}
#if 1
	serial_puts("Setup xburst CPU args as:\n");
	serial_put_hex(CPU_ID);
	serial_put_hex(CFG_EXTAL);
	serial_put_hex(CFG_CPU_SPEED);
	serial_put_hex(PHM_DIV);
	serial_put_hex(fw_args->use_uart);
	serial_put_hex(CONFIG_BAUDRATE);
	serial_put_hex(SDRAM_BW16);
	serial_put_hex(SDRAM_BANK4);
	serial_put_hex(SDRAM_ROW);
	serial_put_hex(SDRAM_COL);
	serial_put_hex(REG_CPM_CPCCR);
#endif
	serial_puts("xburst stage1 run finish !\n");
	if (CPU_ID == 0x4760) {
		__asm__ (
			"li  $31, 0xbfc012e0 \n\t"
			"jr  $31 \n\t "
			);
	}
}
Exemple #12
0
static void
curvature(GwyContainer *data, GwyRunType run)
{
    GwyDataField *dfield, *mfield;
    CurvatureArgs args;
    gboolean ok;
    gint id;

    g_return_if_fail(run & CURVATURE_RUN_MODES);
    g_return_if_fail(g_type_from_name("GwyLayerLine"));
    gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD, &dfield,
                                     GWY_APP_MASK_FIELD, &mfield,
                                     GWY_APP_DATA_FIELD_ID, &id,
                                     0);
    g_return_if_fail(dfield);

    if (!gwy_si_unit_equal(gwy_data_field_get_si_unit_xy(dfield),
                           gwy_data_field_get_si_unit_z(dfield))) {
        GtkWidget *dialog;

        dialog = gtk_message_dialog_new
                        (gwy_app_find_window_for_channel(data, id),
                         GTK_DIALOG_DESTROY_WITH_PARENT,
                         GTK_MESSAGE_ERROR,
                         GTK_BUTTONS_OK,
                         _("%s: Lateral dimensions and value must "
                           "be the same physical quantity."),
                         _("Curvature"));
        gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_destroy(dialog);
        return;
    }

    load_args(gwy_app_settings_get(), &args);
    if (run == GWY_RUN_INTERACTIVE) {
        ok = curvature_dialog(&args, data, dfield, mfield, id);
        save_args(gwy_app_settings_get(), &args);
        if (!ok)
            return;
    }
    curvature_do(data, dfield, mfield, id, &args);
    if (args.set_selection)
        gwy_app_channel_log_add_proc(data, id, id);
}
Exemple #13
0
int main( int argc, char** argv )
{
	SSTRACE_ARGS args; int rc = 0;

	memset( &args, 0, sizeof( args ) );
	ErrBuffer[0] = 0;

	if( argc < 3 )
	{
		print_usage();
		return 0;
	}

	if( load_args( argc, argv, &args ) != 0 )
	{
		if( strlen( ErrBuffer ) ) 
		{
			fprintf( stderr, ErrBuffer );
		}
		else
		{
			print_usage();
		}

		return 1;
	}

	/* Initialize OpenSSL library before using DSSL! */
	SSL_library_init();	
	OpenSSL_add_all_ciphers();
	OpenSSL_add_all_digests();

	rc = proceed( &args );
	if( rc != 0 )
	{
		if( strlen( ErrBuffer ) ) fprintf( stderr, ErrBuffer );
	}

	/* Cleanup OpenSSL */
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();

	return rc;
}
Exemple #14
0
static PyObject *
do_call(PyObject *func, PyObject ***pp_stack, int na, int nk)
{
	PyObject *callargs = NULL;
	PyObject *kwdict = NULL;
	PyObject *result = NULL;

	if (nk > 0) {
		kwdict = update_keyword_args(NULL, nk, pp_stack, func);
		if (kwdict == NULL)
			goto call_fail;
	}
	callargs = load_args(pp_stack, na);
	if (callargs == NULL)
		goto call_fail;
	result = PyObject_Call(func, callargs, kwdict);
 call_fail:
	Py_XDECREF(callargs);
	Py_XDECREF(kwdict);
	return result;
}
Exemple #15
0
int
init(int argc, char* argv[], struct SSettings* psettings)
{
    assert(psettings != NULL);
    
    if (load_args(argc, argv, psettings) == 0)
    {
        return 0;
    }
    
    // Check if the imput files and directories exist
    if (psettings->is_simplified_mode)
    {
        if (!mist_file_exists(psettings->tpl_path))
        {
            print_error(errFileNotFound, psettings->tpl_path);
            return 0;
        }
    }
    else
    {
        if (!mist_dir_exists(psettings->tpl_path))
        {
            print_error(errDirNotFound, psettings->tpl_path);
            return 0;
        }
        if (mist_dir_is_root(psettings->tpl_path))
        {
            print_error(errTplDirRoot);
            return 0;
        }
    }

    if (!mist_file_exists(psettings->val_path))
    {
        print_error(errFileNotFound, psettings->val_path);
        return 0;
    }
    return 1;
}
Exemple #16
0
void PServerService::process_request (TcpServerConnection *conn,
		std::string msg_received)
{
	try {
		auto tokens = CommandHandler::tokenize(msg_received);

		/* fetch command tag and remove it from the vector of tokens */
#if GCC_VERSION >= 40900
		auto iter = tokens.cbegin();
#else
		auto iter = tokens.begin();
#endif
		std::string cmd_tag = *iter;
		tokens.erase(iter);

		/* execute command */
		auto cmd_handler = CommandFactory::make_cmd(cmd_tag);

		cmd_handler->load_args(tokens);
		auto reply_msg = cmd_handler->exec();

		/* send reply message */
		conn->WriteData(reply_msg.data(), reply_msg.size());
	}
	catch (CommandHandler::Exception& ex) {
		std::string err("ERROR 400 ");
		err += ex.what();
		err += std::string("\n");

		conn->WriteData(err.data(), err.size());
	}
	catch (std::runtime_error& ex) {
		std::string err("ERROR 400 ");
		err += ex.what();
		err += std::string("\n");

		conn->WriteData(err.data(), err.size());
	}
}
Exemple #17
0
static void
do_level(GwyContainer *data,
         GwyRunType run,
         LevelMethod level_type,
         const gchar *dialog_title)
{
    GwyDataField *dfield;
    GwyDataField *mfield;
    LevelArgs args;
    gdouble c, bx, by;
    GQuark quark;
    gint id;

    g_return_if_fail(run & LEVEL_RUN_MODES);
    gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD_KEY, &quark,
                                     GWY_APP_DATA_FIELD, &dfield,
                                     GWY_APP_DATA_FIELD_ID, &id,
                                     GWY_APP_MASK_FIELD, &mfield,
                                     0);
    g_return_if_fail(dfield && quark);

    load_args(gwy_app_settings_get(), &args);
    if (run != GWY_RUN_IMMEDIATE && mfield) {
        gboolean ok = level_dialog(&args, dialog_title);
        save_args(gwy_app_settings_get(), &args);
        if (!ok)
            return;
    }
    if (args.masking == GWY_MASK_IGNORE)
        mfield = NULL;

    if (mfield) {
        if (args.masking == GWY_MASK_EXCLUDE) {
            mfield = gwy_data_field_duplicate(mfield);
            gwy_data_field_multiply(mfield, -1.0);
            gwy_data_field_add(mfield, 1.0);
        }
        else
            g_object_ref(mfield);
    }

    gwy_app_undo_qcheckpoint(data, quark, NULL);
    if (mfield)
        gwy_data_field_area_fit_plane(dfield, mfield, 0, 0,
                                      gwy_data_field_get_xres(dfield),
                                      gwy_data_field_get_yres(dfield),
                                      &c, &bx, &by);
    else
        gwy_data_field_fit_plane(dfield, &c, &bx, &by);

    switch (level_type) {
        case LEVEL_SUBTRACT:
        c = -0.5*(bx*gwy_data_field_get_xres(dfield)
                  + by*gwy_data_field_get_yres(dfield));
        gwy_data_field_plane_level(dfield, c, bx, by);
        break;

        case LEVEL_ROTATE:
        bx = gwy_data_field_rtoj(dfield, bx);
        by = gwy_data_field_rtoi(dfield, by);
        gwy_data_field_plane_rotate(dfield, atan2(bx, 1), atan2(by, 1),
                                    GWY_INTERPOLATION_LINEAR);
        gwy_debug("b = %g, alpha = %g deg, c = %g, beta = %g deg",
                  bx, 180/G_PI*atan2(bx, 1), by, 180/G_PI*atan2(by, 1));
        break;

        default:
        g_assert_not_reached();
        break;
    }

    gwy_app_channel_log_add_proc(data, id, id);
    gwy_data_field_data_changed(dfield);
    gwy_object_unref(mfield);
}
Exemple #18
0
static void
unrotate(GwyContainer *data, GwyRunType run)
{
    enum { nder = 4800 };
    GwyDataField *dfield, *mfield, *sfield;
    UnrotateArgs args;
    gdouble correction[GWY_SYMMETRY_LAST];
    GwyPlaneSymmetry symm;
    GwyDataLine *derdist;
    GQuark dquark, mquark, squark;
    gdouble phi;
    gboolean ok = TRUE;
    gint id;

    g_return_if_fail(run & UNROTATE_RUN_MODES);
    gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD_KEY, &dquark,
                                     GWY_APP_DATA_FIELD, &dfield,
                                     GWY_APP_DATA_FIELD_ID, &id,
                                     GWY_APP_MASK_FIELD_KEY, &mquark,
                                     GWY_APP_MASK_FIELD, &mfield,
                                     GWY_APP_SHOW_FIELD_KEY, &squark,
                                     GWY_APP_SHOW_FIELD, &sfield,
                                     0);
    g_return_if_fail(dfield && dquark && mquark && squark);

    load_args(gwy_app_settings_get(), &args);
    derdist = GWY_DATA_LINE(gwy_data_line_new(nder, 2*G_PI, FALSE));
    gwy_data_field_slope_distribution(dfield, derdist, 5);
    symm = gwy_data_field_unrotate_find_corrections(derdist, correction);
    g_object_unref(derdist);

    if (run == GWY_RUN_INTERACTIVE) {
        ok = unrotate_dialog(&args, data, dfield, id, correction, symm);
        save_args(gwy_app_settings_get(), &args);
        if (!ok)
            return;
    }

    if (args.symmetry)
        symm = args.symmetry;
    phi = correction[symm];

    if (!mfield)
        mquark = 0;
    if (!sfield)
        squark = 0;
    if (!mfield && sfield)
        GWY_SWAP(GQuark, mquark, squark);
    gwy_app_undo_qcheckpoint(data, dquark, mquark, squark, 0);
    gwy_data_field_rotate(dfield, phi, args.interp);
    gwy_data_field_data_changed(dfield);
    if (mfield) {
        gwy_data_field_rotate(mfield, phi, GWY_INTERPOLATION_ROUND);
        gwy_data_field_data_changed(mfield);
    }
    if (sfield) {
        gwy_data_field_rotate(sfield, phi, args.interp);
        gwy_data_field_data_changed(sfield);
    }
    gwy_app_channel_log_add_proc(data, id, id);
}
Exemple #19
0
static PyObject *
call_function(PyObject ***pp_stack, int oparg)
{
	int na = oparg & 0xff;
	int nk = (oparg>>8) & 0xff;
	int n = na + 2 * nk;
	PyObject **pfunc = (*pp_stack) - n - 1;
	PyObject *func = *pfunc;
	PyObject *x, *w;

	/* Always dispatch PyCFunction first, because these are
	   presumed to be the most frequent callable object.
	*/
	if (PyCFunction_Check(func) && nk == 0) {
		int flags = PyCFunction_GET_FLAGS(func);
		if (flags & (METH_NOARGS | METH_O)) {
			PyCFunction meth = PyCFunction_GET_FUNCTION(func);
			PyObject *self = PyCFunction_GET_SELF(func);
			if (flags & METH_NOARGS && na == 0) 
				x = (*meth)(self, NULL);
			else if (flags & METH_O && na == 1) {
				PyObject *arg = EXT_POP(*pp_stack);
				x = (*meth)(self, arg);
				Py_DECREF(arg);
			}
			else {
				err_args(func, flags, na);
				x = NULL;
			}
		}
		else {
			PyObject *callargs;
			callargs = load_args(pp_stack, na);
			x = PyCFunction_Call(func, callargs, NULL);
			Py_XDECREF(callargs); 
		} 
	} else {
		if (PyMethod_Check(func) && PyMethod_GET_SELF(func) != NULL) {
			/* optimize access to bound methods */
			PyObject *self = PyMethod_GET_SELF(func);
			Py_INCREF(self);
			func = PyMethod_GET_FUNCTION(func);
			Py_INCREF(func);
			Py_DECREF(*pfunc);
			*pfunc = self;
			na++;
			n++;
		} else
			Py_INCREF(func);
		if (PyFunction_Check(func))
			x = fast_function(func, pp_stack, n, na, nk);
		else 
			x = do_call(func, pp_stack, na, nk);
		Py_DECREF(func);
	}
	
	/* What does this do? */
	while ((*pp_stack) > pfunc) {
		w = EXT_POP(*pp_stack);
		Py_DECREF(w);
	}
	return x;
}
Exemple #20
0
static GtkWidget*
dialog_create(GwyUnitoolState *state)
{
    static struct {
        MaskEditMode mode;
        const gchar *stock_id;
        const gchar *tooltip;
    }
    const modes[] = {
        {
            MASK_EDIT_SET,
            GWY_STOCK_MASK_SET,
            N_("Set mask to selection"),
        },
        {
            MASK_EDIT_ADD,
            GWY_STOCK_MASK_ADD,
            N_("Add selection to mask"),
        },
        {
            MASK_EDIT_REMOVE,
            GWY_STOCK_MASK_SUBTRACT,
            N_("Subtract selection from mask"),
        },
        {
            MASK_EDIT_INTERSECT,
            GWY_STOCK_MASK_INTERSECT,
            N_("Intersect selection with mask"),
        },
    };
    ToolControls *controls;
    GtkWidget *dialog, *table, *frame, *toolbox, *button, *group, *hbox, *label;
    gint i, row;

    gwy_debug("");
    controls = (ToolControls*)state->user_data;
    load_args(gwy_app_settings_get(), controls);

    dialog = gtk_dialog_new_with_buttons(_("Mask Editor"), NULL, 0, NULL);
    gwy_unitool_dialog_add_button_hide(dialog);

    frame = gwy_unitool_windowname_frame_create(state);
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame,
                       FALSE, FALSE, 0);

    table = gtk_table_new(7, 4, FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(table), 4);
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
    row = 0;

    hbox = gtk_hbox_new(FALSE, 4);
    gtk_table_attach(GTK_TABLE(table), hbox, 0, 4, row, row+1,
                     GTK_EXPAND | GTK_FILL, 0, 2, 2);

    label = gtk_label_new(_("Mode:"));
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

    toolbox = gwy_toolbox_new(G_N_ELEMENTS(modes));
    group = NULL;
    for (i = 0; i < G_N_ELEMENTS(modes); i++) {
        button = gwy_toolbox_append(GWY_TOOLBOX(toolbox),
                                    GTK_TYPE_RADIO_BUTTON, group,
                                    _(modes[i].tooltip), NULL,
                                    modes[i].stock_id,
                                    G_CALLBACK(mode_changed_cb), state);
        if (!group)
            group = button;
        g_object_set_data(G_OBJECT(button), "select-mode",
                          GUINT_TO_POINTER(modes[i].mode));
        if (modes[i].mode == controls->mode)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
    }
    gtk_box_pack_start(GTK_BOX(hbox), toolbox, FALSE, FALSE, 0);
    gtk_table_set_row_spacing(GTK_TABLE(table), row, 8);
    row++;

    row += gwy_unitool_rect_info_table_setup(&controls->labels,
                                             GTK_TABLE(table), 0, row);

    return dialog;
}
int main(int argc, char **argv){

    int i,j;

    /* initialize MPI */
    int rc = MPI_Init(&argc, &argv);
    if(rc != MPI_SUCCESS){
        printf ("Error starting MPI program. Terminating.\n");
        MPI_Abort (MPI_COMM_WORLD, rc);
    }

    /* get MPI environment */
    MPI_Comm_size (MPI_COMM_WORLD, &task_num); 
    MPI_Comm_rank (MPI_COMM_WORLD, &rank);

    /* check and load arguements */
    if(argc != 9){
        printf("arguements error\n");
        exit(EXIT_FAILURE);
    }
    load_args(argv);
    x_enable = (rank == 0) ? x_enable : 0; // only rank 0 (master) use X window

    /* initialize X window */
    if(x_enable){
        init_X();
        XFlush(X.display);
    }

    /* start mandelbrot set test for every pixel */
    pixel_value = malloc_2d_int(point_num_x, point_num_y);

    node_time = (double*)malloc(task_num * sizeof(double));
    double begin = MPI_Wtime();

    if(rank == 0){
        mpi_master();
    }
    else{
        mpi_slaver();
    }

    double end = MPI_Wtime();
    total_time = end - begin;
    if(rank == 0){
        printf("(N,Total");
        for(i=0; i<task_num; i++){
            printf(",N%d", i+1);
        }
        printf(")->(%d,%lf", point_num_x*point_num_y, total_time);
        for(i=0; i<task_num; i++){
            printf(",%lf", node_time[i]);
        }
        printf(")\n");
    }

    free(node_time);
    free_2d_int(pixel_value, point_num_x);

    /* show result */
    if(x_enable){
        sleep(3);
    }

    MPI_Finalize();
}