Пример #1
0
void tree_kernel_vs_dag_size(DOC *X, double *Y, long totdoc, int SAMPLE_SIZE, KERNEL_PARM kernel_parm) {
    int i, j, k;
    int nsamples, num_nodes;
    long runtime_start;
    // get the dag over the full training set
    int dag_size[] = {1e+3, 5e+3, 10e+3, 20e+3, 30e+3, 40e+3, 50e+3};
    //    int dag_size[3] = {5e+3, 10e+3, 20e+3};
    long kernel_evals;
    
    for (j = 0; j< sizeof(dag_size)/sizeof(dag_size[0]); j++) {
        nsamples = dag_size[j]/SAMPLE_SIZE;
        printf("Number of examples: %d\n",dag_size[j]);
        
        /* uSVM */  
        printf("\nuSVM\n");
        printf("----\n");
        double value = 0;
        kernel_evals = 0;
        elem_counts = 0;
        runtime_start = get_runtime();
        for (i = 0; i<dag_size[j]; i++) {
             for (k = 0; k<SAMPLE_SIZE; k++) {
                value += Y[i]*kernel(&kernel_parm, &X[k], &X[i]);
            } 
        }        
        printf("kernel value: %.4f\n",value); 
        printf("time: %.4f\n", ((float)get_runtime() - (float)runtime_start)/100.0 );                        
                
        printf("================================\n");
        
        
    }
}
bool FSkookumScriptEditor::is_property_type_supported_and_known(UProperty * var_p) const
  {
  if (!is_property_type_supported(var_p))
    {
    return false;
    }

  UObjectPropertyBase * object_var_p = Cast<UObjectPropertyBase>(var_p);
  if (object_var_p && (!object_var_p->PropertyClass || !get_runtime()->is_static_class_known_to_skookum(object_var_p->PropertyClass)))
    {
    return false;
    }

  UStructProperty * struct_var_p = Cast<UStructProperty>(var_p);
  if (struct_var_p && (!struct_var_p->Struct || (get_skookum_struct_type(struct_var_p->Struct) == SkTypeID_UStruct && !get_runtime()->is_static_struct_known_to_skookum(struct_var_p->Struct))))
    {
    return false;
    }

  UArrayProperty * array_var_p = Cast<UArrayProperty>(var_p);
  if (array_var_p && (!array_var_p->Inner || !is_property_type_supported_and_known(array_var_p->Inner)))
    {
    return false;
    }

  UEnum * enum_p = get_enum(var_p);
  if (enum_p && !get_runtime()->is_static_enum_known_to_skookum(enum_p))
    {
    return false;
    }

  return true;
  }
Пример #3
0
void dag_tree_kernel_vs_dag_size(DOC *X, double *Y, long totdoc, int SAMPLE_SIZE, KERNEL_PARM kernel_parm) {
    int i, j, k;
    int nsamples, num_nodes;
    long runtime_start;
    // get the dag over the full training set
    int dag_size[] = {1e+3, 5e+3, 10e+3, 20e+3, 30e+3, 40e+3, 50e+3};
    //    int dag_size[3] = {5e+3, 10e+3, 20e+3};
    
    
    for (j = 0; j< sizeof(dag_size)/sizeof(dag_size[0]); j++) {
        nsamples = dag_size[j]/SAMPLE_SIZE;
        printf("Number of examples: %d\n",dag_size[j]);
        
        //        /* uSVM */  
        //        printf("\nuSVM\n");
        //        printf("----\n");
        //        double value = 0;
        //        kernel_evals = 0;
        //        elem_counts = 0;
        //        runtime_start = get_runtime();
        //        for (i = 0; i<dag_size[j]; i++) {
        //             for (k = 0; k<SAMPLE_SIZE; k++) {
        //                value += Y[i]*kernel(&kernel_parm, &X[k], &X[i]);
        //            } 
        //        }        
        //        printf("kernel value: %.4f\n",value); 
        //        printf("time: %.4f\n", ((float)get_runtime() - (float)runtime_start)/100.0 );                        
        
        /* SDAG */        
        printf("\nSDAG\n");
        printf("----\n");
        printf("number of dag models: %d\n",nsamples);
        dag_model_t **dags;
        dags = my_malloc(sizeof(dag_model_t*)*nsamples);
        num_nodes = 0;
        
        runtime_start = get_runtime();
        for (k = 0; k < nsamples; k++) {
            dags[k] = dag_model_new();
            for (i = k*SAMPLE_SIZE; i<(k+1)*SAMPLE_SIZE; i++) {
                dag_insert_tree(dags[k], &X[i], Y[i]);
            }
        }        
        printf("time to insert trees: %.4f\n", ((float)get_runtime() - (float)runtime_start)/100.0 );
        
        //        for (k = 0; k < nsamples; k++) 
        //            num_nodes += dag_model_stats(dags[k]);
        
        compute_sdag(X, dags, SAMPLE_SIZE, nsamples, kernel_parm);        
        //        printf("Total number of nodes in models: %d\n",num_nodes);
        for (k = 0; k< nsamples; k++) {
            dag_free_model(dags[k]);
        }
                
        printf("================================\n");
        
        
    }
}
void FSkookumScriptEditor::on_skookum_button_clicked()
  {
  FString focus_class_name;
  FString focus_member_name;

  // There must be a better way of finding the active editor...
  TArray<UObject*> obj_array = FAssetEditorManager::Get().GetAllEditedAssets();
  double latest_activation_time = 0.0;
  IAssetEditorInstance * active_editor_p = nullptr;
  if (obj_array.Num() > 0)
    {
    for (auto obj_iter = obj_array.CreateConstIterator(); obj_iter; ++obj_iter)
      {
      // Don't allow user to perform certain actions on objects that aren't actually assets (e.g. Level Script blueprint objects)
      UBlueprint * blueprint_p = Cast<UBlueprint>(*obj_iter);
      if (blueprint_p)
        {
        IAssetEditorInstance * editor_p = FAssetEditorManager::Get().FindEditorForAsset(blueprint_p, false);
        if (editor_p->GetLastActivationTime() > latest_activation_time)
          {
          latest_activation_time = editor_p->GetLastActivationTime();
          active_editor_p = editor_p;
          }
        }
      }
    }

  if (active_editor_p)
    {
    // We found the most recently used Blueprint editor
    FBlueprintEditor * blueprint_editor_p = static_cast<FBlueprintEditor *>(active_editor_p);
    // Get name of associated Blueprint
    focus_class_name = blueprint_editor_p->GetBlueprintObj()->GetName();
    // See if any SkookumScript node is selected, if so, tell the IDE
    const FGraphPanelSelectionSet node_array = blueprint_editor_p->GetSelectedNodes();
    for (auto obj_iter = node_array.CreateConstIterator(); obj_iter; ++obj_iter)
      {
      UK2Node_CallFunction * call_node_p = Cast<UK2Node_CallFunction>(*obj_iter);
      if (call_node_p)
        {
        focus_member_name = call_node_p->FunctionReference.GetMemberName().ToString();
        break; // For now, just return the first one
        }
      UK2Node_Event * event_node_p = Cast<UK2Node_Event>(*obj_iter);
      if (event_node_p)
        {
        focus_member_name = event_node_p->EventReference.GetMemberName().ToString();
        break; // For now, just return the first one
        }
      }
    }

  // Bring up IDE and navigate to selected class/method/coroutine
  get_runtime()->show_ide(focus_class_name, focus_member_name, false, false);

  // Request recompilation if there have previously been errors
  get_runtime()->freshen_compiled_binaries_if_have_errors();
  }
Пример #5
0
// TODO: callback must finish installing new heap
// TODO: callback must set up future pool
// AGAS callback to client
void notify_worker(notification_header const& header)
{
    // This lock acquires the bbb mutex on creation. When it goes out of scope,
    // it's dtor calls big_boot_barrier::notify().
    big_boot_barrier::scoped_lock lock(get_big_boot_barrier());

    naming::resolver_client& agas_client = get_runtime().get_agas_client();

    // set our prefix
    agas_client.local_locality(header.prefix);
    get_runtime().get_config().parse("assigned locality",
        boost::str(boost::format("hpx.locality=%1%")
                  % naming::get_locality_id_from_gid(header.prefix)));

    // store the full addresses of the agas servers in our local service
    agas_client.primary_ns_addr_ = header.primary_ns_address;
    agas_client.component_ns_addr_ = header.component_ns_address;
    agas_client.symbol_ns_addr_ = header.symbol_ns_address;

    // Assign the initial parcel gid range to the parcelport. Note that we can't
    // get the parcelport through the parcelhandler because it isn't up yet.
    get_runtime().get_id_pool().set_range(header.parcelport_lower_gid
                                        , header.parcelport_upper_gid);

    // assign the initial gid range to the unique id range allocator that our
    // response heap is using
    response_heap_type::get_heap().set_range(header.response_lower_gid
                                           , header.response_upper_gid);

    // finish setting up the first heap.
    response_heap_type::block_type* p
        = reinterpret_cast<response_heap_type::block_type*>
            (header.response_heap_ptr);

    // set the base gid that we bound to this heap
    p->set_gid(header.response_lower_gid);

    // push the heap onto the OSHL
    response_heap_type::get_heap().add_heap(p);

    // set up the future pools
    naming::resolver_client::promise_pool_type& promise_pool
        = agas_client.hosted->promise_pool_;

    util::runtime_configuration const& ini_ = get_runtime().get_config();

    const std::size_t pool_size = ini_.get_agas_promise_pool_size();

    for (std::size_t i = 0; i < pool_size; ++i)
        promise_pool.enqueue(
            new lcos::packaged_action<server::primary_namespace::service_action>);
}
Пример #6
0
void find_most_violated_constraint(SVECTOR **fydelta, double *rhs, 
				   EXAMPLE *ex, SVECTOR *fycached, long n, 
				   STRUCTMODEL *sm, STRUCT_LEARN_PARM *sparm,
				   double *rt_viol, double *rt_psi, 
				   long *argmax_count)
     /* returns fydelta=fy-fybar and rhs scalar value that correspond
	to the most violated constraint for example ex */
{
  double      rt2=0;
  LABEL       ybar;
  SVECTOR     *fybar, *fy;
  double      factor,lossval;

  if(struct_verbosity>=2) rt2=get_runtime();
  (*argmax_count)++;
  if(sparm->loss_type == SLACK_RESCALING) 
    ybar=find_most_violated_constraint_slackrescaling(ex->x,ex->y,sm,sparm);
  else
    ybar=find_most_violated_constraint_marginrescaling(ex->x,ex->y,sm,sparm);
  if(struct_verbosity>=2) (*rt_viol)+=MAX(get_runtime()-rt2,0);
  
  if(empty_label(ybar)) {
    printf("ERROR: empty label was returned for example\n");
    /* exit(1); */
    /* continue; */
  }
  
  /**** get psi(x,y) and psi(x,ybar) ****/
  if(struct_verbosity>=2) rt2=get_runtime();
  if(fycached)
    fy=copy_svector(fycached); 
  else 
    fy=psi(ex->x,ex->y,sm,sparm);
  fybar=psi(ex->x,ybar,sm,sparm);
  if(struct_verbosity>=2) (*rt_psi)+=MAX(get_runtime()-rt2,0);
  lossval=loss(ex->y,ybar,sparm);
  free_label(ybar);
  
  /**** scale feature vector and margin by loss ****/
  if(sparm->loss_type == SLACK_RESCALING)
    factor=lossval/n;
  else                 /* do not rescale vector for */
    factor=1.0/n;      /* margin rescaling loss type */
  mult_svector_list(fy,factor);
  mult_svector_list(fybar,-factor);
  append_svector_list(fybar,fy);   /* compute fy-fybar */

  (*fydelta)=fybar;
  (*rhs)=lossval/n;
}
Пример #7
0
void output_stream::write_async(
    buffer const& in
) { // {{{
    // Perform the IO in another OS thread.
    get_runtime().get_thread_pool("io_pool")->get_io_service().post(
        boost::bind(&output_stream::call_write_async, this, in));
} // }}}
//---------------------------------------------------------------------------------------
// Called when the map is done loading (load progress reaches 100%)
void FSkookumScriptEditor::on_map_opened(const FString & file_name, bool as_template)
  {
  // Generate all script files one more time to be sure
  generate_all_class_script_files();

  // Let runtime know we are done opening a new map
  get_runtime()->on_editor_map_opened();
  }
Пример #9
0
 void runtime_support::free_component_locally(agas::gva const& g,
     naming::gid_type const& gid)
 {
     components::server::runtime_support* p =
         reinterpret_cast<components::server::runtime_support*>(
               get_runtime().get_runtime_support_lva());
     p->free_component(g, gid, 1);
 }
Пример #10
0
 naming::gid_type create_raw_counter(counter_info const& info,
     hpx::util::function_nonser<boost::int64_t(bool)> const& f, error_code& ec)
 {
     naming::gid_type gid;
     get_runtime().get_counter_registry().create_raw_counter(
         info, f, gid, ec);
     return gid;
 }
Пример #11
0
 // \brief Create a new aggregating performance counter instance based
 //        on given base counter name and given base time interval
 //        (milliseconds).
 naming::gid_type create_arithmetics_counter(counter_info const& info,
     std::vector<std::string> const& base_counter_names, error_code& ec)
 {
     naming::gid_type gid;
     get_runtime().get_counter_registry().
         create_arithmetics_counter(info, base_counter_names, gid, ec);
     return gid;
 }
Пример #12
0
 naming::gid_type create_raw_counter_value(
     counter_info const& info, boost::int64_t* countervalue,
     error_code& ec)
 {
     naming::gid_type gid;
     get_runtime().get_counter_registry().create_raw_counter_value(
         info, countervalue, gid, ec);
     return gid;
 }
void FSkookumScriptEditor::delete_class_script_files(UClass * ue_class_p)
  {
  FString class_name;
  const FString directory_to_delete = get_skookum_class_path(ue_class_p, &class_name);
  if (FPaths::DirectoryExists(directory_to_delete))
    {
    IFileManager::Get().DeleteDirectory(*directory_to_delete, false, true);
    get_runtime()->on_class_scripts_changed_by_editor(class_name, ISkookumScriptRuntime::ChangeType_deleted);
    }
  }
Пример #14
0
 // \brief Create a new aggregating performance counter instance based
 //        on given base counter name and given base time interval
 //        (milliseconds).
 naming::gid_type create_statistics_counter(
     counter_info const& info, std::string const& base_counter_name,
     std::vector<boost::int64_t> const& parameters, error_code& ec)
 {
     naming::gid_type gid;
     get_runtime().get_counter_registry().
         create_statistics_counter(info, base_counter_name,
             parameters, gid, ec);
     return gid;
 }
Пример #15
0
    HPX_EXPORT std::exception_ptr
    get_exception(Exception const& e, std::string const& func,
        std::string const& file, long line, std::string const& auxinfo)
    {
        if (is_of_lightweight_hpx_category(e))
            return construct_lightweight_exception(e, func, file, line);

        std::int64_t pid = ::getpid();
        std::string back_trace(backtrace());

        std::string state_name("not running");
        std::string hostname;
        hpx::runtime* rt = get_runtime_ptr();
        if (rt)
        {
            state rts_state = rt->get_state();
            state_name = get_runtime_state_name(rts_state);

            if (rts_state >= state_initialized &&
                rts_state < state_stopped)
            {
                std::ostringstream strm;
                strm << get_runtime().here();
                hostname = strm.str();
            }
        }

        // if this is not a HPX thread we do not need to query neither for
        // the shepherd thread nor for the thread id
        error_code ec(lightweight);
        std::uint32_t node = get_locality_id(ec);

        std::size_t shepherd = std::size_t(-1);
        threads::thread_id_type thread_id;
        util::thread_description thread_name;

        threads::thread_self* self = threads::get_self_ptr();
        if (nullptr != self)
        {
            if (threads::threadmanager_is(state_running))
                shepherd = hpx::get_worker_thread_num();

            thread_id = threads::get_self_id();
            thread_name = threads::get_thread_description(thread_id);
        }

        std::string env(get_execution_environment());
        std::string config(configuration_string());

        return construct_exception(e, func, file, line, back_trace, node,
            hostname, pid, shepherd,
            reinterpret_cast<std::size_t>(thread_id.get()),
            util::as_string(thread_name), env, config,
            state_name, auxinfo);
    }
//---------------------------------------------------------------------------------------
// Attempt to load blueprint with given qualified class path
UBlueprint * FSkookumScriptEditor::load_blueprint_asset(const FString & class_path, bool * sk_class_deleted_p)
  {
  // Try to extract asset path from meta file of Sk class
  FString full_class_path = m_overlay_path / class_path;
  FString meta_file_path = full_class_path / TEXT("!Class.sk-meta");
  FString meta_file_text;
  *sk_class_deleted_p = false;
  if (FFileHelper::LoadFileToString(meta_file_text, *meta_file_path))
    {
    // Found meta file - try to extract asset path contained in it
    int32 package_path_begin_pos = meta_file_text.Find(m_package_name_key);
    if (package_path_begin_pos >= 0)
      {
      package_path_begin_pos += m_package_name_key.Len();
      int32 package_path_end_pos = meta_file_text.Find(TEXT("\""), ESearchCase::CaseSensitive, ESearchDir::FromStart, package_path_begin_pos);
      if (package_path_end_pos > package_path_begin_pos)
        {
        // Successfully got the path of the package, so assemble with asset name and load the asset
        FString package_path = meta_file_text.Mid(package_path_begin_pos, package_path_end_pos - package_path_begin_pos);
        FString class_name = FPaths::GetCleanFilename(class_path);
        // If there's a dot in the name, use portion right of it
        int dot_pos = -1;
        if (class_name.FindChar(TCHAR('.'), dot_pos))
          {
          class_name = class_name.Mid(dot_pos + 1);
          }
        FString asset_path = package_path + TEXT(".") + class_name;
        UBlueprint * blueprint_p = LoadObject<UBlueprint>(nullptr, *asset_path);
        if (!blueprint_p)
          {
          // Asset not found, ask the user what to do
          FText title = FText::Format(FText::FromString(TEXT("Asset Not Found For {0}")), FText::FromString(class_name));
          if (FMessageDialog::Open(
            EAppMsgType::YesNo,
            FText::Format(FText::FromString(
              TEXT("Cannot find Blueprint asset belonging to SkookumScript class '{0}'. ")
              TEXT("It was originally generated from the asset '{1}' but this asset appears to no longer exist. ")
              TEXT("Maybe it was deleted or renamed. ")
              TEXT("If you no longer need the SkookumScript class '{0}', you can fix this issue by deleting the class. ")
              TEXT("Would you like to delete the SkookumScript class '{0}'?")), FText::FromString(class_name), FText::FromString(asset_path)),
            &title) == EAppReturnType::Yes)
            {
            // User requested deletion, so nuke it
            IFileManager::Get().DeleteDirectory(*full_class_path, false, true);
            *sk_class_deleted_p = true;
            get_runtime()->on_class_scripts_changed_by_editor(class_name, ISkookumScriptRuntime::ChangeType_deleted);
            }
          }
        return blueprint_p;
        }
      }
    }

  return nullptr;
  }
Пример #17
0
 void create_consolestream()
 {
     naming::resolver_client& agas_client = get_runtime().get_agas_client();
     if (!agas_client.is_console())
     {
         HPX_THROW_EXCEPTION(service_unavailable,
             "hpx::iostreams::create_consolestream",
             "this function should be called on the console only");
     }
     detail::create_ostream(detail::consolestream_tag());
 }
Пример #18
0
 std::stringstream const& get_consolestream()
 {
     naming::resolver_client& agas_client = get_runtime().get_agas_client();
     if (!agas_client.is_console())
     {
         HPX_THROW_EXCEPTION(service_unavailable,
             "hpx::iostreams::get_consolestream",
             "this function should be called on the console only");
     }
     return detail::get_consolestream();
 }
void FSkookumScriptEditor::on_class_updated(UClass * ue_class_p)
  {
  // 1) Refresh actions (in Blueprint editor drop down menu)
  FBlueprintActionDatabase::Get().RefreshClassActions(ue_class_p);

  // Storage for gathered objects
  TArray<UObject*> obj_array;

  // 2) Refresh node display of all SkookumScript function call nodes
  obj_array.Reset();
  GetObjectsOfClass(UK2Node_CallFunction::StaticClass(), obj_array, true, RF_ClassDefaultObject);
  for (auto obj_p : obj_array)
    {
    UK2Node_CallFunction * function_node_p = Cast<UK2Node_CallFunction>(obj_p);
    UFunction * target_function_p = function_node_p->GetTargetFunction();
    // Also refresh all nodes with no target function as it is probably a Sk function that was deleted
    //if (!target_function_p || get_runtime()->is_skookum_blueprint_function(target_function_p))
    if (target_function_p && get_runtime()->is_skookum_blueprint_function(target_function_p))
      {
      const UEdGraphSchema * schema_p = function_node_p->GetGraph()->GetSchema();
      schema_p->ReconstructNode(*function_node_p, true);
      }
    }

  // 3) Refresh node display of all SkookumScript event nodes
  obj_array.Reset();
  GetObjectsOfClass(UK2Node_Event::StaticClass(), obj_array, true, RF_ClassDefaultObject);
  for (auto obj_p : obj_array)
    {
    UK2Node_Event * event_node_p = Cast<UK2Node_Event>(obj_p);
    UFunction * event_function_p = event_node_p->FindEventSignatureFunction();
    if (event_function_p && get_runtime()->is_skookum_blueprint_event(event_function_p))
      {
      const UEdGraphSchema * schema_p = event_node_p->GetGraph()->GetSchema();
      schema_p->ReconstructNode(*event_node_p, true);
      }
    }

  // 4) Try recompiling any Blueprints that previously had errors
  recompile_blueprints_with_errors();
  }
void FSkookumScriptEditor::ShutdownModule()
  {
  get_runtime()->set_editor_interface(nullptr);
  m_runtime_p.Reset();

  if (!IsRunningCommandlet())
    {

    // Remove delegates
    FCoreUObjectDelegates::OnAssetLoaded.Remove(m_on_asset_loaded_handle);
    FCoreUObjectDelegates::OnObjectModified.Remove(m_on_object_modified_handle);
    FEditorDelegates::OnMapOpened.Remove(m_on_map_opened_handle);
    FEditorDelegates::OnNewAssetCreated.Remove(m_on_new_asset_created_handle);
    FEditorDelegates::OnAssetsDeleted.Remove(m_on_assets_deleted_handle);
    FEditorDelegates::OnAssetPostImport.Remove(m_on_asset_post_import_handle);

    FAssetRegistryModule * asset_registry_p = FModuleManager::GetModulePtr<FAssetRegistryModule>(AssetRegistryConstants::ModuleName);
    if (asset_registry_p)
      {
      asset_registry_p->Get().OnAssetAdded().Remove(m_on_asset_added_handle);
      asset_registry_p->Get().OnAssetRenamed().Remove(m_on_asset_renamed_handle);
      asset_registry_p->Get().OnInMemoryAssetCreated().Remove(m_on_in_memory_asset_created_handle);
      asset_registry_p->Get().OnInMemoryAssetDeleted().Remove(m_on_in_memory_asset_deleted_handle);
      }

    //---------------------------------------------------------------------------------------
    // UI extension

    if (m_level_extension_manager.IsValid())
      {
      FSkookumScriptEditorCommands::Unregister();
      m_level_tool_bar_extender->RemoveExtension(m_level_tool_bar_extension.ToSharedRef());
      m_level_extension_manager->RemoveExtender(m_level_tool_bar_extender);
      }
    else
      {
      m_level_extension_manager.Reset();
      }

    if (m_blueprint_extension_manager.IsValid())
      {
      FSkookumScriptEditorCommands::Unregister();
      m_blueprint_tool_bar_extender->RemoveExtension(m_blueprint_tool_bar_extension.ToSharedRef());
      m_blueprint_extension_manager->RemoveExtender(m_blueprint_tool_bar_extender);
      }
    else
      {
      m_blueprint_extension_manager.Reset();
      }

    FSkookumStyles::Shutdown();
    }
  }
void FSkookumScriptEditor::rename_class_script_files(UClass * ue_class_p, const FString & old_class_name)
  {
#if !PLATFORM_EXCEPTIONS_DISABLED
  try
#endif
    {
    FString new_class_name;
    const FString new_class_path = get_skookum_class_path(ue_class_p, &new_class_name);
    FString old_class_path = FPaths::GetPath(new_class_path) / old_class_name;
    // Does old class folder exist?
    if (FPaths::DirectoryExists(old_class_path))
      {
      // Old folder exists - decide how to change its name
      // Does new class folder already exist?
      if (FPaths::DirectoryExists(new_class_path))
        {
        // Yes, delete so we can rename the old folder
        IFileManager::Get().DeleteDirectory(*new_class_path, false, true);
        }
      // Now rename old to new
      if (!IFileManager::Get().Move(*new_class_path, *old_class_path, true, true))
        {
        FError::Throwf(TEXT("Couldn't rename class from '%s' to '%s'"), *old_class_path, *new_class_path);
        }
      get_runtime()->on_class_scripts_changed_by_editor(old_class_name, ISkookumScriptRuntime::ChangeType_deleted);
      get_runtime()->on_class_scripts_changed_by_editor(new_class_path, ISkookumScriptRuntime::ChangeType_created);
      }
    else
      {
      // Old folder does not exist - check that new folder exists, assuming the class has already been renamed
      checkf(FPaths::DirectoryExists(new_class_path), TEXT("Couldn't rename class from '%s' to '%s'. Neither old nor new class folder exist."), *old_class_path, *new_class_path);
      }
    }
#if !PLATFORM_EXCEPTIONS_DISABLED
  catch (TCHAR * error_msg_p)
    {
    checkf(false, error_msg_p);
    }
#endif
  }
Пример #22
0
void output_stream::write_sync(
    buffer const& in
) { // {{{
    threads::thread_self& self = threads::get_self();
    threads::thread_id_type id = self.get_thread_id();

    // Perform the IO in another OS thread.
    get_runtime().get_thread_pool("io_pool")->get_io_service().post(
        boost::bind(&output_stream::call_write_sync, this, in, id));

    // Sleep until the worker thread wakes us up.
    self.yield(threads::suspended);
} // }}}
Пример #23
0
 void apply_late(
     boost::uint32_t source_locality_id
   , boost::uint32_t target_locality_id
   , parcelset::locality const & dest
   , Action act
   , Args &&... args
 ) { // {{{
     naming::address addr(naming::get_gid_from_locality_id(target_locality_id));
     parcelset::parcel p(naming::get_id_from_locality_id(target_locality_id),
             addr, act, std::forward<Args>(args)...);
     if (!p.parcel_id())
         p.parcel_id() = parcelset::parcel::generate_unique_id(source_locality_id);
     get_runtime().get_parcel_handler().put_parcel(std::move(p));
 } // }}}
Пример #24
0
void compute_sdag(DOC *X, dag_model_t **dags, int SAMPLE_SIZE, int nsamples, KERNEL_PARM kernel_parm) {
    double value = 0;
    long runtime_start;
    int i,k;
    // sum of models
    kernel_evals = 0;
    elem_counts = 0;
    runtime_start = get_runtime();
    
    
    // the problem is here!!! change the loops and the speedup advantage is gone!
    for (k = 0; k < nsamples; k++) {
        for (i = 0; i<SAMPLE_SIZE; i++) {
            value += dag_tree_kernel(&kernel_parm, dags[k], &X[i]);
        } 
    }
    
    printf("kernel value: %.4f\n",value); 
    printf("time: %.4f\n", ((float)get_runtime() - (float)runtime_start)/100.0 );
    
    printf("Number of kernel evaluations: %ld\n",kernel_evals);
    printf("Number of loop iterations inside JudySL: %ld\n",elem_counts);
}
Пример #25
0
    void install_counter_type(std::string const& name,
        counter_type type, std::string const& helptext, boost::uint32_t version,
        error_code& ec)
    {
        counter_info info(type, name, helptext,
            version ? version : HPX_PERFORMANCE_COUNTER_V1);
        boost::shared_ptr<manage_counter_type> p =
            boost::make_shared<manage_counter_type>(info);

        // Install the counter type.
        p->install(ec);

        // Register the shutdown function which will clean up this counter type.
        get_runtime().add_shutdown_function(
            boost::bind(&counter_type_shutdown, p));
    }
Пример #26
0
static inline int record_callback(char *buff, int bytes, void *param)
{
	channel_t *channel = (channel_t *)param;
	rec_driver_t *driver = (rec_driver_t *)channel->rec_driver;
	int ret;

	if (!is_record(channel->rec_state) || channel->rec_error == 1)
		return -1;

	channel->bgn_time = channel->end_time;
	channel->end_time = time(NULL);
	channel->last_data_time = get_runtime();
	if (channel->end_time < channel->bgn_time)
		channel->end_time = channel->bgn_time;

	if (channel->is_rtp_packet) {
		char out_buff[OUT_BUFF_SIZE];
		int out_bytes;

		if (channel->payload_type == RTP_PT_H264) {
			out_bytes = rtp_get_h264_data(buff, bytes, out_buff, 
					OUT_BUFF_SIZE);
			if (out_bytes <= 0)
				return -1;
		} else if (channel->payload_type == RTP_PT_MJPEG) {
			return -1;	/* TODO */
		} else {
			return -1;	/* TODO */
		}

		ret = driver->rmd_di_rec_record(channel->rec_handle, 
				out_buff, out_bytes, channel->bgn_time, 
				channel->end_time);
	} else {
		ret = driver->rmd_di_rec_record(channel->rec_handle, buff, 
				bytes, channel->bgn_time, channel->end_time);
	}

	if (ret != 0) {
		syslog(LOG_DEBUG, "record [%s] error: %lu", channel->rec_name, 
				driver->rmd_di_rec_geterror());
		channel->rec_error = 1;
		return -1;
	}

	return 0;
}
Пример #27
0
    ///////////////////////////////////////////////////////////////////////////
    // Install a new generic performance counter type in a way, which will
    // uninstall it automatically during shutdown.
    counter_status install_counter_type(std::string const& name,
        counter_type type, std::string const& helptext,
        HPX_STD_FUNCTION<create_counter_func> const& create_counter,
        HPX_STD_FUNCTION<discover_counters_func> const& discover_counters,
        boost::uint32_t version, std::string const& uom, error_code& ec)
    {
        counter_info info(type, name, helptext,
            version ? version : HPX_PERFORMANCE_COUNTER_V1, uom);
        boost::shared_ptr<manage_counter_type> p =
            boost::make_shared<manage_counter_type>(info);

        // Install the counter type.
        p->install(create_counter, discover_counters, ec);

        // Register the shutdown function which will clean up this counter type.
        get_runtime().add_shutdown_function(
            boost::bind(&counter_type_shutdown, p));
        return status_valid_data;
    }
Пример #28
0
        // create an arbitrary counter on this locality
        naming::gid_type create_counter_local(counter_info const& info)
        {
            // find create function for given counter
            error_code ec;

            create_counter_func f;
            get_runtime().get_counter_registry().get_counter_create_function(
                info, f, ec);
            if (ec) {
                HPX_THROW_EXCEPTION(bad_parameter, "create_counter_local",
                    "no create function for performance counter found: " +
                    remove_counter_prefix(info.fullname_) +
                        " (" + ec.get_message() + ")");
                return naming::invalid_gid;
            }

            counter_path_elements paths;
            get_counter_path_elements(info.fullname_, paths, ec);
            if (ec) return hpx::naming::invalid_gid;

            if (paths.parentinstancename_ == "locality" &&
                paths.parentinstanceindex_ !=
                    static_cast<boost::int64_t>(hpx::get_locality_id()))
            {
                HPX_THROW_EXCEPTION(bad_parameter, "create_counter_local",
                    "attempt to create counter on wrong locality ("
                     + ec.get_message() + ")");
                return hpx::naming::invalid_gid;
            }

            // attempt to create the new counter instance
            naming::gid_type gid = f(info, ec);
            if (ec) {
                HPX_THROW_EXCEPTION(bad_parameter, "create_counter_local",
                    "couldn't create performance counter: " +
                    remove_counter_prefix(info.fullname_) +
                        " (" + ec.get_message() + ")");
                return naming::invalid_gid;
            }

            return gid;
        }
Пример #29
0
void external_dataset_sort(external_dataset_t* data)
{
    struct runtime rt;
    void* results = NULL;
    size_t i;
    
    stream_t* tmp;
    stream_t* stream = data->stream;
    stream_seek(stream, 0);
    tmp = stream_create(stream->config, "tmp.stream");
    stream_open(tmp, O_CREAT | O_TRUNC | O_RDWR | O_SYNC);
    /* sort each individual chunk of memory size */
    for(i = 0; i < data->n_records / MEMORY_RECORDS(stream); i++)
    {
        memory_read(stream, RECORDS(data->mem), MEMORY_RECORDS(stream));
        N_RECORDS(data->mem) = MEMORY_RECORDS(stream);
        results = NULL;
        start_timing(&rt);
        fp_im_sort(data->context, RECORDS(data->mem), N_RECORDS(data->mem), &results);
        stop_timing(&rt);
        printf("Sort time: %f\n", get_runtime(rt));
        memory_write(tmp, RECORDS(data->mem), N_RECORDS(data->mem));
        dataset_print(data->mem, TRUE);

    }
    if(data->n_records % MEMORY_RECORDS(stream))
    {
        memory_read(stream, RECORDS(data->mem), data->n_records % MEMORY_RECORDS(stream));
        N_RECORDS(data->mem) = data->n_records % MEMORY_RECORDS(stream);
        start_timing(&rt);
        results = NULL;
        fp_im_sort(data->context, RECORDS(data->mem), N_RECORDS(data->mem), &results);
        stop_timing(&rt);
        memory_write(tmp, RECORDS(data->mem), N_RECORDS(data->mem));
        dataset_print(data->mem, TRUE);
    }
    /* merge memory chunks block by block */
}
Пример #30
0
    HPX_EXPORT void throw_exception(Exception const& e, std::string const& func,
        std::string const& file, long line)
    {
        boost::int64_t pid_ = ::getpid();
        std::string back_trace(backtrace());

        std::string hostname_ = "";
        if (get_runtime_ptr())
        {
            util::osstream strm;
            strm << get_runtime().here();
            hostname_ = util::osstream_get_string(strm);
        }

        // if this is not a HPX thread we do not need to query neither for
        // the shepherd thread nor for the thread id
        boost::uint32_t node = 0;
        std::size_t shepherd = std::size_t(-1);
        std::size_t thread_id = 0;
        std::string thread_name("");

        threads::thread_self* self = threads::get_self_ptr();
        if (NULL != self)
        {
            if (threads::threadmanager_is(running))
            {
                node = get_locality_id();
                shepherd = threads::threadmanager_base::get_worker_thread_num();
            }

            thread_id = reinterpret_cast<std::size_t>(self->get_thread_id());
            thread_name = threads::get_thread_description(self->get_thread_id());
        }

        rethrow_exception(e, func, file, line, back_trace, node, hostname_,
            pid_, shepherd, thread_id, thread_name);
    }