static int undup_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { char b[PATH_MAX+1]; int n, ret; struct stub *stub; double t0, t1; t0 = rtc(); n = snprintf(b, PATH_MAX, "%s/%s", state->basedir, path); if (n > PATH_MAX) return -ENAMETOOLONG; stub = (struct stub *)fi->fh; if (!stub) return -EIO; debug("undup_read off=%lld size=%d path=%s len=%lld\n", (long long)offset, (int)size, path, (long long)stub->hdr.len); ret = stub_read(state, stub, buf, size, offset); debug("undup_read return %d errno=%d\n", ret, errno); t1 = rtc(); count_event(COUNT_READ, t1 - t0, size); state_wrlock(state); count_maybe_dump(state, t1); state_unlock(state); return ret; }
void list_extensions () { disp_list ("Final Cartridge 3 Basic Extension keywords for", final_cart_3, "%-15s", 4); rtc (stderr); disp_list ("Graphics52 Basic Extension keywords for", graphics_52, "%-15s", 4); rtc (stderr); disp_list ("6510+ Assembler Extension keywords for", asm6510plus, "%-15s", 4); }
int pagein_fadvise(const char *fname, off_t o) { int fd = getfd(fname); u64 t1; t1 = rtc(); if(posix_fadvise(fd, o * pgsz, pgsz, POSIX_FADV_WILLNEED) == -1) fprintf(stderr, "fadvise(%s, %lld, %lld, WILLNEED): %s\n", fname, (long long)o, (long long)pgsz, strerror(errno)); if(o_time) account_pagein(t1, rtc()); return 1; }
int main(int argc, char * argv []) { const int n = argc > 1 ? atoi(argv[1]) : 1000000; fprintf(stderr, " -- writing %d particles -- \n", n); assert(n > 16); MPI_Init(&argc, &argv); int rank, nrank; MPI_Comm_rank (MPI_COMM_WORLD, &rank); MPI_Comm_size (MPI_COMM_WORLD, &nrank); const MPI_Comm MPI_WORKING_WORLD = MPI_COMM_WORLD; std::vector<real4> pos(n), vel(n); std::vector<int> IDs(n); for (int i = 0; i < n ; i++) { const float fi = i; pos[i] = (real4){ fi, fi+1.0f, fi-1.0f, -fi-1.0f}; vel[i] = (real4){2.0f*fi, 2.0f*fi+1.0f, 2.0f*fi-1.0f, -2.0f*fi-1.0f}; IDs[i] = 3*i-2; } const float time = 0.125; std::string fileName; fileName.resize(256); MPI_Barrier(MPI_WORKING_WORLD); const double t0 = rtc(); #ifndef _SION_ sprintf(&fileName[0], "%s_%010.4f-%d", "naive_test", time, rank); const size_t nbytes = write_snapshot( &pos[0], &vel[0], &IDs[0], n, fileName, time, rank, nrank, MPI_WORKING_WORLD); #else sprintf(&fileName[0], "%s_%010.4f-%d", "sion_test", time, nrank); const size_t nbytes = sion_write_snapshot( &pos[0], &vel[0], &IDs[0], n, fileName, time, rank, nrank, MPI_WORKING_WORLD); #endif MPI_Barrier(MPI_WORKING_WORLD); const double t1 = rtc(); if (rank == 0) fprintf(stderr, " -- writing took %g sec -- BW= %g MB/s\n", (t1-t0), nbytes/1e6/(t1-t0)); MPI_Finalize(); }
sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, const GrBackendRenderTarget& backendRT, GrSurfaceOrigin origin, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props) { if (!context) { return nullptr; } if (!SkSurface_Gpu::Valid(context, backendRT.config(), colorSpace.get())) { return nullptr; } sk_sp<GrRenderTargetContext> rtc( context->contextPriv().makeBackendRenderTargetRenderTargetContext(backendRT, origin, std::move(colorSpace), props)); if (!rtc) { return nullptr; } sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), backendRT.width(), backendRT.height(), SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; } return sk_make_sp<SkSurface_Gpu>(std::move(device)); }
sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* context, const GrBackendTexture& tex, GrSurfaceOrigin origin, int sampleCnt, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props) { if (!context) { return nullptr; } if (!SkSurface_Gpu::Valid(context, tex.config(), colorSpace.get())) { return nullptr; } sampleCnt = SkTMax(1, sampleCnt); sk_sp<GrRenderTargetContext> rtc( context->contextPriv().makeBackendTextureAsRenderTargetRenderTargetContext( tex, origin, sampleCnt, std::move(colorSpace), props)); if (!rtc) { return nullptr; } sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), tex.width(), tex.height(), SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; } return sk_make_sp<SkSurface_Gpu>(std::move(device)); }
BOOL CRuntimeDlg::AddRCControl(CWnd* pWnd, LPCTSTR szCaption, DWORD dwStyle, DWORD dwExStyle, int x, int y, int cx, int cy, UINT nID, UINT nIconID) { ASSERT_VALID(pWnd); CString sClass = CWinClasses::GetClass(*pWnd); if (!dwStyle) dwStyle = CRCCtrlParser::GetDefaultStyles(sClass); if (!(dwStyle & WS_NOTVISIBLE)) dwStyle |= WS_VISIBLE; else dwStyle &= ~WS_NOTVISIBLE; if (CRCCtrlParser::CtrlWantsClientEdge(sClass)) dwExStyle |= WS_EX_CLIENTEDGE; if (GetSafeHwnd()) return (NULL != CreateControl(pWnd, szCaption, dwStyle, dwExStyle, x, y, cx, cy, nID, TRUE, nIconID)); else { RTCONTROL rtc(pWnd, sClass, szCaption, dwStyle, dwExStyle, CRect(x, y, x + cx, y + cy), nID, TRUE, nIconID); m_lstControls.AddTail(rtc); } return TRUE; }
int main(void) { SystemInit(); CWS2812SPI ws2812(60); ws2812.init(); RTC_AnimationDriver rtc(&ws2812); rtc.init(); CAnimationClock clock(&ws2812, &rtc); rtc.registerAnimation(clock); //CAnimationKnightRider kr(&ws2812, BLUE); //rtc.registerAnimation(kr); CDCF77Decoder dcf77; dcf77.init(); while(1) { rtc.updateAnimations(); } }
//----------------------------------------------------------------------------// void BasicRenderedStringParser::appendRenderedText(RenderedString& rs, const String& text) const { size_t cpos = 0; // split the given string into lines based upon the newline character while (text.length() > cpos) { // find next newline const size_t nlpos = text.find('\n', cpos); // calculate length of this substring const size_t len = ((nlpos != String::npos) ? nlpos : text.length()) - cpos; // construct new text component and append it. RenderedStringTextComponent rtc(text.substr(cpos, len), d_fontName); rtc.setPadding(d_padding); rtc.setColours(d_colours); rtc.setVerticalFormatting(d_vertAlignment); rtc.setAspectLock(d_aspectLock); rs.appendComponent(rtc); // break line if needed if (nlpos != String::npos) rs.appendLineBreak(); // advance current position. +1 to skip the \n char cpos += len + 1; } }
BOOL CRuntimeDlg::AddRCControl(LPCTSTR szRCType, LPCTSTR szClass, LPCTSTR szCaption, DWORD dwStyle, DWORD dwExStyle, int x, int y, int cx, int cy, UINT nID, UINT nIconID) { CString sClass(szClass); // get the win32 class name if (sClass.IsEmpty() || _tcsicmp(szRCType, _T("CONTROL")) != 0) { if (!CRCCtrlParser::GetClassName(szRCType, sClass) || sClass.IsEmpty()) return FALSE; } if (!dwStyle) dwStyle = CRCCtrlParser::GetDefaultStyles(sClass); if (!(dwStyle & WS_NOTVISIBLE)) dwStyle |= WS_VISIBLE; else dwStyle &= ~WS_NOTVISIBLE; if (CRCCtrlParser::CtrlWantsClientEdge(sClass)) dwExStyle |= WS_EX_CLIENTEDGE; if (GetSafeHwnd()) return (NULL != CreateControl(sClass, szCaption, dwStyle, dwExStyle, x, y, cx, cy, nID, TRUE, nIconID)); else { RTCONTROL rtc(NULL, sClass, szCaption, dwStyle, dwExStyle, CRect(x, y, x + cx, y + cy), nID, TRUE, nIconID); m_lstControls.AddTail(rtc); } return TRUE; }
int* matmul(const int* x, const int* y, int r, int s, int t){ int *z = (int*) malloc(r * t * sizeof(int)); for (int i=0; i < r; i++) { x += i*s; for (int j=0; j < t; j++) { *z = rtc(x, y+j, s, t); z++; } } return z; }
int getfd(const char *fname) { static char prevfname[PATH_MAX]; static int prevfd = -1; int fd; u64 t1; int onoatime = o_noatime ? O_NOATIME : 0; if(!strcmp(fname, prevfname)) return prevfd; if(o_time) t1 = rtc(); if((fd = open(fname, O_RDONLY|onoatime)) == -1) die("%s: %s\n", fname, strerror(errno)); if(o_time) account_open(t1, rtc()); if(prevfd > 0) close(prevfd); prevfd = fd; strncpy(prevfname, fname, PATH_MAX); return fd; }
BOOL CRuntimeDlg::AddControl(CWnd* pWnd, LPCTSTR szCaption, DWORD dwStyle, DWORD dwExStyle, int x, int y, int cx, int cy, UINT nID) { if (GetSafeHwnd()) return CreateControl(pWnd, szCaption, dwStyle, dwExStyle, x, y, cx, cy, nID, FALSE); else { RTCONTROL rtc(pWnd, NULL, szCaption, dwStyle, dwExStyle, CRect(x, y, x + cx, y + cy), nID, FALSE); m_lstControls.AddTail(rtc); } return TRUE; }
static void cmd_gettime(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) return; RTC_TIME tm; DS1307 rtc(&I2C_DRIVER); if (rtc.get_time(tm)) chprintf(chp, "%s\r\n", tm.to_str()); else chprintf(chp, "Failed to get system time\r\n"); }
void ColouredRenderedStringParser::appendRenderedText(CEGUI::RenderedString& rs, const CEGUI::String& text) const { size_t cpos = 0; // split the given string into lines based upon the newline character while (text.length() > cpos) { // find next newline const size_t nlpos = text.find('\n', cpos); // calculate length of this substring const size_t len = ((nlpos != CEGUI::String::npos) ? nlpos : text.length()) - cpos; // construct new text component and append it. if (len > 0) { //If we're using colours different from those of the default colours we'll also use our own implementation which doesn't do modulation. if (d_initialColours.d_bottom_left != d_colours.d_bottom_left || d_initialColours.d_top_left != d_colours.d_top_left || d_initialColours.d_top_right != d_colours.d_top_right || d_initialColours.d_bottom_right != d_colours.d_bottom_right) { RenderedColourStringTextComponent rtc(text.substr(cpos, len), d_fontName); rtc.setPadding(d_padding); rtc.setColours(d_colours); rtc.setVerticalFormatting(d_vertAlignment); rtc.setAspectLock(d_aspectLock); rs.appendComponent(rtc); } else { CEGUI::RenderedStringTextComponent rtc(text.substr(cpos, len), d_fontName); rtc.setPadding(d_padding); rtc.setColours(d_colours); rtc.setVerticalFormatting(d_vertAlignment); rtc.setAspectLock(d_aspectLock); rs.appendComponent(rtc); } } // break line if needed if (nlpos != CEGUI::String::npos) rs.appendLineBreak(); // advance current position. +1 to skip the \n char cpos += len + 1; } }
void list_cmds () { int i = 0; fprintf (stdout, "\n%s %s:\n\n", "These are the valid command line arguments for", program); while (cmds [i].command [0]) { fprintf (stdout, "%-15s %s\n", cmds [i].command, cmds [i].desc); i ++; if (! (i % PAGE_BREAK)) rtc (stderr); } }
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { GrContext* ctx = ctxInfo.grContext(); sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext( SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin)); if (!rtc) { return; } ctx->flush(); // Adding discard to appease vulkan validation warning about loading uninitialized data on draw rtc->discard(); test_path(ctx, rtc.get(), create_path_0()); test_path(ctx, rtc.get(), create_path_1()); test_path(ctx, rtc.get(), create_path_2()); test_path(ctx, rtc.get(), create_path_3()); test_path(ctx, rtc.get(), create_path_4()); test_path(ctx, rtc.get(), create_path_5()); test_path(ctx, rtc.get(), create_path_6()); test_path(ctx, rtc.get(), create_path_7()); test_path(ctx, rtc.get(), create_path_8()); test_path(ctx, rtc.get(), create_path_9()); test_path(ctx, rtc.get(), create_path_10()); test_path(ctx, rtc.get(), create_path_11()); test_path(ctx, rtc.get(), create_path_12()); test_path(ctx, rtc.get(), create_path_13()); test_path(ctx, rtc.get(), create_path_14()); test_path(ctx, rtc.get(), create_path_15()); test_path(ctx, rtc.get(), create_path_16()); SkMatrix nonInvertibleMatrix = SkMatrix::MakeScale(0, 0); std::unique_ptr<GrFragmentProcessor> fp(create_linear_gradient_processor(ctx)); test_path(ctx, rtc.get(), create_path_17(), nonInvertibleMatrix, GrAAType::kCoverage, std::move(fp)); test_path(ctx, rtc.get(), create_path_18()); test_path(ctx, rtc.get(), create_path_19()); test_path(ctx, rtc.get(), create_path_20(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_21(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_22()); test_path(ctx, rtc.get(), create_path_23()); test_path(ctx, rtc.get(), create_path_24()); test_path(ctx, rtc.get(), create_path_25(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_26(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_27(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_28(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_29()); }
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { GrContext* ctx = ctxInfo.grContext(); sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext( SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 0, kTopLeft_GrSurfaceOrigin)); if (!rtc) { return; } ctx->flush(); test_path(ctx, rtc.get(), create_path_0()); test_path(ctx, rtc.get(), create_path_1()); test_path(ctx, rtc.get(), create_path_2()); test_path(ctx, rtc.get(), create_path_3()); test_path(ctx, rtc.get(), create_path_4()); test_path(ctx, rtc.get(), create_path_5()); test_path(ctx, rtc.get(), create_path_6()); test_path(ctx, rtc.get(), create_path_7()); test_path(ctx, rtc.get(), create_path_8()); test_path(ctx, rtc.get(), create_path_9()); test_path(ctx, rtc.get(), create_path_10()); test_path(ctx, rtc.get(), create_path_11()); test_path(ctx, rtc.get(), create_path_12()); test_path(ctx, rtc.get(), create_path_13()); test_path(ctx, rtc.get(), create_path_14()); test_path(ctx, rtc.get(), create_path_15()); test_path(ctx, rtc.get(), create_path_16()); SkMatrix nonInvertibleMatrix = SkMatrix::MakeScale(0, 0); sk_sp<GrFragmentProcessor> fp(create_linear_gradient_processor(ctx)); test_path(ctx, rtc.get(), create_path_17(), nonInvertibleMatrix, GrAAType::kCoverage, fp); test_path(ctx, rtc.get(), create_path_18()); test_path(ctx, rtc.get(), create_path_19()); test_path(ctx, rtc.get(), create_path_20(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_21(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_22()); }
FLOPPY_FORMATS_END void fdc37c93x_device::device_add_mconfig(machine_config &config) { // floppy disc controller smc37c78_device &fdcdev(SMC37C78(config, floppy_controller_fdcdev, 24'000'000)); fdcdev.intrq_wr_callback().set(FUNC(fdc37c93x_device::irq_floppy_w)); fdcdev.drq_wr_callback().set(FUNC(fdc37c93x_device::drq_floppy_w)); FLOPPY_CONNECTOR(config, "fdc:0", pc_hd_floppies, "35hd", fdc37c93x_device::floppy_formats); FLOPPY_CONNECTOR(config, "fdc:1", pc_hd_floppies, "35hd", fdc37c93x_device::floppy_formats); // parallel port PC_LPT(config, pc_lpt_lptdev); pc_lpt_lptdev->irq_handler().set(FUNC(fdc37c93x_device::irq_parallel_w)); // serial ports NS16450(config, pc_serial1_comdev, XTAL(1'843'200)); // or NS16550 ? pc_serial1_comdev->out_int_callback().set(FUNC(fdc37c93x_device::irq_serial1_w)); pc_serial1_comdev->out_tx_callback().set(FUNC(fdc37c93x_device::txd_serial1_w)); pc_serial1_comdev->out_dtr_callback().set(FUNC(fdc37c93x_device::dtr_serial1_w)); pc_serial1_comdev->out_rts_callback().set(FUNC(fdc37c93x_device::rts_serial1_w)); NS16450(config, pc_serial2_comdev, XTAL(1'843'200)); pc_serial2_comdev->out_int_callback().set(FUNC(fdc37c93x_device::irq_serial2_w)); pc_serial2_comdev->out_tx_callback().set(FUNC(fdc37c93x_device::txd_serial2_w)); pc_serial2_comdev->out_dtr_callback().set(FUNC(fdc37c93x_device::dtr_serial2_w)); pc_serial2_comdev->out_rts_callback().set(FUNC(fdc37c93x_device::rts_serial2_w)); // RTC ds12885_device &rtc(DS12885(config, "rtc")); rtc.irq().set(FUNC(fdc37c93x_device::irq_rtc_w)); rtc.set_century_index(0x32); // keyboard KBDC8042(config, m_kbdc); m_kbdc->set_keyboard_type(kbdc8042_device::KBDC8042_PS2); m_kbdc->input_buffer_full_callback().set(FUNC(fdc37c93x_device::irq_keyboard_w)); m_kbdc->system_reset_callback().set(FUNC(fdc37c93x_device::kbdp20_gp20_reset_w)); m_kbdc->gate_a20_callback().set(FUNC(fdc37c93x_device::kbdp21_gp25_gatea20_w)); }
void disp_list (char *title, Keyword_type *list, char *format, int limit) { int i = 0, lines = 0; fprintf (stdout, "\n%s %s:\n\n", title, program); while (list [i].keyword [0]) { fprintf (stdout, format, list [i].keyword); i ++; if (i && ! (i % limit)) { fprintf (stdout, "\n"); lines ++; if (! (lines % PAGE_BREAK)) rtc (stderr); } } if (i % limit) fprintf (stdout, "\n"); }
sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, const GrBackendRenderTarget& rt, GrSurfaceOrigin origin, SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props) { if (!context) { return nullptr; } GrBackendRenderTarget rtCopy = rt; if (!validate_backend_render_target(context, rtCopy, &rtCopy.fConfig, colorType, colorSpace)) { return nullptr; } if (!SkSurface_Gpu::Valid(context, rtCopy.config(), colorSpace.get())) { return nullptr; } if (!context) { return nullptr; } sk_sp<GrRenderTargetContext> rtc( context->contextPriv().makeBackendRenderTargetRenderTargetContext( rtCopy, origin, std::move(colorSpace), props)); if (!rtc) { return nullptr; } sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), rtCopy.width(), rtCopy.height(), SkGpuDevice::kUninit_InitContents)); if (!device) { return nullptr; } return sk_make_sp<SkSurface_Gpu>(std::move(device)); }
static void cmd_settime(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) return; RTC_TIME tm; char line[SHELL_MAX_LINE_LENGTH]; DS1307 rtc(&I2C_DRIVER); chprintf(chp, "Enter the date (date 1..31): ", NULL); shellGetLine(chp, line, sizeof(line)); tm.date = atol(line); chprintf(chp, "Enter the date (month 1..12): ", NULL); shellGetLine(chp, line, sizeof(line)); tm.mon = atol(line); chprintf(chp, "Enter the date (year): ", NULL); shellGetLine(chp, line, sizeof(line)); tm.year = atol(line); chprintf(chp, "Enter the time (hours 0..23): ", NULL); shellGetLine(chp, line, sizeof(line)); tm.hour = atol(line); chprintf(chp, "Enter the time (minutes 0..59): ", NULL); shellGetLine(chp, line, sizeof(line)); tm.min = atol(line); chprintf(chp, "Enter the time (seconds 0..59): ", NULL); shellGetLine(chp, line, sizeof(line)); tm.sec = atol(line); chprintf(chp, "Setting RTC with %04d/%02d/%02d %02d:%02d:%02d\r\n", tm.year, tm.mon, tm.date, tm.hour, tm.min, tm.sec); // TODO some validation here tm.year = tm.year - 1900; tm.mon = tm.mon - 1; // Months since Jan (0-11) if(!rtc.set_time(tm)) chprintf(chp, "Failed setting up RTC time\r\n", NULL); }
void mstation_state::mstation(machine_config &config) { /* basic machine hardware */ Z80(config, m_maincpu, XTAL(4'000'000)); //unknown clock m_maincpu->set_addrmap(AS_PROGRAM, &mstation_state::mstation_mem); m_maincpu->set_addrmap(AS_IO, &mstation_state::mstation_io); /* video hardware */ screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); screen.set_refresh_hz(50); screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */ screen.set_screen_update(FUNC(mstation_state::screen_update)); screen.set_size(320, 128); screen.set_visarea(0, 320-1, 0, 128-1); screen.set_palette("palette"); PALETTE(config, "palette", FUNC(mstation_state::mstation_palette), 2); AMD_29F080(config, "flash0"); SST_28SF040(config, "flash1"); // IRQ 4 is generated every second, used for auto power off TIMER(config, "1hz_timer").configure_periodic(FUNC(mstation_state::mstation_1hz_timer), attotime::from_hz(1)); // IRQ 1 is used for scan the kb and for cursor blinking TIMER(config, "kb_timer").configure_periodic(FUNC(mstation_state::mstation_kb_timer), attotime::from_hz(50)); rp5c01_device &rtc(RP5C01(config, "rtc", XTAL(32'768))); rtc.out_alarm_callback().set(FUNC(mstation_state::rtc_irq)); ADDRESS_MAP_BANK(config, "bank0").set_map(&mstation_state::mstation_banked_map).set_options(ENDIANNESS_LITTLE, 8, 32, 0x4000); ADDRESS_MAP_BANK(config, "bank1").set_map(&mstation_state::mstation_banked_map).set_options(ENDIANNESS_LITTLE, 8, 32, 0x4000); /* internal ram */ RAM(config, RAM_TAG).set_default_size("128K"); }
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo) { GrContext* const context = ctxInfo.grContext(); GrResourceProvider* rp = context->resourceProvider(); sk_sp<GrRenderTargetContext> rtc( context->makeDeferredRenderTargetContext(SkBackingFit::kExact, kScreenSize, kScreenSize, kRGBA_8888_GrPixelConfig, nullptr)); if (!rtc) { ERRORF(reporter, "could not create render target context."); return; } constexpr float d = (float) kScreenSize; Vertex vdata[kNumMeshes * 4] = { {0, 0, kMeshColors[0]}, {0, d, kMeshColors[0]}, {d, 0, kMeshColors[0]}, {d, d, kMeshColors[0]}, {0, 0, kMeshColors[1]}, {0, d, kMeshColors[1]}, {d, 0, kMeshColors[1]}, {d, d, kMeshColors[1]}, {0, 0, kMeshColors[2]}, {0, d, kMeshColors[2]}, {d, 0, kMeshColors[2]}, {d, d, kMeshColors[2]}, {0, 0, kMeshColors[3]}, {0, d, kMeshColors[3]}, {d, 0, kMeshColors[3]}, {d, d, kMeshColors[3]} }; sk_sp<const GrBuffer> vbuff(rp->createBuffer(sizeof(vdata), kVertex_GrBufferType, kDynamic_GrAccessPattern, GrResourceProvider::kNoPendingIO_Flag | GrResourceProvider::kRequireGpuMemory_Flag, vdata)); if (!vbuff) { ERRORF(reporter, "vbuff is null."); return; } uint32_t resultPx[kScreenSize * kScreenSize]; for (ScissorState scissorState : {ScissorState::kEnabled, ScissorState::kDisabled}) { rtc->clear(nullptr, 0xbaaaaaad, true); rtc->priv().testingOnly_addDrawOp( skstd::make_unique<GrPipelineDynamicStateTestOp>(scissorState, vbuff)); rtc->readPixels(SkImageInfo::Make(kScreenSize, kScreenSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType), resultPx, 4 * kScreenSize, 0, 0, 0); for (int y = 0; y < kScreenSize; ++y) { for (int x = 0; x < kScreenSize; ++x) { int expectedColorIdx; if (ScissorState::kEnabled == scissorState) { expectedColorIdx = (x < kScreenSplitX ? 0 : 2) + (y < kScreenSplitY ? 0 : 1); } else { expectedColorIdx = kNumMeshes - 1; } uint32_t expected = kMeshColors[expectedColorIdx]; uint32_t actual = resultPx[y * kScreenSize + x]; if (expected != actual) { ERRORF(reporter, "[scissor=%s] pixel (%i,%i): got 0x%x expected 0x%x", ScissorState::kEnabled == scissorState ? "enabled" : "disabled", x, y, actual, expected); return; } } } } }
void help () { fprintf (stdout, "\n%s: Text <==> C64 Basic Converter\n", program); fprintf (stdout, "Version %s %s %s\n", VERSION, VDATE, VCOMM); fprintf (stdout, "Copyright (c) %s %s %s\n", COPYRIGHT, AUTHOR, EMAIL); fprintf (stdout, "Extension 6510+ keywords added by Martin Piper ([email protected])\n"); fprintf (stdout, "%s\n", WEB); fprintf (stdout, "This software is FREEWARE and is freely distributable.\n"); if (strcmp (program, PROGNAME)) fprintf (stdout, "\n%s%s%s\n", "This program was originally named ", PROGNAME, ".EXE."); fprintf (stdout, "\n%s%s%s%s%s%s%s\n", program, " converts ascii text file representations of Commodore basic", "\nprogram listings into program images suitable to run on a", " C64. It \nalso converts basic programs back into ascii text", " listings. ", program, "\ndoes NOT perform syntax checking."); fprintf (stdout, "\n%s%s%s\n", "*** Use the \"", cmds [LIST].command, "\" command line argument for a list of valid commands."); fprintf (stdout, "\n%s%s%s\n", "You may specify multiple commands and/or", " file names on the command \nline in the order you want the", " commands to occur."); fprintf (stdout, "\n%s%s%s%s%s%s%s%s\n", "Default extensions are \"", TXT_EXT, "\" for ascii text files and \"", PRG_EXT, "\" for \nCommodore Basic program files. That means you", " may specify extensions \nbut if you don't ", program, " will look for files with the defaults."); rtc (stderr); fprintf (stdout, "%s%s%s%s%s%s%s%s%s%s%s\n", "An input text file may contain", " multiple program listings. Use the \n\"", cmds [MULT].command, "\" command to enable this function. Mark the start of each ", "\nlisting with \"", START_PROC, " {file name}\" and the end with \"", STOP_PROC, "\". \nThis feature is only available with the \"", cmds [TOPRG].command, "\" command."); fprintf (stdout, "\n%s%s%s%s%s%s%s%s%s%s%s\n", "Keywords, variables, and quoted named identifiers are NOT", " case-\nsensitive but quoted strings and comments ARE.", " So, if you issue a\n\"POKE 53272,21\" command on your C64 the", " quoted strings will appear as\nupper case and graphics. But", " if you do a \"POKE 53272,23\" the strings\nwill be lower case and", " upper case. In other words, ASCII to PETASCII\nconversion is performed" " automatically. To represent special characters\nin quoted strings", " use named identifiers, like \"", CLEAR_WORD, "\", or curly-\nbracketed ascii values, between \"{001}\"", " and \"{255}\". You may also\nspecify quantities like", " \"{down*10}\" or \"{001*5}\"."); fprintf (stdout, "\n%s%s%s%s%s%s%s%s%d%s\n", "You may break up the ascii text lines by appending a \"\\\"", " continuation\ncharacter to the end of a line. The next line of", " text will be combined\nwith the current line to create one numbered", " Basic command line. So,\nthe next line of text should NOT have a", " line number, and any leading\nwhitespace characters will be", " ignored. Do NOT break up a keyword in\ncontinuing a line -- ", program, " will not parse it correctly. BTW, the\nmaximum line length is ", MAXLINE - 2, " characters."); rtc (stderr); fprintf (stdout, "%s%s%s%s%s%s%s%s%s%s%s\n", "If you find that much of a listing will require many continuation", " chars \nand each logical (basic) line is hanging-indented, use the ", cmds [COL].command, " command. \n", program, " will start a new basic line when a line number starts in column\n", "one and will continue the line, ignoring the physical end of line", " (cr/lf), \nuntil another number appears in column one or the end of", " the file is \nreached. All but one leading spaces are ignored when", " continuing a line. \nAny non-numeric chars in the first column are", " not allowed."); fprintf (stdout, "%s%s%s%s\n", "Use TRANS64, Bernhard Schwall", " <*****@*****.**>,", "\nor some other utility program to transfer your basic programs", " between \nyour PC and C64 or emulator disk images."); fprintf (stdout, "\n%s%s%s%s%s%s%s\n", "I would like to give special thanks to the following people.", " Peter \nKarlsson (Fidonet 2:204/145.42) <*****@*****.**>", " for \nassisting with the keyword/token list and with testing.", " Also to Phil \nHoff <*****@*****.**> for heavy-duty", " testing and pushing \nfor more features. Ville Muikkula", " <*****@*****.**> for testing \nand suggestions for", " special char replacement."); rtc (stderr); fprintf (stdout, "\n%s%s%s%s%s%s\n", "OK, now for the scary part. This software is provided to you", " \"AS-IS\".\nNo other warranties of any kind, express or implied,", " are made to you\nas to the software or any medium it may be on,", " including but not\nlimited to warranties of merchantability or", " fitness for a particular\npurpose. So use at your own risk.", " Whew! Are you still there?"); fprintf (stdout, "\n%s%s%s%s%s%s%s\n", "If you like ", program, " and/or find it useful please consider sending me", "\nan email or a couple bucks to encourage me to continue", " improving \nit or write other useful software. Thanks -- ", AUTHOR, "."); }
static int undup_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { char b[PATH_MAX+1]; int i, n, ret = 0; struct stub *stub; u8 *fillbuf = NULL; size_t nwrite = 0; off_t orig_offset = offset; double t0, t1; t0 = rtc(); n = snprintf(b, PATH_MAX, "%s/%s", state->basedir, path); if (n > PATH_MAX) return -ENAMETOOLONG; stub = (struct stub *)fi->fh; debug("undup_write path=%s size=%d offset=%lld fi=%p flags=%x stub=%p\n", path, (int)size, (long long)offset, fi, fi ? (int)fi->flags : 0, stub); if (!stub) return -EIO; if ((i = offset % state->blksz) > 0) { off_t blkoff = offset - i; debug(" offset fill i=%d off=%lld blkoff=%lld\n", i, (long long)offset, (long long)blkoff); fillbuf = malloc(state->blksz); if (!fillbuf) { ret = -ENOMEM; goto out_close; } ret = stub_read(state, stub, fillbuf, state->blksz, blkoff); if (ret == -1) goto out_close; n = state->blksz - i; if (n > size) n = size; memcpy(fillbuf + i, buf, n); if (i + n < state->blksz && ret < state->blksz) { int m = i + n; if (m < ret) m = ret; memset(fillbuf + m, 0, state->blksz - m); } debug(" prefix write i=%d n=%d blkoff=%lld offset=%lld\n", i, n, (long long)blkoff, (long long)offset); ret = stub_write(state, stub, fillbuf, state->blksz, blkoff); if (ret == -1) { goto out_close; } offset = offset + n; size -= n; buf += n; nwrite += n; debug(" end prefix nwrite=%d n=%d off=%lld\n", (int)nwrite, n, (long long)offset); } for (i = 0; i + state->blksz <= size; i += state->blksz) { n = size - i; if (n > state->blksz) n = state->blksz; debug(" write block i=%d n=%d nwrite=%d offset=%lld\n", i, n, (int)nwrite, (long long)offset); stub_write(state, stub, buf + i, n, offset + i); nwrite += n; debug(" end block nwrite=%d n=%d\n", (int)nwrite, n); } if (i < size) { off_t blkoff = offset + i; ASSERT(i < state->blksz); debug(" tail write i=%d offset=%lld blkoff=%lld size=%d\n", i, (long long)offset, (long long)blkoff, (int)size); if (!fillbuf) fillbuf = malloc(state->blksz); if (!fillbuf) { ret = -ENOMEM; goto out; } ret = stub_read(state, stub, fillbuf, state->blksz, blkoff); if (ret < 0) { debug("stub_read failed! write bail.\n"); goto out; } if (ret < state->blksz) { /* * less than full buffer was read (probably 0 due to read-past-eof) * so fill out the rest of the buffer with NUL. */ memset(fillbuf + ret, state->blksz - ret, 0); } n = size - i; ASSERT(n < state->blksz); memcpy(fillbuf, buf + i, n); if (n < state->blksz) memset(fillbuf + n, 0, state->blksz - n); ret = stub_write(state, stub, fillbuf, state->blksz, blkoff); if (ret == -1) { goto out; } nwrite += n; debug(" end tail nwrite=%d n=%d off=%lld\n", (int)nwrite, n, (long long)offset); } out: if (stub_refresh(state, stub) == -1) { ret = -1; } else { stub_update_len(stub, orig_offset + nwrite, 0); } out_close: free(fillbuf); t1 = rtc(); count_event(COUNT_WRITE, t1 - t0, size); count_maybe_dump(state, t1); debug("undup_write ret=%d n=%d errno=%d\n", ret, n, errno); return ret == -1 ? -errno : ret < 0 ? ret : n; }
int main(int argc, char * argv[]) { fprintf(stderr, " ~~~~~~~~~~~~~~~~~~~~~~~~~ \n"); const int rep = argc > 1 ? atoi(argv[1]) : 1024; fprintf(stderr, " rep= %d\n", rep); const int nthreads = argc > 2 ? atoi(argv[2]) : 2; fprintf(stderr, " nthreads= %d\n", nthreads); double bytes_sum = 0.0, dt_max = 0.0; #pragma omp parallel num_threads(nthreads) { real *x; #pragma omp critical { x = (real*)_mm_malloc(N*sizeof(real), ALIGN); } for (int i = 0; i < N; i++) { x[i] = drand48(); } const real a = drand48(); int n; replace(a,x,&n); replace(a,x,&n); replace(a,x,&n); #if 1 #pragma omp master { fprintf(stderr, " --- used %d KB of memory per array --- \n", n*sizeof(real)*nthreads); } #endif #pragma omp barrier const double t0 = rtc(); for (int r = 0; r < rep; r++) { replace(a,x,&n); } const double t1 = rtc(); #pragma omp barrier const double dt = t1-t0; const double bytes = 2.0*sizeof(real)*n*rep; #pragma omp critical { bytes_sum += bytes; if (dt > dt_max) dt_max = dt; } #pragma omp master fprintf(stderr, " ----- \n"); fprintf(stderr, " tid= %2d: done in %g sec:: BW= %g GB/s \n", nthreads, dt, bytes/dt/1e9); #pragma omp barrier #pragma omp master { fprintf(stderr, " ----- \n"); fprintf(stderr, " total: done in %g sec:: BW= %g GB/s \n", dt_max, bytes_sum/dt_max/1e9); } #pragma omp critical { _mm_free(x); } } fprintf(stderr, " ~~~~~~~~~~~~~~~~~~~~~~~~~ \n"); return 0; }