void memory_release_loop() { memory_release_lock.lock(); while (!stop_memory_release_thread) { memory_release_cond.timedwait(memory_release_lock, 15); MallocExtension::instance()->ReleaseFreeMemory(); } memory_release_lock.unlock(); }
void callback(graphlab::vertex_id_type v) { //logstream(LOG_INFO) << "Locked " << ggraph->global_vid(v) << std::endl; mt.lock(); ASSERT_EQ(current_demand_set[v], 1); locked_set[v]++; nlocksacquired++; mt.unlock(); // graphlab::my_sleep(1); locked_elements.enqueue(v); }
/* Global thread func for running lda */ void fn_run_lda(lda::engine_type& lda_engine) { static graphlab::mutex m; if (m.try_lock()) { dc_ptr->cout() << "Running The Collapsed Gibbs Sampler" << std::endl; lda_engine.map_reduce_vertices<graphlab::empty>(lda::signal_only::docs); // Enable sampling lda::cgs_lda_vertex_program::DISABLE_SAMPLING = false; // Run the engine lda_engine.start(); // Finalize the counts // lda::cgs_lda_vertex_program::DISABLE_SAMPLING = true; // lda_engine->signal_all(); // lda_engine->start(); m.unlock(); } }
void thread_stuff() { std::pair<graphlab::vertex_id_type, bool> deq; while(1) { deq = locked_elements.dequeue(); if (deq.second == false) break; else { locks->philosopher_stops_eating(deq.first); mt.lock(); current_demand_set[deq.first] = 0; bool getnextlock = nlocks_to_acquire > 0; if (nlocks_to_acquire > 0) { nlocks_to_acquire--; if (nlocks_to_acquire % 100 == 0) { std::cout << "Remaining: " << nlocks_to_acquire << std::endl; } } if (nlocks_to_acquire == 0 && nlocksacquired == INITIAL_NLOCKS_TO_ACQUIRE + lockable_vertices.size()) cond.signal(); mt.unlock(); if (getnextlock > 0) { graphlab::vertex_id_type toacquire = 0; while(1) { mt.lock(); toacquire = lockable_vertices[graphlab::random::rand() % lockable_vertices.size()]; if (current_demand_set[toacquire] == 0) { current_demand_set[toacquire] = 1; demand_set[toacquire]++; mt.unlock(); break; } mt.unlock(); } locks->make_philosopher_hungry(toacquire); } } } }
/* Obtain a backtrace and print it to ofile. */ void __print_back_trace() { void *array[1024]; size_t size, i; char **strings; back_trace_file_lock.lock(); if (write_error) { back_trace_file_lock.unlock(); return; } char filename[1024]; sprintf(filename, "backtrace.%d", int(graphlab::dc_impl::get_last_dc_procid())); FILE* ofile = NULL; if (write_count == 0) { ofile = fopen(filename, "w"); } else { ofile = fopen(filename, "a"); } // if unable to open the file for output if (ofile == NULL) { // print an error, set the error flag so we don't ever print it again fprintf(stderr, "Unable to open output backtrace file.\n"); write_error = 1; back_trace_file_lock.unlock(); return; } ++write_count; size = backtrace(array, 1024); strings = backtrace_symbols(array, size); fprintf(ofile, "Pointers\n"); fprintf(ofile, "------------\n"); for (i = 0; i < size; ++i) { fprintf(ofile, "%p\n", array[i]); } fprintf(ofile, "Raw\n"); fprintf(ofile, "------------\n"); for (i = 0; i < size; ++i) { fprintf(ofile, "%s\n", strings[i]); } fprintf(ofile, "\nDemangled\n"); fprintf(ofile, "------------\n"); for (i = 0; i < size; ++i) { std::string ret = demangle(strings[i]); fprintf(ofile, "%s\n", ret.c_str()); } free(strings); fprintf(ofile, "\n\n\n\n\n\n\n\n\n\n\n\n\n"); fclose(ofile); back_trace_file_lock.unlock(); }