Platform currentPlatform() { #if defined(Q_OS_LINUX) #if defined(Q_CC_GNU) #if defined(Q_PROCESSOR_X86_64) return Platform("linux", "64", "g++"); #elif defined(Q_PROCESSOR_X86_32) return Platform("linux", "32", "g++"); #endif #endif #endif return Platform(); }
void ecPlatformsDialog::OnModify(wxCommandEvent& event) { long n = m_listCtrl->GetItemCount(); long i; for (i = 0; i < n; i++) { if (m_listCtrl->GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED) { CeCosTestPlatform *pti=Platform(i); ecPlatformEditorDialog dlg(this); dlg.m_strPlatform = pti->Name(); dlg.m_strPrefix = pti->Prefix(); dlg.m_strGDB = pti->GdbCmds(); dlg.m_strCaption = wxT("Modify Platform"); dlg.m_strPrompt = pti->Prompt(); dlg.m_bServerSideGdb = pti->ServerSideGdb(); dlg.m_strInferior = pti->Inferior(); if ( wxID_CANCEL != dlg.ShowModal() ) { *pti = CeCosTestPlatform(dlg.m_strPlatform,dlg.m_strPrefix,dlg.m_strPrompt,dlg.m_strGDB,dlg.m_bServerSideGdb,dlg.m_strInferior); m_listCtrl->SetItem(i, 1, pti->Prefix()); m_listCtrl->SetItem(i, 2, pti->GdbCmds()); m_listCtrl->SetItem(i, 3, pti->Inferior()); m_listCtrl->SetItem(i, 4, pti->Prompt()); m_listCtrl->SetItem(i, 5, pti->ServerSideGdb() ? wxT("Y") : wxT("N")); } } } }
int main() { auto infra = Infrastructure(); auto plat = Platform(); // auto prov = Provision(); auto soft = "gitlab"; auto config = Configure(); auto addon = Addon(); auto valid = Validate(); auto role = CodeRepository(infra, plat, soft, config, addon, valid); CodeRepository.delegator(); return 0; };
static void enumerate (struct channel * channel, struct nic nic [], unsigned size) { extern const byte localcast [ETHER_ADDR_LEN]; for (; size--; nic++) { byte memory [ETHER_ADDR_LEN]; char string [ETHER_ADDR_LEN * 3]; memset (memory, 0x00, sizeof (memory)); if (!memcmp (memory, nic->ethernet, sizeof (memory))) { continue; } memset (memory, 0xFF, sizeof (memory)); if (!memcmp (memory, nic->ethernet, sizeof (memory))) { continue; } #if defined (WINPCAP) || defined (LIBPCAP) printf (" %d", nic->ifindex); #elif defined (__linux__) || defined (__OpenBSD__) || defined (__APPLE__) printf (" %s", nic->ifname); #else #error "Unknown environment" #endif printf (" %s", hexstring (string, sizeof (string), nic->ethernet, sizeof (nic->ethernet))); printf (" %s", decstring (string, sizeof (string), nic->internet, sizeof (nic->internet))); #if 0 printf (" %s", nic->ifname); printf (" %s", nic->ifdesc); #endif channel->ifname = nic->ifname; openchannel (channel); Platform (channel, localcast); closechannel (channel); printf ("\n"); } return; }
void StorageDownloadingPolicy::ScheduleRetry(storage::TCountriesSet const & failedCountries, TProcessFunc const & func) { if (IsDownloadingAllowed() && !failedCountries.empty() && m_autoRetryCounter > 0) { auto action = [this, func, failedCountries] { --m_autoRetryCounter; func(failedCountries); }; m_autoRetryWorker.RestartWith([action]{ Platform().RunOnGuiThread(action); }); } else { m_autoRetryCounter = kAutoRetryCounterMax; } }
/// List of device filters based on environment variables. inline std::vector< std::function<bool(const boost::compute::device&)> > backend_env_filters() { std::vector< std::function<bool(const boost::compute::device&)> > filter; const char *platform = boost::compute::detail::getenv("OCL_PLATFORM"); const char *vendor = boost::compute::detail::getenv("OCL_VENDOR"); const char *name = boost::compute::detail::getenv("OCL_DEVICE"); const char *devtype = boost::compute::detail::getenv("OCL_TYPE"); const char *extension = boost::compute::detail::getenv("OCL_EXTENSION"); if (platform) filter.push_back(Platform(platform)); if (vendor) filter.push_back(Vendor(vendor)); if (name) filter.push_back(Name(name)); if (devtype) filter.push_back(Type(devtype)); if (extension) filter.push_back(Extension(extension)); return filter; }
void ecPlatformsDialog::OnDelete(wxCommandEvent& event) { long sel = -1; long whereFrom = 0; do { sel = ecFindListCtrlSelection(whereFrom, m_listCtrl); if (sel > -1) { if (wxYES == wxMessageBox(wxT("Are you sure you wish to delete this platform?"), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxYES_NO, this)) { delete Platform(sel); m_listCtrl->DeleteItem(sel); delete m_arTargetInfo.Nth(sel); whereFrom = 0; } } } while (sel > -1) ; }
Level::Level(const sf::Image &lvl, const sf::Texture &tileTex) { int imgWd = lvl.GetWidth(); int imgHt = lvl.GetHeight(); bool isWall[imgWd][imgHt]; for (int y=0; y<imgHt; ++y) for (int x=0; x<imgWd; ++x) isWall[x][y] = false; for (int y=0; y<imgHt; ++y) { for (int x=0; x<imgWd; ++x) { // search for new platfomrs if (!isWall[x][y] && lvl.GetPixel(x, y) == sf::Color::Black) { // figure out the collision rectangles int minHt = imgHt+1; int wd; // find the maximum rectangle width for (wd=0; x+wd<imgWd && lvl.GetPixel(x+wd, y) == sf::Color::Black; ++wd){ // find the minimum rectangle height int ht=0; while (y+ht<imgHt && lvl.GetPixel(x+wd, y+ht) == sf::Color::Black) ++ht; if (ht < minHt) minHt = ht; } // mark the platfom area as processed for (int x2=x; x2<x+wd; ++x2) { for (int ht=0; ht<minHt; ++ht) { isWall[x2][y+ht] = true; } } // construct platforms platforms.push_back(Platform(x*TILE_SIZE, y*TILE_SIZE, wd*TILE_SIZE, minHt*TILE_SIZE, tileTex)); } } } }
void GameStageX::update(InputManager *input){ bgScroller->render(screen); if(plyrMgr.isRocketFlying()){ if(bgScroller->isLoadPoint()){ map->load(); plane->addPlane(map); itemMgr->addItems(map); } bgScroller->update(); } if(!this->hasGameStarted){ screen->addMessageToScreen("Press 'Space' to start"); Platform pl1 = Platform(9, "planet.png"); pl1.render(0, 703, renderer); } if(plyrMgr.isRocketFlying()){ this->hasGameStarted = true; } if(plyrMgr.getHasPlayerWon()){ this->levelCompleted = true; SDL_Delay(2000); } int firstY = bgScroller->getFirstY(); int secondY = bgScroller->getSecondY(); itemMgr->update(firstY,secondY,&plyrMgr); plane->update(secondY,firstY,&plyrMgr,screen, *itemMgr); plyrMgr.update(input,screen); screen->update(); }
Epic::Core::Array<Platform> Platform::getPlatformIDs() { Epic::Core::Array<Platform> ret; cl_uint numPlatforms = 0; clGetPlatformIDs(0, nullptr, &numPlatforms); if(numPlatforms > 0) { cl_platform_id *platforms = new cl_platform_id[numPlatforms]; int err = clGetPlatformIDs(numPlatforms, platforms, nullptr); if(err != CL_SUCCESS) { throw OpenCLException(err); } for(cl_uint i = 0; i < numPlatforms; i++) { ret << Platform(platforms[i]); } delete [] platforms; } return ret; }
bool stringListToPackageList(PackageList *packages, const QStringList &packagesIn, QList<const Package *> &packagesOut, const Platform &host, QStringList *alreadyInstalledPackagesOut, QString *notFoundPackage) { PackageMatcher matcher(packages); packagesOut.clear(); // captures expressions like this: <name>[/<version>][#<target>] // examples: qtbase/5.0.0#win32-g++ // qtjsbackend // qtpim#linux-g++-32 // qtquick1/5.1.0 QRegularExpression exp("([a-z0-9\\-_\\+]*)(/[a-z0-9\\-\\+\\.]*)?(#[a-z0-9\\-\\+]*)?"); QRegularExpressionMatch match; InstalledPackages *installed = ConfigurationHandler::instance()->installedPackages(); for (const QString &arg : packagesIn) { match = exp.match(arg); if (!match.hasMatch()) { if (notFoundPackage != 0) { *notFoundPackage = arg; } return false; } const QString id = match.captured(1); const QString version = match.captured(2).remove(0, 1); const Platform target = Platform::fromString(match.captured(3).remove(0, 1)); if (alreadyInstalledPackagesOut != 0 && installed->isPackageInstalled(id, version, host, target)) { alreadyInstalledPackagesOut->append(arg); continue; } packagesOut.append(matcher.matchPackages(id, version, Platform(), target)); } return true; }
// Copyright (c) 2012 by Catch22. All Rights Reserved. // Date: 22/10-2012 // // License: The following code is licensed under the Catch22-License // #include "../src/GameModel/Map/Platform.hpp" #include "../src/GameModel/Physics/PhysicsManager.hpp" #include "catch.hpp" TEST_CASE("Platform", "Tests the Platform: creates a new platform and then checks it's values") { //Create a physicsmanager in order to make the getters work. PhysicsManager manager = PhysicsManager(); PlatformBlock* platformblock1 = new PlatformBlock(INCLINE, new Vector2d(0.0, 0.0)); PlatformBlock* platformblock2 = new PlatformBlock(HORIZONTAL, new Vector2d(2.0, 1.0)); PlatformBlock* platformblock3 = new PlatformBlock(DECLINE, new Vector2d(4.0, 1.0)); Platform platform = Platform(); platform.addPlatformBlock(platformblock1); platform.addPlatformBlock(platformblock2); platform.addPlatformBlock(platformblock3); CHECK(platform.startPoint()->m_x == 0.0); CHECK(platform.startPoint()->m_y == 0.0); CHECK(platform.endPoint()->m_x == 6.0); CHECK(platform.endPoint()->m_y == 0.0); }
/** \param i The number of the specified platform. \return The \a i 'th platform in this list. */ Platform operator[](size_t i) const { return Platform(my_list[i]); }
static void get(std::vector<Platform>* platforms) { platforms->push_back(Platform()); }
size_t RunOverrideTests(int argc, char *argv[], const bool silent, const std::string &routine_name) { auto arguments = RetrieveCommandLineArguments(argc, argv); auto errors = size_t{0}; auto passed = size_t{0}; auto example_routine = TestXgemm<0, T>(); constexpr auto kSeed = 42; // fixed seed for reproducibility // Determines the test settings const auto kernel_name = std::string{"Xgemm"}; const auto precision = PrecisionValue<T>(); const auto valid_settings = std::vector<std::unordered_map<std::string,size_t>>{ { {"GEMMK",0}, {"KREG",1}, {"KWG",16}, {"KWI",2}, {"MDIMA",4}, {"MDIMC",4}, {"MWG",16}, {"NDIMB",4}, {"NDIMC",4}, {"NWG",16}, {"SA",0}, {"SB",0}, {"STRM",0}, {"STRN",0}, {"VWM",1}, {"VWN",1} }, { {"GEMMK",0}, {"KREG",1}, {"KWG",32}, {"KWI",2}, {"MDIMA",4}, {"MDIMC",4}, {"MWG",32}, {"NDIMB",4}, {"NDIMC",4}, {"NWG",32}, {"SA",0}, {"SB",0}, {"STRM",0}, {"STRN",0}, {"VWM",1}, {"VWN",1} }, { {"GEMMK",0}, {"KREG",1}, {"KWG",16}, {"KWI",2}, {"MDIMA",4}, {"MDIMC",4}, {"MWG",16}, {"NDIMB",4}, {"NDIMC",4}, {"NWG",16}, {"SA",0}, {"SB",0}, {"STRM",0}, {"STRN",0}, {"VWM",1}, {"VWN",1} }, }; const auto invalid_settings = std::vector<std::unordered_map<std::string,size_t>>{ { {"GEMMK",0}, {"KREG",1}, {"KWI",2}, {"MDIMA",4}, {"MDIMC",4}, {"MWG",16}, {"NDIMB",4}, {"NDIMC",4}, {"NWG",16}, {"SA",0} }, }; // Retrieves the arguments auto help = std::string{"Options given/available:\n"}; const auto platform_id = GetArgument(arguments, help, kArgPlatform, ConvertArgument(std::getenv("CLBLAST_PLATFORM"), size_t{0})); const auto device_id = GetArgument(arguments, help, kArgDevice, ConvertArgument(std::getenv("CLBLAST_DEVICE"), size_t{0})); auto args = Arguments<T>{}; args.m = GetArgument(arguments, help, kArgM, size_t{256}); args.n = GetArgument(arguments, help, kArgN, size_t{256}); args.k = GetArgument(arguments, help, kArgK, size_t{256}); args.a_ld = GetArgument(arguments, help, kArgALeadDim, args.k); args.b_ld = GetArgument(arguments, help, kArgBLeadDim, args.n); args.c_ld = GetArgument(arguments, help, kArgCLeadDim, args.n); args.a_offset = GetArgument(arguments, help, kArgAOffset, size_t{0}); args.b_offset = GetArgument(arguments, help, kArgBOffset, size_t{0}); args.c_offset = GetArgument(arguments, help, kArgCOffset, size_t{0}); args.layout = GetArgument(arguments, help, kArgLayout, Layout::kRowMajor); args.a_transpose = GetArgument(arguments, help, kArgATransp, Transpose::kNo); args.b_transpose = GetArgument(arguments, help, kArgBTransp, Transpose::kNo); args.kernel_mode = GetArgument(arguments, help, kArgKernelMode, KernelMode::kCrossCorrelation); args.alpha = GetArgument(arguments, help, kArgAlpha, GetScalar<T>()); args.beta = GetArgument(arguments, help, kArgBeta, GetScalar<T>()); // Prints the help message (command-line arguments) if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); } // Initializes OpenCL const auto platform = Platform(platform_id); const auto device = Device(platform, device_id); const auto context = Context(device); auto queue = Queue(context, device); // Populate host matrices with some example data auto host_a = std::vector<T>(args.m * args.k); auto host_b = std::vector<T>(args.n * args.k); auto host_c = std::vector<T>(args.m * args.n); std::mt19937 mt(kSeed); std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit); PopulateVector(host_a, mt, dist); PopulateVector(host_b, mt, dist); PopulateVector(host_c, mt, dist); // Copy the matrices to the device auto device_a = Buffer<T>(context, host_a.size()); auto device_b = Buffer<T>(context, host_b.size()); auto device_c = Buffer<T>(context, host_c.size()); auto device_temp = Buffer<T>(context, args.m * args.n * args.k); // just to be safe device_a.Write(queue, host_a.size(), host_a); device_b.Write(queue, host_b.size(), host_b); device_c.Write(queue, host_c.size(), host_c); auto dummy = Buffer<T>(context, 1); auto buffers = Buffers<T>{dummy, dummy, device_a, device_b, device_c, device_temp, dummy}; // Loops over the valid combinations: run before and run afterwards fprintf(stdout, "* Testing OverrideParameters for '%s'\n", routine_name.c_str()); for (const auto &override_setting : valid_settings) { const auto status_before = example_routine.RunRoutine(args, buffers, queue); if (status_before != StatusCode::kSuccess) { errors++; continue; } // Overrides the parameters const auto status = OverrideParameters(device(), kernel_name, precision, override_setting); if (status != StatusCode::kSuccess) { errors++; continue; } // error shouldn't occur const auto status_after = example_routine.RunRoutine(args, buffers, queue); if (status_after != StatusCode::kSuccess) { errors++; continue; } passed++; } // Loops over the invalid combinations: run before and run afterwards for (const auto &override_setting : invalid_settings) { const auto status_before = example_routine.RunRoutine(args, buffers, queue); if (status_before != StatusCode::kSuccess) { errors++; continue; } // Overrides the parameters const auto status = OverrideParameters(device(), kernel_name, precision, override_setting); if (status == StatusCode::kSuccess) { errors++; continue; } // error should occur const auto status_after = example_routine.RunRoutine(args, buffers, queue); if (status_after != StatusCode::kSuccess) { errors++; continue; } passed++; } // Prints and returns the statistics std::cout << " " << passed << " test(s) passed" << std::endl; std::cout << " " << errors << " test(s) failed" << std::endl; std::cout << std::endl; return errors; }
/* ----------------------------------------------------------------------- */ Platform Context_Properties:: platform() const throw(DIMBO_CL_EXCEPTION(Uninitialized)) { return Platform(this->platform_id()); }
#include "StdAfx.h" #include "main.h" GLfloat boxsize = 2; bool rotating = false; GLfloat degrees = 1; bool mute = false; // Size of the window int width = 800; int height = 600; Cube c = Cube(mute); Platform p = Platform(&c); // Title screen global variables GLfloat mgrow =0.5; bool growing = true; GLfloat msize = 0.5; GLfloat titledegrees = 0; GLfloat titleposition = 0.25; void initRendering() { glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable( GL_BLEND ); glClearColor(0.0,0.0,0.0,0.0);
/** This constructor initialize the context from the first available platfrom on the system with the specified device type. \param type The type of devices to be used in the first available platform. By default,CL_DEVICE_TYPE_DEFAULT is used. */ Context(cl_device_type type = CL_DEVICE_TYPE_DEFAULT) : my_devices(Platform(), type) { initByDevices(); }
bool FContentComparisonHelper::CompareClasses(const FString& InBaseClassName, const TArray<FString>& InBaseClassesToIgnore, int32 InRecursionDepth) { TMap<FString,TArray<FContentComparisonAssetInfo> > ClassToAssetsMap; UClass* TheClass = (UClass*)StaticFindObject(UClass::StaticClass(), ANY_PACKAGE, *InBaseClassName, true); if (TheClass != NULL) { TArray<UClass*> IgnoreBaseClasses; for (int32 IgnoreIdx = 0; IgnoreIdx < InBaseClassesToIgnore.Num(); IgnoreIdx++) { UClass* IgnoreClass = (UClass*)StaticFindObject(UClass::StaticClass(), ANY_PACKAGE, *(InBaseClassesToIgnore[IgnoreIdx]), true); if (IgnoreClass != NULL) { IgnoreBaseClasses.Add(IgnoreClass); } } for( TObjectIterator<UClass> It; It; ++It ) { UClass* TheAssetClass = *It; if ((TheAssetClass->IsChildOf(TheClass) == true) && (TheAssetClass->HasAnyClassFlags(CLASS_Abstract) == false)) { bool bSkipIt = false; for (int32 CheckIdx = 0; CheckIdx < IgnoreBaseClasses.Num(); CheckIdx++) { UClass* CheckClass = IgnoreBaseClasses[CheckIdx]; if (TheAssetClass->IsChildOf(CheckClass) == true) { // UE_LOG(LogEngineUtils, Warning, TEXT("Skipping class derived from other content comparison class...")); // UE_LOG(LogEngineUtils, Warning, TEXT("\t%s derived from %s"), *TheAssetClass->GetFullName(), *CheckClass->GetFullName()); bSkipIt = true; } } if (bSkipIt == false) { TArray<FContentComparisonAssetInfo>* AssetList = ClassToAssetsMap.Find(TheAssetClass->GetFullName()); if (AssetList == NULL) { TArray<FContentComparisonAssetInfo> TempAssetList; ClassToAssetsMap.Add(TheAssetClass->GetFullName(), TempAssetList); AssetList = ClassToAssetsMap.Find(TheAssetClass->GetFullName()); } check(AssetList); // Serialize object with reference collector. const int32 MaxRecursionDepth = 6; InRecursionDepth = FMath::Clamp<int32>(InRecursionDepth, 1, MaxRecursionDepth); TMap<UObject*,bool> RecursivelyGatheredReferences; RecursiveObjectCollection(TheAssetClass, 0, InRecursionDepth, RecursivelyGatheredReferences); // Add them to the asset list for (TMap<UObject*,bool>::TIterator GatheredIt(RecursivelyGatheredReferences); GatheredIt; ++GatheredIt) { UObject* Object = GatheredIt.Key(); if (Object) { bool bAddIt = true; if (ReferenceClassesOfInterest.Num() > 0) { FString CheckClassName = Object->GetClass()->GetName(); if (ReferenceClassesOfInterest.Find(CheckClassName) == NULL) { bAddIt = false; } } if (bAddIt == true) { int32 NewIndex = AssetList->AddZeroed(); FContentComparisonAssetInfo& Info = (*AssetList)[NewIndex]; Info.AssetName = Object->GetFullName(); Info.ResourceSize = Object->GetResourceSize(EResourceSizeMode::Inclusive); } } } } } } } else { UE_LOG(LogEngineUtils, Warning, TEXT("Failed to find class: %s"), *InBaseClassName); return false; } #if 0 // Log them all out UE_LOG(LogEngineUtils, Log, TEXT("CompareClasses on %s"), *InBaseClassName); for (TMap<FString,TArray<FContentComparisonAssetInfo>>::TIterator It(ClassToAssetsMap); It; ++It) { FString ClassName = It.Key(); TArray<FContentComparisonAssetInfo>& AssetList = It.Value(); UE_LOG(LogEngineUtils, Log, TEXT("\t%s"), *ClassName); for (int32 AssetIdx = 0; AssetIdx < AssetList.Num(); AssetIdx++) { FContentComparisonAssetInfo& Info = AssetList(AssetIdx); UE_LOG(LogEngineUtils, Log, TEXT("\t\t%s,%f"), *(Info.AssetName), Info.ResourceSize/1024.0f); } } #endif #if ALLOW_DEBUG_FILES // Write out a CSV file FString CurrentTime = FDateTime::Now().ToString(); FString Platform(FPlatformProperties::PlatformName()); FString BaseCSVName = ( FString(TEXT("ContentComparison/")) + FString::Printf(TEXT("ContentCompare-%s/"), *GEngineVersion.ToString()) + FString::Printf(TEXT("%s"), *InBaseClassName) ); // Handle file name length on consoles... FString EditedBaseClassName = InBaseClassName; FString TimeString = *FDateTime::Now().ToString(); FString CheckLenName = FString::Printf(TEXT("%s-%s.csv"),*InBaseClassName,*TimeString); if (CheckLenName.Len() > PLATFORM_MAX_FILEPATH_LENGTH) { while (CheckLenName.Len() > PLATFORM_MAX_FILEPATH_LENGTH) { EditedBaseClassName = EditedBaseClassName.Right(EditedBaseClassName.Len() - 1); CheckLenName = FString::Printf(TEXT("%s-%s.csv"),*EditedBaseClassName,*TimeString); } BaseCSVName = ( FString(TEXT("ContentComparison/")) + FString::Printf(TEXT("ContentCompare-%s/"), *GEngineVersion.ToString()) + FString::Printf(TEXT("%s"), *EditedBaseClassName) ); } FDiagnosticTableViewer* AssetTable = new FDiagnosticTableViewer( *FDiagnosticTableViewer::GetUniqueTemporaryFilePath(*BaseCSVName), true); if ((AssetTable != NULL) && (AssetTable->OutputStreamIsValid() == true)) { // Fill in the header row AssetTable->AddColumn(TEXT("Class")); AssetTable->AddColumn(TEXT("Asset")); AssetTable->AddColumn(TEXT("ResourceSize(kB)")); AssetTable->CycleRow(); // Fill it in for (TMap<FString,TArray<FContentComparisonAssetInfo> >::TIterator It(ClassToAssetsMap); It; ++It) { FString ClassName = It.Key(); TArray<FContentComparisonAssetInfo>& AssetList = It.Value(); AssetTable->AddColumn(*ClassName); AssetTable->CycleRow(); for (int32 AssetIdx = 0; AssetIdx < AssetList.Num(); AssetIdx++) { FContentComparisonAssetInfo& Info = AssetList[AssetIdx]; AssetTable->AddColumn(TEXT("")); AssetTable->AddColumn(*(Info.AssetName)); AssetTable->AddColumn(TEXT("%f"), Info.ResourceSize/1024.0f); AssetTable->CycleRow(); } } } else if (AssetTable != NULL) { // Created the class, but it failed to open the output stream. UE_LOG(LogEngineUtils, Warning, TEXT("Failed to open output stream in asset table!")); } if (AssetTable != NULL) { // Close it and kill it AssetTable->Close(); delete AssetTable; } #endif return true; }
void Tuner(int argc, char* argv[]) { constexpr auto kSeed = 42; // fixed seed for reproducibility // Sets the parameters and platform/device for which to tune (command-line options) auto command_line_args = RetrieveCommandLineArguments(argc, argv); auto help = std::string{"* Options given/available:\n"}; auto args = Arguments<T>{}; args.platform_id = GetArgument(command_line_args, help, kArgPlatform, ConvertArgument(std::getenv("CLBLAST_PLATFORM"), size_t{0})); args.device_id = GetArgument(command_line_args, help, kArgDevice, ConvertArgument(std::getenv("CLBLAST_DEVICE"), size_t{0})); args.precision = GetArgument(command_line_args, help, kArgPrecision, Precision::kSingle); for (auto &o: C::GetOptions()) { if (o == kArgM) { args.m = GetArgument(command_line_args, help, kArgM, C::DefaultM()); } if (o == kArgN) { args.n = GetArgument(command_line_args, help, kArgN, C::DefaultN()); } if (o == kArgK) { args.k = GetArgument(command_line_args, help, kArgK, C::DefaultK()); } if (o == kArgAlpha) { args.alpha = GetArgument(command_line_args, help, kArgAlpha, GetScalar<T>()); } if (o == kArgBeta) { args.beta = GetArgument(command_line_args, help, kArgBeta, GetScalar<T>()); } if (o == kArgFraction) { args.fraction = GetArgument(command_line_args, help, kArgFraction, C::DefaultFraction()); } if (o == kArgBatchCount) { args.batch_count = GetArgument(command_line_args, help, kArgBatchCount, C::DefaultBatchCount()); } if (o == tStrategy) {args.tStrategy = GetArgument(command_line_args, help, tStrategy, DEFAULT_STRATEGY); } if (o == psoSwarmSize) {args.psoSwarmSize = GetArgument(command_line_args, help, psoSwarmSize, DEFAULT_PSO_SWARM); } if (o == psoInfG) {args.psoInfG = GetArgument(command_line_args, help, psoInfG, DEFAULT_PSO_G); } if (o == psoInfL) {args.psoInfL = GetArgument(command_line_args, help, psoInfL, DEFAULT_PSO_L); } if (o == psoInfR) {args.psoInfR = GetArgument(command_line_args, help, psoInfR, DEFAULT_PSO_R); } } const auto num_runs = GetArgument(command_line_args, help, kArgNumRuns, C::DefaultNumRuns()); fprintf(stdout, "%s\n", help.c_str()); // Tests validity of the given arguments C::TestValidArguments(args); // Tests for validity of the precision and retrieves properties auto isAMD = false; auto isARM = false; auto isGPU = false; { const auto platform = Platform(args.platform_id); const auto device = Device(platform, args.device_id); if (!PrecisionSupported<T>(device)) { printf("* Unsupported precision, skipping this tuning run\n\n"); return; } isAMD = device.IsAMD(); isARM = device.IsARM(); isGPU = device.IsGPU(); } // Creates input buffers with random data auto x_vec = std::vector<T>(C::GetSizeX(args)); auto y_vec = std::vector<T>(C::GetSizeY(args)); auto a_mat = std::vector<T>(C::GetSizeA(args)); auto b_mat = std::vector<T>(C::GetSizeB(args)); auto c_mat = std::vector<T>(C::GetSizeC(args)); auto temp = std::vector<T>(C::GetSizeTemp(args)); std::mt19937 mt(kSeed); std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit); PopulateVector(x_vec, mt, dist); PopulateVector(y_vec, mt, dist); PopulateVector(a_mat, mt, dist); PopulateVector(b_mat, mt, dist); PopulateVector(c_mat, mt, dist); PopulateVector(temp, mt, dist); // Initializes the tuner for the chosen device cltune::Tuner tuner(args.platform_id, args.device_id); // Use full-search to explore all parameter combinations or random-search to search only a part of // the parameter values. The fraction is set as a command-line argument. #ifdef XGEMM_EXEC if(tStrategyFlag) { auto localtStrategy = args.tStrategy; if (args.fraction == 1.0 || args.fraction == 0.0) { localtStrategy = FULL_SEARCH_STRATEGY; } switch (localtStrategy) { case FULL_SEARCH_STRATEGY: tuner.UseFullSearch(); break; case RANDOM_SEARCH_STRATEGY: tuner.UseRandomSearch(1.0/args.fraction); break; case PSO_STRATEGY: tuner.UsePSO(1.0/args.fraction, args.psoSwarmSize, args.psoInfG, args.psoInfL, args.psoInfR); break; case DVDT_STRATEGY: default: tuner.UseFullSearch(); } } #else if (args.fraction == 1.0 || args.fraction == 0.0) { tuner.UseFullSearch(); } else { tuner.UseRandomSearch(1.0/args.fraction); } #endif // Set extra settings for specific defines. This mimics src/routine.cc. auto defines = std::string{""}; if (isAMD && isGPU) { defines += "#define USE_CL_MAD 1\n"; defines += "#define USE_STAGGERED_INDICES 1\n"; } if (isARM && isGPU) { defines += "#define GLOBAL_MEM_FENCE 1\n"; } // Loads the kernel sources and defines the kernel to tune auto sources = defines + C::GetSources(); auto id = tuner.AddKernelFromString(sources, C::KernelName(), C::GlobalSize(args), C::LocalSize()); tuner.SetReferenceFromString(sources, C::KernelName(), C::GlobalSizeRef(args), C::LocalSizeRef()); // Sets the tunable parameters and their possible values C::SetParameters(tuner, id); C::SetConstraints(tuner, id); C::SetLocalMemorySize(tuner, id, args); // Tests for a specific precision tuner.AddParameter(id, "PRECISION", {static_cast<size_t>(args.precision)}); tuner.AddParameterReference("PRECISION", static_cast<size_t>(args.precision)); // Modifies the thread-sizes (both global and local) based on the parameters for (auto ¶meters: C::MulLocal()) { tuner.MulLocalSize(id, parameters); } for (auto ¶meters: C::DivLocal()) { tuner.DivLocalSize(id, parameters); } for (auto ¶meters: C::MulGlobal()) { tuner.MulGlobalSize(id, parameters); } for (auto ¶meters: C::DivGlobal()) { tuner.DivGlobalSize(id, parameters); } // Sets the function's arguments C::SetArguments(tuner, args, x_vec, y_vec, a_mat, b_mat, c_mat, temp); // Starts the tuning process tuner.SetNumRuns(num_runs); tuner.Tune(); // Prints the results to screen auto time_ms = tuner.PrintToScreen(); tuner.PrintFormatted(); // Also prints the performance of the best-case in terms of GB/s or GFLOPS if (time_ms != 0.0) { printf("[ -------> ] %.2lf ms", time_ms); printf(" or %.1lf %s\n", C::GetMetric(args)/(time_ms*1.0e6), C::PerformanceUnit().c_str()); } // Outputs the results as JSON to disk, including some meta-data auto precision_string = std::to_string(static_cast<size_t>(args.precision)); auto metadata = std::vector<std::pair<std::string,std::string>>{ {"kernel_family", C::KernelFamily()}, {"precision", precision_string} }; for (auto &o: C::GetOptions()) { if (o == kArgM) { metadata.push_back({"arg_m", std::to_string(args.m)}); } if (o == kArgN) { metadata.push_back({"arg_n", std::to_string(args.n)}); } if (o == kArgK) { metadata.push_back({"arg_k", std::to_string(args.k)}); } if (o == kArgAlpha) { metadata.push_back({"arg_alpha", ToString(args.alpha)}); } if (o == kArgBeta) { metadata.push_back({"arg_beta", ToString(args.beta)}); } if (o == kArgBatchCount) { metadata.push_back({"arg_batch_count", ToString(args.batch_count)}); } } tuner.PrintJSON("clblast_"+C::KernelFamily()+"_"+precision_string+".json", metadata); }
void Client<T,U>::PerformanceTest(Arguments<U> &args, const SetMetric set_sizes) { // Prints the header of the output table PrintTableHeader(args); // Initializes OpenCL and the libraries auto platform = Platform(args.platform_id); auto device = Device(platform, args.device_id); auto context = Context(device); auto queue = Queue(context, device); #ifdef CLBLAST_REF_CLBLAS if (args.compare_clblas) { clblasSetup(); } #endif // Iterates over all "num_step" values jumping by "step" each time auto s = size_t{0}; while(true) { // Sets the buffer sizes (routine-specific) set_sizes(args); // Populates input host matrices with random data std::vector<T> x_source(args.x_size); std::vector<T> y_source(args.y_size); std::vector<T> a_source(args.a_size); std::vector<T> b_source(args.b_size); std::vector<T> c_source(args.c_size); std::vector<T> ap_source(args.ap_size); std::vector<T> scalar_source(args.scalar_size); PopulateVector(x_source); PopulateVector(y_source); PopulateVector(a_source); PopulateVector(b_source); PopulateVector(c_source); PopulateVector(ap_source); PopulateVector(scalar_source); // Creates the matrices on the device auto x_vec = Buffer<T>(context, args.x_size); auto y_vec = Buffer<T>(context, args.y_size); auto a_mat = Buffer<T>(context, args.a_size); auto b_mat = Buffer<T>(context, args.b_size); auto c_mat = Buffer<T>(context, args.c_size); auto ap_mat = Buffer<T>(context, args.ap_size); auto scalar = Buffer<T>(context, args.scalar_size); x_vec.Write(queue, args.x_size, x_source); y_vec.Write(queue, args.y_size, y_source); a_mat.Write(queue, args.a_size, a_source); b_mat.Write(queue, args.b_size, b_source); c_mat.Write(queue, args.c_size, c_source); ap_mat.Write(queue, args.ap_size, ap_source); scalar.Write(queue, args.scalar_size, scalar_source); auto buffers = Buffers<T>{x_vec, y_vec, a_mat, b_mat, c_mat, ap_mat, scalar}; // Runs the routines and collects the timings auto timings = std::vector<std::pair<std::string, double>>(); auto ms_clblast = TimedExecution(args.num_runs, args, buffers, queue, run_routine_, "CLBlast"); timings.push_back(std::pair<std::string, double>("CLBlast", ms_clblast)); if (args.compare_clblas) { auto ms_clblas = TimedExecution(args.num_runs, args, buffers, queue, run_reference1_, "clBLAS"); timings.push_back(std::pair<std::string, double>("clBLAS", ms_clblas)); } if (args.compare_cblas) { auto ms_cblas = TimedExecution(args.num_runs, args, buffers, queue, run_reference2_, "CPU BLAS"); timings.push_back(std::pair<std::string, double>("CPU BLAS", ms_cblas)); } // Prints the performance of the tested libraries PrintTableRow(args, timings); // Makes the jump to the next step ++s; if (s >= args.num_steps) { break; } args.m += args.step; args.n += args.step; args.k += args.step; args.a_ld += args.step; args.b_ld += args.step; args.c_ld += args.step; } // Cleans-up and returns #ifdef CLBLAST_REF_CLBLAS if (args.compare_clblas) { clblasTeardown(); } #endif }
namespace BrainCloud { const Platform & Platform::AppleTVOS = Platform("APPLE_TV_OS"); const Platform & Platform::BlackBerry = Platform("BB"); const Platform & Platform::Facebook = Platform("FB"); const Platform & Platform::GooglePlayAndroid = Platform("ANG"); const Platform & Platform::iOS = Platform("IOS"); const Platform & Platform::Linux = Platform("LINUX"); const Platform & Platform::Mac = Platform("MAC"); const Platform & Platform::Web = Platform("WEB"); const Platform & Platform::Windows = Platform("WINDOWS"); const Platform & Platform::WindowsPhone = Platform("WINP"); const Platform & Platform::Xbox360 = Platform("XBOX_360"); const Platform & Platform::PS3 = Platform("PS3"); const Platform & Platform::XboxOne = Platform("XBOX_ONE"); const Platform & Platform::PS4 = Platform("PS4"); const Platform & Platform::Wii = Platform("WII"); const Platform & Platform::PSVita = Platform("PS_VITA"); const Platform & Platform::Tizen = Platform("TIZEN"); const Platform & Platform::Roku = Platform("ROKU"); const Platform & Platform::WatchOS = Platform("WATCH_OS"); const Platform & Platform::Unknown = Platform("UNKNOWN"); Platform::Platform(const std::string & in_platform) { m_value = in_platform; } const std::string & Platform::toString() const { return m_value; } const Platform & Platform::fromString(const std::string &in_platform) { // this is a bit slow but not used often if (in_platform == AppleTVOS) { return Platform::AppleTVOS; } if (in_platform == BlackBerry) { return Platform::BlackBerry; } if (in_platform == Facebook) { return Platform::Facebook; } if (in_platform == GooglePlayAndroid) { return Platform::GooglePlayAndroid; } if (in_platform == iOS) { return Platform::iOS; } if (in_platform == Linux) { return Platform::Linux; } if (in_platform == Mac) { return Platform::Mac; } if (in_platform == Web) { return Platform::Web; } if (in_platform == Windows) { return Platform::Windows; } if (in_platform == WindowsPhone) { return Platform::WindowsPhone; } if (in_platform == Xbox360) { return Platform::Xbox360; } if (in_platform == PS3) { return Platform::PS3; } if (in_platform == XboxOne) { return Platform::XboxOne; } if (in_platform == PS4) { return Platform::PS4; } if (in_platform == Wii) { return Platform::Wii; } if (in_platform == PSVita) { return Platform::PSVita; } if (in_platform == Tizen) { return Platform::Tizen; } if (in_platform == Roku) { return Platform::Roku; } if (in_platform == WatchOS) { return Platform::WatchOS; } return Platform::Unknown; } }