//static void HippoGridInfo::onXmlCharacterData(void *userData, const XML_Char *s, int len) { HippoGridInfo *self = (HippoGridInfo*)userData; switch (self->mXmlState) { case XML_GRIDNICK: if (self->mGridNick == "") self->mGridNick.assign(s, len); cleanUpGridNick(self->mGridNick); break; case XML_PLATFORM: { std::string platform(s, len); self->setPlatform(platform); break; } case XML_LOGINURI: self->mLoginUri.assign(s, len); cleanUpUri(self->mLoginUri); break; case XML_HELPERURI: self->mHelperUri.assign(s, len); cleanUpUri(self->mHelperUri); break; case XML_SEARCH: //self->mSearchUrl.assign(s, len); //cleanUpQueryUrl(mSearchUrl); break; case XML_GRIDNAME: self->mGridName.assign(s, len); break; case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; case XML_WEBSITE: self->mWebSite.assign(s, len); break; case XML_SUPPORT: self->mSupportUrl.assign(s, len); break; case XML_REGISTER: self->mRegisterUrl.assign(s, len); break; case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break; case XML_VOID: break; } }
bool PlatformerEntityController::jump(float height, float time) { if (isJumping() || !getEntity() || !getEntity()->hasCharacterController()) return false; // Can only jump when there is a surface beneath the player auto collisionNormal = Vec3(); if (!physics().getCharacterControllerDownAxisCollision(getEntity()->characterController_, collisionNormal)) return false; // Can't launch off surfaces steeper than 45 degrees if (collisionNormal.dot(Vec3::UnitY) < 0.707f) return false; isJumping_ = true; jumpStartTime_ = platform().getTime(); jumpHeight_ = height; jumpTime_ = time; return true; }
asmlinkage int solaris_sysinfo(int cmd, u32 buf, s32 count) { char *p, *q, *r; char buffer[256]; int len; /* Again, we cheat :)) */ switch (cmd) { case SI_SYSNAME: r = "SunOS"; break; case SI_HOSTNAME: r = buffer + 256; down_read(&uts_sem); for (p = utsname()->nodename, q = buffer; q < r && *p && *p != '.'; *q++ = *p++); up_read(&uts_sem); *q = 0; r = buffer; break; case SI_RELEASE: r = "5.6"; break; case SI_MACHINE: r = machine(); break; case SI_ARCHITECTURE: r = "sparc"; break; case SI_HW_PROVIDER: r = "Sun_Microsystems"; break; case SI_HW_SERIAL: r = serial(buffer, sizeof(buffer)); break; case SI_PLATFORM: r = platform(buffer, sizeof(buffer)); break; case SI_SRPC_DOMAIN: r = ""; break; case SI_VERSION: r = "Generic"; break; default: return -EINVAL; } len = strlen(r) + 1; if (count < len) { if (copy_to_user(A(buf), r, count - 1) || __put_user(0, (char __user *)A(buf) + count - 1)) return -EFAULT; } else { if (copy_to_user(A(buf), r, len)) return -EFAULT; } return len; }
void World::generateLevel() { float y = Platform::PLATFORM_HEIGHT / 2; float maxJumpHeight = Bob::BOB_JUMP_VELOCITY * Bob::BOB_JUMP_VELOCITY / (2 * -gravity.y); while(y < WORLD_HEIGHT - WORLD_WIDTH / 2) { int type = MathUtils::randomFloat() > 0.8f ? Platform::PLATFORM_TYPE_MOVING : Platform::PLATFORM_TYPE_STATIC; float x = MathUtils::randomFloat() * (WORLD_WIDTH - Platform::PLATFORM_WIDTH) + Platform::PLATFORM_WIDTH / 2; Platform platform(type, x, y); platforms.push_back(platform); if(MathUtils::randomFloat() > 0.9f && type != Platform::PLATFORM_TYPE_MOVING) { Spring spring(platform.position.x, platform.position.y + Platform::PLATFORM_HEIGHT / 2 + Spring::SPRING_HEIGHT / 2); springs.push_back(spring); } if(y > WORLD_HEIGHT / 3 && MathUtils::randomFloat() > 0.8f) { Squirrel squirrel(platform.position.x + MathUtils::randomFloat(), platform.position.y + Squirrel::SQUIRREL_HEIGHT + MathUtils::randomFloat() * 2); squirrels.push_back(squirrel); } if(MathUtils::randomFloat() > 0.6f) { Coin coin(platform.position.x + MathUtils::randomFloat(), platform.position.y + Coin::COIN_HEIGHT + MathUtils::randomFloat() * 3); coins.push_back(coin); } y += (maxJumpHeight - 0.5f); y -= MathUtils::randomFloat() * (maxJumpHeight / 3); } castle = Castle(WORLD_WIDTH / 2, y); }
int main() { ocl::Platform platform(ocl::device_type::CPU); ocl::Device device = platform.device(ocl::device_type::CPU); //std::cout << "Printing platform" << std::endl; platform.print(false, true, true, true, true, false); std::cout << "Device name: " << device.name() << std::endl; std::cout << "Number of compute units: " << device.maxComputeUnits() << std::endl; std::cout << "Number of maximum work item sizes: " << utl::toString(device.maxWorkItemSizes()) << std::endl; std::cout << "Size of global memory in GiBytes: " << (double(device.globalMemSize()) / double(1<<30)) << std::endl; std::cout << "Size of local memory in KiBytes: " << (double(device.localMemSize()) / double(1<<10)) << std::endl; std::cout << "Size of local memory in GiBytes: " << (double(device.maxMemAllocSize()) / double(1<<30)) << std::endl; std::string s; device.isCpu() ? s = "CPU!" : s = "GPU!"; std::cout << "Device is a " << s << std::endl; return 0; }
int main(int argc, char** argv) { base::CommandLine::Init(argc, argv); WTF::Partitions::initialize(nullptr); WTF::setTimeFunctionsForTesting(dummyCurrentTime); WTF::initialize(nullptr); WTF::initializeMainThread(0); blink::TestingPlatformSupport::Config platformConfig; cc_blink::WebCompositorSupportImpl compositorSupport; platformConfig.compositorSupport = &compositorSupport; blink::TestingPlatformSupport platform(platformConfig); blink::Heap::init(); blink::ThreadState::attachMainThread(); blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); blink::EventTracer::initialize(); blink::HTTPNames::init(); base::TestSuite testSuite(argc, argv); mojo::edk::Init(); base::TestIOThread testIoThread(base::TestIOThread::kAutoStart); WTF::OwnPtr<mojo::edk::test::ScopedIPCSupport> ipcSupport( adoptPtr(new mojo::edk::test::ScopedIPCSupport(testIoThread.task_runner()))); int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base::Unretained(&testSuite))); blink::ThreadState::detachMainThread(); blink::Heap::shutdown(); WTF::shutdown(); WTF::Partitions::shutdown(); return result; }
int main(int argc, char **argv) { auto config = ParseCommandLine(argc, argv); printf("%s\n", mila::version::PrintVersion().c_str()); auto sudoku_solver_initial = mila::sudokusolver::parallel::SudokuSolverBasedOnFilesProfiler(config.platform_id, config.device_id); sudoku_solver_initial.Run(config.input_file, config.output_file, config.number_of_filled_cells); auto duration = sudoku_solver_initial.results().at(sudoku_solver_initial.main_result()); printf("Initial results\n"); printf("Duration [us]: %lld\n", duration); printf("Platform: %s\n", sudoku_solver_initial.platform().getName().c_str()); printf("Device: %s\n", sudoku_solver_initial.device().getName().c_str()); printf("Input file: %s\n", config.input_file.c_str()); printf("Output file: %s\n", config.output_file.c_str()); printf("Number of filled cells: %d\n", config.number_of_filled_cells); auto results = std::vector<float>(config.number_of_iterations); printf("Iterations\n"); for (size_t i = 0; i < config.number_of_iterations; ++i) { auto sudoku_solver = mila::sudokusolver::parallel::SudokuSolverBasedOnFilesProfiler(config.platform_id, config.device_id); sudoku_solver.Run(config.input_file, config.output_file, config.number_of_filled_cells); duration = sudoku_solver.results().at(sudoku_solver.main_result()); printf("Iteration: %d, Duration [us]: %lld\n", i, duration); results[i] = duration; } printf("Statistics\n"); printf("Mean: %f\n", mila::utils::Mean(results)); printf("Median: %f\n", mila::utils::Median(results)); printf("Variance: %f\n", mila::utils::Variance(results)); printf("Standard Deviation: %f\n", mila::utils::StandardDeviation(results)); printf("Coefficient of Variation: %f\n", mila::utils::CoefficientOfVariation(results)); return 0; }
/* * Main */ int main(int argc, char *argv[]) { struct stat file; state st; char self[64]; char selector[BUFSIZE]; char buf[BUFSIZE]; char *dest; char *c; #ifdef HAVE_SHMEM struct shmid_ds shm_ds; shm_state *shm; int shmid; #endif /* Get the name of this binary */ if ((c = strrchr(argv[0], '/'))) sstrlcpy(self, c + 1); else sstrlcpy(self, argv[0]); /* Initialize state */ #ifdef HAVE_LOCALES setlocale(LC_TIME, DATE_LOCALE); #endif init_state(&st); srand(time(NULL) / (getpid() + getppid())); /* Handle command line arguments */ parse_args(&st, argc, argv); /* Open syslog() */ if (st.opt_syslog) openlog(self, LOG_PID, LOG_DAEMON); /* Make sure the computer is turned on */ #ifdef __HAIKU__ if (is_computer_on() != TRUE) die(&st, ERR_ACCESS, "Please turn on the computer first"); #endif /* Refuse to run as root */ #ifdef HAVE_PASSWD if (st.opt_root && getuid() == 0) die(&st, ERR_ACCESS, "Refusing to run as root"); #endif /* Try to get shared memory */ #ifdef HAVE_SHMEM if ((shmid = shmget(SHM_KEY, sizeof(shm_state), IPC_CREAT | SHM_MODE)) == ERROR) { /* Getting memory failed -> delete the old allocation */ shmctl(shmid, IPC_RMID, &shm_ds); shm = NULL; } else { /* Map shared memory */ if ((shm = (shm_state *) shmat(shmid, (void *) 0, 0)) == (void *) ERROR) shm = NULL; /* Initialize mapped shared memory */ if (shm && shm->start_time == 0) { shm->start_time = time(NULL); /* Keep server platform & description in shm */ platform(&st); sstrlcpy(shm->server_platform, st.server_platform); sstrlcpy(shm->server_description, st.server_description); } } /* For debugging shared memory issues */ if (!st.opt_shm) shm = NULL; /* Get server platform and description */ if (shm) { sstrlcpy(st.server_platform, shm->server_platform); if (!*st.server_description) sstrlcpy(st.server_description, shm->server_description); } else #endif platform(&st); /* Read selector */ if (fgets(selector, sizeof(selector) - 1, stdin) == NULL) selector[0] = '\0'; /* Remove trailing CRLF */ chomp(selector); if (st.debug) syslog(LOG_INFO, "client sent us \"%s\"", selector); /* Handle hURL: redirect page */ if (sstrncmp(selector, "URL:") == MATCH) { st.req_filetype = TYPE_HTML; sstrlcpy(st.req_selector, selector); url_redirect(&st); return OK; } /* Handle gopher+ root requests (UMN gopher client is seriously borken) */ if (sstrncmp(selector, "\t$") == MATCH) { printf("+-1" CRLF); printf("+INFO: 1Main menu\t\t%s\t%i" CRLF, st.server_host, st.server_port); printf("+VIEWS:" CRLF " application/gopher+-menu: <512b>" CRLF); printf("." CRLF); if (st.debug) syslog(LOG_INFO, "got a request for gopher+ root menu"); return OK; } /* Convert HTTP request to gopher (respond using headerless HTTP/0.9) */ if (sstrncmp(selector, "GET ") == MATCH || sstrncmp(selector, "POST ") == MATCH ) { if ((c = strchr(selector, ' '))) sstrlcpy(selector, c + 1); if ((c = strchr(selector, ' '))) *c = '\0'; st.req_protocol = PROTO_HTTP; if (st.debug) syslog(LOG_INFO, "got HTTP request for \"%s\"", selector); } /* Save default server_host & fetch session data (including new server_host) */ sstrlcpy(st.server_host_default, st.server_host); #ifdef HAVE_SHMEM if (shm) get_shm_session(&st, shm); #endif /* Loop through the selector, fix it & separate query_string */ dest = st.req_selector; if (selector[0] != '/') *dest++ = '/'; for (c = selector; *c;) { /* Skip duplicate slashes and /./ */ while (*c == '/' && *(c + 1) == '/') c++; if (*c == '/' && *(c + 1) == '.' && *(c + 2) == '/') c += 2; /* Start of a query string (either type 7 or HTTP-style)? */ if (*c == '\t' || (st.opt_query && *c == '?')) { sstrlcpy(st.req_query_string, c + 1); if ((c = strchr(st.req_query_string, '\t'))) *c = '\0'; break; } /* Start of virtual host hint? */ if (*c == ';') { if (st.opt_vhost) sstrlcpy(st.server_host, c + 1); /* Skip vhost on selector */ while (*c && *c != '\t') c++; continue; } /* Copy valid char */ *dest++ = *c++; } *dest = '\0'; /* Remove encodings from selector */ strndecode(st.req_selector, st.req_selector, sizeof(st.req_selector)); /* Deny requests for Slashdot and /../ hackers */ if (strstr(st.req_selector, "/.")) die(&st, ERR_ACCESS, "Refusing to serve out dotfiles"); /* Handle /server-status requests */ #ifdef HAVE_SHMEM if (sstrncmp(st.req_selector, SERVER_STATUS) == MATCH) { if (shm) server_status(&st, shm, shmid); return OK; } #endif /* Remove possible extra cruft from server_host */ if ((c = strchr(st.server_host, '\t'))) *c = '\0'; /* Guess request filetype so we can die() with style... */ st.req_filetype = gopher_filetype(&st, st.req_selector, FALSE); /* Convert seletor to path & stat() */ selector_to_path(&st); if (st.debug) syslog(LOG_INFO, "path to resource is \"%s\"", st.req_realpath); if (stat(st.req_realpath, &file) == ERROR) { /* Handle virtual /caps.txt requests */ if (st.opt_caps && sstrncmp(st.req_selector, CAPS_TXT) == MATCH) { #ifdef HAVE_SHMEM caps_txt(&st, shm); #else caps_txt(&st, NULL); #endif return OK; } /* Requested file not found - die() */ die(&st, ERR_NOTFOUND, NULL); } /* Fetch request filesize from stat() */ st.req_filesize = file.st_size; /* Everyone must have read access but no write access */ if ((file.st_mode & S_IROTH) == 0) die(&st, ERR_ACCESS, "File or directory not world-readable"); if ((file.st_mode & S_IWOTH) != 0) die(&st, ERR_ACCESS, "File or directory world-writeable"); /* If stat said it was a dir then it's a menu */ if ((file.st_mode & S_IFMT) == S_IFDIR) st.req_filetype = TYPE_MENU; /* Not a dir - let's guess the filetype again... */ else if ((file.st_mode & S_IFMT) == S_IFREG) st.req_filetype = gopher_filetype(&st, st.req_realpath, st.opt_magic); /* Menu selectors must end with a slash */ if (st.req_filetype == TYPE_MENU && strlast(st.req_selector) != '/') sstrlcat(st.req_selector, "/"); /* Change directory to wherever the resource was */ sstrlcpy(buf, st.req_realpath); if ((file.st_mode & S_IFMT) != S_IFDIR) c = dirname(buf); else c = buf; if (chdir(c) == ERROR) die(&st, ERR_ACCESS, NULL); /* Keep count of hits and data transfer */ #ifdef HAVE_SHMEM if (shm) { shm->hits++; shm->kbytes += st.req_filesize / 1024; /* Update user session */ update_shm_session(&st, shm); } #endif /* Log the request */ if (st.opt_syslog) { syslog(LOG_INFO, "request for \"gopher://%s:%i/%c%s\" from %s", st.server_host, st.server_port, st.req_filetype, st.req_selector, st.req_remote_addr); } /* Check file type & act accordingly */ switch (file.st_mode & S_IFMT) { case S_IFDIR: log_combined(&st, HTTP_OK); gopher_menu(&st); break; case S_IFREG: log_combined(&st, HTTP_OK); gopher_file(&st); break; default: die(&st, ERR_ACCESS, "Refusing to serve out special files"); } /* Clean exit */ return OK; }
void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEvent, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom) { PlatformWheelEvent platformWheelEvent = platform(wheelEvent); #if PLATFORM(COCOA) switch (wheelEvent.phase()) { case PlatformWheelEventPhaseBegan: m_recentWheelEventDeltaTracker->beginTrackingDeltas(); break; case PlatformWheelEventPhaseEnded: m_recentWheelEventDeltaTracker->endTrackingDeltas(); break; default: break; } if (m_recentWheelEventDeltaTracker->isTrackingDeltas()) { m_recentWheelEventDeltaTracker->recordWheelEventDelta(platformWheelEvent); DominantScrollGestureDirection dominantDirection = DominantScrollGestureDirection::None; dominantDirection = m_recentWheelEventDeltaTracker->dominantScrollGestureDirection(); // Workaround for scrolling issues <rdar://problem/14758615>. if (dominantDirection == DominantScrollGestureDirection::Vertical && platformWheelEvent.deltaX()) platformWheelEvent = platformWheelEvent.copyIgnoringHorizontalDelta(); else if (dominantDirection == DominantScrollGestureDirection::Horizontal && platformWheelEvent.deltaY()) platformWheelEvent = platformWheelEvent.copyIgnoringVerticalDelta(); } #endif #if ENABLE(ASYNC_SCROLLING) MutexLocker locker(m_scrollingTreesMutex); if (RefPtr<ThreadedScrollingTree> scrollingTree = m_scrollingTrees.get(pageID)) { // FIXME: It's pretty horrible that we're updating the back/forward state here. // WebCore should always know the current state and know when it changes so the // scrolling tree can be notified. // We only need to do this at the beginning of the gesture. if (platformWheelEvent.phase() == PlatformWheelEventPhaseBegan) { ScrollingThread::dispatch([scrollingTree, canRubberBandAtLeft, canRubberBandAtRight, canRubberBandAtTop, canRubberBandAtBottom] { scrollingTree->setCanRubberBandState(canRubberBandAtLeft, canRubberBandAtRight, canRubberBandAtTop, canRubberBandAtBottom); }); } ScrollingTree::EventResult result = scrollingTree->tryToHandleWheelEvent(platformWheelEvent); #if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING) if (result == ScrollingTree::DidHandleEvent) updateWheelEventTestTriggersIfNeeded(pageID); #endif if (result == ScrollingTree::DidHandleEvent || result == ScrollingTree::DidNotHandleEvent) { sendDidReceiveEvent(pageID, wheelEvent, result == ScrollingTree::DidHandleEvent); return; } } #else UNUSED_PARAM(canRubberBandAtLeft); UNUSED_PARAM(canRubberBandAtRight); UNUSED_PARAM(canRubberBandAtTop); UNUSED_PARAM(canRubberBandAtBottom); #endif RefPtr<EventDispatcher> eventDispatcher(this); RunLoop::main().dispatch([eventDispatcher, pageID, wheelEvent] { eventDispatcher->dispatchWheelEvent(pageID, wheelEvent); }); }
int main() { using size_t = ::st_buffer_size_t; using num_particles_t = ::st_particle_num_elements_t; using buffer_t = ::st_Buffer; using object_t = ::st_Object; using particles_t = ::st_Particles; using timing_result_t = sixtrack::benchmarks::TimingResult; size_t const NUM_TURNS = size_t{ 20u }; /* ===================================================================== */ /* ==== Prepare Host Buffers */ double begin_time = ::st_Time_get_seconds_since_epoch(); std::vector< size_t > num_particles_list = { 20000u }; std::sort( num_particles_list.begin(), num_particles_list.end() ); /* --------------------------------------------------------------------- */ buffer_t* lhc_beam_elements = ::st_Buffer_new_from_file( ::st_PATH_TO_TEST_LHC_BEAM_ELEMENTS_DATA_NO_BEAM_BEAM ); object_t const* be_begin = ::st_Buffer_get_const_objects_begin( lhc_beam_elements ); object_t const* be_end = ::st_Buffer_get_const_objects_end( lhc_beam_elements ); /* --------------------------------------------------------------------- */ buffer_t* lhc_particles_buffer = ::st_Buffer_new_from_file( st_PATH_TO_TEST_LHC_PARTICLES_DATA_T1_P2_NO_BEAM_BEAM ); particles_t const* lhc_particles = ( particles_t const* )( uintptr_t )::st_Object_get_begin_addr( ::st_Buffer_get_const_objects_begin( lhc_particles_buffer ) ); size_t const lhc_num_particles = ::st_Particles_get_num_of_particles( lhc_particles ); /* --------------------------------------------------------------------- */ size_t const max_num_particles = num_particles_list.back(); size_t const requ_num_slots = ::st_Particles_get_required_num_slots( lhc_particles_buffer, max_num_particles ); size_t const requ_num_dataptrs = ::st_Particles_get_required_num_dataptrs( lhc_particles_buffer, max_num_particles ); size_t const req_particles_buffer_size = ::st_Buffer_calculate_required_buffer_length( lhc_particles_buffer, max_num_particles, requ_num_slots, requ_num_dataptrs, size_t{ 0 } ); buffer_t* particles_buffer = ::st_Buffer_new( req_particles_buffer_size ); /* --------------------------------------------------------------------- */ double now = ::st_Time_get_seconds_since_epoch(); double const time_setup_host_buffers = ( now >= begin_time ) ? ( now - begin_time ) : double{ 0.0 }; /* ===================================================================== */ /* ==== Prepare OpenCL Environment Buffers */ begin_time = ::st_Time_get_seconds_since_epoch(); std::vector< cl::Platform > platforms; cl::Platform::get( &platforms ); std::vector< cl::Device > devices; for( auto const& p : platforms ) { std::vector< cl::Device > temp_devices; p.getDevices( CL_DEVICE_TYPE_ALL, &temp_devices ); for( auto const& d : temp_devices ) { if( !d.getInfo< CL_DEVICE_AVAILABLE >() ) continue; devices.push_back( d ); } } now = ::st_Time_get_seconds_since_epoch(); double const time_get_platforms = ( now >= begin_time ) ? now - begin_time : double{ 0 }; begin_time = ::st_Time_get_seconds_since_epoch(); if( !devices.empty() ) { std::ostringstream a2str( "" ); std::string const PATH_TO_BASE_DIR = ::st_PATH_TO_BASE_DIR; a2str << " -D_GPUCODE=1" << " -D__NAMESPACE=st_" << " -DSIXTRL_DATAPTR_DEC=__global" << " -DSIXTRL_BUFFER_DATAPTR_DEC=__global" << " -DSIXTRL_BUFFER_OBJ_ARGPTR_DEC=__global" << " -DISXTRL_BUFFER_OBJ_DATAPTR_DEC=__global" << " -DSIXTRL_PARTICLE_ARGPTR_DEC=__global" << " -DSIXTRL_PARTICLE_DATAPTR_DEC=__global" << " -DSIXTRL_BE_ARGPTR_DEC=__global" << " -DSIXTRL_BE_DATAPTR_DEC=__global" << " -I" << PATH_TO_BASE_DIR; std::string const REMAP_COMPILE_OPTIONS = a2str.str(); /* ----------------------------------------------------------------- */ std::string path_to_source = PATH_TO_BASE_DIR; path_to_source += "sixtracklib/opencl/impl/track_particles_kernel.cl"; std::ifstream kernel_file( path_to_source, std::ios::in ); std::string const REMAP_PROGRAM_SOURCE_CODE( ( std::istreambuf_iterator< char >( kernel_file ) ), std::istreambuf_iterator< char >() ); kernel_file.close(); path_to_source = PATH_TO_BASE_DIR; path_to_source += "sixtracklib/opencl/impl/"; path_to_source += "track_particles_priv_particles_optimized_kernel.cl"; kernel_file.open( path_to_source, std::ios::in ); std::string const TRACKING_PRORGRAM_SOURCE_CODE( ( std::istreambuf_iterator< char >( kernel_file ) ), std::istreambuf_iterator< char >() ); a2str.str( "" ); a2str << " -D_GPUCODE=1" << " -D__NAMESPACE=st_" << " -DSIXTRL_DATAPTR_DEC=__global" << " -DSIXTRL_BUFFER_DATAPTR_DEC=__global" << " -DSIXTRL_BUFFER_OBJ_ARGPTR_DEC=__global" << " -DISXTRL_BUFFER_OBJ_DATAPTR_DEC=__global" << " -DSIXTRL_PARTICLE_ARGPTR_DEC=__private" << " -DSIXTRL_PARTICLE_DATAPTR_DEC=__private" << " -DSIXTRL_BE_ARGPTR_DEC=__global" << " -DSIXTRL_BE_DATAPTR_DEC=__global" << " -I" << PATH_TO_BASE_DIR; std::string const TRACKING_COMPILE_OPTIONS = a2str.str(); /* ----------------------------------------------------------------- */ for( auto& device : devices ) { cl::Platform platform( device.getInfo< CL_DEVICE_PLATFORM >() ); std::cout << "--------------------------------------------------" << "----------------------------------------------\r\n" << "INFO :: Perform test for device : " << device.getInfo< CL_DEVICE_NAME >() << "\r\n" << "INFO :: Platform : " << platform.getInfo< CL_PLATFORM_NAME >() << "\r\n" << "INFO :: Platform Vendor : " << platform.getInfo< CL_PLATFORM_VENDOR >() << "\r\n" << "INFO :: Device Type : "; auto const device_type = device.getInfo< CL_DEVICE_TYPE >(); switch( device_type ) { case CL_DEVICE_TYPE_CPU: { std::cout << "CPU"; break; } case CL_DEVICE_TYPE_GPU: { std::cout << "GPU"; break; } case CL_DEVICE_TYPE_ACCELERATOR: { std::cout << "Accelerator"; break; } case CL_DEVICE_TYPE_CUSTOM: { std::cout << "Custom"; break; } default: { std::cout << "Unknown"; } }; size_t const device_max_compute_units = device.getInfo< CL_DEVICE_MAX_COMPUTE_UNITS >(); std::cout << "\r\n" << "INFO :: Max work-group size : " << device.getInfo< CL_DEVICE_MAX_WORK_GROUP_SIZE >() << "\r\n" << "INFO :: Max num compute units : " << device_max_compute_units << "\r\n"; /* ------------------------------------------------------------- */ cl_int cl_ret = CL_SUCCESS; cl::Context context( device ); cl::CommandQueue queue( context, device, CL_QUEUE_PROFILING_ENABLE ); cl::Program remap_program( context, REMAP_PROGRAM_SOURCE_CODE ); cl::Program tracking_program( context, TRACKING_PRORGRAM_SOURCE_CODE ); try { cl_ret = remap_program.build( REMAP_COMPILE_OPTIONS.c_str() ); } catch( cl::Error const& e ) { std::cerr << "ERROR :: remap_program :: " << "OpenCL Compilation Error -> Stopping Unit-Test \r\n" << remap_program.getBuildInfo< CL_PROGRAM_BUILD_LOG >( device ) << "\r\n" << std::endl; cl_ret = CL_FALSE; throw; } try { cl_ret = tracking_program.build( TRACKING_COMPILE_OPTIONS.c_str() ); } catch( cl::Error const& e ) { std::cerr << "ERROR :: tracking_program :: " << "OpenCL Compilation Error -> Stopping Unit-Test \r\n" << tracking_program.getBuildInfo< CL_PROGRAM_BUILD_LOG >( device ) << "\r\n" << std::endl; cl_ret = CL_FALSE; throw; } /* ------------------------------------------------------------- */ cl::Kernel remapping_kernel; try { remapping_kernel = cl::Kernel( remap_program, "st_Remap_particles_beam_elements_buffers_opencl" ); } catch( cl::Error const& e ) { std::cout << "kernel remap_kernel :: " << "line = " << __LINE__ << " :: " << "ERROR : " << e.what() << "\r\n" << e.err() << std::endl; cl_ret = CL_FALSE; throw; } size_t remap_work_group_size = remapping_kernel.getWorkGroupInfo< CL_KERNEL_WORK_GROUP_SIZE >( device ); size_t const remap_work_group_size_prefered_multiple = remapping_kernel.getWorkGroupInfo< CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE >( device ); size_t remap_num_threads = remap_work_group_size_prefered_multiple; size_t remap_group_size = remap_work_group_size_prefered_multiple; /* ------------------------------------------------------------- */ cl::Kernel tracking_kernel; try { tracking_kernel = cl::Kernel( tracking_program, "st_Track_particles_beam_elements_priv_particles_optimized_opencl" ); } catch( cl::Error const& e ) { std::cout << "kernel tracking_kernel :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } size_t track_work_group_size = tracking_kernel.getWorkGroupInfo< CL_KERNEL_WORK_GROUP_SIZE >( device ); size_t const track_work_group_size_prefered_multiple = tracking_kernel.getWorkGroupInfo< CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE >( device ); now = ::st_Time_get_seconds_since_epoch(); double const time_cl_program_compile = ( now >= begin_time ) ? ( now - begin_time ) : double{ 0.0 }; /* ============================================================= */ for( auto const NUM_PARTICLES : num_particles_list ) { size_t tracking_num_threads = size_t{ 0 }; size_t tracking_group_size = track_work_group_size; tracking_num_threads = NUM_PARTICLES / track_work_group_size; tracking_num_threads *= track_work_group_size; if( tracking_num_threads < NUM_PARTICLES ) { tracking_num_threads += track_work_group_size; } std::cout << "INFO :: num_particles : " << NUM_PARTICLES << "\r\n" << "INFO :: remap kernel wg size : " << remap_work_group_size << "\r\n" << "INFO :: remap kernel wg size multi : " << remap_work_group_size_prefered_multiple << "\r\n" << "INFO :: remap kernel launch with : " << remap_num_threads << " threads \r\n" << "INFO :: remap_kernel local size : " << remap_group_size << " threads \r\n\r\n" << "INFO :: num_turns : " << NUM_TURNS << "\r\n" << "INFO :: tracking kernel wg size : " << track_work_group_size << "\r\n" << "INFO :: tracking kernel wg size multi : " << track_work_group_size_prefered_multiple << "\r\n" << "INFO :: tracking kernel launch with : " << tracking_num_threads << " threads\r\n" << "INFO :: tracking kernel local size : " << tracking_group_size << " threads\r\n" << std::endl; begin_time = ::st_Time_get_seconds_since_epoch(); int success = ::st_Buffer_reset( particles_buffer ); SIXTRL_ASSERT( success == 0 ); particles_t* particles = ::st_Particles_new( particles_buffer, NUM_PARTICLES ); for( size_t ii = size_t{ 0 } ; ii < NUM_PARTICLES ; ++ii ) { size_t jj = ii % lhc_num_particles; ::st_Particles_copy_single( particles, ii, lhc_particles, jj ); } now = ::st_Time_get_seconds_since_epoch(); double const time_setup_particle_buffer = ( now >= begin_time ) ? ( now - begin_time ) : double{ 0.0 }; /* ========================================================= */ std::vector< cl::Event > write_xfer_events( 3u, cl::Event{} ); cl_ulong write_xfer_when_queued[] = { 0, 0, 0 }; cl_ulong write_xfer_when_submitted[] = { 0, 0, 0 }; cl_ulong write_xfer_when_started[] = { 0, 0, 0 }; cl_ulong write_xfer_when_ended[] = { 0, 0, 0 }; begin_time = ::st_Time_get_seconds_since_epoch(); int32_t success_flag = int32_t{ 0 }; cl::Buffer cl_particles( context, CL_MEM_READ_WRITE, ::st_Buffer_get_size( lhc_particles_buffer ) ); cl::Buffer cl_beam_elements( context, CL_MEM_READ_WRITE, ::st_Buffer_get_size( lhc_beam_elements ) ); cl::Buffer cl_success_flag( context, CL_MEM_READ_WRITE, sizeof( success_flag ) ); try { cl_ret = queue.enqueueWriteBuffer( cl_particles, CL_TRUE, 0, ::st_Buffer_get_size( particles_buffer ), ::st_Buffer_get_const_data_begin( particles_buffer ), nullptr, &write_xfer_events[ 0 ] ); cl_ret |= write_xfer_events[ 0 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_QUEUED, &write_xfer_when_queued[ 0 ] ); cl_ret |= write_xfer_events[ 0 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_SUBMIT, &write_xfer_when_submitted[ 0 ] ); cl_ret |= write_xfer_events[ 0 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_START, &write_xfer_when_started[ 0 ] ); cl_ret |= write_xfer_events[ 0 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_END, &write_xfer_when_ended[ 0 ] ); } catch( cl::Error const& e ) { std::cout << "enqueueWriteBuffer( particles_buffer ) :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } SIXTRL_ASSERT( cl_ret == CL_SUCCESS ); try { cl_ret = queue.enqueueWriteBuffer( cl_beam_elements, CL_TRUE, 0, ::st_Buffer_get_size( lhc_beam_elements ), ::st_Buffer_get_const_data_begin( lhc_beam_elements ), nullptr, &write_xfer_events[ 1 ] ); cl_ret |= write_xfer_events[ 1 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_QUEUED, &write_xfer_when_queued[ 1 ] ); cl_ret |= write_xfer_events[ 1 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_SUBMIT, &write_xfer_when_submitted[ 1 ] ); cl_ret |= write_xfer_events[ 1 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_START, &write_xfer_when_started[ 1 ] ); cl_ret |= write_xfer_events[ 1 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_END, &write_xfer_when_ended[ 1 ] ); } catch( cl::Error const& e ) { std::cout << "enqueueWriteBuffer( beam_elements ) :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } success_flag = int32_t{ 0 }; try { cl_ret = queue.enqueueWriteBuffer( cl_success_flag, CL_TRUE, 0, sizeof( success_flag ), &success_flag, nullptr, &write_xfer_events[ 2 ] ); cl_ret |= write_xfer_events[ 2 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_QUEUED, &write_xfer_when_queued[ 2 ] ); cl_ret |= write_xfer_events[ 2 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_SUBMIT, &write_xfer_when_submitted[ 2 ] ); cl_ret |= write_xfer_events[ 2 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_START, &write_xfer_when_started[ 2 ] ); cl_ret |= write_xfer_events[ 2 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_END, &write_xfer_when_ended[ 2 ] ); } catch( cl::Error const& e ) { std::cout << "enqueueWriteBuffer( success_flag ) :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } now = ::st_Time_get_seconds_since_epoch(); double const time_write_xfer = ( now >= begin_time ) ? ( now - begin_time ) : double{ 0 }; /* ======================================================== */ cl::Event run_remap_kernel_event; cl_ulong run_remap_kernel_when_queued = cl_ulong{ 0 }; cl_ulong run_remap_kernel_when_submitted = cl_ulong{ 0 }; cl_ulong run_remap_kernel_when_started = cl_ulong{ 0 }; cl_ulong run_remap_kernel_when_ended = cl_ulong{ 0 }; begin_time = ::st_Time_get_seconds_since_epoch(); remapping_kernel.setArg( 0, cl_particles ); remapping_kernel.setArg( 1, cl_beam_elements ); remapping_kernel.setArg( 2, cl_success_flag ); try { cl_ret = queue.enqueueNDRangeKernel( remapping_kernel, cl::NullRange, cl::NDRange( remap_num_threads ), cl::NDRange( remap_group_size ), nullptr, &run_remap_kernel_event ); } catch( cl::Error const& e ) { std::cout << "enqueueNDRangeKernel( remapping_kernel ) :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } SIXTRL_ASSERT( cl_ret == CL_SUCCESS ); queue.flush(); run_remap_kernel_event.wait(); cl_ret = run_remap_kernel_event.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_QUEUED, &run_remap_kernel_when_queued ); cl_ret |= run_remap_kernel_event.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_SUBMIT, &run_remap_kernel_when_submitted ); cl_ret |= run_remap_kernel_event.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_START, &run_remap_kernel_when_started ); cl_ret |= run_remap_kernel_event.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_END, &run_remap_kernel_when_ended ); now = ::st_Time_get_seconds_since_epoch(); double const time_run_remapping_kernel = ( now >= begin_time ) ? ( now - begin_time ) : double{ 0 }; /* ========================================================= */ cl::Event xfer_after_remap_events; cl_ulong xfer_after_remap_when_queued = cl_ulong{ 0 }; cl_ulong xfer_after_remap_when_submitted = cl_ulong{ 0 }; cl_ulong xfer_after_remap_when_started = cl_ulong{ 0 }; cl_ulong xfer_after_remap_when_ended = cl_ulong{ 0 }; begin_time = ::st_Time_get_seconds_since_epoch(); try { cl_ret = queue.enqueueReadBuffer( cl_success_flag, CL_TRUE, 0, sizeof( success_flag ), &success_flag, nullptr, &xfer_after_remap_events ); cl_ret = xfer_after_remap_events.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_QUEUED, &xfer_after_remap_when_queued ); cl_ret |= xfer_after_remap_events.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_SUBMIT, &xfer_after_remap_when_submitted ); cl_ret |= xfer_after_remap_events.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_START, &xfer_after_remap_when_started ); cl_ret |= xfer_after_remap_events.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_END, &xfer_after_remap_when_ended ); } catch( cl::Error const& e ) { std::cout << "enqueueReadBuffer( success_flag ) :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } now = ::st_Time_get_seconds_since_epoch(); SIXTRL_ASSERT( cl_ret == CL_SUCCESS ); SIXTRL_ASSERT( success_flag == int32_t{ 0 } ); double const time_xfer_after_remap = ( now >= begin_time ) ? ( now - begin_time ) : double{ 0 }; /* ========================================================== */ uint64_t const turns = NUM_TURNS; cl::Event run_tracking_kernel_event; cl_ulong run_tracking_kernel_when_queued = cl_ulong{ 0 }; cl_ulong run_tracking_kernel_when_submitted = cl_ulong{ 0 }; cl_ulong run_tracking_kernel_when_started = cl_ulong{ 0 }; cl_ulong run_tracking_kernel_when_ended = cl_ulong{ 0 }; begin_time = ::st_Time_get_seconds_since_epoch(); tracking_kernel.setArg( 0, cl_particles ); tracking_kernel.setArg( 1, cl_beam_elements ); tracking_kernel.setArg( 2, turns ); tracking_kernel.setArg( 3, cl_success_flag ); try { cl_ret = queue.enqueueNDRangeKernel( tracking_kernel, cl::NullRange, cl::NDRange( tracking_num_threads ), cl::NDRange( tracking_group_size ), nullptr, &run_tracking_kernel_event ); } catch( cl::Error const& e ) { std::cout << "enqueueNDRangeKernel( remapping_kernel ) :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } cl_ret = queue.flush(); run_tracking_kernel_event.wait(); cl_ret |= run_tracking_kernel_event.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_QUEUED, &run_tracking_kernel_when_queued ); cl_ret |= run_tracking_kernel_event.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_SUBMIT, &run_tracking_kernel_when_submitted ); cl_ret |= run_tracking_kernel_event.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_START, &run_tracking_kernel_when_started ); cl_ret |= run_tracking_kernel_event.getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_END, &run_tracking_kernel_when_ended ); now = ::st_Time_get_seconds_since_epoch(); double const time_run_tracking_kernel = ( now >= begin_time ) ? ( now - begin_time ) : double{ 0 }; double const time_tracking_until_submitted = static_cast< double >( run_tracking_kernel_when_submitted - run_tracking_kernel_when_queued ) * 1e-9; double const time_tracking_until_start = static_cast< double >( run_tracking_kernel_when_started - run_tracking_kernel_when_submitted ) * 1e-9; double const time_tracking_device_execution = static_cast< double >( run_tracking_kernel_when_ended - run_tracking_kernel_when_started ) * 1e-9; /* ========================================================== */ std::vector< cl::Event > xfer_after_tracking_events( 2u, cl::Event{} ); cl_ulong xfer_after_tracking_when_queued[] = { 0, 0 }; cl_ulong xfer_after_tracking_when_submitted[] = { 0, 0 }; cl_ulong xfer_after_tracking_when_started[] = { 0, 0 }; cl_ulong xfer_after_tracking_when_ended[] = { 0, 0 }; begin_time = ::st_Time_get_seconds_since_epoch(); try { cl_ret = queue.enqueueReadBuffer( cl_particles, CL_TRUE, 0, ::st_Buffer_get_size( particles_buffer ), ::st_Buffer_get_data_begin( particles_buffer ), nullptr, &xfer_after_tracking_events[ 0 ] ); cl_ret |= xfer_after_tracking_events[ 0 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_QUEUED, &xfer_after_tracking_when_queued[ 0 ] ); cl_ret |= xfer_after_tracking_events[ 0 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_SUBMIT, &xfer_after_tracking_when_submitted[ 0 ] ); cl_ret |= xfer_after_tracking_events[ 0 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_START, &xfer_after_tracking_when_started[ 0 ] ); cl_ret |= xfer_after_tracking_events[ 0 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_END, &xfer_after_tracking_when_ended[ 0 ] ); } catch( cl::Error const& e ) { std::cout << "enqueueReadBuffer( success_flag ) :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } SIXTRL_ASSERT( cl_ret == CL_SUCCESS ); try { cl_ret = queue.enqueueReadBuffer( cl_success_flag, CL_TRUE, 0, sizeof( success_flag ), &success_flag, nullptr, &xfer_after_tracking_events[ 1 ] ); cl_ret |= xfer_after_tracking_events[ 1 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_QUEUED, &xfer_after_tracking_when_queued[ 1 ] ); cl_ret |= xfer_after_tracking_events[ 1 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_SUBMIT, &xfer_after_tracking_when_submitted[ 1 ] ); cl_ret |= xfer_after_tracking_events[ 1 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_START, &xfer_after_tracking_when_started[ 1 ] ); cl_ret |= xfer_after_tracking_events[ 1 ].getProfilingInfo< cl_ulong >( CL_PROFILING_COMMAND_END, &xfer_after_tracking_when_ended[ 1 ] ); } catch( cl::Error const& e ) { std::cout << "enqueueReadBuffer( success_flag ) :: " << "line = " << __LINE__ << " :: ERROR : " << e.what() << std::endl << e.err() << std::endl; cl_ret = CL_FALSE; throw; } now = ::st_Time_get_seconds_since_epoch(); SIXTRL_ASSERT( cl_ret == CL_SUCCESS ); SIXTRL_ASSERT( success_flag == int32_t{ 0 } ); double const time_xfer_after_tracking = ( now >= begin_time ) ? ( now - begin_time ) : double{ 0 }; /* ======================================================== */ a2str.str( "" ); double time_run_tracking_normalized = time_run_tracking_kernel / static_cast< double >( NUM_TURNS * NUM_PARTICLES ); if( time_run_tracking_normalized >= 0.1 ) { a2str << "sec"; } std::cout << std::endl << "Reslts: \r\n" << "------------------------------------------------" << "------------------------------------------------" << "--------------------------------------------\r\n" << " :: Tracking time : " << std::setw( 20 ) << std::fixed << time_run_tracking_kernel << " [sec] \r\n" << " :: Tracking time/particle/turn : "; if( time_run_tracking_normalized >= 200e-3 ) { std::cout << std::setw( 20 ) << std::fixed << time_run_tracking_normalized << "[sec]\r\n"; } else if( time_run_tracking_normalized >= 200e-6 ) { std::cout << std::setw( 20 ) << std::fixed << time_run_tracking_normalized * 1e3 << "[millisec]\r\n"; } else { std::cout << std::setw( 20 ) << std::fixed << time_run_tracking_normalized * 1e6 << "[usec]\r\n"; } std::cout << " :: device_run_time : " << std::setw( 20 ) << std::fixed << time_tracking_device_execution << "\r\n" << " :: device overhead : " << std::setw( 20 ) << std::fixed << time_tracking_until_start << " + " << time_tracking_until_submitted << "\r\n" << "------------------------------------------------" << "------------------------------------------------" << "--------------------------------------------\r\n" << "\r\n" << std::endl; } int success = ::st_Buffer_remap( particles_buffer ); SIXTRL_ASSERT( success == 0 ); ::st_Buffer_reset( particles_buffer ); } } ::st_Buffer_delete( lhc_particles_buffer ); ::st_Buffer_delete( lhc_beam_elements ); ::st_Buffer_delete( particles_buffer ); return 0; }
void WebPage::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder& arguments) { if (messageID.is<CoreIPC::MessageClassDrawingArea>()) { ASSERT(m_drawingArea); m_drawingArea->didReceiveMessage(connection, messageID, arguments); return; } switch (messageID.get<WebPageMessage::Kind>()) { case WebPageMessage::SetActive: { bool active; if (!arguments.decode(active)) return; setActive(active); break; } case WebPageMessage::SetFocused: { bool focused; if (!arguments.decode(focused)) return; setFocused(focused); break; } case WebPageMessage::MouseEvent: { WebMouseEvent event; if (!arguments.decode(event)) return; connection->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In((uint32_t)event.type())); PlatformMouseEvent platformEvent = platform(event); mouseEvent(platformEvent); break; } case WebPageMessage::WheelEvent: { WebWheelEvent event; if (!arguments.decode(event)) return; connection->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In((uint32_t)event.type())); PlatformWheelEvent platformEvent = platform(event); wheelEvent(platformEvent); break; } case WebPageMessage::KeyEvent: { WebKeyboardEvent event; if (!arguments.decode(event)) return; connection->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In((uint32_t)event.type())); PlatformKeyboardEvent platformEvent = platform(event); keyEvent(platformEvent); break; } case WebPageMessage::LoadURL: { String url; if (!arguments.decode(url)) return; loadURL(url); break; } case WebPageMessage::StopLoading: stopLoading(); break; case WebPageMessage::Reload: bool reloadFromOrigin; if (!arguments.decode(CoreIPC::Out(reloadFromOrigin))) return; reload(reloadFromOrigin); break; case WebPageMessage::GoForward: goForward(); break; case WebPageMessage::GoBack: goBack(); break; case WebPageMessage::DidReceivePolicyDecision: { uint64_t frameID; uint64_t listenerID; uint32_t policyAction; if (!arguments.decode(CoreIPC::Out(frameID, listenerID, policyAction))) return; didReceivePolicyDecision(webFrame(frameID), listenerID, (WebCore::PolicyAction)policyAction); break; } case WebPageMessage::RunJavaScriptInMainFrame: { String script; uint64_t callbackID; if (!arguments.decode(CoreIPC::Out(script, callbackID))) return; runJavaScriptInMainFrame(script, callbackID); break; } case WebPageMessage::GetRenderTreeExternalRepresentation: { uint64_t callbackID; if (!arguments.decode(callbackID)) return; getRenderTreeExternalRepresentation(callbackID); break; } case WebPageMessage::Close: { close(); break; } case WebPageMessage::TryClose: { tryClose(); break; } default: ASSERT_NOT_REACHED(); break; } }
int main(int argc, const char **argv) { device = 0; DmaConfigProxy *dma = 0; InterfaceIndication *deviceIndication = 0; DmaIndication *dmaIndication = 0; fprintf(stderr, "%s %s\n", __DATE__, __TIME__); device = new InterfaceRequestProxy(IfcNames_InterfaceRequest); dma = new DmaConfigProxy(IfcNames_DmaConfig); platformRequest = new PlatformRequestProxy(IfcNames_PlatformRequest); deviceIndication = new InterfaceIndication(IfcNames_InterfaceIndication); dmaIndication = new DmaIndication(dma, IfcNames_DmaIndication); platformIndicationSetup(); fprintf(stderr, "Main::allocating memory...\n"); dma->alloc(PAGE_SIZE*MAX_TAG_COUNT, &hostBufferAlloc); hostBuffer = (unsigned int *)mmap(0, PAGE_SIZE*MAX_TAG_COUNT, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, hostBufferAlloc->header.fd, 0); pthread_t tid; fprintf(stderr, "creating exec thread\n"); if(pthread_create(&tid, NULL, portalExec, NULL)){ fprintf(stderr, "error creating exec thread\n"); exit(1); } dma->dCacheFlushInval(hostBufferAlloc, hostBuffer); fprintf(stderr, "Main::flush and invalidate complete\n"); unsigned int ref_hostBufferAlloc = dma->reference(hostBufferAlloc); printf( "dma->reference done\n" ); fflush(stdout); sleep(1); dma->addrRequest(ref_hostBufferAlloc, 1*sizeof(unsigned int)); printf( "dma->addrRequest done\n" ); fflush(stdout); sleep(1); device->setDmaHandle(ref_hostBufferAlloc); printf( "device->setDmaHandle done\n" ); fflush(stdout); pthread_mutex_init(&readTagMutex, NULL); pthread_cond_init(&readTagCond, NULL); rawWordManager = RawWordManager::getInstance(); for ( int i = 0; i < TAG_COUNT; i++ ) readTagStatus[i] = 0; pageReadTotal = 0; pageWriteTotal = 0; maxTagUsed = 0; printf( "Main started server\n" ); fflush(stdout); start_timer(0); //portalTrace_start(); platform(platformRequest); //portalTrace_stop(); uint64_t cycles = lap_timer(0); uint64_t read_beats = dma->show_mem_stats(ChannelType_Write); uint64_t write_beats = dma->show_mem_stats(ChannelType_Write); float read_util = (float)read_beats/(float)cycles; float write_util = (float)write_beats/(float)cycles; fprintf(stderr, "memory read utilization (beats/cycle): %f\n", read_util); fprintf(stderr, "memory write utilization (beats/cycle): %f\n", write_util); /* MonkitFile("perf.monkit") .setHwCycles(cycles) .setReadBwUtil(read_util) .setWriteBwUtil(write_util) .writeFile(); sleep(2); */ exit(0); }
void TRACKS() { sky(); tree_one(); tree_one_body(); tree_two(); tree_two_body(); wall(); platform(); //quad(); woman(); resting(); home(); /*body_one(); window_one(); c_one(); body_two(); window_two(); door_one(); c_two(); body_three(); window_three(); door_two(); c_three(); body_four(); window_four(); door_three();*/ // glBegin(GL_LINES);// samner lomba line glColor3f(0.0,0.0,0.0); glVertex2f(0,85); glVertex2f(999,85); glVertex2f(999,84); glVertex2f(0,84); glVertex2f(0,82); glVertex2f(999,82); glVertex2f(999,78); glVertex2f(0,78); glVertex2f(0,147); glVertex2f(999,147); glVertex2f(999,148); glVertex2f(0,148); glVertex2f(0,152); glVertex2f(999,152); glVertex2f(0,150); glVertex2f(999,150); glEnd(); quad(); /** boundery strt **/ /* glBegin(GL_LINES);// samner boundery glColor3f(0.0,0.0,0.0); glVertex2f(0,300); glVertex2f(1000,300); glVertex2f(0,297); glVertex2f(1000,297); glColor3f(0.0,0.0,0.0);//boundery samner glVertex2f(0,295); glVertex2f(1000,295); glVertex2f(0,293); glVertex2f(1000,293); glColor3f(0.0,0.0,0.0); glVertex2f(0,400); glVertex2f(1000,400); glVertex2f(0,397); glVertex2f(1000,397); glColor3f(.1111,.10,.0); glVertex2f(0,395); glVertex2f(1000,395); glVertex2f(0,393); glVertex2f(1000,393); glColor3f(.1111,.10,.0); glVertex2f(0,304); glVertex2f(1000,304); glVertex2f(0,305); glVertex2f(1000,305);// samner railline shes // sliper while(c!=1000) { glVertex2f(c,d); glVertex2f(c,d+120); c+=10; } glEnd();*/ /** boundery finish **/ }
bool is166E() { return platform() == MARVELL; }
RenderDevice::RenderDevice(const cl::Device &device, const string &kernelFileName, const unsigned int forceGPUWorkSize, Camera *camera, Sphere *spheres, const unsigned int sceneSphereCount/*, boost::barrier *startBarrier, boost::barrier *endBarrier*/) : /*renderThread(NULL), threadStartBarrier(startBarrier), threadEndBarrier(endBarrier),*/ sphereCount(sceneSphereCount), colorBuffer(NULL), pixelBuffer(NULL), seedBuffer(NULL), pixels(NULL), colors(NULL), seeds(NULL), exeUnitCount(0.0), exeTime(0.0) { deviceName = "anonymouse";//device.getInfo<CL_DEVICE_NAME > ().c_str(); // Allocate a context with the selected device cl::Platform platform = device.getInfo<CL_DEVICE_PLATFORM>(); VECTOR_CLASS<cl::Device> devices; devices.push_back(device); cl_context_properties cps[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform(), 0 }; context = new cl::Context(devices, cps); // Allocate the queue for this device cl_command_queue_properties prop = CL_QUEUE_PROFILING_ENABLE; queue = new cl::CommandQueue(*context, device, prop); // Create the kernel string src = ReadSources(kernelFileName); // Compile sources cl::Program::Sources source(1, make_pair(src.c_str(), src.length())); cl::Program program = cl::Program(*context, source); try { VECTOR_CLASS<cl::Device> buildDevice; buildDevice.push_back(device); #if defined(__EMSCRIPTEN__) program.build(buildDevice, ""); #elif defined(__APPLE__) program.build(buildDevice, "-D__APPLE__"); #else program.build(buildDevice, ""); #endif cl::string result = program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(device); cerr << "[Device::" << deviceName << "]" << " Compilation result: " << result.c_str() << endl; } catch (cl::Error err) { cl::string strError = program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(device); cerr << "[Device::" << deviceName << "]" << " Compilation error:" << endl << strError.c_str() << endl; throw err; } kernel = new cl::Kernel(program, "RadianceGPU"); kernel->getWorkGroupInfo<size_t>(device, CL_KERNEL_WORK_GROUP_SIZE, &workGroupSize); cerr << "[Device::" << deviceName << "]" << " Suggested work group size: " << workGroupSize << endl; // Force workgroup size if applicable and required if ((forceGPUWorkSize > 0) && (device.getInfo<CL_DEVICE_TYPE>() == CL_DEVICE_TYPE_GPU)) { workGroupSize = forceGPUWorkSize; cerr << "[Device::" << deviceName << "]" << " Forced work group size: " << workGroupSize << endl; } // Create the thread for the rendering //renderThread = new boost::thread(boost::bind(RenderDevice::RenderThread, this)); // Create camera buffer cameraBuffer = new cl::Buffer(*context, #if defined (__APPLE__) CL_MEM_READ_ONLY, // CL_MEM_USE_HOST_PTR is very slow with Apple's OpenCL #else CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, #endif sizeof(Camera), camera); cerr << "[Device::" << deviceName << "] Camera buffer size: " << (sizeof(Camera) / 1024) << "Kb" << endl; sphereBuffer = new cl::Buffer(*context, #if defined (__APPLE__) CL_MEM_READ_ONLY, // CL_MEM_USE_HOST_PTR is very slow with Apple's OpenCL #else CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, #endif sizeof(Sphere) * sphereCount, spheres); cerr << "[Device::" << deviceName << "] Scene buffer size: " << (sizeof(Sphere) * sphereCount / 1024) << "Kb" << endl; }
void Remapper::dataIn( Node::DataType type, QMutex *mutex, void *data, size_t bytes, qint64 timeStamp ) { switch( type ) { case DataType::Input: { // Copy incoming data to our own buffer GamepadState gamepad; { mutex->lock(); gamepad = *reinterpret_cast<GamepadState *>( data ); mutex->unlock(); } int instanceID = gamepad.instanceID; int joystickID = gamepad.joystickID; QString GUID( QByteArray( reinterpret_cast<const char *>( gamepad.GUID.data ), 16 ).toHex() ); // Do initial calibration if not done yet { if( deadzoneFlag[ GUID ] ) { deadzoneFlag[ GUID ] = false; // Apply default value for( int i = 0; i < gamepad.joystickNumAxes; i++ ) { deadzones[ GUID ][ i ] = 10000; // Check analog value at this moment. If its magnitude is less than 30000 then it's most likely // an analog stick. Otherwise, it might be a trigger (with a centered value of -32768) deadzoneModes[ GUID ][ i ] = ( qAbs( static_cast<int>( gamepad.joystickAxis[ i ] ) ) < 30000 ); } // TODO: Replace with stored value from disk } } // Inject deadzone settings into gamepad { for( int i = 0; i < gamepad.joystickNumAxes; i++ ) { gamepad.deadzone[ i ] = deadzones[ GUID ][ i ]; gamepad.deadzoneMode[ i ] = deadzoneModes[ GUID ][ i ]; } } // Send raw joystick data to the model // Do this before we apply joystick deadzones so the user sees completely unprocessed data { // Copy current gamepad into buffer this->mutex.lock(); gamepadBuffer[ gamepadBufferIndex ] = gamepad; this->mutex.unlock(); // Send buffer on its way emit rawJoystickData( &( this->mutex ), reinterpret_cast<void *>( &gamepadBuffer[ gamepadBufferIndex ] ) ); // Increment the index gamepadBufferIndex = ( gamepadBufferIndex + 1 ) % 100; } // Apply deadzones to each stick and both triggers independently { qreal deadzone = 0.0; bool deadzoneMode = false; for( int i = 0; i < 4; i++ ) { int xAxis; int yAxis; // For the analog sticks, average the underlying joystick axes together to get the final deadzone value // If either axis has deadzone mode set to true, it'll apply to both // FIXME: If users complain about this, expand the code to handle this case (one axis true and one axis false) and treat axes indepenently switch( i ) { case 0: { xAxis = SDL_CONTROLLER_AXIS_LEFTX; yAxis = SDL_CONTROLLER_AXIS_LEFTY; Val val = gameControllerToJoystick[ GUID ][ Key( AXIS, SDL_CONTROLLER_AXIS_LEFTX ) ]; int axisID = val.second.first; if( val.first == AXIS ) { deadzone = deadzones[ GUID ][ axisID ]; deadzoneMode = deadzoneModes[ GUID ][ axisID ]; } Val val2 = gameControllerToJoystick[ GUID ][ Key( AXIS, SDL_CONTROLLER_AXIS_LEFTY ) ]; axisID = val2.second.first; if( val2.first == AXIS ) { deadzone += deadzones[ GUID ][ axisID ]; deadzone /= 2.0; deadzoneMode = deadzoneMode || deadzoneModes[ GUID ][ axisID ]; } break; } case 1: { xAxis = SDL_CONTROLLER_AXIS_RIGHTX; yAxis = SDL_CONTROLLER_AXIS_RIGHTY; Val val = gameControllerToJoystick[ GUID ][ Key( AXIS, SDL_CONTROLLER_AXIS_RIGHTX ) ]; int axisID = val.second.first; if( val.first == AXIS ) { deadzone = deadzones[ GUID ][ axisID ]; deadzoneMode = deadzoneModes[ GUID ][ axisID ]; } Val val2 = gameControllerToJoystick[ GUID ][ Key( AXIS, SDL_CONTROLLER_AXIS_RIGHTY ) ]; axisID = val2.second.first; if( val2.first == AXIS ) { deadzone += deadzones[ GUID ][ axisID ]; deadzone /= 2.0; deadzoneMode = deadzoneMode || deadzoneModes[ GUID ][ axisID ]; } break; } // For simplicity, just map the triggers to the line y = x case 2: { xAxis = SDL_CONTROLLER_AXIS_TRIGGERLEFT; yAxis = SDL_CONTROLLER_AXIS_TRIGGERLEFT; Val val = gameControllerToJoystick[ GUID ][ Key( AXIS, SDL_CONTROLLER_AXIS_TRIGGERLEFT ) ]; int axisID = val.second.first; if( val.first == AXIS ) { deadzone = deadzones[ GUID ][ axisID ]; deadzoneMode = deadzoneModes[ GUID ][ axisID ]; } break; } case 3: { xAxis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT; yAxis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT; Val val = gameControllerToJoystick[ GUID ][ Key( AXIS, SDL_CONTROLLER_AXIS_TRIGGERRIGHT ) ]; int axisID = val.second.first; if( val.first == AXIS ) { deadzone = deadzones[ GUID ][ axisID ]; deadzoneMode = deadzoneModes[ GUID ][ axisID ]; } break; } } // Map from [-32768, 32767] to [0, 32767] if( !deadzoneMode ) { gamepad.axis[ xAxis ] /= 2; gamepad.axis[ yAxis ] /= 2; gamepad.axis[ xAxis ] += 16384; gamepad.axis[ yAxis ] += 16384; } // Get axis coords in cartesian coords // Bottom right is positive -> top right is positive qreal xCoord = gamepad.axis[ xAxis ]; qreal yCoord = -gamepad.axis[ yAxis ]; // Get radius from center QVector2D position( static_cast<float>( xCoord ), static_cast<float>( yCoord ) ); qreal radius = static_cast<qreal>( position.length() ); if( !( radius > deadzone ) ) { gamepad.axis[ xAxis ] = 0; gamepad.axis[ yAxis ] = 0; if( xAxis == SDL_CONTROLLER_AXIS_TRIGGERLEFT ) { gamepad.digitalL2 = false; } if( xAxis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT ) { gamepad.digitalR2 = false; } } else { if( xAxis == SDL_CONTROLLER_AXIS_TRIGGERLEFT ) { gamepad.digitalL2 = true; } if( xAxis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT ) { gamepad.digitalR2 = true; } } } } // Apply deadzones to all joystick axes // Used only when detecting input for remapping { for( int i = 0; i < 16; i++ ) { qreal deadzoneRadius = deadzones[ GUID ][ i ]; qreal coord = gamepad.joystickAxis[ i ]; if( !deadzoneModes[ GUID ][ i ] ) { coord += 32768; } if( !( qAbs( coord ) > deadzoneRadius ) ) { gamepad.joystickAxis[ i ] = 0; } } } // If ignoreMode is set, the user hasn't let go of the button they were remapping to // Do not let the button go through until they let go { if( ignoreMode && ignoreModeGUID == GUID && ignoreModeInstanceID == gamepad.instanceID ) { if( ignoreModeVal.first == BUTTON ) { if( gamepad.joystickButton[ ignoreModeVal.second.first ] == SDL_PRESSED ) { gamepad.joystickButton[ ignoreModeVal.second.first ] = SDL_RELEASED; } else { ignoreMode = false; } } else if( ignoreModeVal.first == HAT ) { if( gamepad.joystickHat[ ignoreModeVal.second.first ] != SDL_HAT_CENTERED ) { gamepad.joystickHat[ ignoreModeVal.second.first ] = SDL_HAT_CENTERED; } else { ignoreMode = false; } } else if( ignoreModeVal.first == AXIS ) { if( gamepad.joystickAxis[ ignoreModeVal.second.first ] != 0 ) { gamepad.joystickAxis[ ignoreModeVal.second.first ] = 0; } else { ignoreMode = false; } } } } // If we opened an SDL2 Game controller handle from this class, keep it and inject it into all gamepads we send out { if( gameControllerHandles[ instanceID ] ) { gamepad.gamecontrollerHandle = gameControllerHandles[ instanceID ]; } } // If we are in remap mode, check for a button press from the stored GUID, and remap the stored button to that button // All game controller states are cleared past this point if in remap mode { if( remapMode && GUID == remapModeGUID ) { // Find a button press, the first one we encounter will be the new remapping bool foundInput = false; Key key = remapModeKey; Val value = Val( INVALID, VHat( -1, -1 ) ); // Prioritize buttons and hats over analog sticks for( int joystickButton = 0; joystickButton < 256; joystickButton++ ) { if( gamepad.joystickButton[ joystickButton ] == SDL_PRESSED ) { qCDebug( phxInput ).nospace() << "Button b" << joystickButton << " from GUID " << GUID << " now activates " << keyToMappingString( key ); foundInput = true; value.first = BUTTON; value.second = VHat( joystickButton, -1 ); break; } } for( int joystickHat = 0; joystickHat < 16; joystickHat++ ) { if( gamepad.joystickHat[ joystickHat ] != SDL_HAT_CENTERED ) { qCDebug( phxInput ).nospace() << "Hat h" << joystickHat << "." << gamepad.joystickHat[ joystickHat ] << " from GUID " << GUID << " now activates " << keyToMappingString( key ); foundInput = true; value.first = HAT; value.second = VHat( joystickHat, gamepad.joystickHat[ joystickHat ] ); break; } } for( int joystickAxis = 0; joystickAxis < 16; joystickAxis++ ) { if( gamepad.joystickAxis[ joystickAxis ] != 0 ) { qCDebug( phxInput ).nospace() << "Axis a" << joystickAxis << " from GUID " << GUID << " now activates " << keyToMappingString( key ); foundInput = true; value.first = AXIS; value.second = VHat( joystickAxis, -1 ); break; } } if( foundInput ) { // Store the new remapping internally gameControllerToJoystick[ GUID ][ remapModeKey ] = value; // Tell SDL2 about it QString mappingString; QString platform( SDL_GetPlatform() ); { QString friendlyName = QString( SDL_JoystickName( gamepad.joystickHandle ) ); mappingString.append( GUID ).append( "," ).append( friendlyName ).append( "," ); for( Key key : gameControllerToJoystick[ GUID ].keys() ) { if( gameControllerToJoystick[ GUID ][ key ].first != INVALID ) { mappingString.append( keyToMappingString( key ) ).append( ':' ) .append( valToMappingString( gameControllerToJoystick[ GUID ][ key ] ) ).append( ',' ); } } mappingString.append( "platform:" ).append( platform ).append( "," ); qDebug().nospace() << mappingString; // Give SDL the new mapping string SDL_GameControllerAddMapping( mappingString.toUtf8().constData() ); // If this is not a game controller, reopen as one SDL_GameController *gamecontrollerHandle = nullptr; if( !gameControllerHandles[ instanceID ] ) { gamecontrollerHandle = SDL_GameControllerOpen( joystickID ); gamepad.gamecontrollerHandle = gamecontrollerHandle; // Store internally so we can inject it into all future events from this instanceID gameControllerHandles[ instanceID ] = gamecontrollerHandle; qDebug() << "Opened newly remapped joystick as a game controller:" << gamecontrollerHandle; } } // Store this mapping to disk { if( !userDataPath.isEmpty() ) { QFile mappingFile( userDataPath + "/gamecontrollerdb.txt" ); mappingFile.open( QIODevice::ReadWrite | QIODevice::Text ); QByteArray mappingFileData = mappingFile.readAll(); if( !mappingFile.isOpen() ) { qWarning() << "Unable to open mapping file for reading" << mappingFile.errorString(); } mappingFile.close(); QTextStream mappingFileStreamIn( &mappingFileData ); mappingFileStreamIn.setCodec( "UTF-8" ); mappingFile.open( QIODevice::WriteOnly | QIODevice::Text ); if( !mappingFile.isOpen() ) { qWarning() << "Unable to open mapping file for writing" << mappingFile.errorString(); } QTextStream mappingFileStreamOut( &mappingFile ); mappingFileStreamOut.setCodec( "UTF-8" ); QString line = ""; while( !line.isNull() ) { line = mappingFileStreamIn.readLine(); // We want to replace the line (any line) for our platform that contains our GUID // We'll also filter out empty lines if( line.isEmpty() || ( line.contains( GUID ) && line.contains( platform ) ) ) { continue; } mappingFileStreamOut << line << endl; } mappingFileStreamOut << mappingString << endl; mappingFile.close(); } else { qWarning() << "Unable to open controller mapping file, user data path not set"; } } // End remap mode, start ignore mode { remapMode = false; ignoreMode = true; ignoreModeGUID = GUID; ignoreModeVal = value; ignoreModeInstanceID = gamepad.instanceID; } // Tell the model we're done { emit setMapping( GUID, keyToMappingString( key ), valToFriendlyString( value ) ); emit remappingEnded(); } } // Clear all game controller states (joystick states are untouched) for( int i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { gamepad.button[ i ] = 0; } for( int i = 0; i < SDL_CONTROLLER_AXIS_MAX; i++ ) { gamepad.axis[ i ] = 0; } } else if( remapMode ) { // Clear all gamepad states for( int i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { gamepad.button[ i ] = 0; } for( int i = 0; i < SDL_CONTROLLER_AXIS_MAX; i++ ) { gamepad.axis[ i ] = 0; } } } // OR all joystick button, hat and analog states together by GUID for RemapperModel to indicate presses { for( int i = 0; i < 256; i++ ) { pressed[ GUID ] |= gamepad.joystickButton[ i ]; } for( int i = 0; i < 16; i++ ) { pressed[ GUID ] |= ( gamepad.joystickHat[ i ] != SDL_HAT_CENTERED ); } for( int i = 0; i < 16; i++ ) { pressed[ GUID ] |= ( gamepad.joystickAxis[ i ] != 0 ); } } // Apply axis to d-pad, if enabled // This will always be enabled if we're not currently playing so GlobalGamepad can use the analog stick { if( analogToDpad[ GUID ] || !playing ) { // TODO: Support other axes? int xAxis = SDL_CONTROLLER_AXIS_LEFTX; int yAxis = SDL_CONTROLLER_AXIS_LEFTY; // TODO: Let user configure these qreal threshold = 16384.0; // Size in degrees of the arc covering and centered around each cardinal direction // If <90, there will be gaps in the diagonals // If >180, this code will always produce diagonal inputs qreal rangeDegrees = 180.0 - 45.0; // Get axis coords in cartesian coords // Bottom right is positive -> top right is positive qreal xCoord = gamepad.axis[ xAxis ]; qreal yCoord = -gamepad.axis[ yAxis ]; // Get radius from center QVector2D position( static_cast<float>( xCoord ), static_cast<float>( yCoord ) ); qreal radius = static_cast<qreal>( position.length() ); // Get angle in degrees qreal angle = qRadiansToDegrees( qAtan2( yCoord, xCoord ) ); if( angle < 0.0 ) { angle += 360.0; } if( radius > threshold ) { qreal halfRange = rangeDegrees / 2.0; if( angle > 90.0 - halfRange && angle < 90.0 + halfRange ) { gamepad.button[ SDL_CONTROLLER_BUTTON_DPAD_UP ] = true; } if( angle > 270.0 - halfRange && angle < 270.0 + halfRange ) { gamepad.button[ SDL_CONTROLLER_BUTTON_DPAD_DOWN ] = true; } if( angle > 180.0 - halfRange && angle < 180.0 + halfRange ) { gamepad.button[ SDL_CONTROLLER_BUTTON_DPAD_LEFT ] = true; } if( angle > 360.0 - halfRange || angle < 0.0 + halfRange ) { gamepad.button[ SDL_CONTROLLER_BUTTON_DPAD_RIGHT ] = true; } } } } // Apply d-pad to axis, if enabled { if( dpadToAnalog[ GUID ] ) { gamepad = mapDpadToAnalog( gamepad ); } } // Send updated data out { // Copy current gamepad into buffer this->mutex.lock(); gamepadBuffer[ gamepadBufferIndex ] = gamepad; this->mutex.unlock(); // Send buffer on its way emit dataOut( DataType::Input, &( this->mutex ), reinterpret_cast<void *>( &gamepadBuffer[ gamepadBufferIndex ] ), 0, nodeCurrentTime() ); // Increment the index gamepadBufferIndex = ( gamepadBufferIndex + 1 ) % 100; } break; } case DataType::KeyboardInput: { // Unpack keyboard states and write to gamepad according to remap data { mutex->lock(); KeyboardState keyboard = *reinterpret_cast<KeyboardState *>( data ); for( int i = keyboard.head; i < keyboard.tail; i = ( i + 1 ) % 128 ) { int key = keyboard.key[ i ]; bool pressed = keyboard.pressed[ i ]; if( keyboardKeyToSDLButton.contains( key ) ) { keyboardGamepad.button[ keyboardKeyToSDLButton[ key ] ] = pressed ? SDL_PRESSED : SDL_RELEASED; } } mutex->unlock(); } // OR all key states together and store that value for( int i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { keyboardKeyPressed |= keyboardGamepad.button[ i ]; } // Apply d-pad to axis, if enabled if( dpadToAnalogKeyboard ) { keyboardGamepad = mapDpadToAnalog( keyboardGamepad, true ); } // Send gamepad on its way { // Copy current gamepad into buffer this->mutex.lock(); gamepadBuffer[ gamepadBufferIndex ] = keyboardGamepad; this->mutex.unlock(); // Send buffer on its way emit dataOut( DataType::Input, &( this->mutex ), reinterpret_cast< void * >( &gamepadBuffer[ gamepadBufferIndex ] ), 0, nodeCurrentTime() ); // Increment the index gamepadBufferIndex = ( gamepadBufferIndex + 1 ) % 100; } break; } default: { emit dataOut( type, mutex, data, bytes, timeStamp ); break; } } }
bool isIMX31L() { return platform() == IM31L; }
int main(int argc, char* argv[]) { SpiderConfig cfg; ExecutionStat stat; initActors(); DynStack pisdfStack("PisdfStack"); DynStack archiStack("ArchiStack"); #define SH_MEM 0x00500000 PlatformLinux platform(4, SH_MEM, &archiStack, daq_fft_fcts, N_FCT_DAQ_FFT); Archi* archi = platform.getArchi(); cfg.memAllocType = MEMALLOC_SPECIAL_ACTOR; cfg.memAllocStart = (void*)0; cfg.memAllocSize = SH_MEM; cfg.schedulerType = SCHEDULER_LIST; cfg.srdagStack = {STACK_DYNAMIC, "SrdagStack", 0, 0}; cfg.transfoStack = {STACK_DYNAMIC, "TransfoStack", 0, 0}; spider_init(cfg); printf("Start\n"); // try{ PiSDFGraph *topPisdf = init_daq_fft(archi, &pisdfStack); topPisdf->print("topPisdf.gv"); Platform::get()->rstTime(); spider_launch(archi, topPisdf); spider_printGantt(archi, spider_getLastSRDAG(), "daq_fft.pgantt", "latex.tex", &stat); spider_getLastSRDAG()->print("daq_fft.gv"); printf("EndTime = %d ms\n", stat.globalEndTime/1000000); printf("Memory use = "); if(stat.memoryUsed < 1024) printf("\t%5.1f B", stat.memoryUsed/1.); else if(stat.memoryUsed < 1024*1024) printf("\t%5.1f KB", stat.memoryUsed/1024.); else if(stat.memoryUsed < 1024*1024*1024) printf("\t%5.1f MB", stat.memoryUsed/1024./1024.); else printf("\t%5.1f GB", stat.memoryUsed/1024./1024./1024.); printf("\n"); FILE* f = fopen("timings.csv", "w+"); fprintf(f, "Actors,x86\n"); printf("Actors:\n"); for(int j=0; j<stat.nbActor; j++) { printf("\t%12s:", stat.actors[j]->getName()); fprintf(f, "%s", stat.actors[j]->getName()); for(int k=0; k<archi->getNPETypes(); k++) { printf("\t%d (x%d)", stat.actorTimes[j][k]/stat.actorIterations[j][k], stat.actorIterations[j][k]); fprintf(f, ",%d", stat.actorTimes[j][k]/stat.actorIterations[j][k]); } printf("\n"); fprintf(f, "\n"); } free_daq_fft(topPisdf, &pisdfStack); // }catch(const char* s){ // printf("Exception : %s\n", s); // } printf("finished\n"); spider_free(); return 0; }
int main(int argc, char* argv[]){ SpiderConfig cfg; ExecutionStat stat; initActors(); DynStack pisdfStack("PisdfStack"); DynStack archiStack("ArchiStack"); #define SH_MEM 0x00500000 PlatformK2Arm platform(2, 4, SH_MEM, &archiStack, radix2_fft_fcts, N_FCT_RADIX2_FFT); Archi* archi = platform.getArchi(); cfg.memAllocType = MEMALLOC_SPECIAL_ACTOR; cfg.memAllocStart = (void*)0; cfg.memAllocSize = SH_MEM; cfg.schedulerType = SCHEDULER_LIST; cfg.srdagStack.type = STACK_DYNAMIC; cfg.srdagStack.name = "SrdagStack"; cfg.srdagStack.size = 0; cfg.srdagStack.start = 0; cfg.transfoStack.type = STACK_DYNAMIC; cfg.transfoStack.name = "TransfoStack"; cfg.transfoStack.size = 0; cfg.transfoStack.start = 0; spider_init(cfg); printf("Start\n"); try{ pisdfStack.freeAll(); PiSDFGraph *topPisdf = init_Radix2_fft(archi, &pisdfStack); topPisdf->print("topPisdf.gv"); Platform::get()->rstTime(); spider_launch(archi, topPisdf); spider_printGantt(archi, spider_getLastSRDAG(), "radixFFT_2.pgantt", "latex.tex", &stat); spider_getLastSRDAG()->print("radixFFT_2.gv"); printf("EndTime = %ld us\n", stat.globalEndTime/1000); printf("Memory use = "); if(stat.memoryUsed < 1024) printf("\t%5.1f B", stat.memoryUsed/1.); else if(stat.memoryUsed < 1024*1024) printf("\t%5.1f KB", stat.memoryUsed/1024.); else if(stat.memoryUsed < 1024*1024*1024) printf("\t%5.1f MB", stat.memoryUsed/1024./1024.); else printf("\t%5.1f GB", stat.memoryUsed/1024./1024./1024.); printf("\n"); printf("Actors:\n"); for(int j=0; j<stat.nbActor; j++){ printf("\t%18s:", stat.actors[j]->getName()); for(int k=0; k<archi->getNPETypes(); k++) printf("\t%8ld (x%3ld)", stat.actorTimes[j][k]/stat.actorIterations[j][k], stat.actorIterations[j][k]); printf("\n"); } free_Radix2_fft(topPisdf, &pisdfStack); }catch(const char* s){ printf("Exception : %s\n", s); } printf("finished\n"); spider_free(); return 0; }
void Updates::buildQuery() { Query = QString("/update-new.php?uuid=%1&version=%2").arg(ConfigurationManager::instance()->uuid().toString()).arg(Core::version()); if (Application::instance()->configuration()->deprecatedApi()->readBoolEntry("General", "SendSysInfo"), true) { QString platform("&system="); #if defined(Q_OS_LINUX) platform.append("Linux-"); QFile issue("/etc/issue"); if (issue.open(QIODevice::ReadOnly | QIODevice::Text)) { QString tmp = issue.readLine(); tmp.truncate(tmp.indexOf(" ")); platform.append(tmp); issue.close(); } else platform.append("Unknown"); #elif defined(Q_OS_FREEBSD) platform.append("FreeBSD"); #elif defined(Q_OS_NETBSD) platform.append("NetBSD"); #elif defined(Q_OS_OPENBSD) platform.append("OpenBSD"); #elif defined(Q_OS_SOLARIS) platform.append("Solaris"); #elif defined(Q_OS_MAC) switch (QSysInfo::MacintoshVersion) { case QSysInfo::MV_PANTHER: platform.append("MacOSX-Panther"); break; case QSysInfo::MV_TIGER: platform.append("MacOSX-Tiger"); break; case QSysInfo::MV_LEOPARD: platform.append("MacOSX-Leopard"); break; case QSysInfo::MV_SNOWLEOPARD: platform.append("MacOSX-SnowLeopard"); break; default: platform.append("MacOSX-Unknown"); break; } #elif defined(Q_OS_WIN) switch (QSysInfo::WindowsVersion) { case QSysInfo::WV_95: platform.append("Windows95"); break; case QSysInfo::WV_98: platform.append("Windows98"); break; case QSysInfo::WV_Me: platform.append("WindowsME"); break; case QSysInfo::WV_NT: platform.append("WindowsNT"); break; case QSysInfo::WV_2000: platform.append("Windows2000"); break; case QSysInfo::WV_XP: platform.append("WindowsXP"); break; case QSysInfo::WV_2003: platform.append("Windows2003"); break; case QSysInfo::WV_VISTA: platform.append("WindowsVista"); break; case QSysInfo::WV_WINDOWS7: platform.append("Windows7"); break; default: platform.append("Windows-Unknown"); break; } #elif defined(Q_OS_HAIKU) platform.append("Haiku OS"); #else platform.append("Unknown"); #endif Query.append(platform); } }
int main(void) { EGLDisplay m_eglDisplay; EGLContext m_eglContext; EGLSurface m_eglSurface; EGLint attributeList[] = { EGL_RED_SIZE, 1, EGL_DEPTH_SIZE, 1, EGL_NONE }; EGLint aEGLAttributes[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_DEPTH_SIZE, 16, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, EGL_NONE }; EGLint aEGLContextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE }; EGLConfig m_eglConfig[1]; EGLint nConfigs; unsigned char mIndices[] = { 0, 1, 2 }; signed short mVertices[] = { -50, -29, 0, 50, -29, 0, 0, 58, 0 }; HWND hwnd; HDC hdc; MSG sMessage; int bDone = 0; // Platform init. platform(&hwnd, 640, 480); ShowWindow(hwnd, SW_SHOW); SetForegroundWindow(hwnd); SetFocus(hwnd); // EGL init. hdc = GetDC(hwnd); m_eglDisplay = eglGetDisplay(hdc); eglInitialize(m_eglDisplay, NULL, NULL); eglChooseConfig(m_eglDisplay, aEGLAttributes, m_eglConfig, 1, &nConfigs); printf("EGLConfig = %p\n", m_eglConfig[0]); m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig[0], (NativeWindowType)hwnd, 0); m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig[0], EGL_NO_CONTEXT, aEGLContextAttributes); printf("EGLContext = %p\n", m_eglContext); eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_SHORT, 0, mVertices); /* Set projection matrix so screen extends to (-160, -120) at bottom left * and to (160, 120) at top right, with -128..128 as Z buffer. */ glMatrixMode(GL_PROJECTION); glOrthox(-160<<16, 160<<16, -120<<16, 120<<16, -128<<16, 128<<16); glMatrixMode(GL_MODELVIEW); glClearColorx(0x10000, 0x10000, 0, 0); glColor4x(0x10000, 0, 0, 0); // Main event loop while(!bDone) { // Do Windows stuff: if(PeekMessage(&sMessage, NULL, 0, 0, PM_REMOVE)) { if(sMessage.message == WM_QUIT) { bDone = 1; } else { TranslateMessage(&sMessage); DispatchMessage(&sMessage); } } glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, mIndices); glRotatex(2<<16, 0, 0, 0x10000); eglSwapBuffers(m_eglDisplay, m_eglSurface); Sleep(30); } // Exit. eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(m_eglDisplay, m_eglContext); eglDestroySurface(m_eglDisplay, m_eglSurface); eglTerminate(m_eglDisplay); ReleaseDC(hwnd, hdc); DestroyWindow(hwnd); return 0; }
virtual void draw(sf::Time deltaTime) { //std::cout << powerups.size() << "\n"; //statyczne scrollowanie if (clock.getElapsedTime().asSeconds()>5) { scrolling+=0.1; clock.restart(); } background1.move(0, scrolling); for (unsigned int i=0; i<platforms.size(); ++i) { platforms[i].sprite.move(0, scrolling); } for (unsigned int i=0; i<powerups.size(); i++) { powerups[i].move(0, scrolling); } for (unsigned int i=0; i<effects.size(); i++) { effects[i].move(0, scrolling); } //sprawdzanie czy tadzik jest w planszy if (spTadzik.sprite.getGlobalBounds().top>window->getSize().y) gameOver(); if (spTadzik.sprite.getGlobalBounds().left<0 && Utils::sgn(speedX)==-1) { speedX = -1.1*speedX; spTadzik.sprite.setPosition(spTadzik.sprite.getGlobalBounds().width/2, spTadzik.sprite.getPosition().y); } else if (spTadzik.sprite.getGlobalBounds().left+spTadzik.sprite.getGlobalBounds().width>window->getSize().x && Utils::sgn(speedX)==1) { speedX = -1.1*speedX; spTadzik.sprite.setPosition(window->getSize().x-spTadzik.sprite.getGlobalBounds().width/2, spTadzik.sprite.getPosition().y); } //input z klawiatury if (sf::Keyboard::isKeyPressed(sf::Keyboard::A) || sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) { speedX-=addSpeed; } if (sf::Keyboard::isKeyPressed(sf::Keyboard::D) || sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) { speedX+=addSpeed; } //przypadki if (isStanding) { if (std::abs(speedX)<0.001 && activeAnim!=0) { spTadzik.setAnimation(&TadzikStand); activeAnim = 0; } else if (std::abs(speedX)>0.001 && activeAnim!=1) { spTadzik.setAnimation(&TadzikRun); activeAnim = 1; } spTadzik.sprite.setPosition(spTadzik.sprite.getPosition().x, platforms[standingPlatformNumber].sprite.getPosition().y); if (sf::Keyboard::isKeyPressed(sf::Keyboard::W) || sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) { jump(speedX+Utils::sgn(speedX)*10); } if (!platforms[standingPlatformNumber].testForStanding(spTadzik.sprite)) isStanding = false; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) || sf::Keyboard::isKeyPressed(sf::Keyboard::S)) { isStanding = false; } } if (isSuperman && isJumping) { if (goUp<0) { //spTadzik.sprite.setTexture(texPlayerJumpSuper); isSuperman = false; } else { speedY-=1; goUp--; spTadzik.setAnimation(&TadzikJumpSuper); } } if (isRolling) { spTadzik.sprite.setRotation(Utils::sgn(speedX)*speedY*20); } if (!isStanding) { speedY += gravity; if (speedY>0) { if (isJumping) spTadzik.setAnimation(&TadzikFall); isJumping = false; isRolling = false; spTadzik.sprite.setOrigin(spTadzik.sprite.getTextureRect().width/2, spTadzik.sprite.getTextureRect().height); spTadzik.sprite.setRotation(0); } if (isJumping) { if (spTadzik.sprite.getPosition().y>window->getSize().y*(1.0/3.0)) { spTadzik.sprite.move(0, speedY); } else { background1.move(0, -speedY); for (unsigned int i=0; i<platforms.size(); ++i) { platforms[i].sprite.move(0, -speedY); } for (unsigned int i=0; i<powerups.size(); i++) { powerups[i].move(0, -speedY); } } } else { spTadzik.sprite.move(0, speedY); } score-=speedY; } //sprawdzanie czy stoi na jakiejs platformie for (unsigned int i=0; i<platforms.size(); ++i) { if (platforms[i].isAbove(spTadzik.sprite)) { if (platforms[i].testForStanding(spTadzik.sprite) && !isJumping) { //std::cout << "standing on " << standingPlatformNumber << "\n"; isStanding = true; standingPlatformNumber = i; spTadzik.sprite.setPosition(spTadzik.sprite.getPosition().x, platforms[standingPlatformNumber].sprite.getPosition().y); spTadzik.setAnimation(&TadzikRun); speedY=0; } } } //obracanie if (Utils::sgn(prevSpeedX)!=Utils::sgn(speedX)) { flip(); prevSpeedX=speedX; } //dodawanie platform i powerupow if (score - lastPlatformGenerated > window->getSize().y/2) { if (Utils::randFloat(0, 50)<10) { powerup1.setPosition(Utils::randFloat(10, window->getSize().x-10), Utils::randFloat(-100, -50)); powerup1.setScale(3, 3); powerups.push_back(powerup1); } int tmp = Utils::randFloat(-100, -50); lastPlatformGenerated = score + tmp; tmpPlatform.setPosition(Utils::randFloat(0, window->getSize().x-tmpPlatform.getTextureRect().width), tmp); tmpPlatform.setScale(Utils::randFloat(1, 3), 1); platforms.push_back(platform(tmpPlatform)); } //glupoty spTadzik.sprite.move(speedX, 0); speedX*=(1-airResistance); spTadzik.update(std::abs(speedX)*deltaTime.asMilliseconds()); if (score>highScore) highScore=score; textScore.setString(Utils::stringify(highScore/10)); //rysowanie window->clear(); window->draw(background1); window->draw(textScore); //ogarnianie objektow for (int i=platforms.size()-1; i>=0; --i) { if (platforms[i].sprite.getPosition().y>window->getSize().y+500) { platforms.erase(platforms.begin()+i); } window->draw(platforms[i].sprite); } for (int i=powerups.size()-1; i>=0; --i) { if (Collision::PixelPerfectTest(powerups[i], spTadzik.sprite)) { isSuperman = true; goUp = 40; powerups.erase(powerups.begin()+i); } if (powerups[i].getPosition().y>window->getSize().y+500) { powerups.erase(powerups.begin()+i); } if(powerups.size() > 0) window->draw(powerups[i]); } window->draw(spTadzik.sprite); if (highScore>20000) { sceneManager->callMeBaby(); } }
void OpenCL::setDevice(cl::Device device, bool glSharing) { try { // Check if we are setting the same device if (gpuDevice_() == device()) { std::vector<cl_context_properties> sharingProperties = getGLSharingContextProperties(); std::vector<cl_context_properties> contextProperties = gpuContext_.getInfo<CL_CONTEXT_PROPERTIES>(); bool sharingEnabled = (std::find(contextProperties.begin(), contextProperties.end(), *sharingProperties.begin()) != contextProperties.end()); if (sharingEnabled == glSharing) { // The device and sharing properties are the same. // No need to update the device return; } } gpuDevice_ = device; cl::Platform platform = device.getInfo<CL_DEVICE_PLATFORM>(); std::vector<cl_context_properties> properties; if (glSharing) properties = getGLSharingContextProperties(); cl_context_properties platformProperties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)platform(), 0}; properties.insert(properties.end(), platformProperties, platformProperties+ sizeof(platformProperties)/sizeof(cl_context_properties)); try { gpuContext_ = cl::Context(gpuDevice_, &properties[0]); } catch (cl::Error&) { LogInfo("ERROR: Unable to create OpenCL context. Trying to create without openGL sharing... "); properties.clear(); properties.insert(properties.end(), platformProperties, platformProperties+ sizeof(platformProperties)/sizeof(cl_context_properties)); gpuContext_ = cl::Context(gpuDevice_, &properties[0]); LogInfo("Succeeded creating OpenCL without OpenGL sharing. "); } cl_command_queue_properties queueProperties = 0; cl_command_queue_properties supportedQueueProperties; gpuDevice_.getInfo(CL_DEVICE_QUEUE_PROPERTIES, &supportedQueueProperties); #if IVW_PROFILING if (supportedQueueProperties & CL_QUEUE_PROFILING_ENABLE) queueProperties |= CL_QUEUE_PROFILING_ENABLE; #endif synchronosGPUQueue_ = cl::CommandQueue(gpuContext_, gpuDevice_, queueProperties); if (supportedQueueProperties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) queueProperties |= CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; asyncGPUQueue_ = cl::CommandQueue(gpuContext_, gpuDevice_, queueProperties); STRING_CLASS deviceExtensions = gpuDevice_.getInfo<CL_DEVICE_EXTENSIONS>(); size_t foundAt = deviceExtensions.find_first_of("cl_khr_gl_event"); if (foundAt != std::string::npos) { // Efficient cl/gl synchronization possible } } catch (cl::Error& err) { LogError("Faile to set OpenCL device. " << err.what() << "(" << err.err() << "), " << errorCodeToString(err.err()) << std::endl); } }
bool isAk98() { return platform() == AK98; }
int main(int argc, char* argv[]){ SpiderConfig cfg; ExecutionStat stat; initActors(); DynStack pisdfStack("PisdfStack"); DynStack archiStack("ArchiStack"); //#define SH_MEM 0x00500000 #define SH_MEM 0x10000000 PlatformLinux platform(1, SH_MEM, &archiStack, top_fft_fcts, N_FCT_TOP_FFT); Archi* archi = platform.getArchi(); cfg.memAllocType = MEMALLOC_SPECIAL_ACTOR; cfg.memAllocStart = (void*)0; cfg.memAllocSize = SH_MEM; cfg.schedulerType = SCHEDULER_LIST; cfg.srdagStack = {STACK_DYNAMIC, "SrdagStack", 0, 0}; cfg.transfoStack = {STACK_DYNAMIC, "TransfoStack", 0, 0}; spider_init(cfg); printf("Start\n"); // try{ for(int i=1; i<=3; i++){ // printf("NStep = %d\n", i); char ganttPath[30]; sprintf(ganttPath, "radixFFT_%d.pgantt", i); char srdagPath[30]; sprintf(srdagPath, "radixFFT_%d.gv", i); pisdfStack.freeAll(); PiSDFGraph *topPisdf = init_top_fft(archi, &pisdfStack); topPisdf->print("topPisdf.gv"); Platform::get()->rstTime(); spider_launch(archi, topPisdf); // spider_printGantt(archi, spider_getLastSRDAG(), ganttPath, "latex.tex", &stat); spider_getLastSRDAG()->print(srdagPath); printf("EndTime = %d ms\n", stat.globalEndTime/1000000); printf("Memory use = "); if(stat.memoryUsed < 1024) printf("\t%5.1f B", stat.memoryUsed/1.); else if(stat.memoryUsed < 1024*1024) printf("\t%5.1f KB", stat.memoryUsed/1024.); else if(stat.memoryUsed < 1024*1024*1024) printf("\t%5.1f MB", stat.memoryUsed/1024./1024.); else printf("\t%5.1f GB", stat.memoryUsed/1024./1024./1024.); printf("\n"); // printf("Actors:\n"); // for(int j=0; j<stat.nbActor; j++){ // printf("\t%12s:", stat.actors[j]->getName()); // for(int k=0; k<archi->getNPETypes(); k++) // printf("\t%d (x%d)", // stat.actorTimes[j][k]/stat.actorIterations[j][k], // stat.actorIterations[j][k]); // printf("\n"); // } free_top_fft(topPisdf, &pisdfStack); } // }catch(const char* s){ // printf("Exception : %s\n", s); // } printf("finished\n"); spider_free(); return 0; }
int main(int argc, char* argv[]) { SpiderConfig cfg; ExecutionStat stat; // initActors(); StaticStack pisdfStack("PisdfStack", pisdfStackMem, PISDF_SIZE); StaticStack archiStack("ArchiStack", archiStackMem, ARCHI_SIZE); #define SH_MEM 0x04000000 PlatformK2Arm platform(1, 0, USE_DDR, SH_MEM, &archiStack, stereo_fcts, N_FCT_STEREO); Archi* archi = platform.getArchi(); cfg.memAllocType = MEMALLOC_SPECIAL_ACTOR; cfg.memAllocStart = (void*)0; cfg.memAllocSize = SH_MEM; cfg.schedulerType = SCHEDULER_LIST; cfg.srdagStack.type = STACK_STATIC; cfg.srdagStack.name = "SrdagStack"; cfg.srdagStack.size = SRDAG_SIZE; cfg.srdagStack.start = srdagStack; cfg.transfoStack.type = STACK_STATIC; cfg.transfoStack.name = "TransfoStack"; cfg.transfoStack.size = TRANSFO_SIZE; cfg.transfoStack.start = transfoStack; spider_init(cfg); printf("Start\n"); try { int i=1; // for(int i=1; i<=1; i++){ printf("NStep = %d\n", i); char ganttPath[30]; sprintf(ganttPath, "stereo.pgantt"); char srdagPath[30]; sprintf(srdagPath, "stereo.gv"); pisdfStack.freeAll(); PiSDFGraph *topPisdf = init_stereo(archi, &pisdfStack); topPisdf->print("topPisdf.gv"); Platform::get()->rstTime(); spider_launch(archi, topPisdf); // spider_printGantt(archi, spider_getLastSRDAG(), ganttPath, "latex.tex", &stat); spider_getLastSRDAG()->print(srdagPath); printf("EndTime = %d ms\n", stat.globalEndTime/1000000); printf("Memory use = "); if(stat.memoryUsed < 1024) printf("\t%5.1f B", stat.memoryUsed/1.); else if(stat.memoryUsed < 1024*1024) printf("\t%5.1f KB", stat.memoryUsed/1024.); else if(stat.memoryUsed < 1024*1024*1024) printf("\t%5.1f MB", stat.memoryUsed/1024./1024.); else printf("\t%5.1f GB", stat.memoryUsed/1024./1024./1024.); printf("\n"); printf("Actors:\n"); for(int j=0; j<stat.nbActor; j++) { printf("\t%12s:", stat.actors[j]->getName()); for(int k=0; k<archi->getNPETypes(); k++) printf("\t%d (x%d)", stat.actorTimes[j][k]/stat.actorIterations[j][k], stat.actorIterations[j][k]); printf("\n"); } free_stereo(topPisdf, &pisdfStack); // } } catch(const char* s) { printf("Exception : %s\n", s); } printf("finished\n"); spider_free(); return 0; }
int main(int argc, char* argv[]){ SpiderConfig cfg; ExecutionStat stat; initActors(); DynStack pisdfStack("PisdfStack"); DynStack archiStack("ArchiStack"); #define SH_MEM 0x00500000 PlatformK2Arm platform(4, 8, SH_MEM, &archiStack, daq_fft_fcts, N_FCT_DAQ_FFT); Archi* archi = platform.getArchi(); cfg.memAllocType = MEMALLOC_SPECIAL_ACTOR; cfg.memAllocStart = (void*)0; cfg.memAllocSize = SH_MEM; cfg.schedulerType = SCHEDULER_LIST; cfg.srdagStack = {STACK_DYNAMIC, "SrdagStack", 0, 0}; cfg.transfoStack = {STACK_DYNAMIC, "TransfoStack", 0, 0}; spider_init(cfg); printf("Start\n"); try{ PiSDFGraph *topPisdf = init_daq_fft(archi, &pisdfStack); topPisdf->print("topPisdf.gv"); for(int i=0; i<2; i++){ Platform::get()->rstTime(); spider_launch(archi, topPisdf); spider_printGantt(archi, spider_getLastSRDAG(), "dac_fft_group_fixed.pgantt", "dac_fft_group_fixed.tex", &stat); spider_getLastSRDAG()->print("dac_fft_group.gv"); printf("EndTime = %ld ms\n", stat.globalEndTime/1000000); printf("Memory use = "); if(stat.memoryUsed < 1024) printf("\t%5.1f B", stat.memoryUsed/1.); else if(stat.memoryUsed < 1024*1024) printf("\t%5.1f KB", stat.memoryUsed/1024.); else if(stat.memoryUsed < 1024*1024*1024) printf("\t%5.1f MB", stat.memoryUsed/1024./1024.); else printf("\t%5.1f GB", stat.memoryUsed/1024./1024./1024.); printf("\n"); FILE* f = fopen("timings.csv", "w+"); fprintf(f, "Actors,c6678,CortexA15\n"); Time fftTime = 0; printf("Actors:\n"); for(int j=0; j<stat.nbActor; j++){ printf("\t%12s:", stat.actors[j]->getName()); fprintf(f, "%s", stat.actors[j]->getName()); for(int k=0; k<archi->getNPETypes(); k++){ if(stat.actorIterations[j][k] > 0){ printf("\t(%d): %8ld (x%ld)", k, stat.actorTimes[j][k]/stat.actorIterations[j][k], stat.actorIterations[j][k]); fprintf(f, ",%ld", stat.actorTimes[j][k]/stat.actorIterations[j][k]); }else{ printf("\t(%d): 0 (x0)", k); fprintf(f, ",%ld", (Time)-1); } } if(strcmp(stat.actors[j]->getName(), "T_1") == 0){ fftTime -= stat.actorFisrt[j]; } if(strcmp(stat.actors[j]->getName(), "T_6") == 0){ fftTime += stat.actorLast[j]; } printf("\n"); fprintf(f, "\n"); } printf("fftTime = %ld us\n", fftTime/1000); } free_daq_fft(topPisdf, &pisdfStack); }catch(const char* s){ printf("Exception : %s\n", s); } printf("finished\n"); spider_free(); return 0; }
bool TargetRunner::Load() { LOG (INFO) << "Reading config file..."; TiXmlDocument doc( VFS->GetRelativePath(this->configPath).c_str()); bool status = doc.LoadFile(); if (!status) { LOG (LERROR) << "LERROR on loading xml document!"; return false; } TiXmlElement *target = doc .FirstChildElement(Constants::XML_TAG_BUILD_CONFIG) ->FirstChildElement(Constants::XML_TAG_BUILD_TARGET); TiXmlElement *opt; while (target) { const char* value = target->Attribute(Constants::XML_ATTR_TARGET_NAME); if (!value) { LOG(LERROR) << "Every target must have a name!"; return false; } cpp0x::shared_ptr<Target> buildTarget (new Target()); cpp0x::shared_ptr<std::string> name(new std::string(value)); buildTarget->SetTargetName(name); if (std::string(value).compare(Constants::DEFAULT_TARGET_NAME) == 0) { value = target->Attribute(Constants::XML_ATTR_TO_BE_BUILT); if (value) { defaultTargetName = std::string(value); } } if (opt = target->FirstChildElement(Constants::XML_TAG_PLATFORM)) { cpp0x::shared_ptr<std::string> platform(new std::string(opt->GetText())); buildTarget->SetPlatform(platform); } if (opt = target->FirstChildElement(Constants::XML_TAG_PROJECT_DIR)) { cpp0x::shared_ptr<std::string> projectDir(new std::string(opt->GetText())); buildTarget->SetProjectDir(projectDir); } if (opt = target->FirstChildElement(Constants::XML_TAG_BUILD_DIR)) { cpp0x::shared_ptr<std::string> buildDir(new std::string(opt->GetText())); buildTarget->SetBuildDir(buildDir); } if (opt = target->FirstChildElement(Constants::XML_TAG_CMAKE_PROJECT_TYPE)) { cpp0x::shared_ptr<std::string> cmakeProjectType(new std::string(opt->GetText())); buildTarget->SetCmakeProjectType(cmakeProjectType); } if (opt = target->FirstChildElement(Constants::XML_TAG_CUSTOM_ARGS)) { cpp0x::shared_ptr<std::string> customArgs(new std::string(opt->GetText())); buildTarget->SetCustomArgs(customArgs); } if (opt = target->FirstChildElement(Constants::XML_TAG_PROJECTS_ROOT_DIR)) { cpp0x::shared_ptr<std::string> projectsRootDir(new std::string(opt->GetText())); buildTarget->SetProjectsRootDir(projectsRootDir); } if (opt = target->FirstChildElement(Constants::XML_TAG_KRAL_PATH)) { cpp0x::shared_ptr<std::string> kralPath(new std::string(opt->GetText())); buildTarget->SetKralPath(kralPath); } if (opt = target->FirstChildElement(Constants::XML_TAG_CMAKE)) { cpp0x::shared_ptr<std::string> cmake(new std::string(opt->GetText())); buildTarget->SetCmake(cmake); } if (opt = target->FirstChildElement(Constants::XML_TAG_ANDROID_API_LEVEL)) { cpp0x::shared_ptr<std::string> androidApiLevel(new std::string(opt->GetText())); buildTarget->SetAndroidApiLevel(androidApiLevel); } if (opt = target->FirstChildElement(Constants::XML_TAG_ANDROID_ARM_TARGET)) { cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText())); buildTarget->SetAndroidArmTarget(value); } if (opt = target->FirstChildElement(Constants::XML_TAG_BUILD_TYPE)) { cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText())); buildTarget->SetBuildType(value); } else { cpp0x::shared_ptr<std::string> value(new std::string("Debug")); buildTarget->SetBuildType(value); } if (opt = target->FirstChildElement(Constants::XML_TAG_ANDROID_ASSETS)) { cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText())); buildTarget->SetAssets(value); } if (opt = target->FirstChildElement(Constants::XML_TAG_COMPILER_CUSTOM_OPTS)) { cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText())); buildTarget->SetCompilerCustomOptions(value); } if (opt = target->FirstChildElement(Constants::XML_TAG_PACKAGE_DIRS)) { cpp0x::shared_ptr<std::string> value(new std::string(opt->GetText())); buildTarget->SetPackageDirs(value); } if (buildTarget->GetTargetName()->compare(Constants::DEFAULT_TARGET_NAME) == 0) { this->defaultTarget = buildTarget; } else { this->targets.push_back(buildTarget); } target = target->NextSiblingElement(); } return true; }
bool isImx508() { return platform() == IMX508; }
int main(){ #if DSP PlatformK2Dsp platform(0); #else PlatformLinux platform(0); #endif FILE* fres; printf("Start\n"); try{ fres = fopen("omp/omp_homo.csv", "w+"); int iter = 1; for(iter=1; iter<=17; iter++){ printf("h**o %d\n", iter); OmpMonitor monitor(0); hclm_sched( /*MNext*/ 0, /*MStart*/ 12, /*N*/ iter, /*NbS*/ 4000, &monitor); monitor.saveData(iter, "h**o"); fprintf(fres, "%d,%d\n", iter, monitor.getEndTime()); } fclose(fres); fres = fopen("omp/omp_inc.csv", "w+"); for(iter=1; iter<=17; iter++){ printf("inc %d\n", iter); OmpMonitor monitor(0); hclm_sched( /*MNext*/ 1, /*MStart*/ 1, /*N*/ iter, /*NbS*/ 4000, &monitor); monitor.saveData(iter, "inc"); fprintf(fres, "%d,%d\n", iter, monitor.getEndTime()); } fclose(fres); fres = fopen("omp/omp_dec.csv", "w+"); for(iter=1; iter<=17; iter++){ printf("dec %d\n", iter); OmpMonitor monitor(0); hclm_sched( /*MNext*/ -1, /*MStart*/ iter, /*N*/ iter, /*NbS*/ 4000, &monitor); monitor.saveData(iter, "dec"); fprintf(fres, "%d,%d\n", iter, monitor.getEndTime()); } fclose(fres); }catch(char const* ex){ printf("Error: %s\n",ex); } printf("End\n"); return 0; }