author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
410,219
04.05.2021 12:18:36
25,200
8cc80df6c824a48a8d67e8f828d5776c02584bfd
Move to public version of TestPlatform dependency
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterImpl/TestAdapterImpl.csproj", "new_path": "Nodejs/Product/TestAdapterImpl/TestAdapterImpl.csproj", "diff": "<Version>4.7.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.TestPlatform.ObjectModel\">\n- <Version>17.0.0-release-20210407-01</Version>\n+ <Version>16.10.0-release-20210429-01</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Interop\">\n<Version>17.0.0-preview-2-31221-277</Version>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterNetStandard/TestAdapterNetStandard.csproj", "new_path": "Nodejs/Product/TestAdapterNetStandard/TestAdapterNetStandard.csproj", "diff": "<PrivateAssets>all</PrivateAssets>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>\n</PackageReference>\n- <PackageReference Include=\"Microsoft.TestPlatform.ObjectModel\" Version=\"17.0.0-release-20210407-01\" />\n+ <PackageReference Include=\"Microsoft.TestPlatform.ObjectModel\" Version=\"16.10.0-release-20210429-01\" />\n<PackageReference Include=\"Microsoft.VisualStudio.Telemetry\" Version=\"16.3.59\" />\n<PackageReference Include=\"Newtonsoft.Json\" Version=\"12.0.2\" />\n<PackageReference Include=\"Microsoft.SourceLink.GitHub\" Version=\"1.0.0\" PrivateAssets=\"all\" />\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Move to public version of TestPlatform dependency
410,219
05.05.2021 13:50:18
25,200
36720ae1b8502fbb2d2953e4cd586e3b3d69dd26
Consume latest testwindow dependency from public feed
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "new_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "diff": "<Version>17.0.0-preview-2-31221-277</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.TestWindow.Interfaces\">\n- <Version>17.0.0-beta.21222.4</Version>\n+ <Version>17.0.0-beta.21223.1</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.VsInteractiveWindow\">\n<Version>4.0.0-beta.21220.1</Version>\n" }, { "change_type": "MODIFY", "old_path": "nuget.config", "new_path": "nuget.config", "diff": "<clear />\n<add key=\"vssdk\" value=\"https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json\" />\n<add key=\"vs-impl\" value=\"https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json\" />\n+ <add key=\"dotnet-tools\" value=\"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json\" />\n<add key=\"nuget.org\" value=\"https://api.nuget.org/v3/index.json\" />\n</packageSources>\n</configuration>\n\\ No newline at end of file\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Consume latest testwindow dependency from public feed
410,219
07.05.2021 17:01:37
25,200
e2c4508b3b27665d67ea726cf9370431533b5220
Stop saving all files on TestContainer acquisition during change detection
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterImpl/TestContainerDiscoverer.cs", "new_path": "Nodejs/Product/TestAdapterImpl/TestContainerDiscoverer.cs", "diff": "@@ -267,11 +267,6 @@ namespace Microsoft.NodejsTools.TestAdapter\nyield break;\n}\n- if (this.detectingChanges)\n- {\n- this.SaveModifiedFiles(project);\n- }\n-\nif (!this.knownProjects.TryGetValue(path, out var projectInfo) || !TryGetProjectUnitTestProperties(projectInfo.Project, out _, out _))\n{\n// Don't return any containers for projects we don't know about or that we know that they are not configured for JavaScript unit tests.\n@@ -297,22 +292,6 @@ namespace Microsoft.NodejsTools.TestAdapter\nyield return new TestContainer(this, path, latestWrite);\n}\n- private void SaveModifiedFiles(IVsProject project)\n- {\n- // save all the open files in the project...\n- foreach (var itemPath in project.GetProjectItems())\n- {\n- if (string.IsNullOrEmpty(itemPath))\n- {\n- continue;\n- }\n-\n- var solution = (IVsSolution)this.serviceProvider.GetService(typeof(SVsSolution));\n- ErrorHandler.ThrowOnFailure(\n- solution.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, (IVsHierarchy)project, /* save entire project */ 0));\n- }\n- }\n-\nprivate bool ShouldDiscover(string pathToItem)\n{\nif (string.IsNullOrEmpty(pathToItem))\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterImpl/VsProjectExtensions.cs", "new_path": "Nodejs/Product/TestAdapterImpl/VsProjectExtensions.cs", "diff": "@@ -145,7 +145,7 @@ namespace Microsoft.NodejsTools.TestAdapter\n/// <summary>\n/// Get the items present in the project\n/// </summary>\n- public static IEnumerable<string> GetProjectItems(this IVsProject project)\n+ private static IEnumerable<string> GetProjectItems(this IVsProject project)\n{\nif (project == null)\n{\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Stop saving all files on TestContainer acquisition during change detection
410,219
13.05.2021 11:15:43
25,200
af38b680bbefa83eb15dececf4d0501af1e4bd35
Allow WebRole project to be opened in dev16 and dev17
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/WebRole/WebRole.csproj", "new_path": "Nodejs/Product/WebRole/WebRole.csproj", "diff": "<Reference Include=\"System.Web\" />\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n- <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VSTarget)\\WebApplications\\Microsoft.WebApplication.targets\" />\n+ <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\WebApplications\\Microsoft.WebApplication.targets\" />\n<Import Project=\"..\\ProjectAfter.targets\" />\n<!-- To modify your build process, add your task inside one of the targets below and uncomment it.\nOther similar extension points exist, see Microsoft.Common.targets.\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Allow WebRole project to be opened in dev16 and dev17
410,219
13.05.2021 17:21:23
25,200
3df77cecb0297f086210bbe9b59196509a17b8da
Various fixes to allow building with MSBuild 17
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "new_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"Microsoft.Build.Utilities.Core\">\n- <Version>16.6.0</Version>\n+ <Version>17.0.0-preview-21256-03</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.CSharp\">\n<Version>4.7.0</Version>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/NodejsToolsVsix/NodejsToolsVsix.csproj", "new_path": "Nodejs/Product/NodejsToolsVsix/NodejsToolsVsix.csproj", "diff": "<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n+ <PackageReference Include=\"Microsoft.VSSDK.BuildTools\">\n+ <Version>17.0.1597</Version>\n+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n+ <PrivateAssets>all</PrivateAssets>\n+ </PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n<Import Project=\"$(VSToolsPath)\\VSSDK\\Microsoft.VsSDK.targets\" Condition=\"'$(VSToolsPath)' != ''\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/NodejsToolsVsix/source.extension.vsixmanifest", "new_path": "Nodejs/Product/NodejsToolsVsix/source.extension.vsixmanifest", "diff": "Id specifications are minimums; any SKU equal or 'higher' will accept\nthem. -->\n<Installation SystemComponent=\"true\">\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Community\" />\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Pro\" />\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Enterprise\" />\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Community\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Pro\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Enterprise\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n</Installation>\n<Assets>\n<Asset Type=\"Microsoft.VisualStudio.VsPackage\" d:Source=\"Project\" d:ProjectName=\"Nodejs\" Path=\"|Nodejs;PkgdefProjectOutputGroup|\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TargetsVsix/TargetsVsix.csproj", "new_path": "Nodejs/Product/TargetsVsix/TargetsVsix.csproj", "diff": "<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n+ <PackageReference Include=\"Microsoft.VSSDK.BuildTools\">\n+ <Version>17.0.1597</Version>\n+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n+ <PrivateAssets>all</PrivateAssets>\n+ </PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n<Import Project=\"$(VSToolsPath)\\VSSDK\\Microsoft.VsSDK.targets\" Condition=\"'$(VSToolsPath)' != ''\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TargetsVsix/source.extension.vsixmanifest", "new_path": "Nodejs/Product/TargetsVsix/source.extension.vsixmanifest", "diff": "<AllowClientRole>true</AllowClientRole>\n</Metadata>\n<Installation SystemComponent=\"true\" AllUsers=\"true\">\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Community\" />\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Pro\" />\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Enterprise\" />\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Community\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Pro\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Enterprise\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n</Installation>\n<Dependencies>\n<Dependency Id=\"Microsoft.Framework.NDP\" DisplayName=\"Microsoft .NET Framework\" d:Source=\"Manual\" Version=\"[4.5,)\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestAdapter.csproj", "new_path": "Nodejs/Product/TestAdapter/TestAdapter.csproj", "diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"Microsoft.Build\">\n- <Version>16.6.0</Version>\n+ <Version>17.0.0-preview-21256-03</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.CSharp\">\n<Version>4.7.0</Version>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterImpl/TestAdapterImpl.csproj", "new_path": "Nodejs/Product/TestAdapterImpl/TestAdapterImpl.csproj", "diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"Microsoft.Build\">\n- <Version>16.6.0</Version>\n+ <Version>17.0.0-preview-21256-03</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.CSharp\">\n<Version>4.7.0</Version>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterVsix/TestAdapterVsix.csproj", "new_path": "Nodejs/Product/TestAdapterVsix/TestAdapterVsix.csproj", "diff": "<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n+ <PackageReference Include=\"Microsoft.VSSDK.BuildTools\">\n+ <Version>17.0.1597</Version>\n+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n+ <PrivateAssets>all</PrivateAssets>\n+ </PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n<Import Project=\"$(VSToolsPath)\\VSSDK\\Microsoft.VsSDK.targets\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterVsix/source.extension.vsixmanifest", "new_path": "Nodejs/Product/TestAdapterVsix/source.extension.vsixmanifest", "diff": "<AllowClientRole>true</AllowClientRole>\n</Metadata>\n<Installation SystemComponent=\"true\">\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Community\" />\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Pro\" />\n- <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Enterprise\" />\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Community\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Pro\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n+ <InstallationTarget Version=\"[17.0.0,18.0)\" Id=\"Microsoft.VisualStudio.Enterprise\">\n+ <ProductArchitecture>amd64</ProductArchitecture>\n+ </InstallationTarget>\n</Installation>\n<Dependencies>\n<Dependency Id=\"Microsoft.Framework.NDP\" DisplayName=\"Microsoft .NET Framework\" d:Source=\"Manual\" Version=\"[4.5,)\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Tests/TestAdapter.Tests/TestAdapter.Tests.csproj", "new_path": "Nodejs/Tests/TestAdapter.Tests/TestAdapter.Tests.csproj", "diff": "</PropertyGroup>\n<ItemGroup>\n- <PackageReference Include=\"Microsoft.Build\" Version=\"16.8.0\" />\n+ <PackageReference Include=\"Microsoft.Build\" Version=\"17.0.0-preview-21256-03\" />\n<PackageReference Include=\"Microsoft.Build.Utilities.Core\" Version=\"16.8.0\" />\n<PackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"16.7.1\" />\n<PackageReference Include=\"Moq\" Version=\"4.15.1\" />\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Various fixes to allow building with MSBuild 17
410,219
18.05.2021 10:29:40
25,200
b482f5dd8ded57871eeb66c125e93bc9777a52dc
Update deps and adjust to PIA change
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "new_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "diff": "<Version>4.7.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.Internal.VisualStudio.Interop\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Debugger.Interop.10.0\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Debugger.InteropA\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Editor\">\n<!--Required until MS.VS.VSInteractiveWindow updates its editor dependency to a merged interop version-->\n<Version>17.0.32-g9d6b2c6f26</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.ImageCatalog\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Imaging\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Interop\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.ProjectAggregator\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Shell.15.0\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Shell.Framework\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.TestWindow.Interfaces\">\n<Version>17.0.0-beta.21223.1</Version>\n<Version>4.5.0</Version>\n</PackageReference>\n<PackageReference Include=\"VsWebSite.Interop\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.SourceLink.GitHub\">\n<Version>1.0.0</Version>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/SharedProject/ProjectNode.cs", "new_path": "Nodejs/Product/Nodejs/SharedProject/ProjectNode.cs", "diff": "@@ -1266,7 +1266,7 @@ namespace Microsoft.VisualStudioTools.Project\n{\nArray contextParamsAsArray = contextParams;\n- var result = ivsExtensibility.RunWizardFile(wizardToRun, (int)dlgOwner, ref contextParamsAsArray, out wizResultAsInt);\n+ var result = ivsExtensibility.RunWizardFile(wizardToRun, dlgOwner, ref contextParamsAsArray, out wizResultAsInt);\nif (!ErrorHandler.Succeeded(result) && result != VSConstants.OLE_E_PROMPTSAVECANCELLED)\n{\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/ProjectWizard/ProjectWizard.csproj", "new_path": "Nodejs/Product/ProjectWizard/ProjectWizard.csproj", "diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Interop\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Settings.15.0\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Shell.15.0\">\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.TemplateWizardInterface\" >\n- <Version>17.0.0-preview-2-31221-277</Version>\n+ <Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n</ItemGroup>\n<Import Project=\"..\\Nodejs\\SharedResources.proj\" />\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Update deps and adjust to PIA change
410,219
18.05.2021 16:01:26
25,200
814bd01ad20e7d6f68dc939030ea8388607f8a6b
Update dependency versions in Vue project templates
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptVuejsApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptVuejsApp/package.json", "diff": "\"name\": \"\"\n},\n\"dependencies\": {\n- \"vue\": \"2.5.17\",\n- \"vue-class-component\": \"6.0.0\",\n- \"vue-property-decorator\": \"7.0.0\"\n+ \"vue\": \"2.6.12\",\n+ \"vue-class-component\": \"7.2.6\",\n+ \"vue-property-decorator\": \"9.1.2\"\n},\n\"devDependencies\": {\n- \"@vue/cli-plugin-babel\": \"3.0.4\",\n- \"@vue/cli-plugin-typescript\": \"3.0.4\",\n- \"@vue/cli-service\": \"3.0.4\",\n- \"typescript\": \"^4.0.5\",\n- \"vue-template-compiler\": \"2.5.17\"\n+ \"@vue/cli-plugin-babel\": \"4.5.13\",\n+ \"@vue/cli-plugin-typescript\": \"4.5.13\",\n+ \"@vue/cli-service\": \"4.5.13\",\n+ \"typescript\": \"4.1.5\",\n+ \"vue-template-compiler\": \"2.6.12\"\n},\n\"postcss\": {\n\"plugins\": {\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/VuejsApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/VuejsApp/package.json", "diff": "\"name\": \"\"\n},\n\"dependencies\": {\n- \"vue\": \"2.5.17\"\n+ \"vue\": \"2.6.12\"\n},\n\"devDependencies\": {\n- \"@vue/cli-plugin-babel\": \"3.0.4\",\n- \"@vue/cli-plugin-eslint\": \"3.0.4\",\n- \"@vue/cli-service\": \"3.0.4\",\n- \"eslint\": \"5.6.0\",\n- \"eslint-plugin-vue\": \"4.7.1\",\n- \"vue-template-compiler\": \"2.5.17\"\n+ \"@vue/cli-plugin-babel\": \"4.5.13\",\n+ \"@vue/cli-plugin-eslint\": \"4.5.13\",\n+ \"@vue/cli-service\": \"4.5.13\",\n+ \"babel-eslint\": \"10.1.0\",\n+ \"eslint\": \"6.8.0\",\n+ \"eslint-plugin-vue\": \"6.2.2\",\n+ \"vue-template-compiler\": \"2.6.12\"\n},\n\"eslintConfig\": {\n\"root\": true,\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Update dependency versions in Vue project templates
410,219
24.05.2021 11:07:11
25,200
9d3e0b13b5083b4f880a9604760bebf224c4ad5e
Update shell dependencies
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "new_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "diff": "<Version>17.0.0-previews-1-31318-023</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.Debugger.Interop.10.0\">\n- <Version>17.0.0-previews-1-31318-023</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.VisualStudio.Debugger.InteropA\">\n- <Version>17.0.0-previews-1-31318-023</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.VisualStudio.Editor\">\n- <!--Required until MS.VS.VSInteractiveWindow updates its editor dependency to a merged interop version-->\n- <Version>17.0.32-g9d6b2c6f26</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.VisualStudio.ImageCatalog\">\n- <Version>17.0.0-previews-1-31318-023</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.VisualStudio.Imaging\">\n- <Version>17.0.0-previews-1-31318-023</Version>\n+ <Version>17.0.0-previews-1-31321-211</Version>\n</PackageReference>\n- <PackageReference Include=\"Microsoft.VisualStudio.Interop\">\n- <Version>17.0.0-previews-1-31318-023</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.VisualStudio.ProjectAggregator\">\n- <Version>17.0.0-previews-1-31318-023</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.VisualStudio.Shell.15.0\">\n- <Version>17.0.0-previews-1-31318-023</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.VisualStudio.Shell.Framework\">\n- <Version>17.0.0-previews-1-31318-023</Version>\n+ <PackageReference Include=\"Microsoft.VisualStudio.SDK\">\n+ <Version>17.0.0-previews-1-31321-311</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudio.TestWindow.Interfaces\">\n<Version>17.0.0-beta.21223.1</Version>\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Update shell dependencies
410,197
30.08.2021 13:14:18
25,200
fd93d7f31921600cb4aa7f6b80a5fc0c14084d66
Add period for consistency
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/VSPackage.resx", "new_path": "Nodejs/Product/Nodejs/VSPackage.resx", "diff": "<value>Launch for Node.js</value>\n</data>\n<data name=\"6001\" xml:space=\"preserve\">\n- <value>Debug JavaScript/TypeScript files with Node.js</value>\n+ <value>Debug JavaScript/TypeScript files with Node.js.</value>\n</data>\n<assembly alias=\"System.Windows.Forms\" name=\"System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" />\n<data name=\"400\" type=\"System.Resources.ResXFileRef, System.Windows.Forms\">\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Add period for consistency
410,206
03.09.2021 11:36:20
25,200
be12263db8f833675b350c615df21b7708eb388f
Adding configuration to run React tests on Jest.
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "new_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "diff": "@@ -37,8 +37,10 @@ const find_tests = function (testFileList, discoverResultFile, projectFolder) {\n};\nconst run_tests = function (context) {\n+ let projectFolder = context.testCases[0].projectFolder;\n+ process.env.NODE_ENV = process.env.NODE_ENV || 'test';\nreturn new Promise(async resolve => {\n- const jest = detectPackage(context.testCases[0].projectFolder, 'jest');\n+ const jest = detectPackage(projectFolder, 'jest');\nif (!jest) {\nreturn resolve();\n}\n@@ -51,14 +53,15 @@ const run_tests = function (context) {\n});\n}\n- const config = {\n+ let projectFolderJsonReady = projectFolder.replaceAll('\\\\', '\\\\\\\\');\n+ const argv = {\njson: true,\nreporters: [[__dirname + '/jestReporter.js', { context }]],\n- testMatch: [context.testCases[0].testFile]\n- };\n+ config : `{\"roots\":[\"<rootDir>/src\"],\"collectCoverageFrom\":[\"src/**/*.{js,jsx,ts,tsx}\",\"!src/**/*.d.ts\"],\"setupFiles\":[\"${projectFolderJsonReady}\\\\\\\\node_modules\\\\\\\\react-app-polyfill\\\\\\\\jsdom.js\"],\"setupFilesAfterEnv\":[\"<rootDir>/src/setupTests.js\"],\"testMatch\":[\"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}\",\"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}\"],\"testEnvironment\":\"jsdom\",\"testRunner\":\"${projectFolderJsonReady}\\\\\\\\node_modules\\\\\\\\jest-circus\\\\\\\\runner.js\",\"transform\":{\"^.+\\\\\\\\.(js|jsx|mjs|cjs|ts|tsx)$\":\"${projectFolderJsonReady}\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\babelTransform.js\",\"^.+\\\\\\\\.css$\":\"${projectFolderJsonReady}\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\cssTransform.js\",\"^(?!.*\\\\\\\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)\":\"${projectFolderJsonReady}\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\fileTransform.js\"},\"transformIgnorePatterns\":[\"[/\\\\\\\\\\\\\\\\]node_modules[/\\\\\\\\\\\\\\\\].+\\\\\\\\.(js|jsx|mjs|cjs|ts|tsx)$\",\"^.+\\\\\\\\.module\\\\\\\\.(css|sass|scss)$\"],\"modulePaths\":[],\"moduleNameMapper\":{\"^react-native$\":\"react-native-web\",\"^.+\\\\\\\\.module\\\\\\\\.(css|sass|scss)$\":\"identity-obj-proxy\"},\"moduleFileExtensions\":[\"web.js\",\"js\",\"web.ts\",\"ts\",\"web.tsx\",\"tsx\",\"json\",\"web.jsx\",\"jsx\",\"node\"],\"watchPlugins\":[\"jest-watch-typeahead/filename\",\"jest-watch-typeahead/testname\"],\"resetMocks\":true,\"rootDir\":\"${projectFolderJsonReady}\"}`,\n+ }\ntry {\n- await jest.runCLI(config, [context.testCases[0].projectFolder]);\n+ await jest.runCLI(argv, [projectFolder]);\n} catch (error) {\nlogError(error);\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Adding configuration to run React tests on Jest.
410,206
13.09.2021 16:50:06
25,200
b71510351f48e3ce679d8e7466556b442cf207a8
Adding support to user's Jest configutation
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "new_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "diff": "@@ -56,11 +56,7 @@ const run_tests = function (context) {\n});\n}\n- let config = {\n- setupFilesAfterEnv:[\"<rootDir>/src/setupTests.js\"],\n- testMatch: [context.testCases[0].testFile],\n- transform:{\"^.+\\\\.(js|jsx|mjs|cjs|ts|tsx)$\": projectFolder + \"\\\\node_modules\\\\react-scripts\\\\config\\\\jest\\\\babelTransform.js\",\"^.+\\\\\\\\.css$\": projectFolder + \"\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\cssTransform.js\",\"^(?!.*\\\\\\\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)\": projectFolder + \"\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\fileTransform.js\"}\n- }\n+ let config = readConfigs(projectFolder, context);\nconst argv = {\njson: true,\n@@ -127,5 +123,34 @@ function logError() {\nconsole.error.apply(console, errorArgs);\n}\n+function readConfigs(projectFolder, context)\n+{\n+ var userConfig;\n+ const jestConfigPath = projectFolder + \"\\\\jest.config.js\";\n+ const packageJsonPath = projectFolder + \"\\\\package.json\";\n+\n+ if(fs.existsSync(jestConfigPath))\n+ {\n+ userConfig = require(jestConfigPath);\n+ mergeConfigs();\n+ return userConfig;\n+ }\n+\n+ if(fs.existsSync(packageJsonPath))\n+ {\n+ userConfig = require(packageJsonPath).jest;\n+ mergeConfigs();\n+ return userConfig;\n+ }\n+\n+ function mergeConfigs()\n+ {\n+ if(!userConfig) userConfig = {};\n+ if(!userConfig.setupFilesAfterEnv) userConfig.setupFilesAfterEnv = [\"<rootDir>/src/setupTests.js\"];\n+ if(!userConfig.testMatch) userConfig.testMatch = [context.testCases[0].testFile];\n+ if(!userConfig.transform) userConfig.transform = {\"^.+\\\\.(js|jsx|mjs|cjs|ts|tsx)$\": projectFolder + \"\\\\node_modules\\\\react-scripts\\\\config\\\\jest\\\\babelTransform.js\",\"^.+\\\\\\\\.css$\": projectFolder + \"\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\cssTransform.js\",\"^(?!.*\\\\\\\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)\": projectFolder + \"\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\fileTransform.js\"};\n+ }\n+}\n+\nmodule.exports.find_tests = find_tests;\nmodule.exports.run_tests = run_tests;\n\\ No newline at end of file\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Adding support to user's Jest configutation
410,206
07.10.2021 11:59:48
25,200
94b09e2468a17e8957c5ce312fa303a44f739f2a
Adding configuration options to Node Console App and React
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworkFactory.cs", "new_path": "Nodejs/Product/TestAdapter/TestFrameworkFactory.cs", "diff": "@@ -91,18 +91,6 @@ namespace Microsoft.NodejsTools.TestAdapter\nfileAbsolutePath = CommonUtils.GetAbsoluteFilePath(projectRoot, projectItem.EvaluatedInclude);\n}\n- // Check if file is a typecript file. If so, get the javascript file. The javascript file needs to be in the same path and name.\n- // It doesn't work with bundlers or minimizers. Also, project needs to be build in order to have the js file created.\n- var typeScriptTest = TypeScriptHelpers.IsTypeScriptFile(fileAbsolutePath);\n- if (typeScriptTest)\n- {\n- fileAbsolutePath = TypeScriptHelpers.GetTypeScriptBackedJavaScriptFile(project, fileAbsolutePath);\n- }\n- else if (!StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(fileAbsolutePath), \".js\"))\n- {\n- return null;\n- }\n-\nreturn (testFrameworkName, fileAbsolutePath);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "new_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "diff": "@@ -42,6 +42,7 @@ const run_tests = function (context) {\n// NODE_ENV sets the environment context for Node, it can be development, production or test and it needs to be set up for jest to work.\n// If no value was assigned, assign test.\nprocess.env.NODE_ENV = process.env.NODE_ENV || 'test';\n+\nreturn new Promise(async resolve => {\nconst jest = detectPackage(projectFolder, 'jest');\nif (!jest) {\n@@ -117,41 +118,50 @@ function detectPackage(projectFolder, packageName) {\n}\n}\n-function logError() {\n- var errorArgs = Array.from(arguments);\n- errorArgs.unshift(\"NTVS_ERROR:\");\n- console.error.apply(console, errorArgs);\n-}\n-\nfunction readConfigs(projectFolder, context)\n{\n- // First look for Jest.config.js, otherwise look at the package.json under \"jest\" tag\n- var userConfig;\n- const jestConfigPath = projectFolder + \"\\\\jest.config.js\";\n+ var config;\nconst packageJsonPath = projectFolder + \"\\\\package.json\";\n+ const jestConfigPath = projectFolder + \"\\\\jest.config.js\";\n- if(fs.existsSync(jestConfigPath))\n+ // If this is a React project, then the path exists, and we should use the react scripts config generation.\n+ // It already deals with override from package.json config, if there's any.\n+ const pathToReactConfig = projectFolder + \"\\\\node_modules\\\\react-scripts\\\\scripts\\\\utils\\\\createJestConfig.js\";\n+ if(fs.existsSync(pathToReactConfig))\n{\n- userConfig = require(jestConfigPath);\n- mergeConfigs();\n- return userConfig;\n+ const createJestConfig = require(pathToReactConfig);\n+ const path = require('path');\n+ config = createJestConfig(\n+ relativePath => path.resolve(projectFolder + '/node_modules/react-scripts/', relativePath),\n+ projectFolder,\n+ false\n+ )\n+\n+ return config;\n}\n+ // Else, for other frameworks, first prioritize package.json config if jest config exists there under \"jest\".\n+ // If not, try to find jest.config.js. If no file found, finally use a basic config.\nif(fs.existsSync(packageJsonPath))\n{\n- userConfig = require(packageJsonPath).jest;\n- mergeConfigs();\n- return userConfig;\n+ config = require(packageJsonPath).jest;\n}\n- function mergeConfigs()\n+ if(fs.existsSync(jestConfigPath) && !config)\n{\n- // If no config was found OR the user doesn't have these tags set up, add it.\n- if(!userConfig) userConfig = {};\n- if(!userConfig.setupFilesAfterEnv) userConfig.setupFilesAfterEnv = [\"<rootDir>/src/setupTests.js\"];\n- if(!userConfig.testMatch) userConfig.testMatch = [context.testCases[0].testFile];\n- if(!userConfig.transform) userConfig.transform = {\"^.+\\\\.(js|jsx|mjs|cjs|ts|tsx)$\": projectFolder + \"\\\\node_modules\\\\react-scripts\\\\config\\\\jest\\\\babelTransform.js\",\"^.+\\\\\\\\.css$\": projectFolder + \"\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\cssTransform.js\",\"^(?!.*\\\\\\\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)\": projectFolder + \"\\\\\\\\node_modules\\\\\\\\react-scripts\\\\\\\\config\\\\\\\\jest\\\\\\\\fileTransform.js\"};\n+ config = require(jestConfigPath);\n}\n+\n+ if(!config) config = {};\n+ if(!config.testMatch) config.testMatch = [context.testCases[0].testFile];\n+\n+ return config;\n+}\n+\n+function logError() {\n+ var errorArgs = Array.from(arguments);\n+ errorArgs.unshift(\"NTVS_ERROR:\");\n+ console.error.apply(console, errorArgs);\n}\nmodule.exports.find_tests = find_tests;\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Adding configuration options to Node Console App and React
410,206
07.10.2021 17:13:03
25,200
b8c3a4b0dd668d226814da1448adfdfda0254c0b
Changing from var to let
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "new_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "diff": "@@ -120,7 +120,7 @@ function detectPackage(projectFolder, packageName) {\nfunction readConfigs(projectFolder, context)\n{\n- var config;\n+ let config;\nconst packageJsonPath = path.join(projectFolder, 'package.json');\nconst jestConfigPath = path.join(projectFolder, 'jest.config.js');\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Changing from var to let
410,206
12.10.2021 16:21:37
25,200
fefc59fb9491d5428af38cb83f95ce985e8ed7f2
Adding suport to jest.config.ts and restoring code
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "new_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"Newtonsoft.Json\">\n- <Version>13.0.1</Version>\n+ <Version>13.0.0</Version>\n</PackageReference>\n<PackageReference Include=\"System.ValueTuple\">\n<Version>4.5.0</Version>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworkFactory.cs", "new_path": "Nodejs/Product/TestAdapter/TestFrameworkFactory.cs", "diff": "@@ -91,6 +91,22 @@ namespace Microsoft.NodejsTools.TestAdapter\nfileAbsolutePath = CommonUtils.GetAbsoluteFilePath(projectRoot, projectItem.EvaluatedInclude);\n}\n+ // Check if file is a typecript file. If so, get the javascript file. The javascript file needs to be in the same path and name.\n+ // It doesn't work with bundlers or minimizers. Also, project needs to be build in order to have the js file created.\n+ // Note: for Jest we're just passing the .ts or .tsx, no need for .js\n+ if(testFrameworkName != \"Jest\")\n+ {\n+ var typeScriptTest = TypeScriptHelpers.IsTypeScriptFile(fileAbsolutePath);\n+ if (typeScriptTest)\n+ {\n+ fileAbsolutePath = TypeScriptHelpers.GetTypeScriptBackedJavaScriptFile(project, fileAbsolutePath);\n+ }\n+ else if (!StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(fileAbsolutePath), \".js\"))\n+ {\n+ return null;\n+ }\n+ }\n+\nreturn (testFrameworkName, fileAbsolutePath);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "new_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "diff": "@@ -120,9 +120,10 @@ function detectPackage(projectFolder, packageName) {\nfunction readConfigs(projectFolder, context)\n{\n- let config;\n+ var config;\nconst packageJsonPath = path.join(projectFolder, 'package.json');\n- const jestConfigPath = path.join(projectFolder, 'jest.config.js');\n+ const jestConfigPathTS = path.join(projectFolder, 'jest.config.ts');\n+ const jestConfigPathJS = path.join(projectFolder, 'jest.config.js');\n// If this is a React project, then the path exists, and we should use the react scripts config generation.\n// It already deals with override from package.json config, if there's any.\n@@ -134,25 +135,29 @@ function readConfigs(projectFolder, context)\nrelativePath => path.join(projectFolder, 'node_modules/react-scripts/', relativePath),\nprojectFolder,\nfalse\n- )\n+ );\nreturn config;\n}\n// Else, for other frameworks, first prioritize package.json config if jest config exists there under \"jest\".\n- // If not, try to find jest.config.js. If no file found, finally use a basic config.\n+ // If not, try to find jest.config either being TS or JS. If no file found, finally use a basic config.\nif(fs.existsSync(packageJsonPath))\n{\nconfig = require(packageJsonPath).jest;\n}\n- if(!config && fs.existsSync(jestConfigPath))\n+ if(!config && fs.existsSync(jestConfigPathJS))\n{\n- config = require(jestConfigPath);\n+ config = require(jestConfigPathJS);\n+ }\n+ else if(!config && fs.existsSync(jestConfigPathTS))\n+ {\n+ config = require(jestConfigPathTS);\n}\n- if(!config) config = {};\n- if(!config.testMatch) config.testMatch = [context.testCases[0].testFile];\n+ config ||= {};\n+ config.testMatch ||= [context.testCases[0].testFile];\nreturn config;\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Adding suport to jest.config.ts and restoring code
410,206
13.10.2021 15:45:45
25,200
3302f01e8b12dec26cf80a574792ef6b77ef9394
Addressing some comments and removing jest.config.ts support as it's still on testing.
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "new_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "diff": "@@ -122,7 +122,6 @@ function readConfigs(projectFolder, context)\n{\nvar config;\nconst packageJsonPath = path.join(projectFolder, 'package.json');\n- const jestConfigPathTS = path.join(projectFolder, 'jest.config.ts');\nconst jestConfigPathJS = path.join(projectFolder, 'jest.config.js');\n// If this is a React project, then the path exists, and we should use the react scripts config generation.\n@@ -141,7 +140,7 @@ function readConfigs(projectFolder, context)\n}\n// Else, for other frameworks, first prioritize package.json config if jest config exists there under \"jest\".\n- // If not, try to find jest.config either being TS or JS. If no file found, finally use a basic config.\n+ // If not, try to find jest.config.js. If no file found, finally use a basic config.\nif(fs.existsSync(packageJsonPath))\n{\nconfig = require(packageJsonPath).jest;\n@@ -151,10 +150,6 @@ function readConfigs(projectFolder, context)\n{\nconfig = require(jestConfigPathJS);\n}\n- else if(!config && fs.existsSync(jestConfigPathTS))\n- {\n- config = require(jestConfigPathTS);\n- }\nconfig ||= {};\nconfig.testMatch ||= [context.testCases[0].testFile];\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Addressing some comments and removing jest.config.ts support as it's still on testing.
410,206
02.11.2021 15:16:51
25,200
225ebba58deb09bc6a36570df45fd8e922f9ab8b
Fixing operator for older Node versions
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "new_path": "Nodejs/Product/TestAdapter/TestFrameworks/Jest/jest.js", "diff": "@@ -151,8 +151,8 @@ function readConfigs(projectFolder, context)\nconfig = require(jestConfigPathJS);\n}\n- config ||= {};\n- config.testMatch ||= [context.testCases[0].testFile];\n+ config = config || {};\n+ config.testMatch = config.testMatch || [context.testCases[0].testFile];\nreturn config;\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Fixing operator for older Node versions
410,221
30.11.2021 14:51:47
28,800
207d5aef0bedf4d83f8b2c8be0771724aee6a759
Fixing perf issue in TestFilesUpdateWatcher Currently, we use JTF.Run() on each time we get a FilesChanged event, or a DirectoryChangedEx event. This blocks the current (threadpool) thread until the work is complete. This can cause threadpool starvation, and has done so for users, as evidenced by telemetry.
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Telemetry/TelemetryEvents.cs", "new_path": "Nodejs/Product/Nodejs/Telemetry/TelemetryEvents.cs", "diff": "@@ -41,6 +41,11 @@ namespace Microsoft.NodejsTools.Telemetry\npublic const string OperationRegistrationFaulted = Prefix + \"OperationRegistrationFaulted\";\n+ /// <summary>\n+ /// An error occurred within a TestFilesUpdateWatcher event handler\n+ /// </summary>\n+ public const string TestFilesWatcherEventFaulted = Prefix + \"TestFilesWatcherEventFaulted\";\n+\n/// <summary>\n/// User started discovery on the test adapters.\n/// </summary>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterImpl/TestAdapterImpl.csproj", "new_path": "Nodejs/Product/TestAdapterImpl/TestAdapterImpl.csproj", "diff": "<Compile Include=\"..\\TypeScript\\TypeScriptHelpers.cs\">\n<Link>TypeScriptHelpers.cs</Link>\n</Compile>\n+ <Compile Include=\"..\\Nodejs\\Telemetry\\TelemetryEvents.cs\" Link=\"Telemetry\\TelemetryEvents.cs\" />\n<Compile Include=\"Properties\\AssemblyInfo.cs\" />\n<Compile Include=\"RunFromContextFileExtensions.cs\" />\n<Compile Include=\"ServiceProviderExtension.cs\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterImpl/TestFilesUpdateWatcher.cs", "new_path": "Nodejs/Product/TestAdapterImpl/TestFilesUpdateWatcher.cs", "diff": "@@ -4,6 +4,8 @@ using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\n+using System.Threading;\n+using Microsoft.NodejsTools.Telemetry;\nusing Microsoft.VisualStudio;\nusing Microsoft.VisualStudio.Shell;\nusing Microsoft.VisualStudio.Shell.Interop;\n@@ -18,7 +20,10 @@ namespace Microsoft.NodejsTools.TestAdapter\nprivate readonly IDictionary<string, uint> watchedFiles = new Dictionary<string, uint>(StringComparer.OrdinalIgnoreCase);\nprivate readonly IDictionary<string, uint> watchedFolders = new Dictionary<string, uint>(StringComparer.OrdinalIgnoreCase);\n- private bool disposed;\n+ const int NOT_DISPOSED = 0;\n+ const int DISPOSED = 1;\n+\n+ private int disposed = NOT_DISPOSED;\npublic event EventHandler<TestFileChangedEventArgs> FileChangedEvent;\n@@ -87,17 +92,22 @@ namespace Microsoft.NodejsTools.TestAdapter\npublic int FilesChanged(uint cChanges, string[] rgpszFile, uint[] rggrfChange)\n{\n- return ThreadHelper.JoinableTaskFactory.Run(async () =>\n+ ThreadHelper.JoinableTaskFactory.RunAsync(async () =>\n{\nawait ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();\nfor (var i = 0; i < cChanges; i++)\n{\n+ if(this.IsDisposed)\n+ {\n+ return;\n+ }\n+\nthis.FileChangedEvent?.Invoke(this, new TestFileChangedEventArgs(rgpszFile[i], ConvertVSFILECHANGEFLAGS(rggrfChange[i])));\n}\n+ }).FileAndForget(TelemetryEvents.TestFilesWatcherEventFaulted);\nreturn VSConstants.S_OK;\n- });\n}\npublic int DirectoryChanged(string directory)\n@@ -122,17 +132,22 @@ namespace Microsoft.NodejsTools.TestAdapter\npublic int DirectoryChangedEx2(string directory, uint numberOfFilesChanged, string[] filesChanged, uint[] flags)\n{\n- return ThreadHelper.JoinableTaskFactory.Run(async () =>\n+ ThreadHelper.JoinableTaskFactory.RunAsync (async () =>\n{\nawait ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();\nfor (var i = 0; i < numberOfFilesChanged; i++)\n{\n+ if (this.IsDisposed)\n+ {\n+ return;\n+ }\n+\nthis.FileChangedEvent?.Invoke(this, new TestFileChangedEventArgs(filesChanged[i], ConvertVSFILECHANGEFLAGS(flags[i])));\n}\n+ }).FileAndForget(TelemetryEvents.TestFilesWatcherEventFaulted);\nreturn VSConstants.S_OK;\n- });\n}\nprivate static WatcherChangeTypes ConvertVSFILECHANGEFLAGS(uint flag)\n@@ -156,17 +171,18 @@ namespace Microsoft.NodejsTools.TestAdapter\nprivate void CheckDisposed()\n{\n- if (this.disposed)\n+ if (this.disposed == DISPOSED)\n{\nthrow new ObjectDisposedException(nameof(TestFilesUpdateWatcher));\n}\n}\n+ private bool IsDisposed => this.disposed == DISPOSED;\n+\npublic void Dispose()\n{\n- if (!this.disposed)\n+ if (Interlocked.CompareExchange(ref this.disposed, DISPOSED, NOT_DISPOSED) == NOT_DISPOSED)\n{\n- this.disposed = true;\nforeach (var cookie in this.watchedFiles.Values)\n{\nthis.fileWatcher.UnadviseFileChange(cookie);\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Fixing perf issue in TestFilesUpdateWatcher Currently, we use JTF.Run() on each time we get a FilesChanged event, or a DirectoryChangedEx event. This blocks the current (threadpool) thread until the work is complete. This can cause threadpool starvation, and has done so for users, as evidenced by telemetry.
410,207
07.12.2021 11:17:07
10,800
01e317124b93027f16af5c9d19833ae319b8b62a
Renamed template folders to make paths shorter
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "new_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "diff": "</None>\n</ItemGroup>\n<ItemGroup>\n- <_WebRoleZipItem Include=\"Templates\\Files\\CloudServiceWebRole\\WebRole.vstemplate\" />\n- <_WebRoleZipItem Include=\"Templates\\Files\\CloudServiceWebRole\\roletemplatedata.xml\" />\n- <_WebRoleZipItem Include=\"Templates\\Files\\CloudServiceTypeScriptWebRole\\roletemplatedata.xml\" />\n- <_WebRoleZipItem Include=\"Templates\\Files\\CloudServiceTypeScriptWebRole\\TypeScriptWebRole.vstemplate\" />\n- <_WebRoleZipItem Include=\"Templates\\Files\\CloudServiceExpressWebRole\\ExpressWebRole.vstemplate\" />\n- <_WebRoleZipItem Include=\"Templates\\Files\\CloudServiceExpressWebRole\\roletemplatedata.xml\" />\n- <_WebRoleZipItem Include=\"Templates\\Files\\CloudServiceTypeScriptExpressWebRole\\roletemplatedata.xml\" />\n- <_WebRoleZipItem Include=\"Templates\\Files\\CloudServiceTypeScriptExpressWebRole\\TypeScriptExpressWebRole.vstemplate\" />\n- <_WorkerRoleZipItem Include=\"Templates\\Files\\CloudServiceTypeScriptWorkerRole\\roletemplatedata.xml\" />\n- <_WorkerRoleZipItem Include=\"Templates\\Files\\CloudServiceTypeScriptWorkerRole\\TypeScriptWorkerRole.vstemplate\" />\n- <_WorkerRoleZipItem Include=\"Templates\\Files\\CloudServiceWorkerRole\\roletemplatedata.xml\" />\n- <_WorkerRoleZipItem Include=\"Templates\\Files\\CloudServiceWorkerRole\\WorkerRole.vstemplate\" />\n+ <_WebRoleZipItem Include=\"Templates\\Files\\CSWebRole\\WebRole.vstemplate\" />\n+ <_WebRoleZipItem Include=\"Templates\\Files\\CSWebRole\\roletemplatedata.xml\" />\n+ <_WebRoleZipItem Include=\"Templates\\Files\\CSTSWebRole\\roletemplatedata.xml\" />\n+ <_WebRoleZipItem Include=\"Templates\\Files\\CSTSWebRole\\TypeScriptWebRole.vstemplate\" />\n+ <_WebRoleZipItem Include=\"Templates\\Files\\CSExpressWebRole\\ExpressWebRole.vstemplate\" />\n+ <_WebRoleZipItem Include=\"Templates\\Files\\CSExpressWebRole\\roletemplatedata.xml\" />\n+ <_WebRoleZipItem Include=\"Templates\\Files\\CSTSExpressWebRole\\roletemplatedata.xml\" />\n+ <_WebRoleZipItem Include=\"Templates\\Files\\CSTSExpressWebRole\\TypeScriptExpressWebRole.vstemplate\" />\n+ <_WorkerRoleZipItem Include=\"Templates\\Files\\CSTSWorkerRole\\roletemplatedata.xml\" />\n+ <_WorkerRoleZipItem Include=\"Templates\\Files\\CSTSWorkerRole\\TypeScriptWorkerRole.vstemplate\" />\n+ <_WorkerRoleZipItem Include=\"Templates\\Files\\CSWorkerRole\\roletemplatedata.xml\" />\n+ <_WorkerRoleZipItem Include=\"Templates\\Files\\CSWorkerRole\\WorkerRole.vstemplate\" />\n<ZipItem Include=\"@(_WebRoleZipItem)\">\n<OutputSubPath>NETFramework4\\Web Role\\Node.js</OutputSubPath>\n<Language>CloudService</Language>\n" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceExpressWebRole/ExpressWebRole.vstemplate", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSExpressWebRole/ExpressWebRole.vstemplate", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceExpressWebRole/roletemplatedata.xml", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSExpressWebRole/roletemplatedata.xml", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceTypeScriptExpressWebRole/TypeScriptExpressWebRole.vstemplate", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSTSExpressWebRole/TypeScriptExpressWebRole.vstemplate", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceTypeScriptExpressWebRole/roletemplatedata.xml", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSTSExpressWebRole/roletemplatedata.xml", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceTypeScriptWebRole/TypeScriptWebRole.vstemplate", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSTSWebRole/TypeScriptWebRole.vstemplate", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceTypeScriptWebRole/roletemplatedata.xml", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSTSWebRole/roletemplatedata.xml", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceTypeScriptWorkerRole/TypeScriptWorkerRole.vstemplate", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSTSWorkerRole/TypeScriptWorkerRole.vstemplate", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceTypeScriptWorkerRole/roletemplatedata.xml", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSTSWorkerRole/roletemplatedata.xml", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceWebRole/WebRole.vstemplate", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSWebRole/WebRole.vstemplate", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceWebRole/roletemplatedata.xml", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSWebRole/roletemplatedata.xml", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceWorkerRole/WorkerRole.vstemplate", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSWorkerRole/WorkerRole.vstemplate", "diff": "" }, { "change_type": "RENAME", "old_path": "Nodejs/Product/Nodejs/Templates/Files/CloudServiceWorkerRole/roletemplatedata.xml", "new_path": "Nodejs/Product/Nodejs/Templates/Files/CSWorkerRole/roletemplatedata.xml", "diff": "" } ]
C#
Apache License 2.0
microsoft/nodejstools
Renamed template folders to make paths shorter
410,202
11.03.2022 17:34:00
28,800
0b31478b2661fa5534f44d905751941dbd46f9de
Refactor npm install --save command
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.Designer.cs", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.Designer.cs", "diff": "@@ -19,7 +19,7 @@ namespace Microsoft.NodejsTools.NpmUI {\n// class via a tool like ResGen or Visual Studio.\n// To add or remove a member, edit your .ResX file then rerun ResGen\n// with the /str option, or rebuild your VS project.\n- [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"16.0.0.0\")]\n+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"17.0.0.0\")]\n[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\npublic class NpmInstallWindowResources {\n@@ -132,6 +132,15 @@ namespace Microsoft.NodejsTools.NpmUI {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to No Save.\n+ /// </summary>\n+ public static string DevTypeNoSaveChoice {\n+ get {\n+ return ResourceManager.GetString(\"DevTypeNoSaveChoice\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to Optional.\n/// </summary>\n@@ -142,11 +151,11 @@ namespace Microsoft.NodejsTools.NpmUI {\n}\n/// <summary>\n- /// Looks up a localized string similar to Standard.\n+ /// Looks up a localized string similar to Production.\n/// </summary>\n- public static string DevTypeStandardChoice {\n+ public static string DevTypeProductionChoice {\nget {\n- return ResourceManager.GetString(\"DevTypeStandardChoice\", resourceCulture);\n+ return ResourceManager.GetString(\"DevTypeProductionChoice\", resourceCulture);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.resx", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.resx", "diff": "<data name=\"DevTypeOptionalChoice\" xml:space=\"preserve\">\n<value>Optional</value>\n</data>\n- <data name=\"DevTypeStandardChoice\" xml:space=\"preserve\">\n- <value>Standard</value>\n+ <data name=\"DevTypeProductionChoice\" xml:space=\"preserve\">\n+ <value>Production</value>\n+ </data>\n+ <data name=\"DevTypeNoSaveChoice\" xml:space=\"preserve\">\n+ <value>No Save</value>\n</data>\n<data name=\"HomepageLabel\" xml:space=\"preserve\">\n<value>Homepage: </value>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallViewModel.cs", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallViewModel.cs", "diff": "@@ -22,6 +22,7 @@ namespace Microsoft.NodejsTools.NpmUI\nIndexStandard = 0,\nIndexDev = 1,\nIndexOptional = 2,\n+ IndexNoSave = 3,\n}\ninternal static class FilterState\n@@ -44,7 +45,6 @@ namespace Microsoft.NodejsTools.NpmUI\nprivate int selectedDependencyTypeIndex;\nprivate string filterText = string.Empty;\nprivate string arguments = string.Empty;\n- private bool saveToPackageJson = true;\nprivate bool isExecutingCommand = false;\nprivate object selectedVersion;\n@@ -303,16 +303,18 @@ namespace Microsoft.NodejsTools.NpmUI\ninternal void Install(PackageCatalogEntryViewModel package)\n{\n- var type = DependencyType.Standard;\n+ var type = DependencyType.Production;\nswitch ((Indices)this.SelectedDependencyTypeIndex)\n{\ncase Indices.IndexDev:\ntype = DependencyType.Development;\nbreak;\n-\ncase Indices.IndexOptional:\ntype = DependencyType.Optional;\nbreak;\n+ case Indices.IndexNoSave:\n+ type = DependencyType.NoSave;\n+ break;\n}\nif (!string.IsNullOrEmpty(package.Name))\n@@ -327,7 +329,6 @@ namespace Microsoft.NodejsTools.NpmUI\nselectedVersion,\ntype,\nfalse,\n- this.SaveToPackageJson,\nthis.Arguments));\n}\n}\n@@ -352,16 +353,6 @@ namespace Microsoft.NodejsTools.NpmUI\n}\n}\n- public bool SaveToPackageJson\n- {\n- get { return this.saveToPackageJson; }\n- set\n- {\n- this.saveToPackageJson = value;\n- OnPropertyChanged();\n- }\n- }\n-\npublic PackageCatalogEntryViewModel SelectedPackage\n{\nget { return this.selectedPackage; }\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "diff": "<Binding ElementName=\"OtherNpmArgumentsLabel\" />\n</AutomationProperties.LabeledBy>\n</TextBox>\n- <Label Grid.Row=\"3\" HorizontalAlignment=\"Right\" VerticalAlignment=\"Center\" Content=\"{x:Static resx:NpmInstallWindowResources.AddToPackageJsonLabel}\" x:Name=\"AddToPackageJsonLabel\"/>\n- <CheckBox x:Name=\"SaveToPackageJsonCheckbox\" Grid.Column=\"1\" Grid.Row=\"3\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Left\"\n- IsChecked=\"{Binding SaveToPackageJson}\" Margin=\"4\" TabIndex=\"10\" Content=\"{x:Static resx:NpmInstallWindowResources.AddToPackageJsonCheckboxLabel}\">\n- <AutomationProperties.LabeledBy>\n- <Binding ElementName=\"AddToPackageJsonLabel\" />\n- </AutomationProperties.LabeledBy>\n- </CheckBox>\n<Label Grid.Row=\"2\" HorizontalAlignment=\"Right\" VerticalAlignment=\"Center\" Content=\"{x:Static resx:NpmInstallWindowResources.DependencyTypeLabel}\" x:Name=\"DependencyTypeLabel\" />\n<ComboBox Name=\"DependencyComboBox\"\n<AutomationProperties.LabeledBy>\n<Binding ElementName=\"DependencyTypeLabel\" />\n</AutomationProperties.LabeledBy>\n- <ComboBoxItem Tag=\"St\" IsSelected=\"True\" Content=\"{x:Static resx:NpmInstallWindowResources.DevTypeStandardChoice}\" />\n+ <ComboBoxItem Tag=\"St\" IsSelected=\"True\" Content=\"{x:Static resx:NpmInstallWindowResources.DevTypeProductionChoice}\" />\n<ComboBoxItem Tag=\"Dev\" Content=\"{x:Static resx:NpmInstallWindowResources.DevTypeDevelopmentChoice}\" />\n<ComboBoxItem Tag=\"Opt\" Content=\"{x:Static resx:NpmInstallWindowResources.DevTypeOptionalChoice}\" />\n+ <ComboBoxItem Tag=\"NoS\" Content=\"{x:Static resx:NpmInstallWindowResources.DevTypeNoSaveChoice}\" />\n</ComboBox>\n<Label Grid.Row=\"4\" HorizontalAlignment=\"Right\" VerticalAlignment=\"Center\" Content=\"{x:Static resx:NpmInstallWindowResources.SelectedVersionLabel}\" x:Name=\"SelectedVersionLabel\"/>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml.cs", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml.cs", "diff": "@@ -17,7 +17,7 @@ namespace Microsoft.NodejsTools.NpmUI\nprivate readonly NpmPackageInstallViewModel viewModel;\nprivate const string NpmResultGuid = \"2A7B6678-DFC9-40AA-BF2C-AD08B40A3031\";\n- internal NpmPackageInstallWindow(INpmController controller, NpmWorker npmWorker, DependencyType dependencyType = DependencyType.Standard)\n+ internal NpmPackageInstallWindow(INpmController controller, NpmWorker npmWorker, DependencyType dependencyType = DependencyType.Production)\n{\nthis.DataContext = this.viewModel = new NpmPackageInstallViewModel(npmWorker, this.Dispatcher);\n@@ -129,8 +129,7 @@ namespace Microsoft.NodejsTools.NpmUI\nprivate void ResetOptionsButton_Click(object sender, RoutedEventArgs e)\n{\n- this.DependencyComboBox.SelectedIndex = (int)DependencyType.Standard;\n- this.SaveToPackageJsonCheckbox.IsChecked = true;\n+ this.DependencyComboBox.SelectedIndex = (int)DependencyType.Production;\nthis.OtherNpmArgumentsTextBox.Text = string.Empty;\nthis.OtherNpmArgumentsTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Project/NodeModulesNode.cs", "new_path": "Nodejs/Product/Nodejs/Project/NodeModulesNode.cs", "diff": "@@ -400,7 +400,7 @@ namespace Microsoft.NodejsTools.Project\nreturn base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut);\n}\n- public void ManageModules(DependencyType dependencyType = DependencyType.Standard)\n+ public void ManageModules(DependencyType dependencyType = DependencyType.Production)\n{\nCheckNotDisposed();\n@@ -528,8 +528,7 @@ namespace Microsoft.NodejsTools.Project\nawait commander.InstallPackageByVersionAsync(\npackage.Name,\nnull == dep ? \"*\" : dep.VersionRangeText,\n- DependencyType.Standard,\n- false);\n+ DependencyType.Production);\n});\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Npm/DependencyType.cs", "new_path": "Nodejs/Product/Npm/DependencyType.cs", "diff": "@@ -4,8 +4,9 @@ namespace Microsoft.NodejsTools.Npm\n{\npublic enum DependencyType\n{\n- Standard = 0,\n+ Production = 0,\nDevelopment,\nOptional,\n+ NoSave\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Npm/INpmCommander.cs", "new_path": "Nodejs/Product/Npm/INpmCommander.cs", "diff": "@@ -20,14 +20,12 @@ namespace Microsoft.NodejsTools.Npm\n/// <param name=\"packageName\"></param>\n/// <param name=\"versionRange\"></param>\n/// <param name=\"type\"></param>\n- /// <param name=\"saveToPackageJson\"></param>\n/// <exception cref=\"PackageJsonException\">If there is an error reading a package.json file when modules are refreshed.</exception>\n/// <returns></returns>\nTask<bool> InstallPackageByVersionAsync(\nstring packageName,\nstring versionRange,\n- DependencyType type,\n- bool saveToPackageJson);\n+ DependencyType type);\n/// <summary>\n///\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Npm/SPI/NpmCommander.cs", "new_path": "Nodejs/Product/Npm/SPI/NpmCommander.cs", "diff": "@@ -135,8 +135,7 @@ namespace Microsoft.NodejsTools.Npm.SPI\nstring packageName,\nstring versionRange,\nDependencyType type,\n- bool global,\n- bool saveToPackageJson)\n+ bool global)\n{\nreturn DoCommandExecute(true,\nnew NpmInstallCommand(\n@@ -145,22 +144,20 @@ namespace Microsoft.NodejsTools.Npm.SPI\nversionRange,\ntype,\nglobal,\n- saveToPackageJson,\nthis.npmController.PathToNpm));\n}\npublic Task<bool> InstallPackageByVersionAsync(\nstring packageName,\nstring versionRange,\n- DependencyType type,\n- bool saveToPackageJson)\n+ DependencyType type)\n{\n- return InstallPackageByVersionAsync(this.npmController.FullPathToRootPackageDirectory, packageName, versionRange, type, false, saveToPackageJson);\n+ return InstallPackageByVersionAsync(this.npmController.FullPathToRootPackageDirectory, packageName, versionRange, type, false);\n}\nprivate DependencyType GetDependencyType(string packageName)\n{\n- var type = DependencyType.Standard;\n+ var type = DependencyType.Production;\nvar root = this.npmController.RootPackage;\nif (null != root)\n{\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Npm/SPI/NpmInstallCommand.cs", "new_path": "Nodejs/Product/Npm/SPI/NpmInstallCommand.cs", "diff": "@@ -19,7 +19,6 @@ namespace Microsoft.NodejsTools.Npm.SPI\nstring versionRange,\nDependencyType type,\nbool global = false,\n- bool saveToPackageJson = true,\nstring pathToNpm = null,\nbool useFallbackIfNpmNotFound = true)\n: base(fullPathToRootPackageDirectory, showConsole: false, pathToNpm: pathToNpm)\n@@ -28,8 +27,7 @@ namespace Microsoft.NodejsTools.Npm.SPI\npackageName,\nversionRange,\ntype,\n- global,\n- saveToPackageJson);\n+ global);\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Npm/SPI/NpmUninstallCommand.cs", "new_path": "Nodejs/Product/Npm/SPI/NpmUninstallCommand.cs", "diff": "@@ -20,7 +20,7 @@ namespace Microsoft.NodejsTools.Npm.SPI\n: string.Format(CultureInfo.InvariantCulture,\n\"uninstall {0} --{1}\",\npackageName,\n- (type == DependencyType.Standard\n+ (type == DependencyType.Production\n? \"save\"\n: (type == DependencyType.Development ? \"save-dev\" : \"save-optional\")));\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Refactor npm install --save command
410,202
22.03.2022 17:04:53
25,200
b816e783c674a5cc0b13d832491d3fcaed739d9a
Add Foreground to base component.
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "diff": "MinWidth=\"600\"\nWindowStartupLocation=\"CenterOwner\"\nBackground=\"{DynamicResource {x:Static wpf:Controls.BackgroundKey}}\"\n+ Foreground=\"{DynamicResource {x:Static wpf:Controls.ForegroundKey}}\"\nResizeMode=\"CanResizeWithGrip\">\n<!-- Theming -->\nText=\"{x:Static resx:NpmInstallWindowResources.SearchForPackagesLabel}\">\n<TextBlock.Style>\n<Style TargetType=\"TextBlock\" BasedOn=\"{StaticResource {x:Type TextBlock}}\">\n- <Setter Property=\"Foreground\" Value=\"{DynamicResource {x:Static wpf:Controls.ForegroundKey}}\" />\n<Setter Property=\"Visibility\" Value=\"Hidden\"/>\n<Style.Triggers>\n<DataTrigger Binding=\"{Binding FilterText}\" Value=\"\">\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Add Foreground to base component.
410,202
28.03.2022 16:16:55
25,200
2d5afba667651cee67a3f02514b0506beeec93c9
Removed ProgressBar and disabled options when installing on npm window
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallViewModel.cs", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallViewModel.cs", "diff": "@@ -377,6 +377,7 @@ namespace Microsoft.NodejsTools.NpmUI\nOnPropertyChanged();\nOnPropertyChanged(nameof(ExecutionProgressVisibility));\n+ OnPropertyChanged(nameof(AreOptionsEnabled));\n}\n}\n}\n@@ -386,6 +387,8 @@ namespace Microsoft.NodejsTools.NpmUI\nget { return IsExecutingCommand ? Visibility.Visible : Visibility.Collapsed; }\n}\n+ public bool AreOptionsEnabled => !this.IsExecutingCommand;\n+\n#endregion\npublic event PropertyChangedEventHandler PropertyChanged;\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "diff": "<RowDefinition Height=\"*\"/>\n<RowDefinition Height=\"Auto\"/>\n</Grid.RowDefinitions>\n- <ProgressBar Name=\"_progress\"\n- Height=\"4\"\n- IsEnabled=\"{Binding Path=IsExecutingCommand}\"\n- IsIndeterminate=\"{Binding Path=IsExecutingCommand}\"\n- Visibility=\"{Binding Path=ExecutionProgressVisibility}\" Grid.Row=\"1\" Grid.ColumnSpan=\"2\"/>\n<Button x:Name=\"CloseButton\"\nGrid.Column=\"1\"\nCommand=\"ApplicationCommands.Close\"\n<StackPanel Grid.Row=\"1\"\nOrientation=\"Vertical\"\n- HorizontalAlignment=\"Stretch\">\n+ HorizontalAlignment=\"Stretch\"\n+ IsEnabled=\"{Binding Path=AreOptionsEnabled}\">\n<Separator/>\n<Grid x:Name=\"InstallOptions\" DockPanel.Dock=\"Top\" VerticalAlignment=\"Stretch\">\n<Grid.RowDefinitions>\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Removed ProgressBar and disabled options when installing on npm window
410,207
30.03.2022 15:51:10
10,800
12e3b5f6816219114b658e62a318c77ea57e4c4c
Updated MicroBuild nuget to 1.0.0
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "new_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "diff": "<Version>17.0.18-preview-0001-g64bd43440b</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/NodejsToolsVsix/NodejsToolsVsix.csproj", "new_path": "Nodejs/Product/NodejsToolsVsix/NodejsToolsVsix.csproj", "diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Npm/Npm.csproj", "new_path": "Nodejs/Product/Npm/Npm.csproj", "diff": "<Version>4.7.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/PressAnyKey/PressAnyKey.csproj", "new_path": "Nodejs/Product/PressAnyKey/PressAnyKey.csproj", "diff": "<Version>4.7.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/ProjectWizard/ProjectWizard.csproj", "new_path": "Nodejs/Product/ProjectWizard/ProjectWizard.csproj", "diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TargetsVsix/TargetsVsix.csproj", "new_path": "Nodejs/Product/TargetsVsix/TargetsVsix.csproj", "diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapter/TestAdapter.csproj", "new_path": "Nodejs/Product/TestAdapter/TestAdapter.csproj", "diff": "<Version>4.7.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterImpl/TestAdapterImpl.csproj", "new_path": "Nodejs/Product/TestAdapterImpl/TestAdapterImpl.csproj", "diff": "<Version>17.0.0-preview-2-31221-277</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterNetStandard/TestAdapterNetStandard.csproj", "new_path": "Nodejs/Product/TestAdapterNetStandard/TestAdapterNetStandard.csproj", "diff": "</ItemGroup>\n<ItemGroup>\n- <PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\" Version=\"0.4.1\">\n+ <PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\" Version=\"1.0.0\">\n<PrivateAssets>all</PrivateAssets>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterVsix/TestAdapterVsix.csproj", "new_path": "Nodejs/Product/TestAdapterVsix/TestAdapterVsix.csproj", "diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/WebRole/WebRole.csproj", "new_path": "Nodejs/Product/WebRole/WebRole.csproj", "diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"Microsoft.VisualStudioEng.MicroBuild.Core\">\n- <Version>0.4.1</Version>\n+ <Version>1.0.0</Version>\n<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Updated MicroBuild nuget to 1.0.0
410,207
31.03.2022 16:40:19
10,800
9d8f7b4c754b597d814570239a133c78887b58b5
Added SBOM solution
[ { "change_type": "MODIFY", "old_path": "Nodejs/Setup/NodejsTools.vsmanproj", "new_path": "Nodejs/Setup/NodejsTools.vsmanproj", "diff": "<OutputPath>$(BinDirectory)\\$(Configuration)\\</OutputPath>\n</PropertyGroup>\n<ItemGroup>\n- <MergeManifest Include=\"$(BuildOutputRoot)\\Setup\\NodejsToolsVsix\\Microsoft.VisualStudio.NodejsTools.NodejsTools.json\" />\n- <MergeManifest Include=\"$(BuildOutputRoot)\\Setup\\TargetsVsix\\Microsoft.VisualStudio.NodejsTools.Targets.json\" />\n- <MergeManifest Include=\"$(BuildOutputRoot)\\Setup\\TestAdapterVsix\\Microsoft.VisualStudio.NodejsTools.TestAdapter.json\" />\n+ <MergeManifest Include=\"$(BuildOutputRoot)\\Setup\\NodejsToolsVsix\\Microsoft.VisualStudio.NodejsTools.NodejsTools.json\" SBOMFileLocation=\"$(SYSTEM_ARTIFACTSDIRECTORY)\\sbom\\_manifest\\spdx_2.2\\manifest.spdx.json\" />\n+ <MergeManifest Include=\"$(BuildOutputRoot)\\Setup\\TargetsVsix\\Microsoft.VisualStudio.NodejsTools.Targets.json\" SBOMFileLocation=\"$(SYSTEM_ARTIFACTSDIRECTORY)\\sbom\\_manifest\\spdx_2.2\\manifest.spdx.json\" />\n+ <MergeManifest Include=\"$(BuildOutputRoot)\\Setup\\TestAdapterVsix\\Microsoft.VisualStudio.NodejsTools.TestAdapter.json\" SBOMFileLocation=\"$(SYSTEM_ARTIFACTSDIRECTORY)\\sbom\\_manifest\\spdx_2.2\\manifest.spdx.json\" />\n</ItemGroup>\n<ItemGroup>\n<ProjectReference Include=\"..\\Product\\NodejsToolsVsix\\NodejsToolsVsix.csproj\">\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Added SBOM solution
410,207
01.04.2022 15:04:39
10,800
0a6ebb25fc54df9fefb6b743ff53b1a9fff6a8db
Removed test project from solution
[ { "change_type": "MODIFY", "old_path": "Nodejs/NodejsTools.sln", "new_path": "Nodejs/NodejsTools.sln", "diff": "@@ -36,8 +36,6 @@ Project(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"TestAdapterNetStandard\", \"P\nEndProject\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Tests\", \"Tests\", \"{D7506803-B6A3-4C7C-893A-270CEC896F12}\"\nEndProject\n-Project(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"TestAdapter.Tests\", \"Tests\\TestAdapter.Tests\\TestAdapter.Tests.csproj\", \"{1587F42C-8744-4CC4-B09B-DE00951B4714}\"\n-EndProject\nGlobal\nGlobalSection(SolutionConfigurationPlatforms) = preSolution\nDebug|Any CPU = Debug|Any CPU\n@@ -142,14 +140,6 @@ Global\n{06A4F57E-3E4F-40F0-AA7D-1C0204CE88B8}.Release|Any CPU.Build.0 = Release|Any CPU\n{06A4F57E-3E4F-40F0-AA7D-1C0204CE88B8}.Release|x86.ActiveCfg = Release|Any CPU\n{06A4F57E-3E4F-40F0-AA7D-1C0204CE88B8}.Release|x86.Build.0 = Release|Any CPU\n- {1587F42C-8744-4CC4-B09B-DE00951B4714}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n- {1587F42C-8744-4CC4-B09B-DE00951B4714}.Debug|Any CPU.Build.0 = Debug|Any CPU\n- {1587F42C-8744-4CC4-B09B-DE00951B4714}.Debug|x86.ActiveCfg = Debug|Any CPU\n- {1587F42C-8744-4CC4-B09B-DE00951B4714}.Debug|x86.Build.0 = Debug|Any CPU\n- {1587F42C-8744-4CC4-B09B-DE00951B4714}.Release|Any CPU.ActiveCfg = Release|Any CPU\n- {1587F42C-8744-4CC4-B09B-DE00951B4714}.Release|Any CPU.Build.0 = Release|Any CPU\n- {1587F42C-8744-4CC4-B09B-DE00951B4714}.Release|x86.ActiveCfg = Release|Any CPU\n- {1587F42C-8744-4CC4-B09B-DE00951B4714}.Release|x86.Build.0 = Release|Any CPU\nEndGlobalSection\nGlobalSection(SolutionProperties) = preSolution\nHideSolutionNode = FALSE\n@@ -167,7 +157,6 @@ Global\n{A9609A35-B083-41A9-A0E8-AA1E2C4DA9A9} = {F9719B35-F359-47A7-A2F8-34F42E53C809}\n{D9BADB3D-B6E9-4A54-8196-9374CFB93DA9} = {8AB8B6AC-77EB-47E7-904F-422588542C4D}\n{06A4F57E-3E4F-40F0-AA7D-1C0204CE88B8} = {F9719B35-F359-47A7-A2F8-34F42E53C809}\n- {1587F42C-8744-4CC4-B09B-DE00951B4714} = {D7506803-B6A3-4C7C-893A-270CEC896F12}\nEndGlobalSection\nGlobalSection(ExtensibilityGlobals) = postSolution\nSolutionGuid = {B1CAB318-7961-42BF-A7B1-FBDB3EC225E9}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Removed test project from solution
410,207
04.04.2022 10:08:19
10,800
dd524a7d0ee653de8b7b32a93ca22f2d57cd2419
Moved Setup sln out of the root folder
[ { "change_type": "RENAME", "old_path": "Nodejs/NodejsSetup.sln", "new_path": "Nodejs/Setup/NodejsSetup.sln", "diff": "@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.0.31717.387\nMinimumVisualStudioVersion = 10.0.40219.1\n-Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"NodejsTools\", \"Setup\\NodejsTools.vsmanproj\", \"{D9BADB3D-B6E9-4A54-8196-9374CFB93DA9}\"\n+Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"NodejsTools\", \"NodejsTools.vsmanproj\", \"{D9BADB3D-B6E9-4A54-8196-9374CFB93DA9}\"\nEndProject\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Setup\", \"Setup\", \"{8AB8B6AC-77EB-47E7-904F-422588542C4D}\"\nEndProject\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Moved Setup sln out of the root folder
410,202
18.04.2022 16:01:45
25,200
8c63741a7149cf9c1ccad72504bb96eff309a638
Ignore exceptions when disposing already disposed items
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/SharedProject/CommonProjectNode.cs", "new_path": "Nodejs/Product/Nodejs/SharedProject/CommonProjectNode.cs", "diff": "@@ -473,9 +473,17 @@ namespace Microsoft.VisualStudioTools.Project\n}\nif (this.UserBuildProject != null)\n+ {\n+ try\n{\nthis.UserBuildProject.ProjectCollection.UnloadProject(this.UserBuildProject);\n}\n+ catch(InvalidOperationException)\n+ {\n+ // The project was already been unloaded. Ignore the exception and continue execution.\n+ }\n+\n+ }\nthis.idleManager.OnIdle -= this.OnIdle;\nthis.idleManager.Dispose();\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Ignore exceptions when disposing already disposed items
410,207
20.04.2022 11:32:30
10,800
d6dd02cc1b56ad1cb24b4ef0c48a81a985bbc64c
Hiding templates with very low usage to simplify selection
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/CloudService/CloudService.vstemplate", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/CloudService/CloudService.vstemplate", "diff": "<LanguageTag>Typescript</LanguageTag>\n<PlatformTag>Azure</PlatformTag>\n<ProjectTypeTag>Cloud</ProjectTypeTag>\n+ <Hidden>true</Hidden>\n</TemplateData>\n<TemplateContent>\n<Project File=\"CloudService.ccproj\" ReplaceParameters=\"true\">\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/FromExistingCode/FromExistingCode.vstemplate", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/FromExistingCode/FromExistingCode.vstemplate", "diff": "<PlatformTag>macOS</PlatformTag>\n<ProjectTypeTag>Web</ProjectTypeTag>\n<ProjectTypeTag>Console</ProjectTypeTag>\n+ <Hidden>true</Hidden>\n</TemplateData>\n<TemplateContent>\n<Project File=\"FromExistingCode.njsproj\" ReplaceParameters=\"true\">\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptFromExistingCode/FromExistingCode.vstemplate", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptFromExistingCode/FromExistingCode.vstemplate", "diff": "<PlatformTag>macOS</PlatformTag>\n<ProjectTypeTag>Web</ProjectTypeTag>\n<ProjectTypeTag>Console</ProjectTypeTag>\n+ <Hidden>true</Hidden>\n</TemplateData>\n<TemplateContent>\n<Project File=\"FromExistingCode.njsproj\" ReplaceParameters=\"true\">\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptVuejsApp/TypeScriptVuejsApp.vstemplate", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptVuejsApp/TypeScriptVuejsApp.vstemplate", "diff": "<PlatformTag>Linux</PlatformTag>\n<PlatformTag>macOS</PlatformTag>\n<ProjectTypeTag>Web</ProjectTypeTag>\n+ <Hidden>true</Hidden>\n</TemplateData>\n<TemplateContent>\n<Project File=\"TypeScriptVuejsApp.njsproj\" ReplaceParameters=\"true\">\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Hiding templates with very low usage to simplify selection
410,207
30.05.2022 10:17:53
10,800
d6c440c1d8e19f5ac6c5c0af55a889a153466ea8
Added error message on old Node version debugging
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "new_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "diff": "@@ -86,6 +86,12 @@ namespace Microsoft.NodejsTools.Project\nStartWithChromeDebugger(file, nodePath, shouldStartBrowser, browserPath);\nTelemetryHelper.LogDebuggingStarted(\"ChromeV2\", nodeVersion.ToString());\n}\n+ else\n+ {\n+ var output = OutputWindowRedirector.GetGeneral(NodejsPackage.Instance);\n+ output.WriteErrorLine(string.Format(CultureInfo.CurrentCulture, Resources.ErrorDebuggingNode7NotSupported));\n+ output.ShowAndActivate();\n+ }\n}\nelse\n{\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Resources.Designer.cs", "new_path": "Nodejs/Product/Nodejs/Resources.Designer.cs", "diff": "@@ -19,7 +19,7 @@ namespace Microsoft.NodejsTools {\n// class via a tool like ResGen or Visual Studio.\n// To add or remove a member, edit your .ResX file then rerun ResGen\n// with the /str option, or rebuild your VS project.\n- [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"16.0.0.0\")]\n+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"17.0.0.0\")]\n[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\ninternal class Resources {\n@@ -407,6 +407,15 @@ namespace Microsoft.NodejsTools {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to Debugging Node 7 and below is not supported. Current Node version is {0}..\n+ /// </summary>\n+ internal static string ErrorDebuggingNode7NotSupported {\n+ get {\n+ return ResourceManager.GetString(\"ErrorDebuggingNode7NotSupported\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to Launch url &apos;{0}&apos; is not valid .\n/// </summary>\n@@ -417,7 +426,7 @@ namespace Microsoft.NodejsTools {\n}\n/// <summary>\n- /// Looks up a localized string similar to Executing npm command..\n+ /// Looks up a localized string similar to Executing npm command.\n/// </summary>\ninternal static string ExecutingNpmCommandMessage {\nget {\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Resources.resx", "new_path": "Nodejs/Product/Nodejs/Resources.resx", "diff": "@@ -743,4 +743,7 @@ The following error occurred trying to execute npm.cmd:\n<data name=\"ExecutingNpmCommandMessage\" xml:space=\"preserve\">\n<value>Executing npm command</value>\n</data>\n+ <data name=\"ErrorDebuggingNode7NotSupported\" xml:space=\"preserve\">\n+ <value>Debugging Node 7 and below is not supported. Current Node version is {0}.</value>\n+ </data>\n</root>\n\\ No newline at end of file\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Added error message on old Node version debugging
410,207
01.06.2022 11:20:24
10,800
99428bfeee19fbf587bb6cb9ac2613328b013b7a
Removed V3 Feature Flag, making V3 the main debugger
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "new_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "diff": "@@ -235,10 +235,9 @@ namespace Microsoft.NodejsTools.Project\nreturn optionVal != 0;\n}\n}\n- catch (Exception) { } // do nothing. proceed to trying the feature flag below.\n+ catch (Exception) { } // do nothing\n- var featureFlagsService = (IVsFeatureFlags)ServiceProvider.GlobalProvider.GetService(typeof(SVsFeatureFlags));\n- return featureFlagsService is IVsFeatureFlags && featureFlagsService.IsFeatureEnabled(\"JavaScript.Debugger.V3CdpNodeDebugAdapter\", false);\n+ return true;\n}\nprivate int TestServerPort\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Removed V3 Feature Flag, making V3 the main debugger
410,202
15.03.2022 16:28:08
25,200
9cb5b576963ac0faf4726598a5bca2bab8dac7cc
Fixed narration of Author. Fixed narration order of OtherNpmArguments
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "diff": "<Run Text=\"{Binding Path=Description, Mode=OneWay}\"/>\n</TextBlock>\n- <StackPanel Orientation=\"Horizontal\" Margin=\"0 4 0 4\" x:Name=\"AuthorBlock\" Visibility=\"{Binding Path=AuthorVisibility, Mode=OneWay}\" KeyboardNavigation.TabIndex=\"7\">\n- <TextBlock Margin=\"0\" FontWeight=\"Bold\" xml:space=\"preserve\" Text=\"{x:Static resx:NpmInstallWindowResources.AuthorLabel}\" />\n- <TextBlock Text=\"{Binding Path=Author, Mode=OneWay}\"/>\n- </StackPanel>\n+ <TextBlock Margin=\"0 4 0 4\" x:Name=\"AuthorBlock\" Visibility=\"{Binding Path=AuthorVisibility, Mode=OneWay}\" KeyboardNavigation.TabIndex=\"7\">\n+ <Run FontWeight=\"Bold\" xml:space=\"preserve\" Text=\"{x:Static resx:NpmInstallWindowResources.AuthorLabel}\" />\n+ <Run Text=\"{Binding Path=Author, Mode=OneWay}\"/>\n+ </TextBlock>\n- <StackPanel Margin=\"0 4 0 4\" x:Name=\"HomepageBlock\"\n- Visibility=\"{Binding HomepagesVisibility}\"\n- Orientation=\"Horizontal\">\n+ <StackPanel Margin=\"0 4 0 4\" x:Name=\"HomepageBlock\" Visibility=\"{Binding HomepagesVisibility}\" Orientation=\"Horizontal\">\n<TextBlock Margin=\"0\" FontWeight=\"Bold\" xml:space=\"preserve\" Text=\"{x:Static resx:NpmInstallWindowResources.HomepageLabel}\" />\n<ItemsControl ItemsSource=\"{Binding Path=Homepages, Mode=OneWay}\" IsTabStop=\"False\">\n<ItemsControl.ItemTemplate>\n</Grid.ColumnDefinitions>\n<TextBlock Grid.Row=\"1\" FontWeight=\"Bold\" Margin=\"0 4 0 4\" Text=\"{x:Static resx:NpmInstallWindowResources.OptionsLabel}\" />\n- <Label Grid.Row=\"5\" HorizontalAlignment=\"Right\" VerticalAlignment=\"Center\" Content=\"{x:Static resx:NpmInstallWindowResources.OtherNpmArgumentsLabel}\" Name=\"OtherNpmArgumentsLabel\" />\n- <TextBox x:Name=\"OtherNpmArgumentsTextBox\" Grid.Column=\"1\" Grid.Row=\"5\" HorizontalAlignment=\"Stretch\" Text=\"{Binding Arguments}\" Margin=\"4\" TabIndex=\"12\">\n- <AutomationProperties.LabeledBy>\n- <Binding ElementName=\"OtherNpmArgumentsLabel\" />\n- </AutomationProperties.LabeledBy>\n- </TextBox>\n<Label Grid.Row=\"2\" HorizontalAlignment=\"Right\" VerticalAlignment=\"Center\" Content=\"{x:Static resx:NpmInstallWindowResources.DependencyTypeLabel}\" x:Name=\"DependencyTypeLabel\" />\n<ComboBox Name=\"DependencyComboBox\"\n</CompositeCollection>\n</ComboBox.ItemsSource>\n</ComboBox>\n+\n+ <Label Grid.Row=\"5\" HorizontalAlignment=\"Right\" VerticalAlignment=\"Center\" Content=\"{x:Static resx:NpmInstallWindowResources.OtherNpmArgumentsLabel}\" Name=\"OtherNpmArgumentsLabel\" />\n+ <TextBox x:Name=\"OtherNpmArgumentsTextBox\" Grid.Column=\"1\" Grid.Row=\"5\" HorizontalAlignment=\"Stretch\" Text=\"{Binding Arguments}\" Margin=\"4\" TabIndex=\"12\">\n+ <AutomationProperties.LabeledBy>\n+ <Binding ElementName=\"OtherNpmArgumentsLabel\" />\n+ </AutomationProperties.LabeledBy>\n+ </TextBox>\n</Grid>\n<StackPanel Orientation=\"Horizontal\" Margin=\"0 8 0 0\">\n<Button x:Name=\"InstallButton\" Margin=\"0 0 4 0\"\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Fixed narration of Author. Fixed narration order of OtherNpmArguments
410,207
07.12.2021 10:57:21
10,800
e97927f7f9e13aba69788b6687915acd5017d536
Switched to launching using PineZorro The new server protocol in vs-debug-js has issues, and when launching a browser via the new server protocol, breakpoints are not set correctly. Switched to launching using the debugger to avoid this issue while still having debug support for the browser.
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "new_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "diff": "@@ -240,6 +240,24 @@ namespace Microsoft.NodejsTools.Project\nreturn true;\n}\n+ internal static bool EnableV3BrowserDebugging()\n+ {\n+ var userRegistryRoot = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writable: false);\n+ try\n+ {\n+ object userDebuggerOption = userRegistryRoot.OpenSubKey(\"Debugger\")?.GetValue(\"EnableJavaScriptNodeBrowserDebugging\");\n+ if (userDebuggerOption is int optionVal)\n+ {\n+ return optionVal != 0;\n+ }\n+ }\n+ catch (Exception) { } // do nothing. proceed to trying the feature flag below.\n+\n+ var featureFlagsService = (IVsFeatureFlags)ServiceProvider.GlobalProvider.GetService(typeof(SVsFeatureFlags));\n+ return featureFlagsService is IVsFeatureFlags && featureFlagsService.IsFeatureEnabled(\"JavaScript.Debugger.V3CdpNodeBrowserDebug\", false);\n+ }\n+\n+\nprivate int TestServerPort\n{\nget\n@@ -282,26 +300,6 @@ namespace Microsoft.NodejsTools.Project\n_project.ProjectGuid.ToString(),\nJObject.FromObject(envVars));\n- bool usingV3Debugger = ShouldUseV3CdpDebugger();\n-\n- if (usingV3Debugger && shouldStartBrowser && (browserPath.EndsWith(\"chrome.exe\") || browserPath.EndsWith(\"msedge.exe\")))\n- {\n- config = new NodePinezorroDebugLaunchConfig()\n- {\n- ConfigName = \"Debug Node program and browser from Visual Studio\",\n- Request = \"launch\",\n- DebugType = browserPath.EndsWith(\"chrome.exe\") ? \"chrome\" : \"edge\",\n- RuntimeExecutable = browserPath,\n- BrowserUrl = webBrowserUrl,\n- BrowserUserDataDir = true,\n- Server = config.toPwaChromeServerConfig(),\n- WorkingDir = cwd,\n- WebRoot = cwd,\n- ProjectGuid = _project.ProjectGuid.ToString()\n- };\n- shouldStartBrowser = false; // the v3 cdp debug adapter will launch the browser as part of debugging so no need to launch it here anymore\n- }\n-\nvar jsonContent = JObject.FromObject(config).ToString();\nvar debugTargets = new[] {\n@@ -320,6 +318,17 @@ namespace Microsoft.NodejsTools.Project\n// Launch browser\nif (shouldStartBrowser && !string.IsNullOrWhiteSpace(webBrowserUrl))\n+ {\n+ if (ShouldUseV3CdpDebugger() && EnableV3BrowserDebugging())\n+ {\n+ var uri = new Uri(webBrowserUrl);\n+ OnPortOpenedHandler.CreateHandler(\n+ uri.Port,\n+ timeout: 5_000, // 5 seconds\n+ action: () => DebugBrowser(browserPath, webBrowserUrl)\n+ );\n+ }\n+ else\n{\nvar uri = new Uri(webBrowserUrl);\nOnPortOpenedHandler.CreateHandler(\n@@ -329,6 +338,7 @@ namespace Microsoft.NodejsTools.Project\n);\n}\n}\n+ }\nprivate static string[] ConvertArguments(string argumentString)\n{\n@@ -466,6 +476,41 @@ namespace Microsoft.NodejsTools.Project\n}\n}\n+ private void DebugBrowser(string browserPath, string webBrowserUrl)\n+ {\n+ var serviceProvider = _project.Site;\n+ var cwd = _project.GetWorkingDirectory(); // Current working directory\n+\n+ var config = new NodePinezorroDebugLaunchConfig()\n+ {\n+ ConfigName = \"Debug Node program and browser from Visual Studio\",\n+ Request = \"launch\",\n+ DebugType = browserPath.EndsWith(\"chrome.exe\") ? \"chrome\" : \"edge\",\n+ RuntimeExecutable = browserPath,\n+ BrowserUrl = webBrowserUrl,\n+ BrowserUserDataDir = true,\n+ WorkingDir = cwd,\n+ WebRoot = cwd,\n+ ProjectGuid = _project.ProjectGuid.ToString()\n+ };\n+\n+ var launchJson = JObject.FromObject(config).ToString();\n+\n+ var debugTargets = new[] {\n+ new VsDebugTargetInfo4() {\n+ dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess,\n+ guidLaunchDebugEngine = GetDebuggerGuid(),\n+ bstrExe = browserPath,\n+ bstrOptions = launchJson\n+ }\n+ };\n+\n+ var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];\n+\n+ var debugger = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger));\n+ debugger.LaunchDebugTargets4(1, debugTargets, processInfo);\n+ }\n+\nprivate IEnumerable<KeyValuePair<string, string>> GetEnvironmentVariables()\n{\nvar envVars = this._project.GetProjectProperty(NodeProjectProperty.Environment);\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Switched to launching using PineZorro The new server protocol in vs-debug-js has issues, and when launching a browser via the new server protocol, breakpoints are not set correctly. Switched to launching using the debugger to avoid this issue while still having debug support for the browser.
410,207
11.02.2022 11:02:59
10,800
8d47a288110b1cc76bf3758d25702c2916035259
Removed browser feature flag
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "new_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "diff": "@@ -240,24 +240,6 @@ namespace Microsoft.NodejsTools.Project\nreturn true;\n}\n- internal static bool EnableV3BrowserDebugging()\n- {\n- var userRegistryRoot = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_UserSettings, writable: false);\n- try\n- {\n- object userDebuggerOption = userRegistryRoot.OpenSubKey(\"Debugger\")?.GetValue(\"EnableJavaScriptNodeBrowserDebugging\");\n- if (userDebuggerOption is int optionVal)\n- {\n- return optionVal != 0;\n- }\n- }\n- catch (Exception) { } // do nothing. proceed to trying the feature flag below.\n-\n- var featureFlagsService = (IVsFeatureFlags)ServiceProvider.GlobalProvider.GetService(typeof(SVsFeatureFlags));\n- return featureFlagsService is IVsFeatureFlags && featureFlagsService.IsFeatureEnabled(\"JavaScript.Debugger.V3CdpNodeBrowserDebug\", false);\n- }\n-\n-\nprivate int TestServerPort\n{\nget\n@@ -319,7 +301,7 @@ namespace Microsoft.NodejsTools.Project\n// Launch browser\nif (shouldStartBrowser && !string.IsNullOrWhiteSpace(webBrowserUrl))\n{\n- if (ShouldUseV3CdpDebugger() && EnableV3BrowserDebugging())\n+ if (ShouldUseV3CdpDebugger())\n{\nvar uri = new Uri(webBrowserUrl);\nOnPortOpenedHandler.CreateHandler(\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Removed browser feature flag
410,207
21.06.2022 11:26:28
10,800
52004059a26b25f5292eb2a8cbaf8bd4b8868966
Switched test debugging to use the new debugger
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/TestAdapterImpl/VisualStudioApp.cs", "new_path": "Nodejs/Product/TestAdapterImpl/VisualStudioApp.cs", "diff": "@@ -163,8 +163,8 @@ namespace Microsoft.VisualStudioTools\nreturn (DTE)runningObject;\n}\n- private static readonly Guid WebkitPortSupplierGuid = Guid.Parse(\"4103f338-2255-40c0-acf5-7380e2bea13d\");\n- private static readonly Guid Node2AttachEngineGuid = Guid.Parse(\"3F14B534-C345-44B5-AF84-642246EEEB62\");\n+ private static readonly Guid V3PortSupplierGuid = Guid.Parse(\"61D1E397-7AA6-4ED9-815A-0C5CA0E728B4\");\n+ private static readonly Guid V3AttachEngineGuid = Guid.Parse(\"394120B6-2FF9-4D0D-8953-913EF5CD0BCD\");\nprivate bool AttachToProcessNode2DebugAdapter(int port)\n{\n@@ -177,14 +177,14 @@ namespace Microsoft.VisualStudioTools\nvar debugUri = $\"http://127.0.0.1:{port}\";\ntry\n{\n- Marshal.StructureToPtr(Node2AttachEngineGuid, pDebugEngine, false);\n+ Marshal.StructureToPtr(V3AttachEngineGuid, pDebugEngine, false);\nvar dbgInfo = new VsDebugTargetInfo4()\n{\ndlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning,\npDebugEngines = pDebugEngine,\ndwDebugEngineCount = 1,\nbstrExe = \"dummy\",\n- guidPortSupplier = WebkitPortSupplierGuid,\n+ guidPortSupplier = V3PortSupplierGuid,\nbstrPortName = debugUri,\ndwProcessId = 1\n};\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Switched test debugging to use the new debugger
410,207
22.06.2022 11:08:46
10,800
905e213cf829116497b1918a34be4b514a66158a
Fixed file list for vue templates
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "new_path": "Nodejs/Product/Nodejs/Nodejs.csproj", "diff": "</Content>\n<ZipItem Include=\"Templates\\Files\\JestUnitTest\\UnitTest.js\" />\n<ZipItem Include=\"Templates\\Files\\JestUnitTest\\UnitTest.vstemplate\" />\n- <TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\babel.config.js\" />\n- <ZipProject Include=\"ProjectTemplates\\VuejsApp\\babel.config.js\" />\n- <Resource Include=\"ProjectTemplates\\VuejsApp\\logo.png\" />\n- <Resource Include=\"ProjectTemplates\\TypeScriptVuejsApp\\logo.png\" />\n<Content Include=\"Workspace\\OpenFolderSchema.json\">\n<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\n<IncludeInVSIX>true</IncludeInVSIX>\n<Compile Include=\"SharedProject\\CommonProjectNode.DiskMerger.cs\" />\n<ZipItem Include=\"Templates\\Files\\TypeScriptJsConfig\\jsconfig.json\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\App.vue\" />\n+ <TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\babel.config.js\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\favicon.ico\" />\n- <TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\Home.vue\" />\n+ <TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\HelloWorld.vue\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\index.html\" />\n+ <TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\logo.png\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\main.ts\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\package.json\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\README.md\" />\n+ <TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\shims-vue.d.ts\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\tsconfig.json\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\TypeScriptVuejsApp.njsproj\" />\n<TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\TypeScriptVuejsApp.vstemplate\" />\n<ZipProject Include=\"ProjectTemplates\\VuejsApp\\App.vue\" />\n+ <ZipProject Include=\"ProjectTemplates\\VuejsApp\\babel.config.js\" />\n<ZipProject Include=\"ProjectTemplates\\VuejsApp\\favicon.ico\" />\n- <ZipProject Include=\"ProjectTemplates\\VuejsApp\\Home.vue\" />\n+ <ZipProject Include=\"ProjectTemplates\\VuejsApp\\HelloWorld.vue\" />\n<ZipProject Include=\"ProjectTemplates\\VuejsApp\\index.html\" />\n+ <ZipProject Include=\"ProjectTemplates\\VuejsApp\\logo.png\" />\n<ZipProject Include=\"ProjectTemplates\\VuejsApp\\main.js\" />\n<ZipProject Include=\"ProjectTemplates\\VuejsApp\\package.json\" />\n<ZipProject Include=\"ProjectTemplates\\VuejsApp\\README.md\" />\n<ZipItem Include=\"Templates\\Files\\TypeScriptVueComponent\\TypeScriptVueComponent.vstemplate\" />\n<ZipItem Include=\"Templates\\Files\\TypeScriptVueComponent\\TypeScriptVueComponent.vue\" />\n<None Include=\"ProjectTemplates\\TypeScriptVuejsApp\\.browserslistrc\" />\n- <None Include=\"ProjectTemplates\\TypeScriptVuejsApp\\HelloWorld.vue\" />\n<None Include=\"ProjectTemplates\\VuejsApp\\.browserslistrc\" />\n- <None Include=\"ProjectTemplates\\VuejsApp\\HelloWorld.vue\" />\n<None Include=\"Theme\\contrast.vstheme\">\n<SubType>Designer</SubType>\n</None>\n<ItemGroup>\n<ZipItem Include=\"Templates\\Files\\TypeScriptJasmineUnitTest\\UnitTest.ts\" />\n</ItemGroup>\n- <ItemGroup>\n- <TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\shims-tsx.d.ts\" />\n- <TypeScriptProject Include=\"ProjectTemplates\\TypeScriptVuejsApp\\shims-vue.d.ts\" />\n- </ItemGroup>\n<ItemGroup>\n<WCFMetadata Include=\"Connected Services\\\" />\n</ItemGroup>\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Fixed file list for vue templates
410,207
28.06.2022 16:02:27
10,800
875a864c2e336c1b72a240336867f83e65a24bca
Re-enabling From Existing Code templates
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/FromExistingCode/FromExistingCode.vstemplate", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/FromExistingCode/FromExistingCode.vstemplate", "diff": "<PlatformTag>macOS</PlatformTag>\n<ProjectTypeTag>Web</ProjectTypeTag>\n<ProjectTypeTag>Console</ProjectTypeTag>\n- <Hidden>true</Hidden>\n</TemplateData>\n<TemplateContent>\n<Project File=\"FromExistingCode.njsproj\" ReplaceParameters=\"true\">\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptFromExistingCode/FromExistingCode.vstemplate", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptFromExistingCode/FromExistingCode.vstemplate", "diff": "<PlatformTag>macOS</PlatformTag>\n<ProjectTypeTag>Web</ProjectTypeTag>\n<ProjectTypeTag>Console</ProjectTypeTag>\n- <Hidden>true</Hidden>\n</TemplateData>\n<TemplateContent>\n<Project File=\"FromExistingCode.njsproj\" ReplaceParameters=\"true\">\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Re-enabling From Existing Code templates
410,207
28.06.2022 17:15:21
10,800
3f5cc0329815af3ffb948f08857446d206a9af36
Fixed Vue project templates
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptVuejsApp/TypeScriptVuejsApp.njsproj", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptVuejsApp/TypeScriptVuejsApp.njsproj", "diff": "<Folder Include=\"src\\components\\\" />\n</ItemGroup>\n<ItemGroup>\n- <Content Include=\".browserslistrc\" />\n- <Content Include=\".gitignore\" />\n<Content Include=\"babel.config.js\" />\n- <Content Include=\"package-lock.json\" />\n<Content Include=\"package.json\" />\n<Content Include=\"public\\favicon.ico\" />\n<Content Include=\"public\\index.html\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptVuejsApp/TypeScriptVuejsApp.vstemplate", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptVuejsApp/TypeScriptVuejsApp.vstemplate", "diff": "<ProjectItem>shims-vue.d.ts</ProjectItem>\n</Folder>\n<ProjectItem>babel.config.js</ProjectItem>\n- <ProjectItem>.browserslistrc</ProjectItem>\n<ProjectItem ReplaceParameters=\"true\">package.json</ProjectItem>\n<ProjectItem ReplaceParameters=\"true\">README.md</ProjectItem>\n<ProjectItem>tsconfig.json</ProjectItem>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/VuejsApp/VuejsApp.njsproj", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/VuejsApp/VuejsApp.njsproj", "diff": "<Folder Include=\"src\\components\\\" />\n</ItemGroup>\n<ItemGroup>\n- <Content Include=\".browserslistrc\" />\n- <Content Include=\".gitignore\" />\n<Content Include=\"babel.config.js\" />\n- <Content Include=\"package-lock.json\" />\n<Content Include=\"package.json\" />\n<Content Include=\"public\\favicon.ico\" />\n<Content Include=\"public\\index.html\" />\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/VuejsApp/VuejsApp.vstemplate", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/VuejsApp/VuejsApp.vstemplate", "diff": "<ProjectItem>App.vue</ProjectItem>\n<ProjectItem OpenInEditor=\"true\">main.js</ProjectItem>\n</Folder>\n- <ProjectItem>.browserslistrc</ProjectItem>\n<ProjectItem>babel.config.js</ProjectItem>\n<ProjectItem ReplaceParameters=\"true\">package.json</ProjectItem>\n<ProjectItem ReplaceParameters=\"true\">README.md</ProjectItem>\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Fixed Vue project templates
410,207
18.07.2022 16:17:02
10,800
b1bf5f5c65b29b5390092b15a6146fc526670a58
Made Node.js debug the node process always
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "new_path": "Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs", "diff": "@@ -282,26 +282,6 @@ namespace Microsoft.NodejsTools.Project\n_project.ProjectGuid.ToString(),\nJObject.FromObject(envVars));\n- bool usingV3Debugger = ShouldUseV3CdpDebugger();\n-\n- if (usingV3Debugger && shouldStartBrowser && (browserPath.EndsWith(\"chrome.exe\") || browserPath.EndsWith(\"msedge.exe\")))\n- {\n- config = new NodePinezorroDebugLaunchConfig()\n- {\n- ConfigName = \"Debug Node program and browser from Visual Studio\",\n- Request = \"launch\",\n- DebugType = browserPath.EndsWith(\"chrome.exe\") ? \"chrome\" : \"edge\",\n- RuntimeExecutable = browserPath,\n- BrowserUrl = webBrowserUrl,\n- BrowserUserDataDir = true,\n- Server = config.toPwaChromeServerConfig(),\n- WorkingDir = cwd,\n- WebRoot = cwd,\n- ProjectGuid = _project.ProjectGuid.ToString()\n- };\n- shouldStartBrowser = false; // the v3 cdp debug adapter will launch the browser as part of debugging so no need to launch it here anymore\n- }\n-\nvar jsonContent = JObject.FromObject(config).ToString();\nvar debugTargets = new[] {\n@@ -316,7 +296,7 @@ namespace Microsoft.NodejsTools.Project\nvar processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];\nvar debugger = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger));\n- debugger.LaunchDebugTargets4(1, debugTargets, processInfo);\n+ debugger.LaunchDebugTargets4((uint)debugTargets.Length, debugTargets, processInfo);\n// Launch browser\nif (shouldStartBrowser && !string.IsNullOrWhiteSpace(webBrowserUrl))\n@@ -528,7 +508,7 @@ namespace Microsoft.NodejsTools.Project\n{\nthis.ConfigName = \"Debug Node.js program from Visual Studio\";\nthis.Request = \"launch\";\n- this.DebugType = \"node2\";\n+ this.DebugType = \"node\";\nthis.Console = \"externalTerminal\";\nthis.Program = program;\nthis.ProgramArgs = programArgs;\n@@ -536,6 +516,7 @@ namespace Microsoft.NodejsTools.Project\nthis.RuntimeArgs = runtimeArgs;\nthis.Port = port;\nthis.WorkingDir = currWorkingDir;\n+ this.WebRoot = currWorkingDir;\nthis.Environment = environmentSettings;\nthis.Trace = trace;\nthis.ProjectGuid = projectGuid;\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Made Node.js debug the node process always
410,208
11.08.2022 18:49:02
25,200
237731796941e5efa031f58bd6a039e8e24e27ef
Update Azure Express apps
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/AzureExpress4App/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/AzureExpress4App/package.json", "diff": "},\n\"engines\": {\n\"node\": \"~6.10.x\"\n+ },\n+ \"devDependencies\": {\n+ \"eslint\": \"^8.21.0\",\n+ \"eslint-plugin-node\": \"^11.1.0\"\n+ },\n+ \"eslintConfig\": {\n+ \"extends\": \"plugin:node/recommended\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptAzureExpressApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptAzureExpressApp/package.json", "diff": "\"@types/express\": \"^4.0.37\",\n\"@types/express-serve-static-core\": \"^4.0.50\",\n\"@types/mime\": \"^1.3.1\",\n- \"@types/serve-static\": \"^1.7.32\",\n\"@types/node\": \"^14.14.7\",\n+ \"@types/serve-static\": \"^1.7.32\",\n+ \"@typescript-eslint/eslint-plugin\": \"^5.33.0\",\n+ \"@typescript-eslint/parser\": \"^5.33.0\",\n+ \"eslint\": \"^8.21.0\",\n\"typescript\": \"^4.5.2\"\n},\n\"engines\": {\n\"node\": \"^8.0.0\"\n+ },\n+ \"eslintConfig\": {\n+ \"parser\": \"@typescript-eslint/parser\",\n+ \"parserOptions\": {\n+ \"ecmaVersion\": \"latest\",\n+ \"sourceType\": \"module\"\n+ },\n+ \"plugins\": [\n+ \"@typescript-eslint\"\n+ ]\n}\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Update Azure Express apps
410,208
11.08.2022 19:35:52
25,200
48b7f9fdfaf3bb4c0260f00286001d6ead104b11
Update Azure Web apps
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/AzureNodejsApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/AzureNodejsApp/package.json", "diff": "},\n\"author\": {\n\"name\": \"\"\n+ },\n+ \"devDependencies\": {\n+ \"eslint\": \"^8.21.0\",\n+ \"eslint-plugin-node\": \"^11.1.0\"\n+ },\n+ \"eslintConfig\": {\n+ \"extends\": \"plugin:node/recommended\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptAzureWebApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptAzureWebApp/package.json", "diff": "},\n\"devDependencies\": {\n\"@types/node\": \"^14.14.7\",\n+ \"@typescript-eslint/eslint-plugin\": \"^5.33.0\",\n+ \"@typescript-eslint/parser\": \"^5.33.0\",\n+ \"eslint\": \"^8.21.0\",\n\"typescript\": \"^4.5.2\"\n},\n\"engines\": {\n\"node\": \"^8.0.0\"\n+ },\n+ \"eslintConfig\": {\n+ \"parser\": \"@typescript-eslint/parser\",\n+ \"parserOptions\": {\n+ \"ecmaVersion\": \"latest\"\n+ },\n+ \"plugins\": [\n+ \"@typescript-eslint\"\n+ ]\n}\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Update Azure Web apps
410,208
11.08.2022 19:52:24
25,200
598c1349f2e5c040ac61a120aff0f4347bc9d22a
Update Express Apps
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/Express4App/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/Express4App/package.json", "diff": "\"morgan\": \"^1.7.0\",\n\"pug\": \"^2.0.0-beta6\",\n\"serve-favicon\": \"^2.3.0\"\n+ },\n+ \"devDependencies\": {\n+ \"eslint\": \"^8.21.0\",\n+ \"eslint-plugin-node\": \"^11.1.0\"\n+ },\n+ \"eslintConfig\": {\n+ \"extends\": \"plugin:node/recommended\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptExpressApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptExpressApp/package.json", "diff": "\"@types/express\": \"^4.0.37\",\n\"@types/express-serve-static-core\": \"^4.0.50\",\n\"@types/mime\": \"^1.3.1\",\n- \"@types/serve-static\": \"^1.7.32\",\n\"@types/node\": \"^14.14.7\",\n+ \"@types/serve-static\": \"^1.7.32\",\n+ \"@typescript-eslint/eslint-plugin\": \"^5.33.0\",\n+ \"@typescript-eslint/parser\": \"^5.33.0\",\n+ \"eslint\": \"^8.21.0\",\n\"typescript\": \"^4.5.2\"\n+ },\n+ \"eslintConfig\": {\n+ \"parser\": \"@typescript-eslint/parser\",\n+ \"parserOptions\": {\n+ \"ecmaVersion\": \"latest\",\n+ \"sourceType\": \"module\"\n+ },\n+ \"plugins\": [\n+ \"@typescript-eslint\"\n+ ]\n}\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Update Express Apps
410,208
12.08.2022 13:25:42
25,200
54a9e9e7c02dd476de081a30702516c862232227
Remove node plugin from JS projects
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/AzureExpress4App/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/AzureExpress4App/package.json", "diff": "\"node\": \"~6.10.x\"\n},\n\"devDependencies\": {\n- \"eslint\": \"^8.21.0\",\n- \"eslint-plugin-node\": \"^11.1.0\"\n+ \"eslint\": \"^8.21.0\"\n},\n\"eslintConfig\": {\n- \"extends\": \"plugin:node/recommended\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/AzureNodejsApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/AzureNodejsApp/package.json", "diff": "\"name\": \"\"\n},\n\"devDependencies\": {\n- \"eslint\": \"^8.21.0\",\n- \"eslint-plugin-node\": \"^11.1.0\"\n+ \"eslint\": \"^8.21.0\"\n},\n\"eslintConfig\": {\n- \"extends\": \"plugin:node/recommended\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/Express4App/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/Express4App/package.json", "diff": "\"serve-favicon\": \"^2.3.0\"\n},\n\"devDependencies\": {\n- \"eslint\": \"^8.21.0\",\n- \"eslint-plugin-node\": \"^11.1.0\"\n+ \"eslint\": \"^8.21.0\"\n},\n\"eslintConfig\": {\n- \"extends\": \"plugin:node/recommended\"\n}\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Remove node plugin from JS projects
410,208
12.08.2022 13:28:51
25,200
537519c9cb6ca1faa7ba17419845779b6ace7df8
Done with JS templates
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/NodejsConsoleApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/NodejsConsoleApp/package.json", "diff": "\"main\": \"app.js\",\n\"author\": {\n\"name\": \"\"\n+ },\n+ \"devDependencies\": {\n+ \"eslint\": \"^8.21.0\"\n+ },\n+ \"eslintConfig\": {\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/NodejsWebApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/NodejsWebApp/package.json", "diff": "\"main\": \"server.js\",\n\"author\": {\n\"name\": \"\"\n+ },\n+ \"devDependencies\": {\n+ \"eslint\": \"^8.21.0\"\n+ },\n+ \"eslintConfig\": {\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/VuejsApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/VuejsApp/package.json", "diff": "\"devDependencies\": {\n\"@vue/cli-plugin-babel\": \"~4.5.0\",\n\"@vue/cli-service\": \"~4.5.0\",\n- \"@vue/compiler-sfc\": \"^3.0.0\"\n+ \"@vue/compiler-sfc\": \"^3.0.0\",\n+ \"eslint\": \"^8.21.0\",\n+ \"eslint-plugin-vue\": \"^9.3.0\"\n+ },\n+ \"eslintConfig\": {\n+ \"extends\": \"plugin:vue/vue3-recommended\"\n}\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Done with JS templates
410,208
12.08.2022 13:57:06
25,200
66443775f9f3b1d8f8fee47af5002828b346688d
Done with TS templates
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptAzureWebRole/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptAzureWebRole/package.json", "diff": "\"author\": {\n\"name\": \"\"\n},\n+ \"engines\": {\n+ \"node\": \"^8.0.0\"\n+ },\n\"devDependencies\": {\n\"@types/node\": \"^14.14.7\",\n- \"typescript\": \"^4.5.2\"\n+ \"typescript\": \"^4.5.2\",\n+ \"@typescript-eslint/eslint-plugin\": \"^5.33.0\",\n+ \"@typescript-eslint/parser\": \"^5.33.0\",\n+ \"eslint\": \"^8.21.0\"\n},\n- \"engines\": {\n- \"node\": \"^8.0.0\"\n+ \"eslintConfig\": {\n+ \"parser\": \"@typescript-eslint/parser\",\n+ \"parserOptions\": {\n+ \"ecmaVersion\": \"latest\",\n+ \"sourceType\": \"module\"\n+ },\n+ \"plugins\": [\n+ \"@typescript-eslint\"\n+ ]\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptConsoleApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptConsoleApp/package.json", "diff": "},\n\"devDependencies\": {\n\"@types/node\": \"^14.14.7\",\n- \"typescript\": \"^4.5.2\"\n+ \"typescript\": \"^4.5.2\",\n+ \"@typescript-eslint/eslint-plugin\": \"^5.33.0\",\n+ \"@typescript-eslint/parser\": \"^5.33.0\",\n+ \"eslint\": \"^8.21.0\"\n+ },\n+ \"eslintConfig\": {\n+ \"parser\": \"@typescript-eslint/parser\",\n+ \"parserOptions\": {\n+ \"ecmaVersion\": \"latest\",\n+ \"sourceType\": \"module\"\n+ },\n+ \"plugins\": [\n+ \"@typescript-eslint\"\n+ ]\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptWebApp/package.json", "new_path": "Nodejs/Product/Nodejs/ProjectTemplates/TypeScriptWebApp/package.json", "diff": "},\n\"devDependencies\": {\n\"@types/node\": \"^14.14.7\",\n- \"typescript\": \"^4.5.2\"\n+ \"typescript\": \"^4.5.2\",\n+ \"@typescript-eslint/eslint-plugin\": \"^5.33.0\",\n+ \"@typescript-eslint/parser\": \"^5.33.0\",\n+ \"eslint\": \"^8.21.0\"\n+ },\n+ \"eslintConfig\": {\n+ \"parser\": \"@typescript-eslint/parser\",\n+ \"parserOptions\": {\n+ \"ecmaVersion\": \"latest\",\n+ \"sourceType\": \"module\"\n+ },\n+ \"plugins\": [\n+ \"@typescript-eslint\"\n+ ]\n}\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Done with TS templates
410,202
02.11.2022 09:48:17
25,200
d20e8f68e753fcb492b93e037fe4d2dacd083044
Added description, author and version to ListItemView
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.Designer.cs", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.Designer.cs", "diff": "@@ -321,6 +321,15 @@ namespace Microsoft.NodejsTools.NpmUI {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to Version:.\n+ /// </summary>\n+ public static string VersionLabel {\n+ get {\n+ return ResourceManager.GetString(\"VersionLabel\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to Install New npm Packages.\n/// </summary>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.resx", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.resx", "diff": "<data name=\"KeywordLabel\" xml:space=\"preserve\">\n<value>Keywords:</value>\n</data>\n+ <data name=\"VersionLabel\" xml:space=\"preserve\">\n+ <value>Version:</value>\n+ </data>\n</root>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "diff": "<ResourceDictionary>\n<Style TargetType=\"{x:Type ListViewItem}\" BasedOn=\"{StaticResource {x:Type ListViewItem}}\">\n<Setter Property=\"HorizontalAlignment\" Value=\"Stretch\" />\n+ <Setter Property=\"AutomationProperties.Name\" Value=\"{Binding Path=Name}\" />\n+ <Setter Property=\"AutomationProperties.HelpText\">\n+ <Setter.Value>\n+ <MultiBinding StringFormat=\"{} {0}, {1}, {2}\">\n+ <Binding Path=\"Description\"/>\n+ <Binding Path=\"VersionWithLabel\" />\n+ <Binding Path=\"AuthorWithLabel\" />\n+ </MultiBinding>\n+ </Setter.Value>\n+ </Setter>\n</Style>\n<DataTemplate x:Key=\"PackageInfoTemplate\">\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/PackageCatalogEntryViewModel.cs", "new_path": "Nodejs/Product/Nodejs/NpmUI/PackageCatalogEntryViewModel.cs", "diff": "@@ -40,11 +40,13 @@ namespace Microsoft.NodejsTools.NpmUI\npublic virtual string Name { get; }\npublic string Version => this.version?.ToString() ?? string.Empty;\n+ public string VersionWithLabel => String.IsNullOrWhiteSpace(this.version?.ToString()) ? string.Empty : $\"{NpmInstallWindowResources.VersionLabel} {this.version?.ToString()}\";\npublic IEnumerable<SemverVersion> AvailableVersions { get; }\npublic string Author { get; }\npublic Visibility AuthorVisibility => string.IsNullOrEmpty(this.Author) ? Visibility.Collapsed : Visibility.Visible;\n+ public string AuthorWithLabel => String.IsNullOrWhiteSpace(this.Author) ? string.Empty : $\"{NpmInstallWindowResources.AuthorLabel} {this.Author}\";\npublic string Description { get; }\npublic Visibility DescriptionVisibility => string.IsNullOrEmpty(this.Description) ? Visibility.Collapsed : Visibility.Visible;\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Added description, author and version to ListItemView (#2412) Co-authored-by: Armando Aguirre <araguir@microsoft.com>
410,202
16.11.2022 13:52:38
28,800
d3415cfcfc546c80652c082e86a6cec22e1b5efa
Added speech action to HelpListItem
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.Designer.cs", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.Designer.cs", "diff": "@@ -159,6 +159,15 @@ namespace Microsoft.NodejsTools.NpmUI {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to press tab to get more details.\n+ /// </summary>\n+ public static string HelpTextSpeechAction {\n+ get {\n+ return ResourceManager.GetString(\"HelpTextSpeechAction\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to Homepage: .\n/// </summary>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.resx", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.resx", "diff": "<data name=\"VersionLabel\" xml:space=\"preserve\">\n<value>Version:</value>\n</data>\n+ <data name=\"HelpTextSpeechAction\" xml:space=\"preserve\">\n+ <value>press tab to get more details</value>\n+ </data>\n</root>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "new_path": "Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml", "diff": "<Setter Property=\"AutomationProperties.Name\" Value=\"{Binding Path=Name}\" />\n<Setter Property=\"AutomationProperties.HelpText\">\n<Setter.Value>\n- <MultiBinding StringFormat=\"{} {0}, {1}, {2}\">\n+ <MultiBinding StringFormat=\"{} {0}, {1}, {2}, {3}\">\n<Binding Path=\"Description\"/>\n<Binding Path=\"VersionWithLabel\" />\n<Binding Path=\"AuthorWithLabel\" />\n+ <Binding Path=\"SpeechAction\" />\n</MultiBinding>\n</Setter.Value>\n</Setter>\n" }, { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/NpmUI/PackageCatalogEntryViewModel.cs", "new_path": "Nodejs/Product/Nodejs/NpmUI/PackageCatalogEntryViewModel.cs", "diff": "@@ -56,6 +56,8 @@ namespace Microsoft.NodejsTools.NpmUI\npublic string Keywords { get; }\n+ public string SpeechAction => NpmInstallWindowResources.HelpTextSpeechAction;\n+\npublic bool IsInstalledLocally => !this.IsLocalInstallMissing && this.localVersion.HasValue;\npublic bool IsLocalInstallOutOfDate => this.IsInstalledLocally && this.localVersion < this.version;\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Added speech action to HelpListItem (#2418) Co-authored-by: Armando Aguirre <araguir@microsoft.com>
410,207
20.01.2023 11:17:01
10,800
152517c1bcbea1a90c41d3afbee599359b14010c
Prevent loading output panes on non-jsts projects
[ { "change_type": "MODIFY", "old_path": "Nodejs/Product/Nodejs/Workspace/TypeScriptActionProviderFactory.cs", "new_path": "Nodejs/Product/Nodejs/Workspace/TypeScriptActionProviderFactory.cs", "diff": "@@ -60,8 +60,6 @@ namespace Microsoft.NodejsTools.Workspace\n{\nawait this.workspaceContext.JTF.SwitchToMainThreadAsync();\n- this.outputPane.InitializeOutputPanes();\n-\nvar actions = new List<IFileContextAction>();\nif (TypeScriptHelpers.IsTsJsConfigJsonFile(filePath))\n@@ -78,6 +76,11 @@ namespace Microsoft.NodejsTools.Workspace\n}\n}\n+ if (actions.Count > 0)\n+ {\n+ this.outputPane.InitializeOutputPanes();\n+ }\n+\nreturn actions;\n}\n}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Prevent loading output panes on non-jsts projects
410,207
17.01.2023 17:18:23
10,800
0a76e2b03608f2fdee0e7d2e38e83d7721149b5f
Created new Extras solution
[ { "change_type": "MODIFY", "old_path": "Nodejs/NodejsTools.sln", "new_path": "Nodejs/NodejsTools.sln", "diff": "@@ -38,8 +38,6 @@ Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Tests\", \"Tests\", \"{D7506803\nEndProject\nProject(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"TestAdapter.Tests\", \"Tests\\TestAdapter.Tests\\TestAdapter.Tests.csproj\", \"{1587F42C-8744-4CC4-B09B-DE00951B4714}\"\nEndProject\n-Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Extras\", \"Extras\\Extras.csproj\", \"{A5967578-4BD9-4717-9C21-D9FD18CD2390}\"\n-EndProject\nGlobal\nGlobalSection(SolutionConfigurationPlatforms) = preSolution\nDebug|Any CPU = Debug|Any CPU\n@@ -204,18 +202,6 @@ Global\n{1587F42C-8744-4CC4-B09B-DE00951B4714}.Release|arm64.ActiveCfg = Release|Any CPU\n{1587F42C-8744-4CC4-B09B-DE00951B4714}.Release|x86.ActiveCfg = Release|Any CPU\n{1587F42C-8744-4CC4-B09B-DE00951B4714}.Release|x86.Build.0 = Release|Any CPU\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Debug|Any CPU.Build.0 = Debug|Any CPU\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Debug|arm64.ActiveCfg = Debug|arm64\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Debug|arm64.Build.0 = Debug|arm64\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Debug|x86.ActiveCfg = Debug|x86\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Debug|x86.Build.0 = Debug|x86\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Release|Any CPU.ActiveCfg = Release|Any CPU\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Release|Any CPU.Build.0 = Release|Any CPU\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Release|arm64.ActiveCfg = Release|arm64\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Release|arm64.Build.0 = Release|arm64\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Release|x86.ActiveCfg = Release|x86\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390}.Release|x86.Build.0 = Release|x86\nEndGlobalSection\nGlobalSection(SolutionProperties) = preSolution\nHideSolutionNode = FALSE\n@@ -234,7 +220,6 @@ Global\n{D9BADB3D-B6E9-4A54-8196-9374CFB93DA9} = {8AB8B6AC-77EB-47E7-904F-422588542C4D}\n{06A4F57E-3E4F-40F0-AA7D-1C0204CE88B8} = {F9719B35-F359-47A7-A2F8-34F42E53C809}\n{1587F42C-8744-4CC4-B09B-DE00951B4714} = {D7506803-B6A3-4C7C-893A-270CEC896F12}\n- {A5967578-4BD9-4717-9C21-D9FD18CD2390} = {F9719B35-F359-47A7-A2F8-34F42E53C809}\nEndGlobalSection\nGlobalSection(ExtensibilityGlobals) = postSolution\nSolutionGuid = {B1CAB318-7961-42BF-A7B1-FBDB3EC225E9}\n" } ]
C#
Apache License 2.0
microsoft/nodejstools
Created new Extras solution
555,923
09.05.2022 15:43:23
-19,080
023b842c0616a7c6f24ba61ccebe4cec6d31b6e1
Update MIT-LICENSE Update the time period of copy rights
[ { "change_type": "MODIFY", "old_path": "MIT-LICENSE", "new_path": "MIT-LICENSE", "diff": "-Copyright (c) 2016-2019 David Heinemeier Hansson, Basecamp\n+Copyright (c) 2016-2022 David Heinemeier Hansson, Basecamp\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n" } ]
Ruby
MIT License
rails/webpacker
Update MIT-LICENSE Update the time period of copy rights
378,349
09.03.2017 04:21:54
21,600
f7f1e0dde2138270b57c7eb4dcf9d46830e6e19c
[Build] Added /usr/local/cuda*/lib*/stubs directory as a default search path for CUDA
[ { "change_type": "MODIFY", "old_path": "scripts/shellTools.sh", "new_path": "scripts/shellTools.sh", "diff": "@@ -79,10 +79,11 @@ function dirWithLibrary {\nlocal mergedLibPaths=\"\"\n- mergedLibPaths=$mergedLibPaths:\"/usr/local/cuda*/lib*\"\nmergedLibPaths=$mergedLibPaths:$OCCA_LIBRARY_PATH\nmergedLibPaths=$mergedLibPaths:$LD_LIBRARY_PATH\nmergedLibPaths=$mergedLibPaths:$DYLD_LIBRARY_PATH\n+ mergedLibPaths=$mergedLibPaths:\"/usr/local/cuda*/lib*\"\n+ mergedLibPaths=$mergedLibPaths:\"/usr/local/cuda*/lib*/stubs\"\nmergedLibPaths=$mergedLibPaths:\"/lib:/usr/lib:/usr/lib32:/usr/lib64:\"\nmergedLibPaths=$mergedLibPaths:\"/usr/lib/*-gnu/\"\n@@ -117,18 +118,19 @@ function dirWithHeader {\nlocal mergedPaths=\"\"\nlocal mergedLibPaths=\"\"\n- mergedPaths=$mergedPaths:\"/usr/local/cuda*/include\"\n- mergedPaths=$mergedPaths:\"/Developer/NVIDIA/CUDA*/include\"\nmergedPaths=$mergedPaths:$OCCA_INCLUDE_PATH\nmergedPaths=$mergedPaths:$CPLUS_INCLUDE_PATH\nmergedPaths=$mergedPaths:$C_INCLUDE_PATH\nmergedPaths=$mergedPaths:$INCLUDEPATH\n+ mergedPaths=$mergedPaths:\"/usr/local/cuda*/include\"\n+ mergedPaths=$mergedPaths:\"/Developer/NVIDIA/CUDA*/include\"\nmergedPaths=$mergedPaths:\"/usr/include\"\n- mergedLibPaths=$mergedLibPaths:\"/usr/local/cuda*/lib*\"\nmergedLibPaths=$mergedLibPaths:$OCCA_LIBRARY_PATH\nmergedLibPaths=$mergedLibPaths:$LD_LIBRARY_PATH\nmergedLibPaths=$mergedLibPaths:$DYLD_LIBRARY_PATH\n+ mergedLibPaths=$mergedLibPaths:\"/usr/local/cuda*/lib*\"\n+ mergedLibPaths=$mergedLibPaths:\"/usr/local/cuda*/lib*/stubs\"\nmergedLibPaths=$mergedLibPaths:\"/lib:/usr/lib:/usr/lib32:/usr/lib64:\"\nmergedLibPaths=$mergedLibPaths:\"/usr/lib/*-gnu/\"\n" } ]
C++
MIT License
libocca/occa
[Build] Added /usr/local/cuda*/lib*/stubs directory as a default search path for CUDA
378,360
28.01.2018 11:43:57
21,600
2eceaa5706ad6cf3a1b153c1f2a8a2fffa2d5945
Fix truncation problem in values shown for Memory when using occainfo. [Sys] Added extra precision to stringifyBytes
[ { "change_type": "MODIFY", "old_path": "src/tools.cpp", "new_path": "src/tools.cpp", "diff": "@@ -1194,23 +1194,29 @@ namespace occa {\nstd::string stringifyBytes(uintptr_t bytes) {\nif (0 < bytes) {\n+\nstd::stringstream ss;\nuint64_t bigBytes = bytes;\nuint64_t big1 = 1;\n+ char bufr[32];\n+# define __ROUNDIT(b) (sprintf( bufr, \"%.3g\", bigBytes / (double)((uint64_t)1 << (b)) ), bufr )\n+\nif (bigBytes < (big1 << 10))\nss << bigBytes << \" bytes\";\nelse if (bigBytes < (big1 << 20))\n- ss << (bigBytes >> 10) << \" KB\";\n+ ss << __ROUNDIT(10) << \" KB\";\nelse if (bigBytes < (big1 << 30))\n- ss << (bigBytes >> 20) << \" MB\";\n+ ss << __ROUNDIT(20) << \" MB\";\nelse if (bigBytes < (big1 << 40))\n- ss << (bigBytes >> 30) << \" GB\";\n+ ss << __ROUNDIT(30) << \" GB\";\nelse if (bigBytes < (big1 << 50))\n- ss << (bigBytes >> 40) << \" TB\";\n+ ss << __ROUNDIT(40) << \" TB\";\nelse\nss << bigBytes << \" bytes\";\n+# undef __ROUNDIT\n+\nreturn ss.str();\n}\n" } ]
C++
MIT License
libocca/occa
Fix truncation problem in values shown for Memory when using occainfo. (#81) [Sys] Added extra precision to stringifyBytes
378,349
11.12.2016 22:31:28
21,600
76350bda8ad48adc8bcc100f30a49691273bddc6
[Core] Moved mode from device.hpp to mode.hpp
[ { "change_type": "MODIFY", "old_path": "include/occa/base.hpp", "new_path": "include/occa/base.hpp", "diff": "#include <iostream>\n#include <vector>\n-#include <map>\n#include <stdint.h>\n#include \"occa/memory.hpp\"\nnamespace occa {\n- class kernel_v; class kernel;\n- class memory_v; class memory;\n- class device_v; class device;\n-\n//---[ Globals & Flags ]--------------\nextern properties settings;\n//====================================\n- //---[ Registration ]-----------------\n- class mode_v;\n-\n- typedef std::map<std::string,mode_v*> strToModeMap_t;\n- typedef strToModeMap_t::iterator strToModeMapIterator;\n-\n- strToModeMap_t& modeMap();\n- bool modeIsEnabled(const std::string &mode);\n-\n- mode_v* getMode(const occa::properties &props);\n- mode_v* getMode(const std::string &mode);\n-\n- device_v* newModeDevice(const occa::properties &props = occa::properties());\n- kernel_v* newModeKernel(const occa::properties &props = occa::properties());\n- memory_v* newModeMemory(const occa::properties &props = occa::properties());\n-\n- void freeModeDevice(device_v *dHandle);\n- void freeModeKernel(kernel_v *kHandle);\n- void freeModeMemory(memory_v *mHandle);\n-\n- class mode_v {\n- protected:\n- std::string modeName;\n-\n- public:\n- std::string& name();\n- virtual device_v* newDevice(const occa::properties &props = occa::properties()) = 0;\n- virtual kernel_v* newKernel(const occa::properties &props = occa::properties()) = 0;\n- virtual memory_v* newMemory(const occa::properties &props = occa::properties()) = 0;\n- };\n-\n- template <class device_t, class kernel_t, class memory_t>\n- class mode : public mode_v {\n- public:\n- mode(std::string modeName_) {\n- modeName = modeName_;\n- modeMap()[modeName] = this;\n- }\n-\n- device_v* newDevice(const occa::properties &props) {\n- occa::properties allProps = props;\n- allProps[\"mode\"] = modeName;\n- return new device_t(allProps);\n- }\n-\n- kernel_v* newKernel(const occa::properties &props) {\n- occa::properties allProps = props;\n- allProps[\"mode\"] = modeName;\n- return new kernel_t(allProps);\n- }\n-\n- memory_v* newMemory(const occa::properties &props) {\n- occa::properties allProps = props;\n- allProps[\"mode\"] = modeName;\n- return new memory_t(allProps);\n- }\n- };\n- //====================================\n-\n-\n//---[ Memory ]-----------------------\nvoid memcpy(void *dest, const void *src,\nconst dim_t bytes,\n" }, { "change_type": "ADD", "old_path": null, "new_path": "include/occa/mode.hpp", "diff": "+/* The MIT License (MIT)\n+ *\n+ * Copyright (c) 2014-2016 David Medina and Tim Warburton\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in all\n+ * copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+ */\n+\n+#ifndef OCCA_MODE_HEADER\n+#define OCCA_MODE_HEADER\n+\n+#include <iostream>\n+#include <map>\n+\n+#include \"occa/defines.hpp\"\n+#include \"occa/tools/properties.hpp\"\n+\n+namespace occa {\n+ class kernel_v; class kernel;\n+ class memory_v; class memory;\n+ class device_v; class device;\n+\n+ class mode_v;\n+\n+ typedef std::map<std::string,mode_v*> strToModeMap_t;\n+ typedef strToModeMap_t::iterator strToModeMapIterator;\n+\n+ strToModeMap_t& modeMap();\n+ bool modeIsEnabled(const std::string &mode);\n+\n+ mode_v* getMode(const occa::properties &props);\n+ mode_v* getMode(const std::string &mode);\n+\n+ device_v* newModeDevice(const occa::properties &props = occa::properties());\n+ kernel_v* newModeKernel(const occa::properties &props = occa::properties());\n+ memory_v* newModeMemory(const occa::properties &props = occa::properties());\n+\n+ void freeModeDevice(device_v *dHandle);\n+ void freeModeKernel(kernel_v *kHandle);\n+ void freeModeMemory(memory_v *mHandle);\n+\n+ class mode_v {\n+ protected:\n+ std::string modeName;\n+\n+ public:\n+ std::string& name();\n+ virtual device_v* newDevice(const occa::properties &props = occa::properties()) = 0;\n+ virtual kernel_v* newKernel(const occa::properties &props = occa::properties()) = 0;\n+ virtual memory_v* newMemory(const occa::properties &props = occa::properties()) = 0;\n+ };\n+\n+ template <class device_t, class kernel_t, class memory_t>\n+ class mode : public mode_v {\n+ public:\n+ mode(std::string modeName_) {\n+ modeName = modeName_;\n+ modeMap()[modeName] = this;\n+ }\n+\n+ device_v* newDevice(const occa::properties &props) {\n+ occa::properties allProps = props;\n+ allProps[\"mode\"] = modeName;\n+ return new device_t(allProps);\n+ }\n+\n+ kernel_v* newKernel(const occa::properties &props) {\n+ occa::properties allProps = props;\n+ allProps[\"mode\"] = modeName;\n+ return new kernel_t(allProps);\n+ }\n+\n+ memory_v* newMemory(const occa::properties &props) {\n+ occa::properties allProps = props;\n+ allProps[\"mode\"] = modeName;\n+ return new memory_t(allProps);\n+ }\n+ };\n+}\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/registration.hpp", "new_path": "include/occa/modes/cuda/registration.hpp", "diff": "# ifndef OCCA_CUDA_REGISTRATION_HEADER\n# define OCCA_CUDA_REGISTRATION_HEADER\n+#include \"occa/mode.hpp\"\n#include \"occa/modes/cuda/device.hpp\"\n#include \"occa/modes/cuda/kernel.hpp\"\n#include \"occa/modes/cuda/memory.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/opencl/registration.hpp", "new_path": "include/occa/modes/opencl/registration.hpp", "diff": "# ifndef OCCA_OPENCL_REGISTRATION_HEADER\n# define OCCA_OPENCL_REGISTRATION_HEADER\n+#include \"occa/mode.hpp\"\n#include \"occa/modes/opencl/device.hpp\"\n#include \"occa/modes/opencl/kernel.hpp\"\n#include \"occa/modes/opencl/memory.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/openmp/registration.hpp", "new_path": "include/occa/modes/openmp/registration.hpp", "diff": "# ifndef OCCA_OPENMP_REGISTRATION_HEADER\n# define OCCA_OPENMP_REGISTRATION_HEADER\n+#include \"occa/mode.hpp\"\n#include \"occa/modes/openmp/device.hpp\"\n#include \"occa/modes/openmp/kernel.hpp\"\n#include \"occa/modes/serial/memory.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/serial/registration.hpp", "new_path": "include/occa/modes/serial/registration.hpp", "diff": "#define OCCA_SERIAL_REGISTRATION_HEADER\n#include \"occa/defines.hpp\"\n+#include \"occa/mode.hpp\"\n#include \"occa/modes/serial/device.hpp\"\n#include \"occa/modes/serial/kernel.hpp\"\n#include \"occa/modes/serial/memory.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/threads/registration.hpp", "new_path": "include/occa/modes/threads/registration.hpp", "diff": "#define OCCA_THREADS_REGISTRATION_HEADER\n#include \"occa/defines.hpp\"\n+#include \"occa/mode.hpp\"\n#include \"occa/modes/threads/device.hpp\"\n#include \"occa/modes/threads/kernel.hpp\"\n#include \"occa/modes/serial/memory.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "src/base.cpp", "new_path": "src/base.cpp", "diff": "*/\n#include \"occa/base.hpp\"\n+#include \"occa/mode.hpp\"\n#include \"occa/tools/sys.hpp\"\nnamespace occa {\n-\n//---[ Globals & Flags ]--------------\nproperties settings;\n//====================================\n- //---[ Registration ]-----------------\n- strToModeMap_t& modeMap() {\n- static strToModeMap_t modeMap_;\n- return modeMap_;\n- }\n-\n- bool modeIsEnabled(const std::string &mode) {\n- return (modeMap().find(mode) != modeMap().end());\n- }\n-\n- mode_v* getMode(const occa::properties &props) {\n- if (!props.has(\"mode\")) {\n- std::cout << \"No OCCA mode given, defaulting to [Serial] mode\\n\";\n- return getMode(\"Serial\");\n- }\n- return getMode(props[\"mode\"]);\n- }\n-\n- mode_v* getMode(const std::string &mode) {\n- if (!modeIsEnabled(mode)) {\n- std::cout << \"OCCA mode [\" << mode << \"] is not enabled, defaulting to [Serial] mode\\n\";\n- return modeMap()[\"Serial\"];\n- }\n- return modeMap()[mode];\n- }\n-\n- device_v* newModeDevice(const occa::properties &props) {\n- return getMode(props)->newDevice(props);\n- }\n-\n- kernel_v* newModeKernel(const occa::properties &props) {\n- return getMode(props)->newKernel(props);\n- }\n-\n- memory_v* newModeMemory(const occa::properties &props) {\n- return getMode(props)->newMemory(props);\n- }\n-\n- void freeModeDevice(device_v *dHandle) {\n- delete dHandle;\n- }\n-\n- void freeModeKernel(kernel_v *kHandle) {\n- delete kHandle;\n- }\n-\n- void freeModeMemory(memory_v *mHandle) {\n- delete mHandle;\n- }\n-\n- std::string& mode_v::name() {\n- return modeName;\n- }\n- //====================================\n-\n-\n//---[ Memory ]-----------------------\nvoid memcpy(void *dest, const void *src,\nconst dim_t bytes,\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "#include \"occa/device.hpp\"\n#include \"occa/base.hpp\"\n+#include \"occa/mode.hpp\"\n#include \"occa/tools/sys.hpp\"\n#include \"occa/tools/io.hpp\"\n#include \"occa/parser/parser.hpp\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/mode.cpp", "diff": "+/* The MIT License (MIT)\n+ *\n+ * Copyright (c) 2014-2016 David Medina and Tim Warburton\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in all\n+ * copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+ */\n+\n+#include \"occa/mode.hpp\"\n+#include \"occa/device.hpp\"\n+#include \"occa/kernel.hpp\"\n+#include \"occa/memory.hpp\"\n+\n+namespace occa {\n+ strToModeMap_t& modeMap() {\n+ static strToModeMap_t modeMap_;\n+ return modeMap_;\n+ }\n+\n+ bool modeIsEnabled(const std::string &mode) {\n+ return (modeMap().find(mode) != modeMap().end());\n+ }\n+\n+ mode_v* getMode(const occa::properties &props) {\n+ if (!props.has(\"mode\")) {\n+ std::cout << \"No OCCA mode given, defaulting to [Serial] mode\\n\";\n+ return getMode(\"Serial\");\n+ }\n+ return getMode(props[\"mode\"]);\n+ }\n+\n+ mode_v* getMode(const std::string &mode) {\n+ if (!modeIsEnabled(mode)) {\n+ std::cout << \"OCCA mode [\" << mode << \"] is not enabled, defaulting to [Serial] mode\\n\";\n+ return modeMap()[\"Serial\"];\n+ }\n+ return modeMap()[mode];\n+ }\n+\n+ device_v* newModeDevice(const occa::properties &props) {\n+ return getMode(props)->newDevice(props);\n+ }\n+\n+ kernel_v* newModeKernel(const occa::properties &props) {\n+ return getMode(props)->newKernel(props);\n+ }\n+\n+ memory_v* newModeMemory(const occa::properties &props) {\n+ return getMode(props)->newMemory(props);\n+ }\n+\n+ void freeModeDevice(device_v *dHandle) {\n+ delete dHandle;\n+ }\n+\n+ void freeModeKernel(kernel_v *kHandle) {\n+ delete kHandle;\n+ }\n+\n+ void freeModeMemory(memory_v *mHandle) {\n+ delete mHandle;\n+ }\n+\n+ std::string& mode_v::name() {\n+ return modeName;\n+ }\n+}\n" } ]
C++
MIT License
libocca/occa
[Core] Moved mode from device.hpp to mode.hpp
378,349
11.12.2016 23:09:25
21,600
bb4bdcc27cb9f434a359a46e50b6b7be7faca192
[UVA] (Dirty,Clean) -> (Stale,Fresh)
[ { "change_type": "MODIFY", "old_path": "include/occa/device.hpp", "new_path": "include/occa/device.hpp", "diff": "@@ -48,7 +48,7 @@ namespace occa {\nbool uvaEnabled_;\nptrRangeMap_t uvaMap;\n- memoryVector_t uvaDirtyMemory;\n+ memoryVector_t uvaStaleMemory;\nstream_t currentStream;\nstd::vector<stream_t> streams;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/memory.hpp", "new_path": "include/occa/memory.hpp", "diff": "@@ -39,7 +39,7 @@ namespace occa {\nstatic const int isManaged = (1 << 0);\nstatic const int inDevice = (1 << 1);\nstatic const int leftInDevice = (1 << 2);\n- static const int isDirty = (1 << 3);\n+ static const int isStale = (1 << 3);\n}\n//---[ memory_v ]---------------------\n@@ -60,7 +60,7 @@ namespace occa {\nbool isManaged() const;\nbool inDevice() const;\nbool leftInDevice() const;\n- bool isDirty() const;\n+ bool isStale() const;\nvoid* uvaHandle();\n@@ -143,7 +143,7 @@ namespace occa {\nbool isManaged() const;\nbool inDevice() const;\nbool leftInDevice() const;\n- bool isDirty() const;\n+ bool isStale() const;\nvoid* getHandle(const occa::properties &props = occa::properties());\n@@ -152,9 +152,9 @@ namespace occa {\nvoid syncToDevice(const dim_t bytes, const dim_t offset);\nvoid syncFromDevice(const dim_t bytes, const dim_t offset);\n- bool uvaIsDirty();\n- void uvaMarkDirty();\n- void uvaMarkClean();\n+ bool uvaIsStale();\n+ void uvaMarkStale();\n+ void uvaMarkFresh();\nvoid copyFrom(const void *src,\nconst dim_t bytes = -1,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/uva.hpp", "new_path": "include/occa/uva.hpp", "diff": "@@ -52,7 +52,7 @@ namespace occa {\ntypedef std::vector<occa::memory_v*> memoryVector_t;\nextern ptrRangeMap_t uvaMap;\n- extern memoryVector_t uvaDirtyMemory;\n+ extern memoryVector_t uvaStaleMemory;\nclass uvaPtrInfo_t {\nprivate:\n@@ -90,8 +90,8 @@ namespace occa {\nvoid sync(void *ptr);\nvoid dontSync(void *ptr);\n- void removeFromDirtyMap(void *ptr);\n- void removeFromDirtyMap(memory_v *mem);\n+ void removeFromStaleMap(void *ptr);\n+ void removeFromStaleMap(memory_v *mem);\nvoid setupMagicFor(void *ptr);\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -47,7 +47,7 @@ namespace occa {\nuvaEnabled_ = m.uvaEnabled_;\nuvaMap = m.uvaMap;\n- uvaDirtyMemory = m.uvaDirtyMemory;\n+ uvaStaleMemory = m.uvaStaleMemory;\ncurrentStream = m.currentStream;\nstreams = m.streams;\n@@ -144,19 +144,19 @@ namespace occa {\ncheckIfInitialized();\nif (dHandle->fakesUva()) {\n- const size_t dirtyEntries = uvaDirtyMemory.size();\n+ const size_t staleEntries = uvaStaleMemory.size();\n- if (dirtyEntries) {\n- for (size_t i = 0; i < dirtyEntries; ++i) {\n- occa::memory_v *mem = uvaDirtyMemory[i];\n+ if (staleEntries) {\n+ for (size_t i = 0; i < staleEntries; ++i) {\n+ occa::memory_v *mem = uvaStaleMemory[i];\nmem->copyTo(mem->uvaPtr, -1, 0, occa::properties(\"async = 1\"));\nmem->memInfo &= ~uvaFlag::inDevice;\n- mem->memInfo &= ~uvaFlag::isDirty;\n+ mem->memInfo &= ~uvaFlag::isStale;\n}\n- uvaDirtyMemory.clear();\n+ uvaStaleMemory.clear();\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/kernel.cpp", "new_path": "src/kernel.cpp", "diff": "@@ -174,9 +174,9 @@ namespace occa {\nmHandle->copyFrom(mHandle->uvaPtr);\nmHandle->memInfo |= uvaFlag::inDevice;\n}\n- if (!isConst && !mHandle->isDirty()) {\n- uvaDirtyMemory.push_back(mHandle);\n- mHandle->memInfo |= uvaFlag::isDirty;\n+ if (!isConst && !mHandle->isStale()) {\n+ uvaStaleMemory.push_back(mHandle);\n+ mHandle->memInfo |= uvaFlag::isStale;\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/memory.cpp", "new_path": "src/memory.cpp", "diff": "@@ -65,8 +65,8 @@ namespace occa {\nreturn (memInfo & uvaFlag::leftInDevice);\n}\n- bool memory_v::isDirty() const {\n- return (memInfo & uvaFlag::isDirty);\n+ bool memory_v::isStale() const {\n+ return (memInfo & uvaFlag::isStale);\n}\nvoid* memory_v::uvaHandle() {\n@@ -154,8 +154,8 @@ namespace occa {\nreturn (mHandle->memInfo & uvaFlag::leftInDevice);\n}\n- bool memory::isDirty() const {\n- return (mHandle->memInfo & uvaFlag::isDirty);\n+ bool memory::isStale() const {\n+ return (mHandle->memInfo & uvaFlag::isStale);\n}\nvoid* memory::getHandle(const occa::properties &props) {\n@@ -206,9 +206,9 @@ namespace occa {\ncopyTo(mHandle->uvaPtr, bytes_, offset);\nmHandle->memInfo |= uvaFlag::inDevice;\n- mHandle->memInfo &= ~uvaFlag::isDirty;\n+ mHandle->memInfo &= ~uvaFlag::isStale;\n- removeFromDirtyMap(mHandle);\n+ removeFromStaleMap(mHandle);\n}\n}\n@@ -231,28 +231,28 @@ namespace occa {\ncopyFrom(mHandle->uvaPtr, bytes_, offset);\nmHandle->memInfo &= ~uvaFlag::inDevice;\n- mHandle->memInfo &= ~uvaFlag::isDirty;\n+ mHandle->memInfo &= ~uvaFlag::isStale;\n- removeFromDirtyMap(mHandle);\n+ removeFromStaleMap(mHandle);\n}\n}\n- bool memory::uvaIsDirty() {\n+ bool memory::uvaIsStale() {\ncheckIfInitialized();\n- return (mHandle && mHandle->isDirty());\n+ return (mHandle && mHandle->isStale());\n}\n- void memory::uvaMarkDirty() {\n+ void memory::uvaMarkStale() {\ncheckIfInitialized();\nif (mHandle != NULL) {\n- mHandle->memInfo |= uvaFlag::isDirty;\n+ mHandle->memInfo |= uvaFlag::isStale;\n}\n}\n- void memory::uvaMarkClean() {\n+ void memory::uvaMarkFresh() {\ncheckIfInitialized();\nif (mHandle != NULL) {\n- mHandle->memInfo &= ~uvaFlag::isDirty;\n+ mHandle->memInfo &= ~uvaFlag::isStale;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -52,7 +52,7 @@ namespace occa {\nuvaEnabled_ = d.uvaEnabled_;\nuvaMap = d.uvaMap;\n- uvaDirtyMemory = d.uvaDirtyMemory;\n+ uvaStaleMemory = d.uvaStaleMemory;\ncompiler = d.compiler;\ncompilerFlags = d.compilerFlags;\n" }, { "change_type": "MODIFY", "old_path": "src/uva.cpp", "new_path": "src/uva.cpp", "diff": "namespace occa {\nptrRangeMap_t uvaMap;\n- memoryVector_t uvaDirtyMemory;\n+ memoryVector_t uvaStaleMemory;\nptrRange_t::ptrRange_t() :\nstart(NULL),\n@@ -174,7 +174,7 @@ namespace occa {\nif (mem == NULL)\nreturn false;\n- return mem->isDirty();\n+ return mem->isStale();\n}\nvoid sync(void *ptr) {\n@@ -191,10 +191,10 @@ namespace occa {\n}\nvoid dontSync(void *ptr) {\n- removeFromDirtyMap(ptr);\n+ removeFromStaleMap(ptr);\n}\n- void removeFromDirtyMap(void *ptr) {\n+ void removeFromStaleMap(void *ptr) {\nptrRangeMap_t::iterator it = uvaMap.find(ptr);\nif (it == uvaMap.end())\n@@ -202,21 +202,21 @@ namespace occa {\nmemory m(it->second);\n- if (!m.uvaIsDirty())\n+ if (!m.uvaIsStale())\nreturn;\n- removeFromDirtyMap(m.getMHandle());\n+ removeFromStaleMap(m.getMHandle());\n}\n- void removeFromDirtyMap(memory_v *mem) {\n+ void removeFromStaleMap(memory_v *mem) {\nocca::memory m(mem);\n- const size_t dirtyEntries = uvaDirtyMemory.size();\n+ const size_t staleEntries = uvaStaleMemory.size();\n- for (size_t i = 0; i < dirtyEntries; ++i) {\n- if (uvaDirtyMemory[i] == mem) {\n- m.uvaMarkClean();\n- uvaDirtyMemory.erase(uvaDirtyMemory.begin() + i);\n+ for (size_t i = 0; i < staleEntries; ++i) {\n+ if (uvaStaleMemory[i] == mem) {\n+ m.uvaMarkFresh();\n+ uvaStaleMemory.erase(uvaStaleMemory.begin() + i);\nbreak;\n}\n" } ]
C++
MIT License
libocca/occa
[UVA] (Dirty,Clean) -> (Stale,Fresh)
378,349
11.12.2016 23:47:20
21,600
21699f3677fcb5e4d484599c3a10a638f9e040ef
[README] Update to README
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "-<a name=\"OCCA\"></a>\n-## OCCA [![Build Status](https://travis-ci.org/libocca/occa.svg?branch=master)](https://travis-ci.org/libocca/occa)\n+<a href=\"http://libocca.org\" target=\"_blank\">![OCCA](http://libocca.org/images/logo/blueOccaLogo.png \"OCCA\")</a>\n+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n+[![Build Status](https://travis-ci.org/libocca/occa.svg?branch=master)](https://travis-ci.org/libocca/occa)\nOCCA is an open-source (MIT license) library used to program current multi-core/many-core architectures.\nDevices (such as CPUs, GPUs, Intel's Xeon Phi, FPGAs, etc) are abstracted using an offload-model for application development and programming for the devices is done through a C-based (OKL) or Fortran-based kernel language (OFL).\n@@ -8,7 +9,7 @@ OCCA gives developers the ability to target devices at run-time by using run-tim\n<a name=\"Taiga\"></a>\n## Taiga\n-We are using <a href=\"https://tree.taiga.io/project/dsm5-occa/kanban\">Taiga</a> to schedule and manage our tasks.\n+We are using <a href=\"https://tree.taiga.io/project/dsm5-occa/backlog\">Taiga</a> to schedule and manage our tasks.\nTo submit an issue, please follow <a href=\"https://tree.taiga.io/project/dsm5-occa/issues?page=1\">this link</a>\n@@ -40,7 +41,7 @@ Python 2 and 3 bindings are available with OCCA.\nIf you wish to setup the occa Python module, rather than using `make`, compile both `libocca.so` and the module with\n```\n-python make.py\n+python scripts/make.py\n```\n@@ -96,7 +97,7 @@ where `<occa>` is the OCCA directory\n### Useful environment variables:\n| Environment Variable | Description |\n|----------------------------|-----------------------------------------------------|\n-| OCCA_CACHE_DIR | Sets directory where kernels are cached (Default: ${HOME}/._occa |\n+| OCCA_CACHE_DIR | Sets directory where kernels are cached (Default: ${HOME}/.occa |\n| OCCA_INCLUDE_PATH | Adds directories to find headers |\n| OCCA_LIBRARY_PATH | Adds directories to find libraries |\n| OCCA_CXX | C++ compiler used for libocca.so and run-time compilation |\n" } ]
C++
MIT License
libocca/occa
[README] Update to README
378,349
11.12.2016 23:53:09
21,600
a01e7f35ec07c1423b99bdc00a3ec1d07cb6100b
[Git] Removed obj/ directory from repo
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": ".gitattributes\n/bin\n+/obj\n/include/occa/defines/compiledDefines.hpp\n/scripts/compilerVendorTest\n.compiledDefinesChanged\n" }, { "change_type": "DELETE", "old_path": "obj/.gitignore", "new_path": null, "diff": "-*\n-!.gitignore\n\\ No newline at end of file\n" } ]
C++
MIT License
libocca/occa
[Git] Removed obj/ directory from repo
378,349
12.12.2016 21:13:19
21,600
17f78d00c64b6e99faa9491b3497a1543b1c48c8
[UVA] UVA is working again (changed property UVA -> uva)
[ { "change_type": "MODIFY", "old_path": "examples/backgroundDevices/main.cpp", "new_path": "examples/backgroundDevices/main.cpp", "diff": "@@ -7,7 +7,7 @@ int main(int argc, char **argv) {\n// Other useful functions:\n// occa::setDevice(\"mode = OpenMP\")\n- // occa::setDevice(\"mode = OpenCL, platformID = 0, deviceID = 1, UVA = enabled\");\n+ // occa::setDevice(\"mode = OpenCL, platformID = 0, deviceID = 1, uva = enabled\");\n// occa::device = occa::currentDevice();\n// Use the default device (mode = Serial)\n" }, { "change_type": "MODIFY", "old_path": "examples/mandelbulb/setuprc", "new_path": "examples/mandelbulb/setuprc", "diff": "-#[DEVICE INFO] \"mode = Serial, UVA = enabled\"\n-#[DEVICE INFO] \"mode = OpenMP, UVA = enabled\"\n-[DEVICE INFO] \"mode = OpenCL, platformID = 0, deviceID = 1, UVA = enabled\"\n-#[DEVICE INFO] \"mode = CUDA, deviceID = 0, UVA = enabled\"\n+#[DEVICE INFO] \"mode = Serial, uva = enabled\"\n+#[DEVICE INFO] \"mode = OpenMP, uva = enabled\"\n+[DEVICE INFO] \"mode = OpenCL, platformID = 0, deviceID = 1, uva = enabled\"\n+#[DEVICE INFO] \"mode = CUDA, deviceID = 0, uva = enabled\"\n[SHAPE FUNCTION] mandelbulb\n#[SHAPE FUNCTION] sphere\n" }, { "change_type": "MODIFY", "old_path": "examples/usingArrays/main.cpp", "new_path": "examples/usingArrays/main.cpp", "diff": "@@ -8,8 +8,8 @@ template <class TM, const int TMi>\nvoid printMatrix(occa::array<TM,TMi> &a);\nint main(int argc, char **argv) {\n- // occa::setDevice(\"mode = OpenCL, platformID = 0, deviceID = 1, UVA = enabled\");\n- // occa::setDevice(\"mode = CUDA, deviceID = 0, UVA = enabled\");\n+ // occa::setDevice(\"mode = OpenCL, platformID = 0, deviceID = 1, uva = enabled\");\n+ // occa::setDevice(\"mode = CUDA, deviceID = 0, uva = enabled\");\n//---[ Testing API ]------------------\nstd::cout << \"Testing API:\\n\";\n" }, { "change_type": "MODIFY", "old_path": "examples/uvaAddVectors/main.cpp", "new_path": "examples/uvaAddVectors/main.cpp", "diff": "@@ -9,7 +9,7 @@ int main(int argc, char **argv) {\n// disabled by default\n// occa::enableUVAByDefault();\n- occa::device device(\"mode = OpenCL, platformID = 0, deviceID = 0, UVA = enabled\");\n+ occa::device device(\"mode = OpenCL, platformID = 0, deviceID = 0, uva = enabled\");\n// Allocate [managed] arrays that will\n// automatically synchronize between\n" }, { "change_type": "MODIFY", "old_path": "include/occa/memory.hpp", "new_path": "include/occa/memory.hpp", "diff": "@@ -71,17 +71,17 @@ namespace occa {\nvirtual kernelArg makeKernelArg() const = 0;\nvirtual void copyTo(void *dest,\n- const udim_t bytes = -1,\n+ const udim_t bytes,\nconst udim_t offset = 0,\nconst occa::properties &props = occa::properties()) = 0;\nvirtual void copyFrom(const void *src,\n- const udim_t bytes = -1,\n+ const udim_t bytes,\nconst udim_t offset = 0,\nconst occa::properties &props = occa::properties()) = 0;\nvirtual void copyFrom(const memory_v *src,\n- const udim_t bytes = -1,\n+ const udim_t bytes,\nconst udim_t destOffset = 0,\nconst udim_t srcOffset = 0,\nconst occa::properties &props = occa::properties()) = 0;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/properties.hpp", "new_path": "include/occa/tools/properties.hpp", "diff": "@@ -97,8 +97,9 @@ namespace occa {\nvoid remove(const std::string &prop);\n- void setOnChangeFunc(hasProperties &holder_);\n+ bool iMatch(const std::string &prop, const std::string &value) const;\n+ void setOnChangeFunc(hasProperties &holder_);\nvoid onChange(properties::Op op,\nconst std::string &prop,\nconst std::string &oldValue,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/string.hpp", "new_path": "include/occa/tools/string.hpp", "diff": "@@ -81,6 +81,13 @@ namespace occa {\ndouble atod(const char *c);\ndouble atod(const std::string &str);\n+\n+ char uppercase(const char c);\n+ char lowercase(const char c);\n+\n+ std::string uppercase(const std::string &str);\n+ std::string lowercase(const std::string &str);\n+\nstd::string stringifyBytes(udim_t bytes);\nstrVector_t split(const std::string &s, const char delimeter);\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -35,7 +35,7 @@ namespace occa {\nmode = properties_[\"mode\"];\nproperties = properties_;\n- uvaEnabled_ = (properties[\"uva\"] == \"enabled\");\n+ uvaEnabled_ = this->properties.iMatch(\"uva\", \"enabled\");\ncurrentStream = NULL;\nbytesAllocated = 0;\n}\n@@ -100,7 +100,7 @@ namespace occa {\nvoid device::setup(const occa::properties &props) {\ndHandle = occa::newModeDevice(props);\n- dHandle->uvaEnabled_ = (props[\"uva\"] == \"ENABLED\");\n+ dHandle->uvaEnabled_ = dHandle->properties.iMatch(\"uva\", \"enabled\");\nstream newStream = createStream();\ndHandle->currentStream = newStream.handle;\n@@ -145,17 +145,15 @@ namespace occa {\nif (dHandle->fakesUva()) {\nconst size_t staleEntries = uvaStaleMemory.size();\n-\n- if (staleEntries) {\nfor (size_t i = 0; i < staleEntries; ++i) {\nocca::memory_v *mem = uvaStaleMemory[i];\n- mem->copyTo(mem->uvaPtr, -1, 0, occa::properties(\"async = 1\"));\n+ mem->copyTo(mem->uvaPtr, mem->size, 0, occa::properties(\"async = 1\"));\nmem->memInfo &= ~uvaFlag::inDevice;\nmem->memInfo &= ~uvaFlag::isStale;\n}\n-\n+ if (staleEntries) {\nuvaStaleMemory.clear();\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/kernel.cpp", "new_path": "src/kernel.cpp", "diff": "@@ -171,7 +171,7 @@ namespace occa {\nmHandle->dHandle->hasUvaEnabled()) {\nif (!mHandle->inDevice()) {\n- mHandle->copyFrom(mHandle->uvaPtr);\n+ mHandle->copyFrom(mHandle->uvaPtr, mHandle->size);\nmHandle->memInfo |= uvaFlag::inDevice;\n}\nif (!isConst && !mHandle->isStale()) {\n@@ -397,11 +397,18 @@ namespace occa {\nvoid kernel::runFromArguments() {\ncheckIfInitialized();\n+ const int argc = (int) kHandle->arguments.size();\n+ for (int i = 0; i < argc; ++i) {\n+ const bool argIsConst = kHandle->metadata.argIsConst(i);\n+ kHandle->arguments[i].setupForKernelCall(argIsConst);\n+ }\n+\n// Add nestedKernels\nif (kHandle->nestedKernelCount()) {\nkHandle->arguments.insert(kHandle->arguments.begin(),\nkHandle->nestedKernelsPtr());\n}\n+\nkHandle->runFromArguments(kHandle->argumentCount(),\nkHandle->argumentsPtr());\n" }, { "change_type": "MODIFY", "old_path": "src/parser/types.cpp", "new_path": "src/parser/types.cpp", "diff": "@@ -2684,7 +2684,6 @@ namespace occa {\nkInfo.baseName = baseName;\nkInfo.nestedKernels = nestedKernels.size();\n-\nkInfo.argumentInfos = argumentInfos;\nreturn kInfo;\n" }, { "change_type": "MODIFY", "old_path": "src/tools/properties.cpp", "new_path": "src/tools/properties.cpp", "diff": "@@ -97,6 +97,18 @@ namespace occa {\nprops.erase(it);\n}\n+ bool properties::iMatch(const std::string &prop, const std::string &value) const {\n+ citer_t it = props.find(prop);\n+ if (it == props.end()) {\n+ return false;\n+ }\n+ return (lowercase(it->second) == lowercase(value));\n+ }\n+\n+ void properties::setOnChangeFunc(hasProperties &holder_) {\n+ holder = &holder_;\n+ }\n+\nvoid properties::onChange(properties::Op op,\nconst std::string &prop,\nconst std::string &oldValue,\n" }, { "change_type": "MODIFY", "old_path": "src/tools/string.cpp", "new_path": "src/tools/string.cpp", "diff": "@@ -182,6 +182,38 @@ namespace occa {\nreturn occa::atod(str.c_str());\n}\n+ char uppercase(const char c) {\n+ if (('a' <= c) && (c <= 'z')) {\n+ return ((c + 'A') - 'a');\n+ }\n+ return c;\n+ }\n+\n+ char lowercase(const char c) {\n+ if (('A' <= c) && (c <= 'Z')) {\n+ return ((c + 'a') - 'A');\n+ }\n+ return c;\n+ }\n+\n+ std::string uppercase(const std::string &str) {\n+ const int chars = (int) str.size();\n+ std::string ret = str;\n+ for (int i = 0; i < chars; ++i) {\n+ ret[i] = uppercase(ret[i]);\n+ }\n+ return ret;\n+ }\n+\n+ std::string lowercase(const std::string &str) {\n+ const int chars = (int) str.size();\n+ std::string ret = str;\n+ for (int i = 0; i < chars; ++i) {\n+ ret[i] = lowercase(ret[i]);\n+ }\n+ return ret;\n+ }\n+\nstd::string stringifyBytes(udim_t bytes) {\nif (0 < bytes) {\nstd::stringstream ss;\n" } ]
C++
MIT License
libocca/occa
[UVA] UVA is working again (changed property UVA -> uva)
378,349
13.12.2016 06:18:10
21,600
a81fdd4d6104c5bd558c8a734e4216c3442852ed
[Sys] Removed warnings when compiling with g++
[ { "change_type": "MODIFY", "old_path": "include/occa/memory.hpp", "new_path": "include/occa/memory.hpp", "diff": "@@ -138,7 +138,7 @@ namespace occa {\nconst std::string& mode();\n- udim_t bytes() const;\n+ udim_t size() const;\nbool isManaged() const;\nbool inDevice() const;\n@@ -180,7 +180,7 @@ namespace occa {\nvoid free();\nvoid detach();\n- void deleteRefs(const bool free = false);\n+ void deleteRefs(const bool freeMemory = false);\n};\n//====================================\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/opencl/utils.hpp", "new_path": "include/occa/modes/opencl/utils.hpp", "diff": "@@ -111,7 +111,8 @@ namespace occa {\ncl_device_id deviceID,\ncl_context context);\n- cl_event& event(streamTag tag);\n+ cl_event& event(streamTag &tag);\n+ const cl_event& event(const streamTag &tag);\nstd::string error(int e);\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/properties.hpp", "new_path": "include/occa/tools/properties.hpp", "diff": "@@ -91,6 +91,7 @@ namespace occa {\nif (!has(prop)) {\nset(prop, t);\n}\n+ return *this;\n}\nproperties operator + (const properties &props) const;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/types.hpp", "new_path": "include/occa/types.hpp", "diff": "#include <iostream>\n#include <vector>\n#include <map>\n-#include <cstdint>\n+#include <stdint.h>\n#include \"occa/defines.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "src/kernel.cpp", "new_path": "src/kernel.cpp", "diff": "@@ -197,8 +197,8 @@ namespace occa {\nkernelInfo::kernelInfo() :\nocca::properties() {}\n- kernelInfo::kernelInfo(const properties &props) :\n- occa::properties(props) {}\n+ kernelInfo::kernelInfo(const properties &props_) :\n+ occa::properties(props_) {}\nbool kernelInfo::isAnOccaDefine(const std::string &name) {\nreturn ((name == \"occaInnerDim0\") ||\n" }, { "change_type": "MODIFY", "old_path": "src/memory.cpp", "new_path": "src/memory.cpp", "diff": "@@ -135,7 +135,7 @@ namespace occa {\nreturn device(mHandle->dHandle).mode();\n}\n- udim_t memory::bytes() const {\n+ udim_t memory::size() const {\nif (mHandle == NULL) {\nreturn 0;\n}\n@@ -352,7 +352,7 @@ namespace occa {\ndeleteRefs(false);\n}\n- void memory::deleteRefs(const bool free) {\n+ void memory::deleteRefs(const bool freeMemory) {\ncheckIfInitialized();\nmHandle->dHandle->bytesAllocated -= (mHandle->size);\n@@ -371,7 +371,7 @@ namespace occa {\n}\n}\n- if (free) {\n+ if (freeMemory) {\nmHandle->free();\n} else {\nmHandle->detach();\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/kernel.cpp", "new_path": "src/modes/opencl/kernel.cpp", "diff": "@@ -137,8 +137,8 @@ namespace occa {\n}\nint kernel::maxDims() {\n- static cl_uint dims = 0;\n- if (dims == 0) {\n+ static cl_uint dims_ = 0;\n+ if (dims_ == 0) {\nsize_t bytes;\nOCCA_CL_CHECK(\"Kernel: Max Dims\",\nclGetDeviceInfo(clDeviceID,\n@@ -147,16 +147,16 @@ namespace occa {\nOCCA_CL_CHECK(\"Kernel: Max Dims\",\nclGetDeviceInfo(clDeviceID,\nCL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,\n- bytes, &dims, NULL));\n+ bytes, &dims_, NULL));\n}\n- return (int) dims;\n+ return (int) dims_;\n}\ndim kernel::maxOuterDims() {\nstatic occa::dim outerDims(0);\nif (outerDims.x == 0) {\n- int dims = maxDims();\n- size_t *od = new size_t[dims];\n+ int dims_ = maxDims();\n+ size_t *od = new size_t[dims_];\nsize_t bytes;\nOCCA_CL_CHECK(\"Kernel: Max Outer Dims\",\nclGetDeviceInfo(clDeviceID,\n@@ -166,7 +166,7 @@ namespace occa {\nclGetDeviceInfo(clDeviceID,\nCL_DEVICE_MAX_WORK_ITEM_SIZES,\nbytes, &od, NULL));\n- for (int i = 0; i < dims; ++i) {\n+ for (int i = 0; i < dims_; ++i) {\nouterDims[i] = od[i];\n}\ndelete [] od;\n@@ -177,7 +177,7 @@ namespace occa {\ndim kernel::maxInnerDims() {\nstatic occa::dim innerDims(0);\nif (innerDims.x == 0) {\n- size_t dims;\n+ size_t dims_;\nsize_t bytes;\nOCCA_CL_CHECK(\"Kernel: Max Inner Dims\",\nclGetKernelWorkGroupInfo(clKernel,\n@@ -188,8 +188,8 @@ namespace occa {\nclGetKernelWorkGroupInfo(clKernel,\nclDeviceID,\nCL_KERNEL_WORK_GROUP_SIZE,\n- bytes, &dims, NULL));\n- innerDims.x = dims;\n+ bytes, &dims_, NULL));\n+ innerDims.x = dims_;\n}\nreturn innerDims;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/utils.cpp", "new_path": "src/modes/opencl/utils.cpp", "diff": "@@ -447,8 +447,12 @@ namespace occa {\ndelete [] binary;\n}\n- cl_event& event(streamTag tag) {\n- return (cl_event&) tag.handle;\n+ cl_event& event(streamTag &tag) {\n+ return (cl_event&) (tag.handle);\n+ }\n+\n+ const cl_event& event(const streamTag &tag) {\n+ return (const cl_event&) (tag.handle);\n}\nstd::string error(int e) {\n" }, { "change_type": "MODIFY", "old_path": "src/parser/magic.cpp", "new_path": "src/parser/magic.cpp", "diff": "@@ -532,8 +532,8 @@ namespace occa {\n// sortIndices();\n}\n- void valueInfo_t::load(varInfo &var) {\n- value.load(var);\n+ void valueInfo_t::load(varInfo &var_) {\n+ value.load(var_);\n}\nvoid valueInfo_t::load(const std::string &s) {\n@@ -850,7 +850,7 @@ namespace occa {\nreturn -1;\n}\n- int valueInfo_t::hasStride(atomInfo_t &stride) {\n+ int valueInfo_t::hasStride(atomInfo_t &stride_) {\nfor (int i = 0; i < indices; ++i) {\n// if (strides[i] == stride) // [<>]\n// return true;\n" }, { "change_type": "MODIFY", "old_path": "src/parser/preprocessor.cpp", "new_path": "src/parser/preprocessor.cpp", "diff": "@@ -720,9 +720,9 @@ namespace occa {\n// ---[ Boolean Operators ]---------------\nbool typeHolder::operator < (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return (bool) (to<bool>() < th.to<bool>()); break;\ncase charType : return (bool) (to<char>() < th.to<char>()); break;\ncase ushortType : return (bool) (to<unsigned short>() < th.to<unsigned short>()); break;\n@@ -743,9 +743,9 @@ namespace occa {\n}\nbool typeHolder::operator <= (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return (bool) (to<bool>() <= th.to<bool>()); break;\ncase charType : return (bool) (to<char>() <= th.to<char>()); break;\ncase ushortType : return (bool) (to<unsigned short>() <= th.to<unsigned short>()); break;\n@@ -766,9 +766,9 @@ namespace occa {\n}\nbool typeHolder::operator == (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return (bool) (to<bool>() == th.to<bool>()); break;\ncase charType : return (bool) (to<char>() == th.to<char>()); break;\ncase ushortType : return (bool) (to<unsigned short>() == th.to<unsigned short>()); break;\n@@ -789,9 +789,9 @@ namespace occa {\n}\nbool typeHolder::operator != (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return (bool) (to<bool>() != th.to<bool>()); break;\ncase charType : return (bool) (to<char>() != th.to<char>()); break;\ncase ushortType : return (bool) (to<unsigned short>() != th.to<unsigned short>()); break;\n@@ -812,9 +812,9 @@ namespace occa {\n}\nbool typeHolder::operator >= (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return (bool) (to<bool>() >= th.to<bool>()); break;\ncase charType : return (bool) (to<char>() >= th.to<char>()); break;\ncase ushortType : return (bool) (to<unsigned short>() >= th.to<unsigned short>()); break;\n@@ -835,9 +835,9 @@ namespace occa {\n}\nbool typeHolder::operator > (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return (bool) (to<bool>() > th.to<bool>()); break;\ncase charType : return (bool) (to<char>() > th.to<char>()); break;\ncase ushortType : return (bool) (to<unsigned short>() > th.to<unsigned short>()); break;\n@@ -858,9 +858,9 @@ namespace occa {\n}\nbool typeHolder::operator && (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return (bool) (to<bool>() && th.to<bool>()); break;\ncase charType : return (bool) (to<char>() && th.to<char>()); break;\ncase ushortType : return (bool) (to<unsigned short>() && th.to<unsigned short>()); break;\n@@ -881,9 +881,9 @@ namespace occa {\n}\nbool typeHolder::operator || (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return (bool) (to<bool>() || th.to<bool>()); break;\ncase charType : return (bool) (to<char>() || th.to<char>()); break;\ncase ushortType : return (bool) (to<unsigned short>() || th.to<unsigned short>()); break;\n@@ -907,9 +907,9 @@ namespace occa {\n// ---[ Binary Operators ]----------------\ntypeHolder typeHolder::operator * (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() * th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() * th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() * th.to<unsigned short>()); break;\n@@ -931,9 +931,9 @@ namespace occa {\n}\ntypeHolder typeHolder::operator + (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() + th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() + th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() + th.to<unsigned short>()); break;\n@@ -955,9 +955,9 @@ namespace occa {\n}\ntypeHolder typeHolder::operator - (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() - th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() - th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() - th.to<unsigned short>()); break;\n@@ -979,9 +979,9 @@ namespace occa {\n}\ntypeHolder typeHolder::operator / (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() / th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() / th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() / th.to<unsigned short>()); break;\n@@ -1002,9 +1002,9 @@ namespace occa {\nreturn typeHolder(0);\n}\ntypeHolder typeHolder::operator % (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() % th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() % th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() % th.to<unsigned short>()); break;\n@@ -1026,9 +1026,9 @@ namespace occa {\n}\ntypeHolder typeHolder::operator & (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() & th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() & th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() & th.to<unsigned short>()); break;\n@@ -1050,9 +1050,9 @@ namespace occa {\n}\ntypeHolder typeHolder::operator | (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() | th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() | th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() | th.to<unsigned short>()); break;\n@@ -1074,9 +1074,9 @@ namespace occa {\n}\ntypeHolder typeHolder::operator ^ (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() ^ th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() ^ th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() ^ th.to<unsigned short>()); break;\n@@ -1098,9 +1098,9 @@ namespace occa {\n}\ntypeHolder typeHolder::operator >> (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() >> th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() >> th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() >> th.to<unsigned short>()); break;\n@@ -1122,9 +1122,9 @@ namespace occa {\n}\ntypeHolder typeHolder::operator << (const typeHolder &th) {\n- const int maxType = typeHolder::maxType(*this, th);\n+ const int mtype = typeHolder::maxType(*this, th);\n- switch(maxType) {\n+ switch(mtype) {\ncase boolType : return typeHolder(to<bool>() << th.to<bool>()); break;\ncase charType : return typeHolder(to<char>() << th.to<char>()); break;\ncase ushortType : return typeHolder(to<unsigned short>() << th.to<unsigned short>()); break;\n" }, { "change_type": "MODIFY", "old_path": "src/parser/statement.cpp", "new_path": "src/parser/statement.cpp", "diff": "@@ -111,12 +111,12 @@ namespace occa {\nif (info & expType::hasInfo)\nreturn occa::hash(leaves[0]);\n- hash_t hash = occa::hash(value);\n+ hash_t hash_ = occa::hash(value);\n- for (int i = 0; i < leafCount; ++i)\n- hash ^= leaves[i]->hash();\n-\n- return hash;\n+ for (int i = 0; i < leafCount; ++i) {\n+ hash_ ^= leaves[i]->hash();\n+ }\n+ return hash_;\n}\nbool expNode::sameAs(expNode &e, const bool nestedSearch) {\n" }, { "change_type": "MODIFY", "old_path": "src/tools/io.cpp", "new_path": "src/tools/io.cpp", "diff": "#if (OCCA_OS & OCCA_LINUX_OS)\n# include <unistd.h>\n+# include <errno.h>\n# include <sys/types.h>\n# include <sys/dir.h>\n#elif (OCCA_OS & OCCA_OSX_OS)\n" }, { "change_type": "MODIFY", "old_path": "src/tools/properties.cpp", "new_path": "src/tools/properties.cpp", "diff": "@@ -120,13 +120,13 @@ namespace occa {\nhash_t properties::hash() const {\nciter_t it = props.begin();\n- hash_t hash;\n+ hash_t hash_;\nwhile (it != props.end()) {\n- hash ^= occa::hash(it->first);\n- hash ^= occa::hash(it->second);\n+ hash_ ^= occa::hash(it->first);\n+ hash_ ^= occa::hash(it->second);\n++it;\n}\n- return hash;\n+ return hash_;\n}\nstd::string properties::toString() const {\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "#include \"occa/defines.hpp\"\n#if (OCCA_OS & OCCA_LINUX_OS)\n+# include <unistd.h>\n# include <sys/time.h>\n# include <sys/sysctl.h>\n-# include <unistd.h>\n+# include <sys/sysinfo.h>\n# include <dlfcn.h>\n+# include <errno.h>\n#elif (OCCA_OS & OCCA_OSX_OS)\n# include <mach/mach_host.h>\n# include <sys/sysctl.h>\n" } ]
C++
MIT License
libocca/occa
[Sys] Removed warnings when compiling with g++
378,349
13.12.2016 07:36:55
21,600
c56068de8b1882419c5d88cc9e9061fb447161e1
[OpenMP] OpenMP mode seems to be working
[ { "change_type": "MODIFY", "old_path": "examples/addVectors/cpp/main.cpp", "new_path": "examples/addVectors/cpp/main.cpp", "diff": "@@ -22,8 +22,8 @@ int main(int argc, char **argv) {\nocca::memory o_a, o_b, o_ab;\n//---[ Device setup with string flags ]-------------------\n- device.setup(\"mode = Serial\");\n- // device.setup(\"mode = OpenMP , schedule = compact, chunk = 10\");\n+ // device.setup(\"mode = Serial\");\n+ device.setup(\"mode = OpenMP , schedule = compact, chunk = 10\");\n// device.setup(\"mode = OpenCL , platformID = 0, deviceID = 1\");\n// device.setup(\"mode = CUDA , deviceID = 0\");\n// device.setup(\"mode = Threads, threadCount = 4, schedule = compact, pinnedCores = [0, 0, 1, 1]\");\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/openmp/device.hpp", "new_path": "include/occa/modes/openmp/device.hpp", "diff": "# ifndef OCCA_OPENMP_DEVICE_HEADER\n# define OCCA_OPENMP_DEVICE_HEADER\n-#include \"occa/devices.hpp\"\n+#include \"occa/modes/serial/device.hpp\"\nnamespace occa {\nnamespace openmp {\nclass device : public serial::device {\npublic:\ndevice(const occa::properties &properties_);\n- void addOccaHeadersToInfo(kernelInfo &info_);\n+\n+ kernel_v* buildKernel(const std::string &filename,\n+ const std::string &functionName,\n+ const occa::properties &props);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/openmp/kernel.hpp", "new_path": "include/occa/modes/openmp/kernel.hpp", "diff": "@@ -32,7 +32,7 @@ namespace occa {\nnamespace openmp {\nclass kernel : public serial::kernel {\npublic:\n- kernel();\n+ kernel(const occa::properties &properties_ = occa::properties());\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/openmp/utils.hpp", "new_path": "include/occa/modes/openmp/utils.hpp", "diff": "# define OCCA_OPENMP_UTILS_HEADER\nnamespace occa {\n- namespace omp {\n+ namespace openmp {\nextern std::string notSupported;\nstd::string baseCompilerFlag(const int vendor_);\n" }, { "change_type": "RENAME", "old_path": "scripts/ompTest.cpp", "new_path": "scripts/openmpTest.cpp", "diff": "" }, { "change_type": "MODIFY", "old_path": "scripts/shellTools.sh", "new_path": "scripts/shellTools.sh", "diff": "@@ -450,8 +450,8 @@ function compilerSupportsOpenMP {\nlocal vendor=$(compilerVendor $compiler)\nlocal ompFlag=$(compilerOpenMPFlags $compiler)\n- local filename=${OCCA_DIR}/scripts/ompTest.cpp\n- local binary=${OCCA_DIR}/scripts/ompTest\n+ local filename=${OCCA_DIR}/scripts/openmpTest.cpp\n+ local binary=${OCCA_DIR}/scripts/openmpTest\n# Test compilation\n$compiler $ompFlag $filename -o $binary > /dev/null 2>&1\n" }, { "change_type": "MODIFY", "old_path": "src/modes/openmp/device.cpp", "new_path": "src/modes/openmp/device.cpp", "diff": "#if OCCA_OPENMP_ENABLED\n-#include \"occa/Serial.hpp\"\n-#include \"occa/OpenMP.hpp\"\n-\n#include <omp.h>\n+#include \"occa/modes/serial/device.hpp\"\n+#include \"occa/modes/openmp/device.hpp\"\n+#include \"occa/modes/openmp/kernel.hpp\"\n+#include \"occa/modes/openmp/utils.hpp\"\n+\nnamespace occa {\nnamespace openmp {\ndevice::device(const occa::properties &properties_) :\n@@ -36,17 +38,26 @@ namespace occa {\n// Generate an OpenMP library dependency (so it doesn't crash when dlclose())\nomp_get_num_threads();\n- getEnvironmentVariables();\n+ const std::string openmpFlag = openmp::compilerFlag(properties.get<int>(\"vendor\"),\n+ properties[\"compiler\"]);\n- vendor = sys::compilerVendor(compiler);\n- ompFlag = omp::compilerFlag(vendor, compiler);\n- supportsOpenMP = (data_.OpenMPFlag != omp::notSupported);\n-\n- sys::addSharedBinaryFlagsTo(vendor, compilerFlags);\n+ if (openmpFlag != openmp::notSupported) {\n+ std::string &compilerFlags = properties[\"compilerFlags\"];\n+ compilerFlags += ' ';\n+ compilerFlags += openmpFlag;\n+ } else {\n+ std::cout << \"Compiler [\" << properties[\"compiler\"]\n+ << \"] does not support OpenMP, defaulting to [Serial] mode\\n\";\n+ }\n}\n- // [REFACTOR]\n- void device::addOccaHeadersToInfo(kernelInfo &info_) {\n+ kernel_v* device::buildKernel(const std::string &filename,\n+ const std::string &functionName,\n+ const occa::properties &props) {\n+ kernel *k = new kernel();\n+ k->dHandle = this;\n+ k->build(filename, functionName, props);\n+ return k;\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/openmp/kernel.cpp", "new_path": "src/modes/openmp/kernel.cpp", "diff": "#include <omp.h>\n#include \"occa/modes/openmp/kernel.hpp\"\n-#include \"occa/base.hpp\"\n+#include \"occa/tools/env.hpp\"\n+#include \"occa/tools/io.hpp\"\nnamespace occa {\nnamespace openmp {\n- kernel::kernel() : serial::kernel() {}\n+ kernel::kernel(const occa::properties &properties_) :\n+ serial::kernel(properties_) {\n+\n+ properties[\"occa::kernelDefines\"] =\n+ io::cacheFile(env::OCCA_DIR + \"/include/occa/modes/openmp/kernelDefines.hpp\",\n+ \"openmpKernelDefines.hpp\");\n+ }\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/openmp/utils.cpp", "new_path": "src/modes/openmp/utils.cpp", "diff": "#if OCCA_OPENMP_ENABLED\n+#include <iostream>\n+\n+#include \"occa/tools/env.hpp\"\n+#include \"occa/tools/io.hpp\"\n+#include \"occa/tools/sys.hpp\"\n+\nnamespace occa {\nnamespace openmp {\nstd::string notSupported = \"N/A\";\n@@ -49,31 +55,31 @@ namespace occa {\nreturn \"\";\n}\n- return omp::notSupported;\n+ return openmp::notSupported;\n}\nstd::string compilerFlag(const int vendor_,\nconst std::string &compiler) {\n#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_OSX_OS))\n- const std::string safeCompiler = removeSlashes(compiler);\n- std::string flag = omp::notSupported;\n+ const std::string safeCompiler = io::removeSlashes(compiler);\n+ std::string flag = openmp::notSupported;\nstd::stringstream ss;\n- const std::string ompTest = env::OCCA_DIR + \"/scripts/ompTest.cpp\";\n- hash_t hash = occa::hashFile(ompTest);\n+ const std::string openmpTest = env::OCCA_DIR + \"/scripts/openmpTest.cpp\";\n+ hash_t hash = occa::hashFile(openmpTest);\nhash ^= occa::hash(vendor_);\nhash ^= occa::hash(compiler);\n- const std::string srcFilename = io::cacheFile(ompTest, \"ompTest.cpp\", hash);\n+ const std::string srcFilename = io::cacheFile(openmpTest, \"openmpTest.cpp\", hash);\nconst std::string binaryFilename = io::dirname(srcFilename) + \"binary\";\nconst std::string outFilename = io::dirname(srcFilename) + \"output\";\nconst std::string hashTag = \"openmp-compiler\";\n- if (!haveHash(hash, hashTag)) {\n- waitForHash(hash, hashTag);\n+ if (!io::haveHash(hash, hashTag)) {\n+ io::waitForHash(hash, hashTag);\n} else {\n- if (!sys::fileExists(infoFilename)) {\n+ if (!sys::fileExists(outFilename)) {\nflag = baseCompilerFlag(vendor_);\nss << compiler\n<< ' ' << flag\n@@ -84,15 +90,15 @@ namespace occa {\nconst int compileError = system(ss.str().c_str());\nif (compileError) {\n- flag = omp::notSupported;\n+ flag = openmp::notSupported;\n}\nio::write(outFilename, flag);\n- releaseHash(hash, hashTag);\n+ io::releaseHash(hash, hashTag);\nreturn flag;\n}\n- releaseHash(hash, hashTag);\n+ io::releaseHash(hash, hashTag);\n}\nss << io::read(outFilename);\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/device.cpp", "new_path": "src/modes/serial/device.cpp", "diff": "@@ -102,7 +102,7 @@ namespace occa {\n#endif\n}\n- properties[\"vendor\"] = vendor;\n+ properties.set(\"vendor\", vendor);\nsys::addSharedBinaryFlagsTo(vendor, compilerFlags);\nproperties[\"compiler\"] = compiler;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/kernel.cpp", "new_path": "src/modes/serial/kernel.cpp", "diff": "@@ -77,9 +77,14 @@ namespace occa {\nreturn buildFromBinary(binaryFile, functionName);\n}\n- const std::string kernelDefines =\n- io::cacheFile(env::OCCA_DIR + \"/include/occa/modes/serial/kernelDefines.hpp\",\n+ std::string kernelDefines;\n+ if (properties.has(\"occa::kernelDefines\")) {\n+ kernelDefines = properties[\"occa::kernelDefines\"];\n+ } else {\n+ kernelDefines = io::cacheFile(env::OCCA_DIR + \"/include/occa/modes/serial/kernelDefines.hpp\",\n\"serialKernelDefines.hpp\");\n+ }\n+\nconst std::string vectorDefines =\nio::cacheFile(env::OCCA_DIR + \"/include/occa/defines/vector.hpp\",\n\"vectorDefines.hpp\");\n" } ]
C++
MIT License
libocca/occa
[OpenMP] OpenMP mode seems to be working
378,349
24.12.2016 18:04:50
21,600
610971bb05140de0b5d0ad5a90aa48cb69eaa6c9
[CUDA] Added CUDA mode description
[ { "change_type": "MODIFY", "old_path": "include/occa/tools/styling.hpp", "new_path": "include/occa/tools/styling.hpp", "diff": "@@ -52,8 +52,8 @@ namespace occa {\nudim_t size() const;\nfieldGroup& add(const std::string &field, const std::string &value = \"\");\n- int fieldWidth() const;\n- int valueWidth() const;\n+ int getFieldWidth() const;\n+ int getValueWidth() const;\n};\nclass section {\n@@ -67,8 +67,8 @@ namespace occa {\nsection& add(const std::string &field, const std::string &value = \"\");\nsection& addDivider();\n- int fieldWidth() const;\n- int valueWidth() const;\n+ int getFieldWidth() const;\n+ int getValueWidth() const;\nstd::string toString(const int sectionWidth,\nconst int fieldWidth,\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/registration.cpp", "new_path": "src/modes/cuda/registration.cpp", "diff": "@@ -32,6 +32,8 @@ namespace occa {\nmodeInfo::modeInfo() {}\nvoid modeInfo::init() {\n+ cuda::init();\n+ }\nstyling::section& modeInfo::getDescription() {\nstatic styling::section section(\"CUDA\");\n@@ -56,8 +58,6 @@ namespace occa {\n}\nreturn section;\n}\n- cuda::init();\n- }\nocca::properties& modeInfo::getProperties() {\nstatic occa::properties properties;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/openmp/registration.cpp", "new_path": "src/modes/openmp/registration.cpp", "diff": "@@ -32,10 +32,6 @@ namespace occa {\nvoid modeInfo::init() {}\n- void modeInfo::setupProperties() {\n- occa::properties &props = getProperties();\n- }\n-\nocca::properties& modeInfo::getProperties() {\nstatic occa::properties properties;\nreturn properties;\n" }, { "change_type": "MODIFY", "old_path": "src/tools/styling.cpp", "new_path": "src/tools/styling.cpp", "diff": "@@ -74,7 +74,7 @@ namespace occa {\nreturn *this;\n}\n- int fieldGroup::fieldWidth() const {\n+ int fieldGroup::getFieldWidth() const {\nconst int fieldCount = (int) fields.size();\nint maxWidth = 0;\nfor (int i = 0; i < fieldCount; ++i) {\n@@ -84,7 +84,7 @@ namespace occa {\nreturn maxWidth;\n}\n- int fieldGroup::valueWidth() const {\n+ int fieldGroup::getValueWidth() const {\nconst int fieldCount = (int) fields.size();\nint maxWidth = 0;\nfor (int i = 0; i < fieldCount; ++i) {\n@@ -123,20 +123,20 @@ namespace occa {\nreturn *this;\n}\n- int section::fieldWidth() const {\n+ int section::getFieldWidth() const {\nconst int groupCount = (int) groups.size();\nint fieldWidth = 0;\nfor (int i = 0; i < groupCount; ++i) {\n- fieldWidth = std::max(fieldWidth, groups[i].fieldWidth());\n+ fieldWidth = std::max(fieldWidth, groups[i].getFieldWidth());\n}\nreturn fieldWidth;\n}\n- int section::valueWidth() const {\n+ int section::getValueWidth() const {\nconst int groupCount = (int) groups.size();\nint valueWidth = 0;\nfor (int i = 0; i < groupCount; ++i) {\n- valueWidth = std::max(valueWidth, groups[i].valueWidth());\n+ valueWidth = std::max(valueWidth, groups[i].getValueWidth());\n}\nreturn valueWidth;\n}\n@@ -209,8 +209,8 @@ namespace occa {\nfor (int i = 0; i < sectionCount; ++i) {\nconst section &iSection = sections[i];\nsectionWidth = std::max(sectionWidth, (int) iSection.name.size());\n- fieldWidth = std::max(fieldWidth , iSection.fieldWidth());\n- valueWidth = std::max(valueWidth , iSection.valueWidth());\n+ fieldWidth = std::max(fieldWidth , iSection.getFieldWidth());\n+ valueWidth = std::max(valueWidth , iSection.getValueWidth());\n}\nfor (int i = 0; i < sectionCount; ++i) {\n" } ]
C++
MIT License
libocca/occa
[CUDA] Added CUDA mode description
378,349
24.12.2016 19:06:41
21,600
b295030024a01bae48d18c0ea350d569738df3dd
[Properties] Added vector <--> string conversion for properties
[ { "change_type": "MODIFY", "old_path": "include/occa/parser/tools.hpp", "new_path": "include/occa/parser/tools.hpp", "diff": "@@ -104,9 +104,9 @@ namespace occa {\nstd::string compressWhitespace(const std::string &str);\n- std::string strip(const char *c, const size_t chars,\n+ std::string compressAllWhitespace(const char *c, const size_t chars,\nconst int parsingLanguage_ = parserInfo::parsingC);\n- void strip(std::string &str,\n+ void compressAllWhitespace(std::string &str,\nconst int parsingLanguage_ = parserInfo::parsingC);\nchar* cReadFile(const std::string &filename);\n@@ -127,8 +127,8 @@ namespace occa {\nint countDelimiters(const char *c, const char delimiter);\n- void skipTo(const char *&c, const char delimiter, const bool checkEscape = false);\n- void skipTo(const char *&c, std::string delimiters, const bool checkEscape = false);\n+ void skipTo(const char *&c, const char delimiter, const char escapeChar = 0);\n+ void skipTo(const char *&c, std::string delimiters, const char escapeChar = 0);\nvoid skipToWord(const char *&c, std::string word);\nstd::string findFileInPath(const std::string &filename);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/properties.hpp", "new_path": "include/occa/tools/properties.hpp", "diff": "@@ -67,7 +67,7 @@ namespace occa {\nTM get(const std::string &prop, const TM &default_ = TM()) const {\nciter_t it = props.find(prop);\nif (it != props.end()) {\n- return fromString<TM>(it->second);\n+ return occa::fromString<TM>(it->second);\n}\nreturn default_;\n}\n@@ -77,6 +77,15 @@ namespace occa {\nreturn (TM*) get<uintptr_t>(prop, (uintptr_t) default_);\n}\n+ template <class TM>\n+ std::vector<TM> getList(const std::string &prop, const std::vector<TM> &default_ = std::vector<TM>()) const {\n+ citer_t it = props.find(prop);\n+ if (it == props.end()) {\n+ return default_;\n+ }\n+ return listFromString<TM>(it->second);\n+ }\n+\nstd::string get(const std::string &prop, const std::string &default_ = \"\") const;\ntemplate <class TM>\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/string.hpp", "new_path": "include/occa/tools/string.hpp", "diff": "#include \"occa/types.hpp\"\nnamespace occa {\n+ std::string strip(const std::string &str);\n+\n+ std::string escape(const std::string &str, const char c, const char excapeChar = '\\\\');\n+ std::string unescape(const std::string &str, const char c, const char excapeChar = '\\\\');\n+\n+ strVector_t split(const std::string &s, const char delimeter, const char escapeChar = 0);\n+\ntemplate <class TM>\ninline std::string toString(const TM &t) {\nstd::stringstream ss;\n@@ -38,6 +45,22 @@ namespace occa {\nreturn ss.str();\n}\n+ template <class TM>\n+ inline std::string toString(const std::vector<TM> &v) {\n+ const int size = (int) v.size();\n+ std::stringstream ss;\n+ ss << '[';\n+ for (int i = 0; i < size; ++i) {\n+ const std::string istr = occa::toString(v[i]);\n+ ss << escape(istr, ',');\n+ if (i < (size - 1)) {\n+ ss << ',';\n+ }\n+ }\n+ ss << ']';\n+ return ss.str();\n+ }\n+\ntemplate <>\ninline std::string toString<std::string>(const std::string &t) {\nreturn t;\n@@ -66,6 +89,28 @@ namespace occa {\nreturn t;\n}\n+ template <class TM>\n+ inline std::vector<TM> listFromString(const std::string &s) {\n+ std::string str = strip(s);\n+ const int chars = (int) str.size();\n+ if (chars && str[chars - 1] == ']') {\n+ str = str.substr(0, chars - 1);\n+ }\n+ if (chars && str[0] == '[') {\n+ str = str.substr(1);\n+ }\n+\n+ strVector_t parts = split(str, ',', '\\\\');\n+ const int partCount = (int) parts.size();\n+\n+ std::vector<TM> ret;\n+ ret.reserve(partCount);\n+ for (int i = 0; i < partCount; ++i) {\n+ ret.push_back(occa::fromString<TM>(unescape(parts[i], '\\\\')));\n+ }\n+ return ret;\n+ }\n+\ntemplate <>\ninline std::string fromString(const std::string &s) {\nreturn s;\n@@ -81,7 +126,6 @@ namespace occa {\ndouble atod(const char *c);\ndouble atod(const std::string &str);\n-\nchar uppercase(const char c);\nchar lowercase(const char c);\n@@ -89,8 +133,6 @@ namespace occa {\nstd::string lowercase(const std::string &str);\nstd::string stringifyBytes(udim_t bytes);\n-\n- strVector_t split(const std::string &s, const char delimeter);\n}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "src/modes/threads/device.cpp", "new_path": "src/modes/threads/device.cpp", "diff": "@@ -43,8 +43,7 @@ namespace occa {\n}\nif (properties.has(\"pinnedCores\")) {\n- // [REFACTOR]\n- // pinnedCores = properties.getAll<int>(\"pinnedCores\");\n+ pinnedCores = properties.getList<int>(\"pinnedCores\");\nif (pinnedCores.size() != (size_t) threads) {\nthreads = (int) pinnedCores.size();\n" }, { "change_type": "MODIFY", "old_path": "src/parser/parser.cpp", "new_path": "src/parser/parser.cpp", "diff": "@@ -231,7 +231,7 @@ namespace occa {\n++c;\n}\n- std::string iFilename = strip(cStart, c - cStart);\n+ std::string iFilename = compressAllWhitespace(cStart, c - cStart);\nconst int chars = iFilename.size();\nconst bool skipFirst = ((iFilename[0] == '\"') ||\n@@ -266,7 +266,7 @@ namespace occa {\nif ((*c != '(') || hasWhitespace) {\nconst size_t chars = strlen(c);\n- info.parts[0] = strip(c, chars);\n+ info.parts[0] = compressAllWhitespace(c, chars);\nc += chars;\nreturn;\n@@ -285,7 +285,7 @@ namespace occa {\nconst char *cStart = c;\nskipTo(c, \",)\");\n- const std::string macroArgName = strip(cStart, c - cStart);\n+ const std::string macroArgName = compressAllWhitespace(cStart, c - cStart);\nif (macroArgName.size()) {\nOCCA_CHECK(!info.hasVarArgs,\n@@ -624,7 +624,7 @@ namespace occa {\nwhile(c < cEnd) {\nif (*c == ',') {\n- args.push_back( strip(cStart, c - cStart) );\n+ args.push_back( compressAllWhitespace(cStart, c - cStart) );\ncStart = ++c; // Skip the [,]\n}\nelse {\n@@ -3607,7 +3607,7 @@ namespace occa {\nwhile(*c != '\\0') {\nconst char *cEnd = readLine(c, parsingLanguage_);\n- line += strip(c, cEnd - c, parsingLanguage_);\n+ line += compressAllWhitespace(c, cEnd - c, parsingLanguage_);\nc = cEnd;\n// Line carrying over to next line\n@@ -3629,7 +3629,7 @@ namespace occa {\n}\nstatus = stripComments(line, parsingLanguage_);\n- strip(line, parsingLanguage_);\n+ compressAllWhitespace(line, parsingLanguage_);\nif (line.size() &&\n((status != insideCommentBlock) ||\n" }, { "change_type": "MODIFY", "old_path": "src/parser/preprocessor.cpp", "new_path": "src/parser/preprocessor.cpp", "diff": "@@ -1425,7 +1425,7 @@ namespace occa {\nif (parser != NULL)\nparser->applyMacros(lineExpNode.value);\n- strip(lineExpNode.value);\n+ compressAllWhitespace(lineExpNode.value);\nlabelCode(lineExpNode);\nlineExpNode.organizeNode();\n" }, { "change_type": "MODIFY", "old_path": "src/parser/tools.cpp", "new_path": "src/parser/tools.cpp", "diff": "@@ -476,7 +476,7 @@ namespace occa {\nreturn ret;\n}\n- std::string strip(const char *c,\n+ std::string compressAllWhitespace(const char *c,\nconst size_t chars,\nconst int parsingLanguage_) {\nif (chars == 0)\n@@ -490,16 +490,16 @@ namespace occa {\nwhile (charIsIn(*cLeft , parserNS::whitespace) && (cLeft <= cRight)) ++cLeft;\nwhile (charIsIn(*cRight, parserNS::whitespace) && (cRight > cLeft)) --cRight;\n- if (cLeft > cRight)\n+ if (cLeft > cRight) {\nreturn \"\";\n-\n+ }\nstd::string ret = \"\";\nconst char *cMid = cLeft;\nwhile (cMid < cRight) {\nif ((cMid[0] == nl) && isWhitespace(cMid[1])) {\n- ret += strip(cLeft, cMid - cLeft);\n+ ret += compressAllWhitespace(cLeft, cMid - cLeft);\nret += ' ';\n++cMid;\n@@ -510,18 +510,18 @@ namespace occa {\n++cMid;\nif ((cMid >= cRight) && ret.size())\n- ret += strip(cLeft, (cMid - cLeft + 1));\n+ ret += compressAllWhitespace(cLeft, (cMid - cLeft + 1));\n}\n- if (ret.size() == 0)\n+ if (ret.size() == 0) {\nreturn compressWhitespace( std::string(cLeft, (cRight - cLeft + 1)) );\n-\n+ }\nreturn compressWhitespace(ret);\n}\n- void strip(std::string &str,\n+ void compressAllWhitespace(std::string &str,\nconst int parsingLanguage_) {\n- str = strip(str.c_str(), str.size());\n+ str = compressAllWhitespace(str.c_str(), str.size());\n}\nchar* cReadFile(const std::string &filename) {\n@@ -697,9 +697,9 @@ namespace occa {\nreturn count;\n}\n- void skipTo(const char *&c, const char delimiter, const bool checkEscape) {\n+ void skipTo(const char *&c, const char delimiter, const char escapeChar) {\nwhile (*c != '\\0') {\n- if (!(checkEscape && (*c == '\\\\')) &&\n+ if (!(escapeChar && (*c == escapeChar)) &&\n(*c == delimiter)) {\nreturn;\n}\n@@ -707,12 +707,12 @@ namespace occa {\n}\n}\n- void skipTo(const char *&c, std::string delimiters, const bool checkEscape) {\n+ void skipTo(const char *&c, std::string delimiters, const char escapeChar) {\nconst size_t chars = delimiters.size();\nconst char *d = delimiters.c_str();\nwhile (*c != '\\0') {\n- if (!(checkEscape && (*c == '\\\\'))) {\n+ if (!(escapeChar && (*c == escapeChar))) {\nfor (size_t i = 0; i < chars; ++i) {\nif (*c == d[i]) {\nreturn;\n" }, { "change_type": "MODIFY", "old_path": "src/tools/string.cpp", "new_path": "src/tools/string.cpp", "diff": "#include \"occa/parser/tools.hpp\"\nnamespace occa {\n+ std::string strip(const std::string &str) {\n+ if (str.size() == 0) {\n+ return str;\n+ }\n+ const char *c = str.c_str();\n+ int start = 0;\n+ int end = (int) (str.size() - 1);\n+ while (c[start] != '\\0' && isWhitespace(c[start])) {\n+ ++start;\n+ }\n+ while (end && isWhitespace(c[end])) {\n+ --end;\n+ }\n+ if (start >= end) {\n+ return \"\";\n+ }\n+ return str.substr(start, end - start + 1);\n+ }\n+\n+ std::string escape(const std::string &str, const char c, const char escapeChar) {\n+ const int chars = (int) str.size();\n+ const char *cstr = str.c_str();\n+ std::string ret;\n+ for (int i = 0; i < chars; ++i) {\n+ if (cstr[i] == c) {\n+ ret += escapeChar;\n+ }\n+ ret += cstr[i];\n+ }\n+ return ret;\n+ }\n+\n+ std::string unescape(const std::string &str, const char c, const char escapeChar) {\n+ std::string ret;\n+ const int chars = (int) str.size();\n+ const char *cstr = str.c_str();\n+ for (int i = 0; i < chars; ++i) {\n+ if (cstr[i] == escapeChar && cstr[i + 1] == c) {\n+ continue;\n+ }\n+ ret += cstr[i];\n+ }\n+ return ret;\n+ }\n+\n+ strVector_t split(const std::string &s, const char delimeter, const char escapeChar) {\n+ strVector_t sv;\n+ const char *c = s.c_str();\n+\n+ while (*c != '\\0') {\n+ const char *cStart = c;\n+ skipTo(c, delimeter, escapeChar);\n+ sv.push_back(std::string(cStart, c - cStart));\n+ if (*c != '\\0') {\n+ ++c;\n+ }\n+ }\n+\n+ return sv;\n+ }\n+\nudim_t atoi(const char *c) {\nudim_t ret = 0;\n@@ -238,20 +299,4 @@ namespace occa {\nreturn \"\";\n}\n-\n- strVector_t split(const std::string &s, const char delimeter) {\n- strVector_t sv;\n- const char *c = s.c_str();\n-\n- while (*c != '\\0') {\n- const char *cStart = c;\n- skipTo(c, delimeter);\n- sv.push_back(std::string(cStart, c - cStart));\n- if (*c != '\\0') {\n- ++c;\n- }\n- }\n-\n- return sv;\n- }\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "@@ -581,7 +581,7 @@ namespace occa {\nsys::vendor::Cray |\nsys::vendor::Pathscale)) {\n- return \"-x c++ -fPIC -shared\"; // [-] -x c++ for now\n+ return \"-x c++ -fPIC -shared\";\n} else if (vendor_ & sys::vendor::HP) {\nreturn \"+z -b\";\n} else if (vendor_ & sys::vendor::VisualStudio) {\n" } ]
C++
MIT License
libocca/occa
[Properties] Added vector <--> string conversion for properties
378,349
25.12.2016 00:28:36
21,600
7361e5717d50bd14a1d80faaf889bd492e33b841
[C] Added refactor fixes, addVectors works
[ { "change_type": "MODIFY", "old_path": "examples/addVectors/c/addVectors.okl", "new_path": "examples/addVectors/c/addVectors.okl", "diff": "@@ -4,7 +4,8 @@ kernel void addVectors(const int entries,\nfloat *ab) {\nfor (int i = 0; i < entries; ++i; tile(16)) {\n- if (i < entries)\n+ if (i < entries) {\nab[i] = a[i] + b[i];\n}\n}\n+}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/c/c_wrapper.cpp", "new_path": "src/lang/c/c_wrapper.cpp", "diff": "@@ -127,6 +127,10 @@ namespace occa {\ndelete t.ptr;\n}\n+ inline void freePtr(const occaObject &t) {\n+ delete t.ptr;\n+ }\n+\ntemplate <>\ninline void free<void>(const occaObject &t) {\nswitch(t.ptr->type) {\n@@ -142,7 +146,7 @@ namespace occa {\ncase float_ : occa::c::free<float>(t); break;\ncase double_ : occa::c::free<double>(t); break;\n- case string_ : occa::c::free<const char*>(t); break;\n+ case string_ : occa::c::freePtr(t); break;\ndefault: break;\n}\n}\n@@ -480,7 +484,7 @@ occaDevice OCCA_RFUNC occaCreateDevice(occaObject info) {\nocca::device device;\nif (info.ptr->type == occa::c::string_) {\ndevice = occa::device((const char*) occa::c::getKernelArg(info).data.void_);\n- occa::c::free<const char*>(info);\n+ occa::c::freePtr(info);\n} else if (info.ptr->type == occa::c::properties_) {\ndevice = occa::device(occa::c::getProperties(info));\n}\n@@ -648,7 +652,7 @@ void OCCA_RFUNC occaStreamFree(occaStream stream) {\nvoid OCCA_RFUNC occaDeviceFree(occaDevice device) {\nocca::c::getDevice(device).free();\n- occa::c::free<occa::device>(device);\n+ occa::c::freePtr(device);\n}\n//======================================\n@@ -755,7 +759,7 @@ void OCCA_RFUNC occaKernelRunN(occaKernel kernel, const int argc, occaType *args\nif (args[i].ptr->type == occa::c::memory_) {\nocca::memory memory_((occa::memory_v*) argPtr);\n- kernel_.addArgument(i, occa::kernelArg(occa::c::memory_));\n+ kernel_.addArgument(i, memory_);\n} else {\nkernel_.addArgument(i, occa::kernelArg(arg));\ndelete args[i].ptr;\n@@ -769,7 +773,7 @@ void OCCA_RFUNC occaKernelRunN(occaKernel kernel, const int argc, occaType *args\nvoid OCCA_RFUNC occaKernelFree(occaKernel kernel) {\nocca::c::getKernel(kernel).free();\n- occa::c::free<occa::kernel>(kernel);\n+ occa::c::freePtr(kernel);\n}\noccaKernelInfo OCCA_RFUNC occaCreateKernelInfo() {\n@@ -865,7 +869,7 @@ void OCCA_RFUNC occaCopyMemToPtr(void *dest, occaMemory src,\nvoid OCCA_RFUNC occaMemoryFree(occaMemory memory) {\nocca::c::getMemory(memory).free();\n- occa::c::free<occa::memory>(memory);\n+ occa::c::freePtr(memory);\n}\n//======================================\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/device.cpp", "new_path": "src/modes/serial/device.cpp", "diff": "@@ -170,11 +170,11 @@ namespace occa {\nmem->dHandle = this;\nmem->size = bytes;\n-\nmem->handle = sys::malloc(bytes);\n- if (src != NULL)\n+ if (src != NULL) {\n::memcpy(mem->handle, src, bytes);\n+ }\nreturn mem;\n}\n" } ]
C++
MIT License
libocca/occa
[C] Added refactor fixes, addVectors works
378,349
25.12.2016 08:24:18
21,600
47bbfd770f3b60a43dd498e153ad74c692f4e1e4
[Bug] Minor bug fixes in CUDA mode
[ { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/kernel.hpp", "new_path": "include/occa/modes/cuda/kernel.hpp", "diff": "@@ -43,8 +43,6 @@ namespace occa {\nCUmodule module;\nCUfunction handle;\n- void *vArgs[2*OCCA_MAX_ARGS];\n-\npublic:\nkernel(const occa::properties &properties_ = occa::properties());\n~kernel();\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -37,8 +37,8 @@ namespace occa {\ndevice::device(const occa::properties &properties_) :\nocca::device_v(properties_) {\n- OCCA_ERROR(\"deviceID\"),\n- \"[OpenCL] device not given [deviceID]\");\n+ OCCA_ERROR(\"[CUDA] device not given [deviceID]\",\n+ properties.has(\"deviceID\"));\nconst int deviceID = properties.get<int>(\"deviceID\");\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/kernel.cpp", "new_path": "src/modes/serial/kernel.cpp", "diff": "@@ -149,7 +149,7 @@ namespace occa {\nif (compileError) {\nio::releaseHash(hash, hashTag);\n- OCCA_ERROR(\"Compilation error\", error);\n+ OCCA_ERROR(\"Compilation error\", compileError);\n}\ndlHandle = sys::dlopen(binaryFile, hash, hashTag);\n" } ]
C++
MIT License
libocca/occa
[Bug] Minor bug fixes in CUDA mode
378,349
30.12.2016 00:41:54
21,600
a8ca0dbea7efb596625e5aefcdf24d236e49fdfe
[Refactor] make test works, added trie tests
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/Makefile", "new_path": "parser_sandbox/Makefile", "diff": "@@ -8,10 +8,10 @@ endif\n#---[ COMPILATION ]-------------------------------\nheaders = $(wildcard $(incPath)/*.hpp) $(wildcard $(incPath)/*.tpp)\nsources = $(wildcard $(srcPath)/*.cpp)\n-tests = $(wildcard $(testPath)/test*.cpp)\n+testSources = $(wildcard $(testPath)/test*.cpp)\nobjects = $(subst $(srcPath)/,$(objPath)/,$(sources:.cpp=.o))\n-testBinaries = $(subst $(testPath)/,$(testPath)/bin/,$(tests:.cpp=))\n+tests = $(subst $(testPath)/,$(testPath)/bin/,$(testSources:.cpp=))\nflags += -I$(incPath)\n@@ -19,7 +19,7 @@ executables = ${PROJ_DIR}/main\nall: $(executables)\n-${PROJ_DIR}/main: $(objects) $(headers) ${PROJ_DIR}/main.cpp $(testBinaries)\n+${PROJ_DIR}/main: $(objects) $(headers) ${PROJ_DIR}/main.cpp $(tests)\n$(compiler) $(compilerFlags) -o ${PROJ_DIR}/main $(flags) $(objects) ${PROJ_DIR}/main.cpp $(paths) $(links)\n$(objPath)/%.o:$(srcPath)/%.cpp $(wildcard $(subst $(srcPath)/,$(incPath)/,$(<:.cpp=.hpp))) $(wildcard $(subst $(srcPath)/,$(incPath)/,$(<:.cpp=.tpp)))\n@@ -30,6 +30,12 @@ $(testPath)/bin/%:$(testPath)/%.cpp\n@mkdir -p $(testPath)/bin\n$(compiler) $(compilerFlags) -o $@ $(flags) $(objects) $< $(paths) $(links)\n+test: $(tests)\n+ @for test in $(tests); do \\\n+ echo $$test; \\\n+ $$test; \\\n+ done\n+\nclean:\nrm -f $(objPath)/*;\nrm -f $(testPath)/bin/*;\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.hpp", "new_path": "parser_sandbox/include/trie.hpp", "diff": "#include <iostream>\n#include <map>\n+namespace occa {\nclass trieNode_t;\ntypedef std::map<char, trieNode_t> trieNodeMap_t;\ntypedef trieNodeMap_t::iterator trieNodeMapIterator;\n@@ -47,4 +48,5 @@ public:\nvoid print() const;\n};\n+}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/trie.cpp", "new_path": "parser_sandbox/src/trie.cpp", "diff": "+#include <cstring>\n+\n#include \"trie.hpp\"\n+namespace occa {\ntrieNode_t::trieNode_t() :\nisLeaf(false) {}\n@@ -87,21 +90,22 @@ const char* trie_t::get(const char *c) const {\nint count = baseNodeCount;\nwhile (count) {\nconst char ci = *c;\n- int i = 0;\n- for (; i < count; ++i) {\n+ bool found = false;\n+ for (int i = 0; i < count; ++i) {\nif (ci == chars[offset + i]) {\n+ count = leafCount[offset + i];\noffset = offsets[offset + i];\n- count = leafCount[offset];\n++c;\nif (isLeaf[offset]) {\nret = c;\n}\n+ found = true;\nbreak;\n}\n}\n- if (i == count) {\n+ if (!found) {\nbreak;\n}\n}\n@@ -119,7 +123,7 @@ bool trie_t::has(const char c) const {\nbool trie_t::has(const char *c) const {\nconst char *cEnd = get(c);\n- return (c != cEnd);\n+ return ((size_t) (cEnd - c + 1) == strlen(c));\n}\nvoid trie_t::print() const {\n@@ -152,3 +156,4 @@ void trie_t::print() const {\n}\nstd::cout << '\\n';\n}\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "parser_sandbox/tests/testTrie.cpp", "diff": "+#include \"occa/defines.hpp\"\n+#include \"occa/tools/sys.hpp\"\n+#include \"occa/tools/testing.hpp\"\n+\n+#include \"trie.hpp\"\n+\n+void testInsert(occa::trie_t &trie);\n+void testSearch(occa::trie_t &trie);\n+\n+int main(const int argc, const char **argv) {\n+ occa::trie_t trie;\n+ testInsert(trie);\n+ testSearch(trie);\n+}\n+\n+void testInsert(occa::trie_t &trie) {\n+ trie.add(\"blue\");\n+ trie.add(\"boring\");\n+ trie.add(\"glue\");\n+ trie.add(\"good\");\n+}\n+\n+void testSearch(occa::trie_t &trie) {\n+ trie.freeze();\n+ occa::testing::compare(trie.has(\"blue\") , true);\n+ occa::testing::compare(trie.has(\"boring\") , true);\n+ occa::testing::compare(trie.has(\"glue\") , true);\n+ occa::testing::compare(trie.has(\"good\") , true);\n+\n+ occa::testing::compare(trie.has(\"red\") , false);\n+ occa::testing::compare(trie.has(\"goo\") , false);\n+ occa::testing::compare(trie.has(\"goods\") , false);\n+}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "@@ -725,7 +725,7 @@ namespace occa {\nstd::cout << std::string('=', 60) << '\\n';\nif (exitInFailure) {\n- exit(1);\n+ throw 1;\n}\n}\n" } ]
C++
MIT License
libocca/occa
[Refactor] make test works, added trie tests
378,349
30.12.2016 10:21:22
21,600
ecd7f729328284150f2a379fbfeb228e3e9990c7
[Refactor] Added unfrozen checks to trie
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.hpp", "new_path": "parser_sandbox/include/trie.hpp", "diff": "@@ -27,11 +27,10 @@ namespace occa {\npublic:\ntrieNode_t root;\n- int nodeCount;\n- int baseNodeCount;\n+ bool isFrozen;\n+ int nodeCount, baseNodeCount;\nchar *chars;\n- int *offsets;\n- int *leafCount;\n+ int *offsets, *leafCount;\nbool *isLeaf;\ntrie_t();\n@@ -41,12 +40,18 @@ namespace occa {\nvoid freeze();\nint freeze(const trieNode_t &node, int offset);\n+ void defrost();\nconst char* get(const char *c) const;\n+ const char* trieGet(const char *c) const;\n+\nbool has(const char c) const;\n+ bool trieHas(const char c) const;\n+\nbool has(const char *c) const;\n+ bool has(const char *c, const int size) const;\n- void print() const;\n+ void print();\n};\n}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/trie.cpp", "new_path": "parser_sandbox/src/trie.cpp", "diff": "#include <cstring>\n+#include \"occa/defines.hpp\"\n+#include \"occa/tools/sys.hpp\"\n#include \"trie.hpp\"\nnamespace occa {\n@@ -28,25 +30,37 @@ namespace occa {\nconst char* trieNode_t::get(const char *c) const {\ncTrieNodeMapIterator it = leaves.find(*c);\nif (it != leaves.end()) {\n- return it->second.get(c + 1);\n+ const char *ret = it->second.get(c + 1);\n+ return ((NULL == ret) && isLeaf) ? (c + 1) : ret;\n} else {\nreturn isLeaf ? c : NULL;\n}\n}\ntrie_t::trie_t() :\n+ isFrozen(false),\nnodeCount(0),\n- baseNodeCount(0) {}\n+ baseNodeCount(0),\n+ chars(NULL),\n+ offsets(NULL),\n+ leafCount(NULL),\n+ isLeaf(NULL) {}\nvoid trie_t::add(const char *c) {\nroot.add(c);\n+ defrost();\n}\nvoid trie_t::add(const std::string &s) {\nroot.add(s.c_str());\n+ defrost();\n}\nvoid trie_t::freeze() {\n+ if (isFrozen) {\n+ defrost();\n+ }\n+\nnodeCount = root.leafNodes();\nbaseNodeCount = (int) root.leaves.size();\n@@ -60,8 +74,8 @@ namespace occa {\nleafCount[nodeCount] = 0;\nisLeaf[nodeCount] = false;\n-\nfreeze(root, 0);\n+ isFrozen = true;\n}\nint trie_t::freeze(const trieNode_t &node, int offset) {\n@@ -83,7 +97,27 @@ namespace occa {\nreturn leafOffset;\n}\n+ void trie_t::defrost() {\n+ if (isFrozen) {\n+ delete [] chars;\n+ delete [] offsets;\n+ delete [] leafCount;\n+ delete [] isLeaf;\n+\n+ chars = NULL;\n+ offsets = NULL;\n+ leafCount = NULL;\n+ isLeaf = NULL;\n+\n+ isFrozen = false;\n+ }\n+ }\n+\nconst char* trie_t::get(const char *c) const {\n+ if (!isFrozen) {\n+ return trieGet(c);\n+ }\n+ const char *cStart = c;\nconst char *ret = c;\nint offset = 0;\n@@ -93,14 +127,14 @@ namespace occa {\nbool found = false;\nfor (int i = 0; i < count; ++i) {\nif (ci == chars[offset + i]) {\n- count = leafCount[offset + i];\n- offset = offsets[offset + i];\n-\n++c;\nif (isLeaf[offset]) {\nret = c;\n}\n+ count = leafCount[offset + i];\n+ offset = offsets[offset + i];\n+\nfound = true;\nbreak;\n}\n@@ -109,10 +143,19 @@ namespace occa {\nbreak;\n}\n}\n- return ret;\n+ // Move to the first char not in the trie\n+ return (ret > cStart) ? ret : cStart;\n+ }\n+\n+ const char* trie_t::trieGet(const char *c) const {\n+ const char *found = root.get(c);\n+ return found ? found : c;\n}\nbool trie_t::has(const char c) const {\n+ if (!isFrozen) {\n+ return trieHas(c);\n+ }\nfor (int i = 0; i < baseNodeCount; ++i) {\nif (chars[i] == c) {\nreturn true;\n@@ -121,12 +164,41 @@ namespace occa {\nreturn false;\n}\n+ bool trie_t::trieHas(const char c) const {\n+ const trieNodeMap_t &leaves = root.leaves;\n+ cTrieNodeMapIterator it = leaves.begin();\n+ while (it != leaves.end()) {\n+ if (c == it->first) {\n+ return true;\n+ }\n+ ++it;\n+ }\n+ return false;\n+ }\n+\nbool trie_t::has(const char *c) const {\nconst char *cEnd = get(c);\n- return ((size_t) (cEnd - c + 1) == strlen(c));\n+ return ((size_t) (cEnd - c) == strlen(c));\n+ }\n+\n+ bool trie_t::has(const char *c, const int size) const {\n+ OCCA_ERROR(\"Cannot search for a char* with size: \" << size,\n+ 0 < size);\n+\n+ char *c2 = new char[size + 1];\n+ c2[size] = '\\0';\n+ ::memcpy(c2, c, size);\n+\n+ const bool has_ = has(c2);\n+ delete [] c2;\n+ return has_;\n}\n- void trie_t::print() const {\n+ void trie_t::print() {\n+ const bool wasFrozen = isFrozen;\n+ if (!isFrozen) {\n+ freeze();\n+ }\nconst std::string headers[] = {\n\"index : \",\n\"chars : \",\n@@ -136,7 +208,8 @@ namespace occa {\n};\nstd::cout << headers[0];\nfor (int i = 0; i < nodeCount; ++i) {\n- std::cout << i << ' ' << std::string(2 - (i < 10 ? 0 : 1), ' ');\n+ std::string spaces(i < 10 ? 2 : ((i < 100) ? 1 : 0), ' ');\n+ std::cout << i << ' ' << spaces;\n}\nstd::cout << '\\n' << headers[1];\nfor (int i = 0; i < nodeCount; ++i) {\n@@ -144,16 +217,21 @@ namespace occa {\n}\nstd::cout << '\\n' << headers[2];\nfor (int i = 0; i < nodeCount; ++i) {\n- std::cout << offsets[i] << ' ' << std::string(2 - (offsets[i] < 10 ? 0 : 1), ' ');\n+ const int offset = offsets[i];\n+ std::string spaces(offset < 10 ? 2 : ((offset < 100) ? 1 : 0), ' ');\n+ std::cout << offsets[i] << ' ' << spaces;\n}\nstd::cout << '\\n' << headers[3];\nfor (int i = 0; i < nodeCount; ++i) {\n- std::cout << leafCount[i] << ' ' << std::string(2 - (leafCount[i] < 10 ? 0 : 1), ' ');\n+ const int lcount = leafCount[i];\n+ std::string spaces(lcount < 10 ? 2 : ((lcount < 100) ? 1 : 0), ' ');\n+ std::cout << leafCount[i] << ' ' << spaces;\n}\nstd::cout << '\\n' << headers[4];\nfor (int i = 0; i < nodeCount; ++i) {\nstd::cout << isLeaf[i] << \" \";\n}\nstd::cout << '\\n';\n+ isFrozen = wasFrozen;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testTrie.cpp", "new_path": "parser_sandbox/tests/testTrie.cpp", "diff": "void testInsert(occa::trie_t &trie);\nvoid testSearch(occa::trie_t &trie);\n+void testFrozenSearch(occa::trie_t &trie);\n+void testRefreeze(occa::trie_t &trie);\nint main(const int argc, const char **argv) {\nocca::trie_t trie;\ntestInsert(trie);\ntestSearch(trie);\n+ testFrozenSearch(trie);\n+ testRefreeze(trie);\n}\nvoid testInsert(occa::trie_t &trie) {\ntrie.add(\"blue\");\n+ trie.add(\"blueblue\");\ntrie.add(\"boring\");\ntrie.add(\"glue\");\ntrie.add(\"good\");\n}\nvoid testSearch(occa::trie_t &trie) {\n+ occa::testing::compare(trie.has(\"blue\") , true);\n+ occa::testing::compare(trie.has(\"boring\") , true);\n+ occa::testing::compare(trie.has(\"glue\") , true);\n+ occa::testing::compare(trie.has(\"good\") , true);\n+\n+ occa::testing::compare(trie.has(\"red\") , false);\n+ occa::testing::compare(trie.has(\"goo\") , false);\n+ occa::testing::compare(trie.has(\"goods\") , false);\n+}\n+\n+void testFrozenSearch(occa::trie_t &trie) {\ntrie.freeze();\nocca::testing::compare(trie.has(\"blue\") , true);\nocca::testing::compare(trie.has(\"boring\") , true);\n@@ -31,3 +47,16 @@ void testSearch(occa::trie_t &trie) {\nocca::testing::compare(trie.has(\"goo\") , false);\nocca::testing::compare(trie.has(\"goods\") , false);\n}\n+\n+void testRefreeze(occa::trie_t &trie) {\n+ occa::testing::compare(trie.isFrozen, true);\n+ occa::testing::compare(trie.has(\"red\"), false);\n+\n+ trie.add(\"red\");\n+ occa::testing::compare(trie.isFrozen, false);\n+ occa::testing::compare(trie.has(\"red\"), true);\n+\n+ trie.freeze();\n+ occa::testing::compare(trie.isFrozen, true);\n+ occa::testing::compare(trie.has(\"red\"), true);\n+}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "@@ -712,7 +712,7 @@ namespace occa {\nconst std::string &message) {\nstd::string header = \"---[ \" + title + \" ]\";\n- header += std::string('-', 60 - header.size());\n+ header += std::string(60 - header.size(), '-');\nstd::cout << '\\n'\n<< header << '\\n'\n@@ -722,7 +722,7 @@ namespace occa {\nif (message.size()) {\nstd::cout << \" Message : \" << message << '\\n';\n}\n- std::cout << std::string('=', 60) << '\\n';\n+ std::cout << std::string(60, '=') << '\\n';\nif (exitInFailure) {\nthrow 1;\n" } ]
C++
MIT License
libocca/occa
[Refactor] Added unfrozen checks to trie
378,349
30.12.2016 12:56:10
21,600
ab08ea43ca493a467c5169a0191756856582bce1
[Refactor] Added stack trace to error output
[ { "change_type": "ADD", "old_path": null, "new_path": "include/occa/tools/lex.hpp", "diff": "+/* The MIT License (MIT)\n+ *\n+ * Copyright (c) 2014-2016 David Medina and Tim Warburton\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in all\n+ * copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+ */\n+\n+#ifndef OCCA_TOOLS_LEX_HEADER\n+#define OCCA_TOOLS_LEX_HEADER\n+\n+#include <iostream>\n+#include <iomanip>\n+#include <sstream>\n+\n+#include \"occa/defines.hpp\"\n+#include \"occa/types.hpp\"\n+\n+namespace occa {\n+ namespace lex {\n+ extern const char whitespaceChars[];\n+\n+ void skipTo(const char *&c, const char delimiter);\n+ void skipTo(const char *&c, const char delimiter, const char escapeChar);\n+\n+ void skipTo(const char *&c, const std::string &match);\n+ void skipTo(const char *&c, const std::string &match, const char escapeChar);\n+\n+ void skipToDelimiter(const char *&c, const std::string &delimiters);\n+ void skipToDelimiter(const char *&c, const std::string &delimiters, const char escapeChar);\n+\n+ bool charIsIn(const char c, const char *delimiters);\n+\n+ bool isWhitespace(const char c);\n+ void skipWhitespace(const char *&c);\n+ void skipToWhitespace(const char *&c);\n+ void skipBetweenWhitespaces(const char *&c);\n+ }\n+}\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/sys.hpp", "new_path": "include/occa/tools/sys.hpp", "diff": "@@ -122,6 +122,9 @@ namespace occa {\nconst int *occaKernelInfoArgs,\nint occaInnerId0, int occaInnerId1, int occaInnerId2,\nint argc, void **args);\n+\n+ void printStacktrace(const int stackStart = 0, const std::string indent = \"\");\n+ std::string prettyStackSymbol(const char *c);\n//==================================\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/Makefile", "new_path": "parser_sandbox/Makefile", "diff": "@@ -14,6 +14,7 @@ objects = $(subst $(srcPath)/,$(objPath)/,$(sources:.cpp=.o))\ntests = $(subst $(testPath)/,$(testPath)/bin/,$(testSources:.cpp=))\nflags += -I$(incPath)\n+compilerFlags += -rdynamic\nexecutables = ${PROJ_DIR}/main\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/basicParser.hpp", "new_path": "parser_sandbox/include/basicParser.hpp", "diff": "#include <iostream>\n#include \"occa/types.hpp\"\n-#include \"tools.hpp\"\n+#include \"occa/tools/lex.hpp\"\n# if 0\nnamespace occa {\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/preprocessor.hpp", "new_path": "parser_sandbox/include/preprocessor.hpp", "diff": "#include \"occa/defines.hpp\"\n#include \"occa/types.hpp\"\n#include \"occa/tools/hash.hpp\"\n+#include \"occa/tools/lex.hpp\"\n-#include \"tools.hpp\"\n#include \"macro.hpp\"\n# if 0\n" }, { "change_type": "DELETE", "old_path": "parser_sandbox/include/tools.hpp", "new_path": null, "diff": "-#ifndef OCCA_PARSER_TOOLS_HEADER2\n-#define OCCA_PARSER_TOOLS_HEADER2\n-\n-#include <iostream>\n-\n-namespace occa {\n- void skipTo(const char *&c, const char delimiter);\n- void skipTo(const char *&c, const char delimiter, const char escapeChar);\n-\n- void skipTo(const char *&c, const std::string &match);\n- void skipTo(const char *&c, const std::string &match, const char escapeChar);\n-\n- void skipToDelimiter(const char *&c, const std::string &delimiters);\n- void skipToDelimiter(const char *&c, const std::string &delimiters, const char escapeChar);\n-}\n-#endif\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/notes.org", "new_path": "parser_sandbox/notes.org", "diff": "@@ -123,3 +123,12 @@ statement\nnew variables\ngetNamespace()\n+* Misc\n+\n+0 libocca.so 0x000000010de01550 _ZN4occa3sys15printStacktraceEv + 32\n+1 libocca.so 0x000000010de01e07 _ZN4occa8_messageERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEbS8_S8_iS8_ + 2103\n+2 libocca.so 0x000000010ddf4ac9 _ZN4occa5errorERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_iS8_ + 185\n+3 testTrie 0x000000010db92996 _ZN4occa7testing7compareIbEEvRKT_S4_ + 1942\n+4 testTrie 0x000000010db91ee2 _Z10testSearchRN4occa6trie_tE + 50\n+5 testTrie 0x000000010db91dd9 main + 57\n+6 libdyld.dylib 0x00007fffb0357255 start + 1\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "parser_sandbox/src/tools.cpp", "new_path": null, "diff": "-#include \"tools.hpp\"\n-\n-namespace occa {\n- void skipTo(const char *&c, const char delimiter) {\n- while (*c != '\\0') {\n- if(*c == delimiter) {\n- return;\n- }\n- ++c;\n- }\n- }\n-\n- void skipTo(const char *&c, const char delimiter, const char escapeChar) {\n- while (*c != '\\0') {\n- if (*c == escapeChar) {\n- c += 2;\n- continue;\n- }\n- if(*c == delimiter) {\n- return;\n- }\n- ++c;\n- }\n- }\n-\n- void skipTo(const char *&c, const std::string &match) {\n- const size_t chars = match.size();\n- const char *d = match.c_str();\n-\n- while (*c != '\\0') {\n- for (size_t i = 0; i < chars; ++i) {\n- if (c[i] != d[i]) {\n- continue;\n- }\n- return;\n- }\n- ++c;\n- }\n- }\n-\n- void skipTo(const char *&c, const std::string &match, const char escapeChar) {\n- const size_t chars = match.size();\n- const char *d = match.c_str();\n-\n- while (*c != '\\0') {\n- if (*c == escapeChar) {\n- c += 2;\n- continue;\n- }\n- for (size_t i = 0; i < chars; ++i) {\n- if (c[i] != d[i]) {\n- continue;\n- }\n- return;\n- }\n- ++c;\n- }\n- }\n-\n- void skipToDelimiter(const char *&c, const std::string &delimiters) {\n- const size_t chars = delimiters.size();\n- const char *d = delimiters.c_str();\n-\n- while (*c != '\\0') {\n- for (size_t i = 0; i < chars; ++i) {\n- if (*c == d[i]) {\n- return;\n- }\n- }\n- ++c;\n- }\n- }\n-\n- void skipToDelimiter(const char *&c, const std::string &delimiters, const char escapeChar) {\n- const size_t chars = delimiters.size();\n- const char *d = delimiters.c_str();\n-\n- while (*c != '\\0') {\n- if (*c == escapeChar) {\n- c += 2;\n- continue;\n- }\n- for (size_t i = 0; i < chars; ++i) {\n- if (*c == d[i]) {\n- return;\n- }\n- }\n- ++c;\n- }\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testTrie.cpp", "new_path": "parser_sandbox/tests/testTrie.cpp", "diff": "@@ -26,7 +26,7 @@ void testInsert(occa::trie_t &trie) {\n}\nvoid testSearch(occa::trie_t &trie) {\n- occa::testing::compare(trie.has(\"blue\") , true);\n+ occa::testing::compare(trie.has(\"blue\") , false);\nocca::testing::compare(trie.has(\"boring\") , true);\nocca::testing::compare(trie.has(\"glue\") , true);\nocca::testing::compare(trie.has(\"good\") , true);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/tools/lex.cpp", "diff": "+/* The MIT License (MIT)\n+ *\n+ * Copyright (c) 2014-2016 David Medina and Tim Warburton\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in all\n+ * copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+ */\n+\n+#include \"occa/tools/lex.hpp\"\n+\n+namespace occa {\n+ namespace lex {\n+ const char whitespaceChars[] = \" \\t\\r\\n\\v\\f\\0\";\n+\n+ void skipTo(const char *&c, const char delimiter) {\n+ while (*c != '\\0') {\n+ if(*c == delimiter) {\n+ return;\n+ }\n+ ++c;\n+ }\n+ }\n+\n+ void skipTo(const char *&c, const char delimiter, const char escapeChar) {\n+ while (*c != '\\0') {\n+ if (*c == escapeChar) {\n+ c += 2;\n+ continue;\n+ }\n+ if(*c == delimiter) {\n+ return;\n+ }\n+ ++c;\n+ }\n+ }\n+\n+ void skipTo(const char *&c, const std::string &match) {\n+ const size_t chars = match.size();\n+ const char *d = match.c_str();\n+\n+ while (*c != '\\0') {\n+ for (size_t i = 0; i < chars; ++i) {\n+ if (c[i] != d[i]) {\n+ continue;\n+ }\n+ return;\n+ }\n+ ++c;\n+ }\n+ }\n+\n+ void skipTo(const char *&c, const std::string &match, const char escapeChar) {\n+ const size_t chars = match.size();\n+ const char *d = match.c_str();\n+\n+ while (*c != '\\0') {\n+ if (*c == escapeChar) {\n+ c += 2;\n+ continue;\n+ }\n+ for (size_t i = 0; i < chars; ++i) {\n+ if (c[i] != d[i]) {\n+ continue;\n+ }\n+ return;\n+ }\n+ ++c;\n+ }\n+ }\n+\n+ void skipToDelimiter(const char *&c, const std::string &delimiters) {\n+ const size_t chars = delimiters.size();\n+ const char *d = delimiters.c_str();\n+\n+ while (*c != '\\0') {\n+ for (size_t i = 0; i < chars; ++i) {\n+ if (*c == d[i]) {\n+ return;\n+ }\n+ }\n+ ++c;\n+ }\n+ }\n+\n+ void skipToDelimiter(const char *&c, const std::string &delimiters, const char escapeChar) {\n+ const size_t chars = delimiters.size();\n+ const char *d = delimiters.c_str();\n+\n+ while (*c != '\\0') {\n+ if (*c == escapeChar) {\n+ c += 2;\n+ continue;\n+ }\n+ for (size_t i = 0; i < chars; ++i) {\n+ if (*c == d[i]) {\n+ return;\n+ }\n+ }\n+ ++c;\n+ }\n+ }\n+\n+ bool charIsIn(const char c, const char *delimiters) {\n+ while (*delimiters != '\\0') {\n+ if (c == *(delimiters++)) {\n+ return true;\n+ }\n+ }\n+ return false;\n+ }\n+\n+ bool isWhitespace(const char c) {\n+ return charIsIn(c, whitespaceChars);\n+ }\n+\n+ void skipWhitespace(const char *&c) {\n+ while (charIsIn(*c, whitespaceChars) &&\n+ (*c != '\\0')) {\n+ ++c;\n+ }\n+ }\n+\n+ void skipToWhitespace(const char *&c) {\n+ while (!charIsIn(*c, whitespaceChars) &&\n+ (*c != '\\0')) {\n+ ++c;\n+ }\n+ }\n+\n+ void skipBetweenWhitespaces(const char *&c) {\n+ skipWhitespace(c);\n+ skipToWhitespace(c);\n+ skipWhitespace(c);\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "#include \"occa/defines.hpp\"\n#if (OCCA_OS & OCCA_LINUX_OS)\n-# include <unistd.h>\n+# include <cxxabi.h>\n+# include <dlfcn.h>\n+# include <errno.h>\n+# include <execinfo.h>\n# include <sys/time.h>\n# include <sys/sysctl.h>\n# include <sys/sysinfo.h>\n-# include <dlfcn.h>\n-# include <errno.h>\n+# include <unistd.h>\n#elif (OCCA_OS & OCCA_OSX_OS)\n+# include <cxxabi.h>\n+# include <dlfcn.h>\n+# include <execinfo.h>\n# include <mach/mach_host.h>\n# include <sys/sysctl.h>\n-# include <dlfcn.h>\n# ifdef __clang__\n# include <CoreServices/CoreServices.h>\n# include <mach/mach_time.h>\n# include <windows.h>\n#endif\n+#include <iomanip>\n+#include <sstream>\n+\n#include <sys/types.h>\n#include <fcntl.h>\n#include \"occa/tools/env.hpp\"\n#include \"occa/tools/hash.hpp\"\n#include \"occa/tools/io.hpp\"\n+#include \"occa/tools/lex.hpp\"\n#include \"occa/tools/misc.hpp\"\n#include \"occa/tools/string.hpp\"\n#include \"occa/tools/sys.hpp\"\n@@ -702,6 +710,59 @@ namespace occa {\n#include \"operators/runFunctionFromArguments.cpp\"\n}\n+\n+ void printStacktrace(const int stackStart, const std::string indent) {\n+#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_OSX_OS))\n+ static const int maxStackSize = 1024;\n+ static void *stack[maxStackSize];\n+ char **stackSymbols;\n+ int stackSize = 0;\n+\n+ stackSize = ::backtrace(stack, maxStackSize);\n+ stackSymbols = ::backtrace_symbols(stack, stackSize);\n+ for (int i = stackStart; i < stackSize; ++i) {\n+ std::cout << indent << prettyStackSymbol(stackSymbols[i]) << '\\n';\n+ }\n+ ::free(stackSymbols);\n+#endif\n+ }\n+\n+ std::string prettyStackSymbol(const char *c) {\n+#if (OCCA_OS == OCCA_OSX_OS)\n+ static size_t maxChars = 1024;\n+ static char prettyBuffer[1024];\n+ std::stringstream ss;\n+ // Skip stack depth\n+ lex::skipBetweenWhitespaces(c);\n+ // Get origin\n+ const char *originStart = c;\n+ lex::skipToWhitespace(c);\n+ std::string origin(originStart, (c - originStart));\n+ // Skip address\n+ lex::skipBetweenWhitespaces(c);\n+ // Get function name\n+ const char *functionStart = c;\n+ lex::skipToWhitespace(c);\n+ std::string function(functionStart, (c - functionStart));\n+ // Skip the +\n+ lex::skipBetweenWhitespaces(c);\n+ // Get address offset\n+ const char *offsetStart = c;\n+ lex::skipToWhitespace(c);\n+ std::string offset(offsetStart, (c - offsetStart));\n+\n+ int status;\n+ const char *prettyFunction = abi::__cxa_demangle(function.c_str(),\n+ prettyBuffer,\n+ &maxChars,\n+ &status);\n+\n+ ss << std::left << std::setw(20) << origin\n+ << std::left << std::setw(50) << (status ? function : prettyFunction);\n+ return ss.str();\n+#elif (OCCA_OS == OCCA_LINUX_OS)\n+#endif\n+ }\n}\nvoid _message(const std::string &title,\n@@ -722,6 +783,8 @@ namespace occa {\nif (message.size()) {\nstd::cout << \" Message : \" << message << '\\n';\n}\n+ std::cout << \" Stack :\\n\";\n+ sys::printStacktrace(3, \" \");\nstd::cout << std::string(60, '=') << '\\n';\nif (exitInFailure) {\n" } ]
C++
MIT License
libocca/occa
[Refactor] Added stack trace to error output
378,349
30.12.2016 14:20:51
21,600
1844f8c04dbaa03740a08babe39831a134f4ecd6
[Refactor] Added linux stacktrace
[ { "change_type": "MODIFY", "old_path": "include/occa/tools/sys.hpp", "new_path": "include/occa/tools/sys.hpp", "diff": "@@ -123,8 +123,8 @@ namespace occa {\nint occaInnerId0, int occaInnerId1, int occaInnerId2,\nint argc, void **args);\n- void printStacktrace(const int stackStart = 0, const std::string indent = \"\");\n- std::string prettyStackSymbol(const char *c);\n+ void printStacktrace(const int frameStart = 0, const std::string indent = \"\");\n+ std::string prettyStackSymbol(void *frame, const char *symbol);\n//==================================\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/primitive.hpp", "new_path": "parser_sandbox/include/primitive.hpp", "diff": "#include <iostream>\n#include <sstream>\n#include <iomanip>\n-#include <cstdint>\n-#include <cstdlib>\n+\n+#include <stdint.h>\n+#include <stdlib.h>\n#include \"occa/defines.hpp\"\n#include \"occa/tools/string.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/primitive.cpp", "new_path": "parser_sandbox/src/primitive.cpp", "diff": "+#include <cstring>\n+\n#include \"primitive.hpp\"\nnamespace occa {\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "@@ -74,12 +74,10 @@ namespace occa {\nnamespace sys {\ndouble currentTime() {\n#if (OCCA_OS & OCCA_LINUX_OS)\n-\ntimespec ct;\nclock_gettime(CLOCK_MONOTONIC, &ct);\nreturn (double) (ct.tv_sec + (1.0e-9 * ct.tv_nsec));\n-\n#elif (OCCA_OS == OCCA_OSX_OS)\n# ifdef __clang__\nuint64_t ct;\n@@ -711,27 +709,29 @@ namespace occa {\n#include \"operators/runFunctionFromArguments.cpp\"\n}\n- void printStacktrace(const int stackStart, const std::string indent) {\n+ void printStacktrace(const int frameStart, const std::string indent) {\n#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_OSX_OS))\n- static const int maxStackSize = 1024;\n- static void *stack[maxStackSize];\n- char **stackSymbols;\n- int stackSize = 0;\n+ static const int maxFrames = 1024;\n+ static void *frames[maxFrames];\n+ char **symbols;\n+ int frameCount = 0;\n- stackSize = ::backtrace(stack, maxStackSize);\n- stackSymbols = ::backtrace_symbols(stack, stackSize);\n- for (int i = stackStart; i < stackSize; ++i) {\n- std::cout << indent << prettyStackSymbol(stackSymbols[i]) << '\\n';\n+ frameCount = ::backtrace(frames, maxFrames);\n+ symbols = ::backtrace_symbols(frames, frameCount);\n+ for (int i = frameStart; i < frameCount; ++i) {\n+ std::cout << indent << prettyStackSymbol(frames[i], symbols[i]) << '\\n';\n}\n- ::free(stackSymbols);\n+ ::free(symbols);\n#endif\n}\n- std::string prettyStackSymbol(const char *c) {\n-#if (OCCA_OS == OCCA_OSX_OS)\n+ std::string prettyStackSymbol(void *frame, const char *symbol) {\nstatic size_t maxChars = 1024;\nstatic char prettyBuffer[1024];\nstd::stringstream ss;\n+\n+#if (OCCA_OS == OCCA_OSX_OS)\n+ const char *c = symbol;\n// Skip stack depth\nlex::skipBetweenWhitespaces(c);\n// Get origin\n@@ -761,6 +761,32 @@ namespace occa {\n<< std::left << std::setw(50) << (status ? function : prettyFunction);\nreturn ss.str();\n#elif (OCCA_OS == OCCA_LINUX_OS)\n+ std::string function;\n+\n+ Dl_info frameInfo;\n+ int status = dladdr(frame, &frameInfo);\n+ const char *dl_name = frameInfo.dli_sname;\n+\n+ if (status && dl_name) {\n+ const char *prettyFunction = abi::__cxa_demangle(dl_name,\n+ prettyBuffer,\n+ &maxChars,\n+ &status);\n+ if (!status) {\n+ function = std::string(prettyFunction);\n+ }\n+ }\n+ if (function.size() == 0) {\n+ const char *c = symbol;\n+ // Get function name\n+ lex::skipWhitespace(c);\n+ const char *functionStart = c;\n+ lex::skipToWhitespace(c);\n+ function = std::string(functionStart, (c - functionStart));\n+ }\n+ return function;\n+#else\n+ return std::string(c);\n#endif\n}\n}\n" } ]
C++
MIT License
libocca/occa
[Refactor] Added linux stacktrace
378,349
31.12.2016 00:19:33
21,600
bddf66053137164ebbadd5ca60cbcbcdd152be64
[Trie] Trie now holds values
[ { "change_type": "MODIFY", "old_path": "include/occa/tools/testing.hpp", "new_path": "include/occa/tools/testing.hpp", "diff": "namespace occa {\nnamespace testing {\n- template <class TM>\n- void compare(const TM &a, const TM &b) {\n+ template <class TM1, class TM2>\n+ void compare(const TM1 &a, const TM2 &b) {\nOCCA_ERROR(\"Comparing Failed\",\na == b);\n}\ntemplate <>\n- void compare<float>(const float &a, const float &b);\n+ void compare<float, float>(const float &a, const float &b);\ntemplate <>\n- void compare<double>(const double &a, const double &b);\n+ void compare<double, float>(const double &a, const float &b);\n+\n+ template <>\n+ void compare<float, double>(const float &a, const double &b);\n+\n+ template <>\n+ void compare<double, double>(const double &a, const double &b);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/Makefile", "new_path": "parser_sandbox/Makefile", "diff": "@@ -14,7 +14,6 @@ objects = $(subst $(srcPath)/,$(objPath)/,$(sources:.cpp=.o))\ntests = $(subst $(testPath)/,$(testPath)/bin/,$(testSources:.cpp=))\nflags += -I$(incPath)\n-compilerFlags += -rdynamic\nexecutables = ${PROJ_DIR}/main\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.hpp", "new_path": "parser_sandbox/include/trie.hpp", "diff": "#define OCCA_TRIE_HEADER2\n#include <iostream>\n+#include <vector>\n#include <map>\nnamespace occa {\n@@ -10,40 +11,71 @@ namespace occa {\ntypedef trieNodeMap_t::iterator trieNodeMapIterator;\ntypedef trieNodeMap_t::const_iterator cTrieNodeMapIterator;\n+ //---[ Node ]-------------------------\nclass trieNode_t {\npublic:\n- bool isLeaf;\n+ class result_t {\n+ public:\n+ int length;\n+ int valueIdx;\n+\n+ result_t();\n+ result_t(const int length_, const int valueIdx);\n+ };\n+\n+ int valueIdx;\ntrieNodeMap_t leaves;\ntrieNode_t();\n+ trieNode_t(const int valueIdx_);\n- void add(const char *c);\n+ void add(const char *c, const int valueIdx_);\n- int leafNodes() const;\n- const char* get(const char *c) const;\n+ int nodeCount() const;\n+ int getValueIdx(const char *c) const;\n+ result_t get(const char *c) const;\n+ result_t get(const char *c, const int length) const;\n};\n+ //====================================\n+ //---[ Trie ]-------------------------\n+ template <class TM>\nclass trie_t {\npublic:\n+ //---[ Result ]---------------------\n+ class result_t {\n+ public:\n+ int length;\n+ TM value;\n+\n+ result_t();\n+ result_t(const int length_, const TM &value_ = TM());\n+ operator bool();\n+ };\n+ //==================================\n+\ntrieNode_t root;\n+ std::vector<TM> values;\nbool isFrozen;\nint nodeCount, baseNodeCount;\nchar *chars;\nint *offsets, *leafCount;\n- bool *isLeaf;\n+ int *valueIndices;\ntrie_t();\n- void add(const char *c);\n- void add(const std::string &s);\n+ void add(const char *c, const TM &value = TM());\n+ void add(const std::string &s, const TM &value = TM());\nvoid freeze();\nint freeze(const trieNode_t &node, int offset);\nvoid defrost();\n- const char* get(const char *c) const;\n- const char* trieGet(const char *c) const;\n+ result_t getFirst(const char *c) const;\n+ result_t trieGetFirst(const char *c) const;\n+\n+ result_t get(const char *c) const;\nbool has(const char c) const;\nbool trieHas(const char c) const;\n@@ -53,5 +85,9 @@ namespace occa {\nvoid print();\n};\n+ //====================================\n}\n+\n+#include \"trie.tpp\"\n+\n#endif\n" }, { "change_type": "ADD", "old_path": null, "new_path": "parser_sandbox/include/trie.tpp", "diff": "+#include <cstring>\n+\n+#include <alloca.h>\n+\n+#include \"occa/defines.hpp\"\n+#include \"occa/tools/sys.hpp\"\n+\n+namespace occa {\n+ //---[ Trie ]-------------------------\n+ // ---[ Result ]---------------------\n+ template <class TM>\n+ trie_t<TM>::result_t::result_t() {}\n+\n+ template <class TM>\n+ trie_t<TM>::result_t::result_t(const int length_, const TM &value_) :\n+ length(length_),\n+ value(value_) {}\n+\n+ template <class TM>\n+ trie_t<TM>::result_t::operator bool() {\n+ return (length != 0);\n+ }\n+ // ==================================\n+\n+ template <class TM>\n+ trie_t<TM>::trie_t() :\n+ isFrozen(false),\n+ nodeCount(0),\n+ baseNodeCount(0),\n+ chars(NULL),\n+ offsets(NULL),\n+ leafCount(NULL),\n+ valueIndices(NULL) {}\n+\n+ template <class TM>\n+ void trie_t<TM>::add(const char *c, const TM &value) {\n+ defrost();\n+ int valueIdx = root.getValueIdx(c);\n+ if (valueIdx < 0) {\n+ valueIdx = values.size();\n+ values.push_back(value);\n+ } else {\n+ values[valueIdx] = value;\n+ }\n+ root.add(c, valueIdx);\n+ }\n+\n+ template <class TM>\n+ void trie_t<TM>::add(const std::string &s, const TM &value) {\n+ defrost();\n+ root.add(s.c_str(), value);\n+ }\n+\n+ template <class TM>\n+ void trie_t<TM>::freeze() {\n+ defrost();\n+\n+ nodeCount = root.nodeCount();\n+ baseNodeCount = (int) root.leaves.size();\n+\n+ chars = new char[nodeCount + 1];\n+ offsets = new int[nodeCount + 1];\n+ leafCount = new int[nodeCount + 1];\n+ valueIndices = new int[nodeCount + 1];\n+\n+ chars[nodeCount] = '\\0';\n+ offsets[nodeCount] = nodeCount;\n+ leafCount[nodeCount] = 0;\n+ valueIndices[nodeCount] = -1;\n+\n+ freeze(root, 0);\n+ isFrozen = true;\n+ }\n+\n+ template <class TM>\n+ int trie_t<TM>::freeze(const trieNode_t &node, int offset) {\n+ const trieNodeMap_t &leaves = node.leaves;\n+ cTrieNodeMapIterator leaf = leaves.begin();\n+ int leafOffset = offset + (int) leaves.size();\n+\n+ while (leaf != leaves.end()) {\n+ const trieNode_t &leafNode = leaf->second;\n+ chars[offset] = leaf->first;\n+ offsets[offset] = leafOffset;\n+ leafCount[offset] = (int) leafNode.leaves.size();\n+ valueIndices[offset] = leafNode.valueIdx;\n+\n+ leafOffset = freeze(leafNode, leafOffset);\n+ ++offset;\n+ ++leaf;\n+ }\n+ return leafOffset;\n+ }\n+\n+ template <class TM>\n+ void trie_t<TM>::defrost() {\n+ if (isFrozen) {\n+ delete [] chars;\n+ delete [] offsets;\n+ delete [] leafCount;\n+ delete [] valueIndices;\n+\n+ chars = NULL;\n+ offsets = NULL;\n+ leafCount = NULL;\n+ valueIndices = NULL;\n+\n+ isFrozen = false;\n+ }\n+ }\n+\n+ template <class TM>\n+ typename trie_t<TM>::result_t trie_t<TM>::getFirst(const char *c) const {\n+ if (!isFrozen) {\n+ return trieGetFirst(c);\n+ }\n+ const char *cStart = c;\n+ int retLength = 0;\n+ int retValueIdx = -1;\n+\n+ int offset = 0;\n+ int count = baseNodeCount;\n+ while (count) {\n+ const char ci = *c;\n+ bool found = false;\n+ for (int i = 0; i < count; ++i) {\n+ if (ci == chars[offset + i]) {\n+ ++c;\n+ if (0 <= valueIndices[offset]) {\n+ retLength = (c - cStart);\n+ retValueIdx = valueIndices[offset];\n+ }\n+\n+ count = leafCount[offset + i];\n+ offset = offsets[offset + i];\n+\n+ found = true;\n+ break;\n+ }\n+ }\n+ if (!found) {\n+ break;\n+ }\n+ }\n+\n+ if (retLength) {\n+ return result_t(retLength, values[retValueIdx]);\n+ }\n+ return result_t(0);\n+ }\n+\n+ template <class TM>\n+ typename trie_t<TM>::result_t trie_t<TM>::trieGetFirst(const char *c) const {\n+ trieNode_t::result_t result = root.get(c);\n+\n+ if (0 <= result.valueIdx) {\n+ return result_t(result.length, values[result.valueIdx]);\n+ }\n+ return result_t(0);\n+ }\n+\n+ template <class TM>\n+ typename trie_t<TM>::result_t trie_t<TM>::get(const char *c) const {\n+ trie_t<TM>::result_t result = getFirst(c);\n+ if (strlen(c) != (size_t) result.length) {\n+ result.length = 0;\n+ result.value = TM();\n+ }\n+ return result;\n+ }\n+\n+ template <class TM>\n+ bool trie_t<TM>::has(const char c) const {\n+ if (!isFrozen) {\n+ return trieHas(c);\n+ }\n+ for (int i = 0; i < baseNodeCount; ++i) {\n+ if (chars[i] == c) {\n+ return true;\n+ }\n+ }\n+ return false;\n+ }\n+\n+ template <class TM>\n+ bool trie_t<TM>::trieHas(const char c) const {\n+ const trieNodeMap_t &leaves = root.leaves;\n+ cTrieNodeMapIterator it = leaves.begin();\n+ while (it != leaves.end()) {\n+ if (c == it->first) {\n+ return true;\n+ }\n+ ++it;\n+ }\n+ return false;\n+ }\n+\n+ template <class TM>\n+ bool trie_t<TM>::has(const char *c) const {\n+ result_t result = get(c);\n+ return ((size_t) result.length == strlen(c));\n+ }\n+\n+ template <class TM>\n+ bool trie_t<TM>::has(const char *c, const int size) const {\n+ OCCA_ERROR(\"Cannot search for a char* with size: \" << size,\n+ 0 < size);\n+\n+ const bool usedAlloca = (size < 1024);\n+ char *c2 = usedAlloca ? ((char*) alloca(size + 1)) : (new char [size + 1]);\n+ c2[size] = '\\0';\n+ ::memcpy(c2, c, size);\n+\n+ const bool has_ = has(c2);\n+ if (!usedAlloca) {\n+ delete [] c2;\n+ }\n+ return has_;\n+ }\n+\n+ template <class TM>\n+ void trie_t<TM>::print() {\n+ const bool wasFrozen = isFrozen;\n+ if (!isFrozen) {\n+ freeze();\n+ }\n+ const std::string headers[] = {\n+ \"index : \",\n+ \"chars : \",\n+ \"offsets : \",\n+ \"leafCount: \",\n+ \"valueIdx : \"\n+ };\n+ std::cout << headers[0];\n+ for (int i = 0; i < nodeCount; ++i) {\n+ std::string spaces(i < 10 ? 2 : ((i < 100) ? 1 : 0), ' ');\n+ std::cout << i << ' ' << spaces;\n+ }\n+ std::cout << '\\n' << headers[1];\n+ for (int i = 0; i < nodeCount; ++i) {\n+ std::cout << chars[i] << \" \";\n+ }\n+ std::cout << '\\n' << headers[2];\n+ for (int i = 0; i < nodeCount; ++i) {\n+ const int offset = offsets[i];\n+ std::string spaces(offset < 10 ? 2 : ((offset < 100) ? 1 : 0), ' ');\n+ std::cout << offsets[i] << ' ' << spaces;\n+ }\n+ std::cout << '\\n' << headers[3];\n+ for (int i = 0; i < nodeCount; ++i) {\n+ const int lcount = leafCount[i];\n+ std::string spaces(lcount < 10 ? 2 : ((lcount < 100) ? 1 : 0), ' ');\n+ std::cout << leafCount[i] << ' ' << spaces;\n+ }\n+ std::cout << '\\n' << headers[4];\n+ for (int i = 0; i < nodeCount; ++i) {\n+ const int valueIdx = valueIndices[i];\n+ std::string spaces(valueIdx < 10 ? 2 : ((valueIdx < 100) ? 1 : 0), ' ');\n+ if (valueIdx < 0) {\n+ spaces = spaces.substr(1);\n+ }\n+ std::cout << valueIdx << ' ' << spaces;\n+ }\n+ std::cout << '\\n';\n+ isFrozen = wasFrozen;\n+ }\n+ //====================================\n+}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/trie.cpp", "new_path": "parser_sandbox/src/trie.cpp", "diff": "-#include <cstring>\n-\n-#include \"occa/defines.hpp\"\n-#include \"occa/tools/sys.hpp\"\n#include \"trie.hpp\"\nnamespace occa {\n+ //---[ Node ]-------------------------\n+ // ---[ Result ]---------------------\n+ trieNode_t::result_t::result_t() {}\n+\n+ trieNode_t::result_t::result_t(const int length_, const int valueIdx_) :\n+ length(length_),\n+ valueIdx(valueIdx_) {}\n+ // ==================================\n+\ntrieNode_t::trieNode_t() :\n- isLeaf(false) {}\n+ valueIdx(-1) {}\n+\n+ trieNode_t::trieNode_t(const int valueIdx_) :\n+ valueIdx(valueIdx_) {}\n- void trieNode_t::add(const char *c) {\n+ void trieNode_t::add(const char *c, const int valueIdx_) {\nif (*c == '\\0') {\n- isLeaf = true;\n+ valueIdx = valueIdx_;\nreturn;\n}\ntrieNode_t &newNode = leaves[*c];\n- newNode.add(c + 1);\n+ newNode.add(c + 1, valueIdx_);\n}\n- int trieNode_t::leafNodes() const {\n+ int trieNode_t::nodeCount() const {\ncTrieNodeMapIterator it = leaves.begin();\nint count = (int) leaves.size();\nwhile (it != leaves.end()) {\n- count += it->second.leafNodes();\n+ count += it->second.nodeCount();\n++it;\n}\nreturn count;\n}\n- const char* trieNode_t::get(const char *c) const {\n- cTrieNodeMapIterator it = leaves.find(*c);\n- if (it != leaves.end()) {\n- const char *ret = it->second.get(c + 1);\n- return ((NULL == ret) && isLeaf) ? (c + 1) : ret;\n- } else {\n- return isLeaf ? c : NULL;\n- }\n- }\n-\n- trie_t::trie_t() :\n- isFrozen(false),\n- nodeCount(0),\n- baseNodeCount(0),\n- chars(NULL),\n- offsets(NULL),\n- leafCount(NULL),\n- isLeaf(NULL) {}\n-\n- void trie_t::add(const char *c) {\n- root.add(c);\n- defrost();\n- }\n-\n- void trie_t::add(const std::string &s) {\n- root.add(s.c_str());\n- defrost();\n- }\n-\n- void trie_t::freeze() {\n- if (isFrozen) {\n- defrost();\n- }\n-\n- nodeCount = root.leafNodes();\n- baseNodeCount = (int) root.leaves.size();\n-\n- chars = new char[nodeCount + 1];\n- offsets = new int[nodeCount + 1];\n- leafCount = new int[nodeCount + 1];\n- isLeaf = new bool[nodeCount + 1];\n-\n- chars[nodeCount] = '\\0';\n- offsets[nodeCount] = nodeCount;\n- leafCount[nodeCount] = 0;\n- isLeaf[nodeCount] = false;\n-\n- freeze(root, 0);\n- isFrozen = true;\n- }\n-\n- int trie_t::freeze(const trieNode_t &node, int offset) {\n- const trieNodeMap_t &leaves = node.leaves;\n- cTrieNodeMapIterator leaf = leaves.begin();\n- int leafOffset = offset + (int) leaves.size();\n-\n- while (leaf != leaves.end()) {\n- const trieNode_t &leafNode = leaf->second;\n- chars[offset] = leaf->first;\n- offsets[offset] = leafOffset;\n- leafCount[offset] = (int) leafNode.leaves.size();\n- isLeaf[offset] = leafNode.isLeaf;\n-\n- leafOffset = freeze(leafNode, leafOffset);\n- ++offset;\n- ++leaf;\n- }\n- return leafOffset;\n- }\n-\n- void trie_t::defrost() {\n- if (isFrozen) {\n- delete [] chars;\n- delete [] offsets;\n- delete [] leafCount;\n- delete [] isLeaf;\n-\n- chars = NULL;\n- offsets = NULL;\n- leafCount = NULL;\n- isLeaf = NULL;\n-\n- isFrozen = false;\n- }\n- }\n-\n- const char* trie_t::get(const char *c) const {\n- if (!isFrozen) {\n- return trieGet(c);\n- }\n- const char *cStart = c;\n- const char *ret = c;\n-\n- int offset = 0;\n- int count = baseNodeCount;\n- while (count) {\n- const char ci = *c;\n- bool found = false;\n- for (int i = 0; i < count; ++i) {\n- if (ci == chars[offset + i]) {\n- ++c;\n- if (isLeaf[offset]) {\n- ret = c;\n- }\n-\n- count = leafCount[offset + i];\n- offset = offsets[offset + i];\n-\n- found = true;\n- break;\n- }\n- }\n- if (!found) {\n- break;\n- }\n- }\n- // Move to the first char not in the trie\n- return (ret > cStart) ? ret : cStart;\n- }\n-\n- const char* trie_t::trieGet(const char *c) const {\n- const char *found = root.get(c);\n- return found ? found : c;\n+ int trieNode_t::getValueIdx(const char *c) const {\n+ result_t result = get(c);\n+ return (strlen(c) == (size_t) result.length) ? result.valueIdx : -1;\n}\n- bool trie_t::has(const char c) const {\n- if (!isFrozen) {\n- return trieHas(c);\n- }\n- for (int i = 0; i < baseNodeCount; ++i) {\n- if (chars[i] == c) {\n- return true;\n- }\n- }\n- return false;\n+ trieNode_t::result_t trieNode_t::get(const char *c) const {\n+ return get(c, 0);\n}\n- bool trie_t::trieHas(const char c) const {\n- const trieNodeMap_t &leaves = root.leaves;\n- cTrieNodeMapIterator it = leaves.begin();\n- while (it != leaves.end()) {\n- if (c == it->first) {\n- return true;\n- }\n- ++it;\n- }\n- return false;\n- }\n-\n- bool trie_t::has(const char *c) const {\n- const char *cEnd = get(c);\n- return ((size_t) (cEnd - c) == strlen(c));\n- }\n-\n- bool trie_t::has(const char *c, const int size) const {\n- OCCA_ERROR(\"Cannot search for a char* with size: \" << size,\n- 0 < size);\n-\n- char *c2 = new char[size + 1];\n- c2[size] = '\\0';\n- ::memcpy(c2, c, size);\n-\n- const bool has_ = has(c2);\n- delete [] c2;\n- return has_;\n- }\n-\n- void trie_t::print() {\n- const bool wasFrozen = isFrozen;\n- if (!isFrozen) {\n- freeze();\n- }\n- const std::string headers[] = {\n- \"index : \",\n- \"chars : \",\n- \"offsets : \",\n- \"leafCount: \",\n- \"isLeaf : \"\n- };\n- std::cout << headers[0];\n- for (int i = 0; i < nodeCount; ++i) {\n- std::string spaces(i < 10 ? 2 : ((i < 100) ? 1 : 0), ' ');\n- std::cout << i << ' ' << spaces;\n- }\n- std::cout << '\\n' << headers[1];\n- for (int i = 0; i < nodeCount; ++i) {\n- std::cout << chars[i] << \" \";\n- }\n- std::cout << '\\n' << headers[2];\n- for (int i = 0; i < nodeCount; ++i) {\n- const int offset = offsets[i];\n- std::string spaces(offset < 10 ? 2 : ((offset < 100) ? 1 : 0), ' ');\n- std::cout << offsets[i] << ' ' << spaces;\n- }\n- std::cout << '\\n' << headers[3];\n- for (int i = 0; i < nodeCount; ++i) {\n- const int lcount = leafCount[i];\n- std::string spaces(lcount < 10 ? 2 : ((lcount < 100) ? 1 : 0), ' ');\n- std::cout << leafCount[i] << ' ' << spaces;\n+ trieNode_t::result_t trieNode_t::get(const char *c, const int length) const {\n+ cTrieNodeMapIterator it = leaves.find(c[length]);\n+ if (it != leaves.end()) {\n+ result_t result = it->second.get(c, length + 1);\n+ if ((result.valueIdx < 0) && (0 <= valueIdx)) {\n+ return result_t(length + 1, valueIdx);\n}\n- std::cout << '\\n' << headers[4];\n- for (int i = 0; i < nodeCount; ++i) {\n- std::cout << isLeaf[i] << \" \";\n+ return result;\n}\n- std::cout << '\\n';\n- isFrozen = wasFrozen;\n+ return result_t(length, valueIdx);\n}\n+ //====================================\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testTrie.cpp", "new_path": "parser_sandbox/tests/testTrie.cpp", "diff": "#include \"trie.hpp\"\n-void testInsert(occa::trie_t &trie);\n-void testSearch(occa::trie_t &trie);\n-void testFrozenSearch(occa::trie_t &trie);\n-void testRefreeze(occa::trie_t &trie);\n+void testInsert(occa::trie_t<std::string> &trie);\n+void testSearch(occa::trie_t<std::string> &trie);\n+void testFrozenSearch(occa::trie_t<std::string> &trie);\n+void testRefreeze(occa::trie_t<std::string> &trie);\nint main(const int argc, const char **argv) {\n- occa::trie_t trie;\n+ occa::trie_t<std::string> trie;\ntestInsert(trie);\ntestSearch(trie);\ntestFrozenSearch(trie);\ntestRefreeze(trie);\n}\n-void testInsert(occa::trie_t &trie) {\n- trie.add(\"blue\");\n- trie.add(\"blueblue\");\n- trie.add(\"boring\");\n- trie.add(\"glue\");\n- trie.add(\"good\");\n+void testInsert(occa::trie_t<std::string> &trie) {\n+ trie.add(\"blue\" , \"blue\");\n+ trie.add(\"blueblue\", \"blueblue\");\n+ trie.add(\"boring\" , \"boring\");\n+ trie.add(\"glue\" , \"glue\");\n+ trie.add(\"good\" , \"good\");\n}\n-void testSearch(occa::trie_t &trie) {\n- occa::testing::compare(trie.has(\"blue\") , false);\n+void testSearch(occa::trie_t<std::string> &trie) {\n+ occa::testing::compare(trie.has(\"blue\") , true);\nocca::testing::compare(trie.has(\"boring\") , true);\nocca::testing::compare(trie.has(\"glue\") , true);\nocca::testing::compare(trie.has(\"good\") , true);\n@@ -34,9 +34,27 @@ void testSearch(occa::trie_t &trie) {\nocca::testing::compare(trie.has(\"red\") , false);\nocca::testing::compare(trie.has(\"goo\") , false);\nocca::testing::compare(trie.has(\"goods\") , false);\n+\n+ occa::testing::compare(trie.getFirst(\"blue\").value , \"blue\");\n+ occa::testing::compare(trie.getFirst(\"boring\").value , \"boring\");\n+ occa::testing::compare(trie.getFirst(\"glue\").value , \"glue\");\n+ occa::testing::compare(trie.getFirst(\"good\").value , \"good\");\n+\n+ occa::testing::compare(trie.getFirst(\"red\").value , \"\");\n+ occa::testing::compare(trie.getFirst(\"goo\").value , \"\");\n+ occa::testing::compare(trie.getFirst(\"goods\").value , \"good\");\n+\n+ occa::testing::compare(trie.get(\"blue\").value , \"blue\");\n+ occa::testing::compare(trie.get(\"boring\").value , \"boring\");\n+ occa::testing::compare(trie.get(\"glue\").value , \"glue\");\n+ occa::testing::compare(trie.get(\"good\").value , \"good\");\n+\n+ occa::testing::compare(trie.get(\"red\").value , \"\");\n+ occa::testing::compare(trie.get(\"goo\").value , \"\");\n+ occa::testing::compare(trie.get(\"goods\").value , \"\");\n}\n-void testFrozenSearch(occa::trie_t &trie) {\n+void testFrozenSearch(occa::trie_t<std::string> &trie) {\ntrie.freeze();\nocca::testing::compare(trie.has(\"blue\") , true);\nocca::testing::compare(trie.has(\"boring\") , true);\n@@ -46,17 +64,40 @@ void testFrozenSearch(occa::trie_t &trie) {\nocca::testing::compare(trie.has(\"red\") , false);\nocca::testing::compare(trie.has(\"goo\") , false);\nocca::testing::compare(trie.has(\"goods\") , false);\n+\n+ occa::testing::compare(trie.getFirst(\"blue\").value , \"blue\");\n+ occa::testing::compare(trie.getFirst(\"boring\").value , \"boring\");\n+ occa::testing::compare(trie.getFirst(\"glue\").value , \"glue\");\n+ occa::testing::compare(trie.getFirst(\"good\").value , \"good\");\n+\n+ occa::testing::compare(trie.getFirst(\"red\").value , \"\");\n+ occa::testing::compare(trie.getFirst(\"goo\").value , \"\");\n+ occa::testing::compare(trie.getFirst(\"goods\").value , \"good\");\n+\n+ occa::testing::compare(trie.get(\"blue\").value , \"blue\");\n+ occa::testing::compare(trie.get(\"boring\").value , \"boring\");\n+ occa::testing::compare(trie.get(\"glue\").value , \"glue\");\n+ occa::testing::compare(trie.get(\"good\").value , \"good\");\n+\n+ occa::testing::compare(trie.get(\"red\").value , \"\");\n+ occa::testing::compare(trie.get(\"goo\").value , \"\");\n+ occa::testing::compare(trie.get(\"goods\").value , \"\");\n}\n-void testRefreeze(occa::trie_t &trie) {\n+void testRefreeze(occa::trie_t<std::string> &trie) {\nocca::testing::compare(trie.isFrozen, true);\nocca::testing::compare(trie.has(\"red\"), false);\n- trie.add(\"red\");\n+ trie.add(\"red\", \"red\");\n+ trie.add(\"blue\", \"red\");\nocca::testing::compare(trie.isFrozen, false);\nocca::testing::compare(trie.has(\"red\"), true);\n+ occa::testing::compare(trie.get(\"red\").value, \"red\");\n+ occa::testing::compare(trie.get(\"blue\").value, \"red\");\ntrie.freeze();\nocca::testing::compare(trie.isFrozen, true);\nocca::testing::compare(trie.has(\"red\"), true);\n+ occa::testing::compare(trie.get(\"red\").value, \"red\");\n+ occa::testing::compare(trie.get(\"blue\").value, \"red\");\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/testing.cpp", "new_path": "src/tools/testing.cpp", "diff": "namespace occa {\nnamespace testing {\ntemplate <>\n- void compare<float>(const float &a, const float &b) {\n+ void compare<float, float>(const float &a, const float &b) {\n+ const double diff = (a - b)/(fabs(a) + fabs(b) + 1e-50);\n+ OCCA_ERROR(\"Comparing Failed\",\n+ diff < 1e-8);\n+ }\n+ template <>\n+ void compare<double, float>(const double &a, const float &b) {\n+ const double diff = (a - b)/(fabs(a) + fabs(b) + 1e-50);\n+ OCCA_ERROR(\"Comparing Failed\",\n+ diff < 1e-8);\n+ }\n+ template <>\n+ void compare<float, double>(const float &a, const double &b) {\nconst double diff = (a - b)/(fabs(a) + fabs(b) + 1e-50);\nOCCA_ERROR(\"Comparing Failed\",\ndiff < 1e-8);\n}\ntemplate <>\n- void compare<double>(const double &a, const double &b) {\n+ void compare<double, double>(const double &a, const double &b) {\nconst double diff = (a - b)/(fabs(a) + fabs(b) + 1e-50);\nOCCA_ERROR(\"Comparing Failed\",\ndiff < 1e-14);\n" } ]
C++
MIT License
libocca/occa
[Trie] Trie now holds values
378,349
31.12.2016 00:29:43
21,600
ab36ea2a91d17275268e650bd736c9c370e8386d
[Trie] Added empty()
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/basicParser.hpp", "new_path": "parser_sandbox/include/basicParser.hpp", "diff": "@@ -166,7 +166,7 @@ namespace occa {\nconst trie_t& getOperatorTrie() {\nstatic trie_t trie;\n- if (trie.baseNodeCount == 0) {\n+ if (trie.empty()) {\nconst precedenceVector_t &prec = getOperatorPrecendence();\nconst int levels = (int) prec.size();\nfor (int level = 0; level < levels; ++level) {\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/preprocessor.hpp", "new_path": "parser_sandbox/include/preprocessor.hpp", "diff": "@@ -23,6 +23,8 @@ namespace occa {\ntypedef macroMap_t::iterator macroMapIterator;\ntypedef macroMap_t::const_iterator cMacroMapIterator;\n+ typedef void (*processDefine_t)(const char *&c);\n+\nclass preprocessor_t {\npublic:\nenum status_t {\n@@ -45,6 +47,29 @@ namespace occa {\nstd::stack<status_t> statusStack;\n+ trie_t<processDefine_t>& getDefineTrie() {\n+ static trie_t<processDefine_t> trie;\n+ if (trie.empty()) {\n+ trie.add(\"if\" , processIf);\n+ trie.add(\"elif\" , processElif);\n+ trie.add(\"else\" , processElse);\n+ trie.add(\"ifdef\" , processIfdef);\n+ trie.add(\"ifndef\", processIfndef);\n+ trie.add(\"endif\" , processEndif);\n+\n+ trie.add(\"define\", processDefine);\n+ trie.add(\"undef\" , processUndef);\n+\n+ trie.add(\"error\" , processError);\n+ trie.add(\"warning\", processWarning);\n+\n+ trie.add(\"include\", processInclude);\n+ trie.add(\"pragma\" , processPragma);\n+ trie.add(\"line\" , processLine);\n+ }\n+ return trie;\n+ }\n+\nvoid clear() {\nmacros.clear();\ncontent.clear();\n@@ -117,61 +142,8 @@ namespace occa {\nocca::skipWhitespace(c);\nconst char *cStart = c;\nocca::skipToWhitespace(c);\n- const char *cEnd = c;\n+ const std::string directive(cStart, c - cStart);\nskipTo(c, '\\n');\n-\n- switch (cEnd - cStart) {\n- case 2:\n- if (stringsAreEqual(cStart, (cEnd - cStart), \"if\")) {\n- addContent(cHash);\n- processIf(c);\n- }\n- break;\n- case 4:\n- if (stringsAreEqual(cStart, (cEnd - cStart), \"else\")) {\n- addContent(cHash);\n- processElse(c);\n- } else if (stringsAreEqual(cStart, (cEnd - cStart), \"elif\")) {\n- addContent(cHash);\n- processElif(c);\n- } else if (stringsAreEqual(cStart, (cEnd - cStart), \"line\")) {\n- processLine(c);\n- }\n- break;\n- case 5:\n- if (stringsAreEqual(cStart, (cEnd - cStart), \"error\")) {\n- processError(c);\n- } else if (stringsAreEqual(cStart, (cEnd - cStart), \"ifdef\")) {\n- addContent(cHash);\n- processIfdef(c);\n- } else if (stringsAreEqual(cStart, (cEnd - cStart), \"endif\")) {\n- addContent(cHash);\n- processEndif(c);\n- } else if (stringsAreEqual(cStart, (cEnd - cStart), \"undef\")) {\n- addContent(cHash);\n- processUndef(c);\n- }\n- break;\n- case 6:\n- if (stringsAreEqual(cStart, (cEnd - cStart), \"define\")) {\n- addContent(cHash);\n- processDefine(c);\n- } else if (stringsAreEqual(cStart, (cEnd - cStart), \"ifndef\")) {\n- addContent(cHash);\n- processIfndef(c);\n- } else if (stringsAreEqual(cStart, (cEnd - cStart), \"pragma\")) {\n- processPragma(c);\n- }\n- break;\n- case 7:\n- if (stringsAreEqual(cStart, (cEnd - cStart), \"include\")) {\n- addContent(cHash);\n- processInclude(c);\n- } else if (stringsAreEqual(cStart, (cEnd - cStart), \"warning\")) {\n- processWarning(c);\n- }\n- break;\n- }\n}\nvoid processIf(const char *&c) {\n@@ -182,7 +154,7 @@ namespace occa {\n}\n}\n- void processElse(const char *&c) {\n+ void processElif(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nstatusStack.push(ignoringAll);\n@@ -190,7 +162,7 @@ namespace occa {\n}\n}\n- void processElif(const char *&c) {\n+ void processElse(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nstatusStack.push(ignoringAll);\n@@ -198,28 +170,28 @@ namespace occa {\n}\n}\n- void processLine(const char *&c) {\n+ void processIfdef(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n}\n}\n- void processError(const char *&c) {\n+ void processIfndef(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n}\n}\n- void processIfdef(const char *&c) {\n+ void processEndif(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n}\n}\n- void processEndif(const char *&c) {\n+ void processDefine(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n@@ -233,35 +205,35 @@ namespace occa {\n}\n}\n- void processDefine(const char *&c) {\n+ void processError(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n}\n}\n- void processIfndef(const char *&c) {\n+ void processWarning(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n}\n}\n- void processPragma(const char *&c) {\n+ void processInclude(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n}\n}\n- void processInclude(const char *&c) {\n+ void processPragma(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n}\n}\n- void processWarning(const char *&c) {\n+ void processLine(const char *&c) {\nstatus_t status = getStatus();\nif (status & ignoring) {\nreturn;\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.hpp", "new_path": "parser_sandbox/include/trie.hpp", "diff": "@@ -72,6 +72,8 @@ namespace occa {\nint freeze(const trieNode_t &node, int offset);\nvoid defrost();\n+ bool empty() const;\n+\nresult_t getFirst(const char *c) const;\nresult_t trieGetFirst(const char *c) const;\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.tpp", "new_path": "parser_sandbox/include/trie.tpp", "diff": "@@ -109,6 +109,11 @@ namespace occa {\n}\n}\n+ template <class TM>\n+ bool trie_t<TM>::empty() const {\n+ return (root.leaves.size() == 0);\n+ }\n+\ntemplate <class TM>\ntypename trie_t<TM>::result_t trie_t<TM>::getFirst(const char *c) const {\nif (!isFrozen) {\n" } ]
C++
MIT License
libocca/occa
[Trie] Added empty()
378,349
31.12.2016 15:45:14
21,600
eb2d203b3794a35f1cd24f2486a2df6599032374
[Trie] Optimized trie frozen fetch
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.tpp", "new_path": "parser_sandbox/include/trie.tpp", "diff": "@@ -47,8 +47,7 @@ namespace occa {\ntemplate <class TM>\nvoid trie_t<TM>::add(const std::string &s, const TM &value) {\n- defrost();\n- root.add(s.c_str(), value);\n+ add(s.c_str(), value);\n}\ntemplate <class TM>\n@@ -119,29 +118,38 @@ namespace occa {\nif (!isFrozen) {\nreturn trieGetFirst(c);\n}\n- const char *cStart = c;\n+ const char * const cStart = c;\nint retLength = 0;\nint retValueIdx = -1;\nint offset = 0;\nint count = baseNodeCount;\n- while (count) {\n+ while (true) {\nconst char ci = *c;\n+ int start = 0, end = (count - 1);\nbool found = false;\n- for (int i = 0; i < count; ++i) {\n- if (ci == chars[offset + i]) {\n+ while (start <= end) {\n+ // Faster than storing the value\n+#define OCCA_TRIE_MID ((start + end) / 2)\n+ const char cmid = chars[offset + OCCA_TRIE_MID];\n+ if (ci < cmid) {\n+ end = (OCCA_TRIE_MID - 1);\n+ } else if (ci > cmid) {\n+ start = (OCCA_TRIE_MID + 1);\n+ } else {\n++c;\n- if (0 <= valueIndices[offset]) {\n+ if (0 <= valueIndices[offset + OCCA_TRIE_MID]) {\nretLength = (c - cStart);\n- retValueIdx = valueIndices[offset];\n+ retValueIdx = valueIndices[offset + OCCA_TRIE_MID];\n}\n- count = leafCount[offset + i];\n- offset = offsets[offset + i];\n+ count = leafCount[offset + OCCA_TRIE_MID];\n+ offset = offsets[offset + OCCA_TRIE_MID];\nfound = true;\nbreak;\n}\n+#undef OCCA_TRIE_MID\n}\nif (!found) {\nbreak;\n@@ -210,17 +218,8 @@ namespace occa {\nbool trie_t<TM>::has(const char *c, const int size) const {\nOCCA_ERROR(\"Cannot search for a char* with size: \" << size,\n0 < size);\n-\n- const bool usedAlloca = (size < 1024);\n- char *c2 = usedAlloca ? ((char*) alloca(size + 1)) : (new char [size + 1]);\n- c2[size] = '\\0';\n- ::memcpy(c2, c, size);\n-\n- const bool has_ = has(c2);\n- if (!usedAlloca) {\n- delete [] c2;\n- }\n- return has_;\n+ result_t result = get(c);\n+ return (result.length == size);\n}\ntemplate <class TM>\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/macro.cpp", "new_path": "parser_sandbox/src/macro.cpp", "diff": "@@ -182,8 +182,11 @@ namespace occa {\nstr = str.substr(0, strChars - 1);\n}\n}\n+ // Ignore strings only made with # or ##\n+ if (str.size()) {\nparts.push_back(str);\n}\n+ }\n// Push back argument part\nparts.push_back(part);\n// Update the lazy string start\n@@ -290,7 +293,7 @@ namespace occa {\n}\n// Separate inputs with spaces\nif ((i < (partCount - 1)) &&\n- !(part.info & macroInfo::concat) &&\n+ !(parts[i + 1].info & macroInfo::concat) &&\n(ret.size() != startRetSize)) {\nret += ' ';\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/preprocessor.cpp", "new_path": "parser_sandbox/tests/preprocessor.cpp", "diff": "@@ -16,78 +16,78 @@ int main(const int argc, const char **argv) {\nvoid testIfElseDefines() {\npreprocessor_t preprocessor;\n- test::compare(\"\",\n+ OCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"#ifdef FOO\\n\"\n\"1\\n\"\n\"#endif\\n\"));\n- test::compare(\"2\",\n+ OCCA_TEST_COMPARE(\"2\",\npreprocessor.process(\"#ifndef FOO\\n\"\n\"2\\n\"\n\"#endif\\n\"));\n- test::compare(\"\",\n+ OCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"#if defined(FOO)\\n\"\n\"3\\n\"\n\"#endif\\n\"));\n- test::compare(\"4\",\n+ OCCA_TEST_COMPARE(\"4\",\npreprocessor.process(\"#if !defined(FOO)\\n\"\n\"4\\n\"\n\"#endif\\n\"));\npreprocessor.process(\"#define FOO 9\\n\");\n- test::compare(\"5\",\n+ OCCA_TEST_COMPARE(\"5\",\npreprocessor.process(\"#ifdef FOO\\n\"\n\"5\\n\"\n\"#endif\\n\"));\n- test::compare(\"\",\n+ OCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"#ifndef FOO\\n\"\n\"6\\n\"\n\"#endif\\n\"));\n- test::compare(\"7\",\n+ OCCA_TEST_COMPARE(\"7\",\npreprocessor.process(\"#if defined(FOO)\\n\"\n\"7\\n\"\n\"#endif\\n\"));\n- test::compare(\"\",\n+ OCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"#if !defined(FOO)\\n\"\n\"8\\n\"\n\"#endif\\n\"));\n- test::compare(\"9\",\n+ OCCA_TEST_COMPARE(\"9\",\npreprocessor.process(\"FOO\\n\"));\n- test::compare(\"10\",\n+ OCCA_TEST_COMPARE(\"10\",\npreprocessor.process(\"#undef FOO\\n\"\n\"#define FOO 10\\n\"\n\"FOO\"));\n- test::compare(\"11\",\n+ OCCA_TEST_COMPARE(\"11\",\npreprocessor.process(\"#define FOO 11\\n\"\n\"FOO\"));\npreprocessor.process(\"#undef FOO\\n\");\n- test::compare(\"\",\n+ OCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"#ifdef FOO\\n\"\n\"12\\n\"\n\"#endif\\n\"));\n- test::compare(\"13\",\n+ OCCA_TEST_COMPARE(\"13\",\npreprocessor.process(\"#ifndef FOO\\n\"\n\"13\\n\"\n\"#endif\\n\"));\n- test::compare(\"\",\n+ OCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"#if defined(FOO)\\n\"\n\"14\\n\"\n\"#endif\\n\"));\n- test::compare(\"15\",\n+ OCCA_TEST_COMPARE(\"15\",\npreprocessor.process(\"#if !defined(FOO)\\n\"\n\"15\\n\"\n\"#endif\\n\"));\n@@ -98,10 +98,10 @@ void testErrorDefines() {\npreprocessor.props[\"exitOnError\"] = false;\npreprocessor.process(\"#error \\\"Error\\\"\\n\");\n- test::compare(1, preprocessor.errors.size());\n+ OCCA_TEST_COMPARE(1, preprocessor.errors.size());\npreprocessor.process(\"#warning \\\"Warning\\\"\\n\");\n- test::compare(1, preprocessor.warnings.size());\n+ OCCA_TEST_COMPARE(1, preprocessor.warnings.size());\n}\nvoid testFunctionMacros() {\n@@ -109,52 +109,52 @@ void testFunctionMacros() {\npreprocessor.props[\"exitOnError\"] = false;\npreprocessor.process(\"#define FOO(A) A\\n\");\n- test::compare(\"\",\n+ OCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"FOO\\n\"));\n- test::compare(\"\",\n+ OCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"FOO()\\n\"));\n- test::compare(\"1\",\n+ OCCA_TEST_COMPARE(\"1\",\npreprocessor.process(\"FOO(1)\\n\"));\npreprocessor.process(\"#undef FOO\\n\"\n\"#define FOO(A, B) A B\\n\");\n- test::compare(\"2 3\",\n+ OCCA_TEST_COMPARE(\"2 3\",\npreprocessor.process(\"FOO(2, 3)\\n\"));\n- test::compare(\"4 5\",\n+ OCCA_TEST_COMPARE(\"4 5\",\npreprocessor.process(\"FOO(4, 5, 6)\\n\"));\npreprocessor.process(\"#undef FOO\\n\"\n\"#define FOO(A, B) A##B\\n\");\n- test::compare(\"6\",\n+ OCCA_TEST_COMPARE(\"6\",\npreprocessor.process(\"FOO(, 6)\\n\"));\npreprocessor.process(\"#undef FOO\\n\"\n\"#define FOO(A, ...) A __VA_ARGS__\\n\");\n- test::compare(\"7\",\n+ OCCA_TEST_COMPARE(\"7\",\npreprocessor.process(\"FOO(7,)\\n\"));\n- test::compare(\"8 9, 10\",\n+ OCCA_TEST_COMPARE(\"8 9, 10\",\npreprocessor.process(\"FOO(8, 9, 10,)\\n\"));\npreprocessor.process(\"#undef FOO\\n\"\n\"#define FOO(...) (X, ##__VA_ARGS__)\\n\");\n- test::compare(\"(X, 11)\",\n+ OCCA_TEST_COMPARE(\"(X, 11)\",\npreprocessor.process(\"FOO(10,)\\n\"));\n- test::compare(\"(X)\",\n+ OCCA_TEST_COMPARE(\"(X)\",\npreprocessor.process(\"FOO()\\n\"));\npreprocessor.process(\"#undef FOO\\n\"\n\"#define FOO(...) __VA_ARGS_COUNT__\\n\");\n- test::compare(\"12\",\n+ OCCA_TEST_COMPARE(\"12\",\npreprocessor.process(\"FOO (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)\\n\"));\npreprocessor.process(\"#undef FOO\\n\"\n\"#define FOO(A) #A\\n\");\n- test::compare(\"\\\"13\\\"\",\n+ OCCA_TEST_COMPARE(\"\\\"13\\\"\",\npreprocessor.process(\"FOO(13)\\n\"));\npreprocessor.process(\"#undef FOO\\n\"\n\"#define FOO(A, B) #A##B\\n\");\n- test::compare(\"\\\"14\\\"\",\n+ OCCA_TEST_COMPARE(\"\\\"14\\\"\",\npreprocessor.process(\"FOO(1, 4)\\n\"));\n}\n@@ -163,66 +163,66 @@ void testEval() {\npreprocessor.props[\"exitOnError\"] = false;\n// Types\n- test::compare<int>(1 + 1,\n+ OCCA_TEST_COMPARE<int>(1 + 1,\npreprocessor.eval<int>(\"1 + 1\"));\n- test::compare<bool>(true,\n+ OCCA_TEST_COMPARE<bool>(true,\npreprocessor.eval<bool>(\"1 + 1\"));\n- test::compare<double>(0.5 + 1.5,\n+ OCCA_TEST_COMPARE<double>(0.5 + 1.5,\npreprocessor.eval<double>(\"0.5 + 1.5\"));\n- test::compare(\"2\",\n+ OCCA_TEST_COMPARE(\"2\",\npreprocessor.eval<std::string>(\"1 + 1\"));\n- test::compare<double>(100000000000L,\n+ OCCA_TEST_COMPARE<double>(100000000000L,\npreprocessor.eval<long>(\"100000000000L\"));\n// Unary Operators\n- test::compare<int>(+1,\n+ OCCA_TEST_COMPARE<int>(+1,\npreprocessor.eval<int>(\"+1\"));\n- test::compare<int>(-1,\n+ OCCA_TEST_COMPARE<int>(-1,\npreprocessor.eval<int>(\"-1\"));\n- test::compare<int>(!1,\n+ OCCA_TEST_COMPARE<int>(!1,\npreprocessor.eval<int>(\"!1\"));\n- test::compare<int>(~1,\n+ OCCA_TEST_COMPARE<int>(~1,\npreprocessor.eval<int>(\"~1\"));\n// Binary Operators\n- test::compare<double>(1 + 2,\n+ OCCA_TEST_COMPARE<double>(1 + 2,\npreprocessor.eval<double>(\"1 + 2\"));\n- test::compare<double>(1 - 2,\n+ OCCA_TEST_COMPARE<double>(1 - 2,\npreprocessor.eval<double>(\"1 - 2\"));\n- test::compare<int>(1 / 2,\n+ OCCA_TEST_COMPARE<int>(1 / 2,\npreprocessor.eval<double>(\"1 / 2\"));\n- test::compare<double>(1 / 2.0,\n+ OCCA_TEST_COMPARE<double>(1 / 2.0,\npreprocessor.eval<double>(\"1 / 2.0\"));\n- test::compare<int>(5 % 2,\n+ OCCA_TEST_COMPARE<int>(5 % 2,\npreprocessor.eval<int>(\"5 % 2\"));\n// Bit operators\n- test::compare<int>(1 & 3,\n+ OCCA_TEST_COMPARE<int>(1 & 3,\npreprocessor.eval<int>(\"1 & 3\"));\n- test::compare<int>(1 ^ 3,\n+ OCCA_TEST_COMPARE<int>(1 ^ 3,\npreprocessor.eval<int>(\"1 ^ 3\"));\n- test::compare<int>(1 | 3,\n+ OCCA_TEST_COMPARE<int>(1 | 3,\npreprocessor.eval<int>(\"1 | 3\"));\n// Shift operators\n- test::compare<int>(0,\n+ OCCA_TEST_COMPARE<int>(0,\npreprocessor.eval<int>(\"1 >> 1\"));\n- test::compare<int>(2,\n+ OCCA_TEST_COMPARE<int>(2,\npreprocessor.eval<int>(\"1 << 1\"));\n// Parentheses\n- test::compare<double>(3*(1 + 1),\n+ OCCA_TEST_COMPARE<double>(3*(1 + 1),\npreprocessor.eval<int>(\"3*(1 + 1)\"));\n- test::compare<double>((3 * 1)*(1 + 1),\n+ OCCA_TEST_COMPARE<double>((3 * 1)*(1 + 1),\npreprocessor.eval<int>(\"(3 * 1)*(1 + 1)\"));\n/*\n// NaN and Inf\nfloat x = preprocessor.eval<float>(\"1/0\");\n- test::compare(true, x != x);\n+ OCCA_TEST_COMPARE(true, x != x);\nx = preprocessor.eval<float>(\"0/0\");\n- test::compare(true, x != x);\n+ OCCA_TEST_COMPARE(true, x != x);\n*/\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testMacro.cpp", "new_path": "parser_sandbox/tests/testMacro.cpp", "diff": "@@ -40,6 +40,8 @@ void testFunctionMacros() {\nmacro.load(\"FOO(A, B) A##B\");\nOCCA_TEST_COMPARE(\" 6\",\nmacro.expand(\", 6)\"));\n+ OCCA_TEST_COMPARE(\"07\",\n+ macro.expand(\"0, 7)\"));\nmacro.load(\"FOO(A, ...) A __VA_ARGS__\");\nOCCA_TEST_COMPARE(\"7 \",\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testTrie.cpp", "new_path": "parser_sandbox/tests/testTrie.cpp", "diff": "#include \"trie.hpp\"\n+#include <time.h>\n+#include <stdlib.h>\n+#include \"occa/tools/io.hpp\"\n+#include \"occa/tools/lex.hpp\"\n+\nvoid testInsert(occa::trie_t<std::string> &trie);\nvoid testSearch(occa::trie_t<std::string> &trie);\nvoid testFrozenSearch(occa::trie_t<std::string> &trie);\n" } ]
C++
MIT License
libocca/occa
[Trie] Optimized trie frozen fetch
378,349
31.12.2016 16:11:47
21,600
6cad5a246842db1a4dce340e3998bd6754d1e625
[Trie] Added autoFreeze
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.hpp", "new_path": "parser_sandbox/include/trie.hpp", "diff": "@@ -57,7 +57,7 @@ namespace occa {\ntrieNode_t root;\nstd::vector<TM> values;\n- bool isFrozen;\n+ bool isFrozen, autoFreeze;\nint nodeCount, baseNodeCount;\nchar *chars;\nint *offsets, *leafCount;\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.tpp", "new_path": "parser_sandbox/include/trie.tpp", "diff": "@@ -43,6 +43,9 @@ namespace occa {\nvalues[valueIdx] = value;\n}\nroot.add(c, valueIdx);\n+ if (autoFreeze) {\n+ freeze();\n+ }\n}\ntemplate <class TM>\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testTrie.cpp", "new_path": "parser_sandbox/tests/testTrie.cpp", "diff": "@@ -92,13 +92,12 @@ void testRefreeze(occa::trie_t<std::string> &trie) {\nOCCA_TEST_COMPARE(trie.has(\"red\"), false);\ntrie.add(\"red\", \"red\");\n- trie.add(\"blue\", \"red\");\nOCCA_TEST_COMPARE(trie.isFrozen, false);\nOCCA_TEST_COMPARE(trie.has(\"red\"), true);\nOCCA_TEST_COMPARE(trie.get(\"red\").value, \"red\");\n- OCCA_TEST_COMPARE(trie.get(\"blue\").value, \"red\");\n- trie.freeze();\n+ trie.autoFreeze = true;\n+ trie.add(\"blue\", \"red\");\nOCCA_TEST_COMPARE(trie.isFrozen, true);\nOCCA_TEST_COMPARE(trie.has(\"red\"), true);\nOCCA_TEST_COMPARE(trie.get(\"red\").value, \"red\");\n" } ]
C++
MIT License
libocca/occa
[Trie] Added autoFreeze
378,349
02.01.2017 09:38:10
21,600
d7337a74ca96e063308bd5354d9d5cbb4b48f4dd
[Trie] Added char limits to get
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/Makefile", "new_path": "parser_sandbox/Makefile", "diff": "@@ -22,11 +22,15 @@ all: $(executables)\n${PROJ_DIR}/main: $(objects) $(headers) ${PROJ_DIR}/main.cpp $(tests)\n$(compiler) $(compilerFlags) -o ${PROJ_DIR}/main $(flags) $(objects) ${PROJ_DIR}/main.cpp $(paths) $(links)\n-$(objPath)/%.o:$(srcPath)/%.cpp $(wildcard $(subst $(srcPath)/,$(incPath)/,$(<:.cpp=.hpp))) $(wildcard $(subst $(srcPath)/,$(incPath)/,$(<:.cpp=.tpp)))\n+$(objPath)/%.o:$(srcPath)/%.cpp $(incPath)/%.hpp\n@mkdir -p $(objPath)\n$(compiler) $(compilerFlags) -o $@ $(flags) -c $(paths) $<\n-$(testPath)/bin/%:$(testPath)/%.cpp\n+$(objPath)/%.o:$(srcPath)/%.cpp $(incPath)/%.hpp $(incPath)/%.tpp\n+ @mkdir -p $(objPath)\n+ $(compiler) $(compilerFlags) -o $@ $(flags) -c $(paths) $<\n+\n+$(testPath)/bin/%:$(testPath)/%.cpp $(objects) $(headers)\n@mkdir -p $(testPath)/bin\n$(compiler) $(compilerFlags) -o $@ $(flags) $(objects) $< $(paths) $(links)\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.hpp", "new_path": "parser_sandbox/include/trie.hpp", "diff": "#include <vector>\n#include <map>\n+#include <limits.h>\n+\nnamespace occa {\nclass trieNode_t;\ntypedef std::map<char, trieNode_t> trieNodeMap_t;\n@@ -21,6 +23,10 @@ namespace occa {\nresult_t();\nresult_t(const int length_, const int valueIdx);\n+\n+ bool success() const {\n+ return (0 <= valueIdx);\n+ }\n};\nint valueIdx;\n@@ -33,8 +39,8 @@ namespace occa {\nint nodeCount() const;\nint getValueIdx(const char *c) const;\n- result_t get(const char *c) const;\nresult_t get(const char *c, const int length) const;\n+ result_t get(const char *c, const int cIdx, const int length) const;\n};\n//====================================\n@@ -54,7 +60,8 @@ namespace occa {\nconst int length_ = 0,\nconst int valueIdx_ = -1);\n- const TM& value() const;\n+ inline bool success() const;\n+ inline const TM& value() const;\n};\n//==================================\n@@ -79,13 +86,13 @@ namespace occa {\nint freeze(const trieNode_t &node, int offset);\nvoid defrost();\n- result_t getFirst(const char *c) const;\n- result_t trieGetFirst(const char *c) const;\n+ result_t getFirst(const char *c, const int length = INT_MAX) const;\n+ result_t trieGetFirst(const char *c, const int length) const;\ninline result_t getFirst(const std::string &s) const {\n- return getFirst(s.c_str());\n+ return getFirst(s.c_str(), s.size());\n}\n- result_t get(const char *c) const;\n+ result_t get(const char *c, const int length = INT_MAX) const;\ninline result_t get(const std::string &s) const {\nreturn get(s.c_str());\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.tpp", "new_path": "parser_sandbox/include/trie.tpp", "diff": "@@ -19,6 +19,11 @@ namespace occa {\nlength(length_),\nvalueIdx(valueIdx_) {}\n+ template <class TM>\n+ bool trie_t<TM>::result_t::success() const {\n+ return (0 <= valueIdx);\n+ }\n+\ntemplate <class TM>\nconst TM& trie_t<TM>::result_t::value() const {\nreturn trie->values[valueIdx];\n@@ -131,9 +136,9 @@ namespace occa {\n}\ntemplate <class TM>\n- typename trie_t<TM>::result_t trie_t<TM>::getFirst(const char *c) const {\n+ typename trie_t<TM>::result_t trie_t<TM>::getFirst(const char *c, const int length) const {\nif (!isFrozen) {\n- return trieGetFirst(c);\n+ return trieGetFirst(c, length);\n}\nconst char * const cStart = c;\nint retLength = 0;\n@@ -141,7 +146,7 @@ namespace occa {\nint offset = 0;\nint count = baseNodeCount;\n- while (true) {\n+ for (int i = 0; i < length; ++i) {\nconst char ci = *c;\nint start = 0, end = (count - 1);\nbool found = false;\n@@ -180,19 +185,19 @@ namespace occa {\n}\ntemplate <class TM>\n- typename trie_t<TM>::result_t trie_t<TM>::trieGetFirst(const char *c) const {\n- trieNode_t::result_t result = root.get(c);\n-\n- if (0 <= result.valueIdx) {\n+ typename trie_t<TM>::result_t trie_t<TM>::trieGetFirst(const char *c, const int length) const {\n+ trieNode_t::result_t result = root.get(c, length);\n+ if (result.success()) {\nreturn result_t(this, result.length, result.valueIdx);\n}\nreturn result_t(this);\n}\ntemplate <class TM>\n- typename trie_t<TM>::result_t trie_t<TM>::get(const char *c) const {\n- trie_t<TM>::result_t result = getFirst(c);\n- if (strlen(c) != (size_t) result.length) {\n+ typename trie_t<TM>::result_t trie_t<TM>::get(const char *c, const int length) const {\n+ const int length_ = (length == INT_MAX) ? strlen(c) : length;\n+ trie_t<TM>::result_t result = getFirst(c, length_);\n+ if (result.length != length_) {\nresult.length = 0;\nresult.valueIdx = -1;\n}\n@@ -235,8 +240,7 @@ namespace occa {\nbool trie_t<TM>::has(const char *c, const int size) const {\nOCCA_ERROR(\"Cannot search for a char* with size: \" << size,\n0 < size);\n- result_t result = get(c);\n- return (result.length == size);\n+ return (get(c, size).success());\n}\ntemplate <class TM>\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/preprocessor.cpp", "new_path": "parser_sandbox/src/preprocessor.cpp", "diff": "@@ -157,11 +157,11 @@ namespace occa {\nupdatingSkipTo(c, delimiters);\nconst char *cEnd = c;\n- directiveTrie_t::result_t result = directives.get(cStart);\n+ directiveTrie_t::result_t result = directives.get(cStart, cEnd - cStart);\nOCCA_ERROR(\"Directive \\\"\"\n<< std::string(cStart, cEnd - cStart)\n<< \"\\\" is not defined\",\n- result.length == (cEnd - cStart));\n+ 0 <= result.valueIdx);\n// Parse #if[,def], #el[se,if], #endif even when ignored\n// For some reason the preprocessor honors ignored #if/#el/#endif stacks\n@@ -258,8 +258,8 @@ namespace occa {\nconst char *cEnd = c;\nupdatingSkipTo(c, '\\n', '\\\\');\n- macroTrie_t::result_t result = sourceMacros.get(cStart);\n- if (result.length == (cEnd - cStart)) {\n+ macroTrie_t::result_t result = sourceMacros.get(cStart, cEnd - cStart);\n+ if (0 <= result.valueIdx) {\nmacro_t &macro = sourceMacros.values[result.valueIdx];\nmacro.undefinedLine = thisLineNumber;\n} else {\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/trie.cpp", "new_path": "parser_sandbox/src/trie.cpp", "diff": "@@ -36,24 +36,25 @@ namespace occa {\n}\nint trieNode_t::getValueIdx(const char *c) const {\n- result_t result = get(c);\n- return (strlen(c) == (size_t) result.length) ? result.valueIdx : -1;\n+ const int length = (int) strlen(c);\n+ result_t result = get(c, length);\n+ return (result.length == length) ? result.valueIdx : -1;\n}\n- trieNode_t::result_t trieNode_t::get(const char *c) const {\n- return get(c, 0);\n+ trieNode_t::result_t trieNode_t::get(const char *c, const int length) const {\n+ return get(c, 0, length);\n}\n- trieNode_t::result_t trieNode_t::get(const char *c, const int length) const {\n- cTrieNodeMapIterator it = leaves.find(c[length]);\n- if (it != leaves.end()) {\n- result_t result = it->second.get(c, length + 1);\n- if ((result.valueIdx < 0) && (0 <= valueIdx)) {\n- return result_t(length + 1, valueIdx);\n+ trieNode_t::result_t trieNode_t::get(const char *c, const int cIdx, const int length) const {\n+ cTrieNodeMapIterator it = leaves.find(c[cIdx]);\n+ if ((cIdx < length) && (it != leaves.end())) {\n+ result_t result = it->second.get(c, cIdx + 1, length);\n+ if (!result.success() && (0 <= valueIdx)) {\n+ return result_t(cIdx + 1, valueIdx);\n}\nreturn result;\n}\n- return result_t(length, valueIdx);\n+ return result_t(cIdx, valueIdx);\n}\n//====================================\n}\n" } ]
C++
MIT License
libocca/occa
[Trie] Added char limits to get
378,349
02.01.2017 18:11:15
21,600
301fade28c91ddb0b4e50f275d7c3d1bac888c79
[Preprocessor] Added macro define tests
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/preprocessor.hpp", "new_path": "parser_sandbox/include/preprocessor.hpp", "diff": "@@ -58,6 +58,7 @@ namespace occa {\nconst macro_t* getMacro(char *c, const size_t chars);\n+ std::string applyMacros(const char *c);\nstd::string applyMacros(char *c, const size_t chars);\nvoid applyMacros(char *c, const size_t chars, std::string &out);\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/macro.cpp", "new_path": "parser_sandbox/src/macro.cpp", "diff": "@@ -62,7 +62,6 @@ namespace occa {\nreturn;\n}\nmacroPartVector_t argNames;\n- // Skip '('\nloadArgs(c, argNames);\nargc = (int) argNames.size();\n@@ -77,8 +76,7 @@ namespace occa {\n}\n}\n- // Skip ')'\n- setParts(++c, argNames);\n+ setParts(c, argNames);\n}\nvoid macro_t::loadName(char *&c) {\n@@ -102,6 +100,7 @@ namespace occa {\nreturn;\n}\n+ // Skip '('\n++c;\nlex::skipWhitespace(c);\nchar *argsStart = c;\n@@ -131,8 +130,7 @@ namespace occa {\n}\nargNames.push_back(arg);\n}\n- c = argsEnd;\n- lex::skipWhitespace(c);\n+ c = argsEnd + (*argsEnd == ')');\n}\nvoid macro_t::setParts(char *&c, macroPartVector_t &argNames) {\n@@ -232,6 +230,7 @@ namespace occa {\nstd::string macro_t::expand(char *&c) const {\nconst int partCount = (int) parts.size();\n+\nif (partCount == 0) {\nreturn \"\";\n} else if ((argc == 0) && !hasVarArgs) {\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/preprocessor.cpp", "new_path": "parser_sandbox/src/preprocessor.cpp", "diff": "@@ -133,6 +133,11 @@ namespace occa {\nreturn NULL;\n}\n+ std::string preprocessor_t::applyMacros(const char *c) {\n+ std::string s(c);\n+ return applyMacros(&(s[0]), s.size());\n+ }\n+\nstd::string preprocessor_t::applyMacros(char *c, const size_t chars) {\nstd::string out;\napplyMacros(c, chars, out);\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testMacro.cpp", "new_path": "parser_sandbox/tests/testMacro.cpp", "diff": "@@ -27,39 +27,39 @@ void testPlainMacros() {\nvoid testFunctionMacros() {\nocca::macro_t macro(\"FOO(A) A\");\nOCCA_TEST_COMPARE(\"\",\n- macro.expand(\")\"));\n+ macro.expand(\"()\"));\nOCCA_TEST_COMPARE(\"1\",\n- macro.expand(\"1)\"));\n+ macro.expand(\"(1)\"));\nmacro.load(\"FOO(A, B) A B\");\nOCCA_TEST_COMPARE(\"2 3\",\n- macro.expand(\"2, 3)\"));\n+ macro.expand(\"(2, 3)\"));\nOCCA_TEST_COMPARE(\"4 5\",\n- macro.expand(\"4, 5, 6)\"));\n+ macro.expand(\"(4, 5, 6)\"));\nmacro.load(\"FOO(A, B) A##B\");\nOCCA_TEST_COMPARE(\" 6\",\n- macro.expand(\", 6)\"));\n+ macro.expand(\"(, 6)\"));\nOCCA_TEST_COMPARE(\"07\",\n- macro.expand(\"0, 7)\"));\n+ macro.expand(\"(0, 7)\"));\nmacro.load(\"FOO(A, ...) A __VA_ARGS__\");\nOCCA_TEST_COMPARE(\"7 \",\n- macro.expand(\"7,)\"));\n+ macro.expand(\"(7,)\"));\nOCCA_TEST_COMPARE(\"8 9, 10,\",\n- macro.expand(\"8, 9, 10,)\"));\n+ macro.expand(\"(8, 9, 10,)\"));\nmacro.load(\"FOO(...) (X, ##__VA_ARGS__)\");\nOCCA_TEST_COMPARE(\"(X, 11 )\",\n- macro.expand(\"11,)\"));\n+ macro.expand(\"(11,)\"));\nOCCA_TEST_COMPARE(\"(X, )\",\n- macro.expand(\")\"));\n+ macro.expand(\"()\"));\nmacro.load(\"FOO(A) #A\");\nOCCA_TEST_COMPARE(\"\\\"12\\\"\",\n- macro.expand(\"12)\"));\n+ macro.expand(\"(12)\"));\nmacro.load(\"FOO(A, B) #A##B\");\nOCCA_TEST_COMPARE(\"\\\"1\\\"3\",\n- macro.expand(\"1, 3)\"));\n+ macro.expand(\"(1, 3)\"));\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testPreprocessor.cpp", "new_path": "parser_sandbox/tests/testPreprocessor.cpp", "diff": "#include \"preprocessor.hpp\"\n+void testMacroDefines();\nvoid testIfElseDefines();\nvoid testErrorDefines();\nvoid testLineDefine();\n-void testFunctionMacros();\nvoid testEval();\nint main(const int argc, const char **argv) {\n+ testMacroDefines();\ntestLineDefine();\n#if 0\ntestIfElseDefines();\ntestErrorDefines();\n- testFunctionMacros();\ntestEval();\n#endif\n}\n+void testMacroDefines() {\n+ occa::preprocessor_t preprocessor;\n+ preprocessor.process(\"#define A\\n\");\n+ OCCA_TEST_COMPARE(\"\",\n+ preprocessor.applyMacros(\"A\"));\n+\n+ preprocessor.process(\"#define B 1 2 3\\n\");\n+ OCCA_TEST_COMPARE(\"1 2 3\",\n+ preprocessor.applyMacros(\"B\"));\n+\n+ preprocessor.process(\"#define C(A1) A1\\n\");\n+ OCCA_TEST_COMPARE(\"\",\n+ preprocessor.applyMacros(\"C()\"));\n+ OCCA_TEST_COMPARE(\"1\",\n+ preprocessor.applyMacros(\"C(1)\"));\n+\n+ preprocessor.process(\"#define D(A1, A2) A1 A2\\n\");\n+ OCCA_TEST_COMPARE(\"2 3\",\n+ preprocessor.applyMacros(\"D(2, 3)\"));\n+ OCCA_TEST_COMPARE(\"4 5\",\n+ preprocessor.applyMacros(\"D(4, 5, 6)\"));\n+\n+ preprocessor.process(\"#define E(A1, A2) A1##A2\\n\");\n+ OCCA_TEST_COMPARE(\" 6\",\n+ preprocessor.applyMacros(\"E(, 6)\"));\n+ OCCA_TEST_COMPARE(\"07\",\n+ preprocessor.applyMacros(\"E(0, 7)\"));\n+\n+ preprocessor.process(\"#define F(A1, ...) A1 __VA_ARGS__\\n\");\n+ OCCA_TEST_COMPARE(\"7 \",\n+ preprocessor.applyMacros(\"F(7,)\"));\n+ OCCA_TEST_COMPARE(\"8 9, 10,\",\n+ preprocessor.applyMacros(\"F(8, 9, 10,)\"));\n+\n+ preprocessor.process(\"#define G(...) (X, ##__VA_ARGS__)\\n\");\n+ OCCA_TEST_COMPARE(\"(X, 11 )\",\n+ preprocessor.applyMacros(\"G(11,)\"));\n+ OCCA_TEST_COMPARE(\"(X, )\",\n+ preprocessor.applyMacros(\"G()\"));\n+\n+ preprocessor.process(\"#define H(A1) #A1\\n\");\n+ OCCA_TEST_COMPARE(\"\\\"12\\\"\",\n+ preprocessor.applyMacros(\"H(12)\"));\n+\n+ preprocessor.process(\"#define I(A1, A2) #A1##A2\\n\");\n+ OCCA_TEST_COMPARE(\"\\\"1\\\"3\",\n+ preprocessor.applyMacros(\"I(1, 3)\"));\n+}\n+\n#if 0\nvoid testIfElseDefines() {\nocca::preprocessor_t preprocessor;\n@@ -114,8 +163,8 @@ void testErrorDefines() {\nvoid testLineDefine() {\nocca::preprocessor_t preprocessor;\npreprocessor.process(\"#line 10\\n\");\n- OCCA_TEST_COMPARE(preprocessor.lineNumber,\n- 11);\n+ OCCA_TEST_COMPARE(11,\n+ preprocessor.lineNumber);\npreprocessor.process(\"#line 20 \\\"foo\\\"\\n\");\nOCCA_TEST_COMPARE(21,\n@@ -125,60 +174,6 @@ void testLineDefine() {\n}\n#if 0\n-void testFunctionMacros() {\n- occa::preprocessor_t preprocessor;\n- preprocessor.props[\"exitOnError\"] = false;\n-\n- preprocessor.process(\"#define FOO(A) A\\n\");\n- OCCA_TEST_COMPARE(\"\",\n- preprocessor.process(\"FOO\\n\"));\n- OCCA_TEST_COMPARE(\"\",\n- preprocessor.process(\"FOO()\\n\"));\n- OCCA_TEST_COMPARE(\"1\",\n- preprocessor.process(\"FOO(1)\\n\"));\n-\n- preprocessor.process(\"#undef FOO\\n\"\n- \"#define FOO(A, B) A B\\n\");\n- OCCA_TEST_COMPARE(\"2 3\",\n- preprocessor.process(\"FOO(2, 3)\\n\"));\n- OCCA_TEST_COMPARE(\"4 5\",\n- preprocessor.process(\"FOO(4, 5, 6)\\n\"));\n-\n- preprocessor.process(\"#undef FOO\\n\"\n- \"#define FOO(A, B) A##B\\n\");\n- OCCA_TEST_COMPARE(\"6\",\n- preprocessor.process(\"FOO(, 6)\\n\"));\n-\n- preprocessor.process(\"#undef FOO\\n\"\n- \"#define FOO(A, ...) A __VA_ARGS__\\n\");\n- OCCA_TEST_COMPARE(\"7\",\n- preprocessor.process(\"FOO(7,)\\n\"));\n- OCCA_TEST_COMPARE(\"8 9, 10\",\n- preprocessor.process(\"FOO(8, 9, 10,)\\n\"));\n-\n- preprocessor.process(\"#undef FOO\\n\"\n- \"#define FOO(...) (X, ##__VA_ARGS__)\\n\");\n- OCCA_TEST_COMPARE(\"(X, 11)\",\n- preprocessor.process(\"FOO(10,)\\n\"));\n- OCCA_TEST_COMPARE(\"(X)\",\n- preprocessor.process(\"FOO()\\n\"));\n-\n- preprocessor.process(\"#undef FOO\\n\"\n- \"#define FOO(...) __VA_ARGS_COUNT__\\n\");\n- OCCA_TEST_COMPARE(\"12\",\n- preprocessor.process(\"FOO (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)\\n\"));\n-\n- preprocessor.process(\"#undef FOO\\n\"\n- \"#define FOO(A) #A\\n\");\n- OCCA_TEST_COMPARE(\"\\\"13\\\"\",\n- preprocessor.process(\"FOO(13)\\n\"));\n-\n- preprocessor.process(\"#undef FOO\\n\"\n- \"#define FOO(A, B) #A##B\\n\");\n- OCCA_TEST_COMPARE(\"\\\"14\\\"\",\n- preprocessor.process(\"FOO(1, 4)\\n\"));\n-}\n-\nvoid testEval() {\nocca::preprocessor_t preprocessor;\npreprocessor.props[\"exitOnError\"] = false;\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testPrimitive.cpp", "new_path": "parser_sandbox/tests/testPrimitive.cpp", "diff": "@@ -12,38 +12,63 @@ int main(const int argc, const char **argv) {\n}\nvoid testLoad() {\n- OCCA_TEST_COMPARE((int) occa::primitive(\"15\"), 15);\n- OCCA_TEST_COMPARE((int) occa::primitive(\"-15\"), -15);\n-\n- OCCA_TEST_COMPARE((int) occa::primitive(\"0xF\"), 15);\n- OCCA_TEST_COMPARE((int) occa::primitive(\"0XF\"), 15);\n- OCCA_TEST_COMPARE((int) occa::primitive(\"-0xF\"), -15);\n- OCCA_TEST_COMPARE((int) occa::primitive(\"-0XF\"), -15);\n-\n- OCCA_TEST_COMPARE((int) occa::primitive(\"0b1111\"), 15);\n- OCCA_TEST_COMPARE((int) occa::primitive(\"0B1111\"), 15);\n- OCCA_TEST_COMPARE((int) occa::primitive(\"-0b1111\"), -15);\n- OCCA_TEST_COMPARE((int) occa::primitive(\"-0B1111\"), -15);\n-\n- OCCA_TEST_COMPARE((double) occa::primitive(\"15.01\"), 15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"-15.01\"), -15.01);\n-\n- OCCA_TEST_COMPARE((double) occa::primitive(\"1.501e1\"), 15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"-1.501e1\"), -15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"1.501E1\"), 15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"-1.501E1\"), -15.01);\n-\n- OCCA_TEST_COMPARE((double) occa::primitive(\"1.501e+1\"), 15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"-1.501e+1\"), -15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"1.501E+1\"), 15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"-1.501E+1\"), -15.01);\n-\n- OCCA_TEST_COMPARE((double) occa::primitive(\"150.1e-1\"), 15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"-150.1e-1\"), -15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"150.1E-1\"), 15.01);\n- OCCA_TEST_COMPARE((double) occa::primitive(\"-150.1E-1\"), -15.01);\n+ OCCA_TEST_COMPARE(15,\n+ (int) occa::primitive(\"15\"));\n+ OCCA_TEST_COMPARE(-15,\n+ (int) occa::primitive(\"-15\"));\n+\n+ OCCA_TEST_COMPARE(15,\n+ (int) occa::primitive(\"0xF\"));\n+ OCCA_TEST_COMPARE(15,\n+ (int) occa::primitive(\"0XF\"));\n+ OCCA_TEST_COMPARE(-15,\n+ (int) occa::primitive(\"-0xF\"));\n+ OCCA_TEST_COMPARE(-15,\n+ (int) occa::primitive(\"-0XF\"));\n+\n+ OCCA_TEST_COMPARE(15,\n+ (int) occa::primitive(\"0b1111\"));\n+ OCCA_TEST_COMPARE(15,\n+ (int) occa::primitive(\"0B1111\"));\n+ OCCA_TEST_COMPARE(-15,\n+ (int) occa::primitive(\"-0b1111\"));\n+ OCCA_TEST_COMPARE(-15,\n+ (int) occa::primitive(\"-0B1111\"));\n+\n+ OCCA_TEST_COMPARE(15.01,\n+ (double) occa::primitive(\"15.01\"));\n+ OCCA_TEST_COMPARE(-15.01,\n+ (double) occa::primitive(\"-15.01\"));\n+\n+ OCCA_TEST_COMPARE(15.01,\n+ (double) occa::primitive(\"1.501e1\"));\n+ OCCA_TEST_COMPARE(-15.01,\n+ (double) occa::primitive(\"-1.501e1\"));\n+ OCCA_TEST_COMPARE(15.01,\n+ (double) occa::primitive(\"1.501E1\"));\n+ OCCA_TEST_COMPARE(-15.01,\n+ (double) occa::primitive(\"-1.501E1\"));\n+\n+ OCCA_TEST_COMPARE(15.01,\n+ (double) occa::primitive(\"1.501e+1\"));\n+ OCCA_TEST_COMPARE(-15.01,\n+ (double) occa::primitive(\"-1.501e+1\"));\n+ OCCA_TEST_COMPARE(15.01,\n+ (double) occa::primitive(\"1.501E+1\"));\n+ OCCA_TEST_COMPARE(-15.01,\n+ (double) occa::primitive(\"-1.501E+1\"));\n+\n+ OCCA_TEST_COMPARE(15.01,\n+ (double) occa::primitive(\"150.1e-1\"));\n+ OCCA_TEST_COMPARE(-15.01,\n+ (double) occa::primitive(\"-150.1e-1\"));\n+ OCCA_TEST_COMPARE(15.01,\n+ (double) occa::primitive(\"150.1E-1\"));\n+ OCCA_TEST_COMPARE(-15.01,\n+ (double) occa::primitive(\"-150.1E-1\"));\n}\nvoid testToString() {\n- OCCA_TEST_COMPARE((std::string) occa::primitive(\"0xFFFFFFFFF\"), \"68719476735L\");\n+ OCCA_TEST_COMPARE(\"68719476735L\",\n+ (std::string) occa::primitive(\"0xFFFFFFFFF\"));\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testTrie.cpp", "new_path": "parser_sandbox/tests/testTrie.cpp", "diff": "@@ -31,77 +31,79 @@ void testInsert(occa::trie_t<std::string> &trie) {\n}\nvoid testSearch(occa::trie_t<std::string> &trie) {\n- OCCA_TEST_COMPARE(trie.has(\"blue\") , true);\n- OCCA_TEST_COMPARE(trie.has(\"boring\") , true);\n- OCCA_TEST_COMPARE(trie.has(\"glue\") , true);\n- OCCA_TEST_COMPARE(trie.has(\"good\") , true);\n-\n- OCCA_TEST_COMPARE(trie.has(\"red\") , false);\n- OCCA_TEST_COMPARE(trie.has(\"goo\") , false);\n- OCCA_TEST_COMPARE(trie.has(\"goods\") , false);\n-\n- OCCA_TEST_COMPARE(trie.getFirst(\"blue\").value() , \"blue\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"boring\").value() , \"boring\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"glue\").value() , \"glue\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"good\").value() , \"good\");\n-\n- OCCA_TEST_COMPARE(trie.getFirst(\"red\").value() , \"\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"goo\").value() , \"\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"goods\").value() , \"good\");\n-\n- OCCA_TEST_COMPARE(trie.get(\"blue\").value() , \"blue\");\n- OCCA_TEST_COMPARE(trie.get(\"boring\").value() , \"boring\");\n- OCCA_TEST_COMPARE(trie.get(\"glue\").value() , \"glue\");\n- OCCA_TEST_COMPARE(trie.get(\"good\").value() , \"good\");\n-\n- OCCA_TEST_COMPARE(trie.get(\"red\").value() , \"\");\n- OCCA_TEST_COMPARE(trie.get(\"goo\").value() , \"\");\n- OCCA_TEST_COMPARE(trie.get(\"goods\").value() , \"\");\n+ OCCA_TEST_COMPARE(true, trie.has(\"blue\"));\n+ OCCA_TEST_COMPARE(true, trie.has(\"boring\"));\n+ OCCA_TEST_COMPARE(true, trie.has(\"glue\"));\n+ OCCA_TEST_COMPARE(true, trie.has(\"good\"));\n+\n+ OCCA_TEST_COMPARE(false, trie.has(\"red\"));\n+ OCCA_TEST_COMPARE(false, trie.has(\"goo\"));\n+ OCCA_TEST_COMPARE(false, trie.has(\"goods\"));\n+\n+ OCCA_TEST_COMPARE(\"blue\" , trie.getFirst(\"blue\").value());\n+ OCCA_TEST_COMPARE(\"boring\", trie.getFirst(\"boring\").value());\n+ OCCA_TEST_COMPARE(\"glue\" , trie.getFirst(\"glue\").value());\n+ OCCA_TEST_COMPARE(\"good\" , trie.getFirst(\"good\").value());\n+\n+ OCCA_TEST_COMPARE(\"\" , trie.getFirst(\"red\").value());\n+ OCCA_TEST_COMPARE(\"\" , trie.getFirst(\"goo\").value());\n+ OCCA_TEST_COMPARE(\"good\", trie.getFirst(\"goods\").value());\n+\n+ OCCA_TEST_COMPARE(\"blue\" , trie.get(\"blue\").value());\n+ OCCA_TEST_COMPARE(\"boring\", trie.get(\"boring\").value());\n+ OCCA_TEST_COMPARE(\"glue\" , trie.get(\"glue\").value());\n+ OCCA_TEST_COMPARE(\"good\" , trie.get(\"good\").value());\n+\n+ OCCA_TEST_COMPARE(\"\", trie.get(\"red\").value());\n+ OCCA_TEST_COMPARE(\"\", trie.get(\"goo\").value());\n+ OCCA_TEST_COMPARE(\"\", trie.get(\"goods\").value());\n}\nvoid testFrozenSearch(occa::trie_t<std::string> &trie) {\ntrie.freeze();\n- OCCA_TEST_COMPARE(trie.has(\"blue\") , true);\n- OCCA_TEST_COMPARE(trie.has(\"boring\") , true);\n- OCCA_TEST_COMPARE(trie.has(\"glue\") , true);\n- OCCA_TEST_COMPARE(trie.has(\"good\") , true);\n-\n- OCCA_TEST_COMPARE(trie.has(\"red\") , false);\n- OCCA_TEST_COMPARE(trie.has(\"goo\") , false);\n- OCCA_TEST_COMPARE(trie.has(\"goods\") , false);\n-\n- OCCA_TEST_COMPARE(trie.getFirst(\"blue\").value() , \"blue\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"boring\").value() , \"boring\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"glue\").value() , \"glue\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"good\").value() , \"good\");\n-\n- OCCA_TEST_COMPARE(trie.getFirst(\"red\").value() , \"\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"goo\").value() , \"\");\n- OCCA_TEST_COMPARE(trie.getFirst(\"goods\").value() , \"good\");\n-\n- OCCA_TEST_COMPARE(trie.get(\"blue\").value() , \"blue\");\n- OCCA_TEST_COMPARE(trie.get(\"boring\").value() , \"boring\");\n- OCCA_TEST_COMPARE(trie.get(\"glue\").value() , \"glue\");\n- OCCA_TEST_COMPARE(trie.get(\"good\").value() , \"good\");\n-\n- OCCA_TEST_COMPARE(trie.get(\"red\").value() , \"\");\n- OCCA_TEST_COMPARE(trie.get(\"goo\").value() , \"\");\n- OCCA_TEST_COMPARE(trie.get(\"goods\").value() , \"\");\n+ OCCA_TEST_COMPARE(true, trie.has(\"blue\"));\n+ OCCA_TEST_COMPARE(true, trie.has(\"boring\"));\n+ OCCA_TEST_COMPARE(true, trie.has(\"glue\"));\n+ OCCA_TEST_COMPARE(true, trie.has(\"good\"));\n+\n+ OCCA_TEST_COMPARE(false, trie.has(\"red\"));\n+ OCCA_TEST_COMPARE(false, trie.has(\"goo\"));\n+ OCCA_TEST_COMPARE(false, trie.has(\"goods\"));\n+\n+ OCCA_TEST_COMPARE(\"blue\" , trie.getFirst(\"blue\").value());\n+ OCCA_TEST_COMPARE(\"boring\", trie.getFirst(\"boring\").value());\n+ OCCA_TEST_COMPARE(\"glue\" , trie.getFirst(\"glue\").value());\n+ OCCA_TEST_COMPARE(\"good\" , trie.getFirst(\"good\").value());\n+\n+ OCCA_TEST_COMPARE(\"\" , trie.getFirst(\"red\").value());\n+ OCCA_TEST_COMPARE(\"\" , trie.getFirst(\"goo\").value());\n+ OCCA_TEST_COMPARE(\"good\", trie.getFirst(\"goods\").value());\n+\n+ OCCA_TEST_COMPARE(\"blue\" , trie.get(\"blue\").value());\n+ OCCA_TEST_COMPARE(\"boring\", trie.get(\"boring\").value());\n+ OCCA_TEST_COMPARE(\"glue\" , trie.get(\"glue\").value());\n+ OCCA_TEST_COMPARE(\"good\" , trie.get(\"good\").value());\n+\n+ OCCA_TEST_COMPARE(\"\", trie.get(\"red\").value());\n+ OCCA_TEST_COMPARE(\"\", trie.get(\"goo\").value());\n+ OCCA_TEST_COMPARE(\"\", trie.get(\"goods\").value());\n}\nvoid testRefreeze(occa::trie_t<std::string> &trie) {\n- OCCA_TEST_COMPARE(trie.isFrozen, true);\n- OCCA_TEST_COMPARE(trie.has(\"red\"), false);\n+ OCCA_TEST_COMPARE(true , trie.isFrozen);\n+ OCCA_TEST_COMPARE(false, trie.has(\"red\"));\ntrie.add(\"red\", \"red\");\n- OCCA_TEST_COMPARE(trie.isFrozen, false);\n- OCCA_TEST_COMPARE(trie.has(\"red\"), true);\n- OCCA_TEST_COMPARE(trie.get(\"red\").value(), \"red\");\n+ OCCA_TEST_COMPARE(false, trie.isFrozen);\n+ OCCA_TEST_COMPARE(true , trie.has(\"red\"));\n+\n+ OCCA_TEST_COMPARE(\"red\", trie.get(\"red\").value());\ntrie.autoFreeze = true;\ntrie.add(\"blue\", \"red\");\n- OCCA_TEST_COMPARE(trie.isFrozen, true);\n- OCCA_TEST_COMPARE(trie.has(\"red\"), true);\n- OCCA_TEST_COMPARE(trie.get(\"red\").value(), \"red\");\n- OCCA_TEST_COMPARE(trie.get(\"blue\").value(), \"red\");\n+ OCCA_TEST_COMPARE(true, trie.isFrozen);\n+ OCCA_TEST_COMPARE(true, trie.has(\"red\"));\n+\n+ OCCA_TEST_COMPARE(\"red\", trie.get(\"red\").value());\n+ OCCA_TEST_COMPARE(\"red\", trie.get(\"blue\").value());\n}\n" } ]
C++
MIT License
libocca/occa
[Preprocessor] Added macro define tests
378,349
10.01.2017 08:20:38
21,600
304dc6f8e15d6fb099d3d77eb9c7d8ae7b2641a0
[JSON] Updated examples
[ { "change_type": "MODIFY", "old_path": "examples/addVectors/f90/main.f90", "new_path": "examples/addVectors/f90/main.f90", "diff": "@@ -8,12 +8,11 @@ program main\ninteger(4) :: platformID = 0, deviceID = 0, dims\n- character(len=1024) :: Serial_Info = \"mode = Serial\"\n- character(len=1024) :: OpenMP_Info = \"mode = OpenMP , schedule = compact, chunk = 10\"\n- character(len=1024) :: OpenCL_Info = \"mode = OpenCL , platformID = 0, deviceID = 0\"\n- character(len=1024) :: CUDA_Info = \"mode = CUDA , deviceID = 0\"\n- character(len=1024) :: Pthreads_Info = \"mode = Pthreads, threadCount = 4, schedule = compact, pinnedCores = [0, 0, 1, 1]\"\n- character(len=1024) :: COI_Info = \"mode = COI , deviceID = 0\"\n+ character(len=1024) :: Serial_Info : \"mode: 'Serial'\"\n+ character(len=1024) :: OpenMP_Info : \"mode: 'OpenMP' , schedule: 'compact', chunk: 10\"\n+ character(len=1024) :: OpenCL_Info : \"mode: 'OpenCL' , platformID: 0, deviceID: 0\"\n+ character(len=1024) :: CUDA_Info : \"mode: 'CUDA' , deviceID: 0\"\n+ character(len=1024) :: Pthreads_Info: \"mode: 'Threads', threadCount: 4, schedule: 'compact', pinnedCores: [0, 0, 1, 1]\"\nreal(4), allocatable :: a(:), b(:), ab(:)\n" }, { "change_type": "MODIFY", "old_path": "examples/customReduction/main.cpp", "new_path": "examples/customReduction/main.cpp", "diff": "@@ -83,7 +83,7 @@ int main(int argc, char **argv) {\na2[i] = 0;\n}\n- occa::device device(\"mode = Serial\");\n+ occa::device device(\"mode: 'Serial'\");\ncustomReduction squareArray;\nocca::memory o_a, o_a2;\n" }, { "change_type": "MODIFY", "old_path": "examples/fd2d/setuprc", "new_path": "examples/fd2d/setuprc", "diff": "-[DEVICE INFO] \"mode = Serial\"\n-#[DEVICE INFO] \"mode = OpenCL, platformID = 0, deviceID = 1\"\n+[DEVICE INFO] \"mode: 'Serial'\"\n+#[DEVICE INFO] \"mode: 'OpenCL', platformID: 0, deviceID: 1\"\n[STENCIL RADIUS]\n7\n" }, { "change_type": "MODIFY", "old_path": "examples/mandelbulb/setuprc", "new_path": "examples/mandelbulb/setuprc", "diff": "-#[DEVICE INFO] \"mode = Serial, uva = enabled\"\n-#[DEVICE INFO] \"mode = OpenMP, uva = enabled\"\n-[DEVICE INFO] \"mode = OpenCL, platformID = 0, deviceID = 1, uva = enabled\"\n-#[DEVICE INFO] \"mode = CUDA, deviceID = 0, uva = enabled\"\n+#[DEVICE INFO] \"mode: 'Serial', uva: true\"\n+#[DEVICE INFO] \"mode: 'OpenMP', uva: true\"\n+[DEVICE INFO] \"mode: 'OpenCL', platformID: 0, deviceID: 1, uva: true\"\n+#[DEVICE INFO] \"mode: 'CUDA', deviceID: 0, uva: true\"\n[SHAPE FUNCTION] mandelbulb\n#[SHAPE FUNCTION] sphere\n" }, { "change_type": "MODIFY", "old_path": "examples/reduction/main.cpp", "new_path": "examples/reduction/main.cpp", "diff": "@@ -26,7 +26,7 @@ int main(int argc, char **argv) {\nocca::kernelInfo reductionInfo;\n- device.setup(\"mode = Serial\");\n+ device.setup(\"mode: 'Serial'\");\no_a = device.malloc(entries*sizeof(float));\no_aRed = device.malloc(reducedEntries*sizeof(float));\n" }, { "change_type": "MODIFY", "old_path": "examples/usingStreams/main.cpp", "new_path": "examples/usingStreams/main.cpp", "diff": "@@ -21,8 +21,8 @@ int main(int argc, char **argv) {\nocca::stream streamA, streamB;\n- // device.setup(\"mode = CUDA, deviceID = 0\");\n- device.setup(\"mode = OpenCL, platformID = 0, deviceID = 1\");\n+ // device.setup(\"mode: 'CUDA', deviceID: 0\");\n+ device.setup(\"mode: 'OpenCL', platformID: 0, deviceID: 1\");\nstreamA = device.getStream();\nstreamB = device.createStream();\n" } ]
C++
MIT License
libocca/occa
[JSON] Updated examples
378,349
10.01.2017 10:03:04
21,600
ce97c3717b9ffc3f29273399a5226fa84f3a4765
[JSON] Updated Cuda and OpenMP
[ { "change_type": "MODIFY", "old_path": "include/occa/base.hpp", "new_path": "include/occa/base.hpp", "diff": "namespace occa {\n//---[ Globals & Flags ]--------------\n- extern properties settings;\n+ properties& settings();\n//====================================\n//---[ Device Functions ]-------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/kernel.hpp", "new_path": "include/occa/kernel.hpp", "diff": "@@ -150,12 +150,12 @@ namespace occa {\nvoid removeDefine(const std::string &macro);\ntemplate <class TM>\n- inline void addDefine(const std::string &macro, const TM &value) {\n+ inline void addDefine(const std::string &macro, const TM &definedValue) {\nstd::string &headers = (*this)[\"headers\"].getString();\nif (isAnOccaDefine(macro)) {\nheaders += \"\\n#undef \" + macro;\n}\n- headers += \"\\n#define \" + macro + \" \" + occa::toString(value);\n+ headers += \"\\n#define \" + macro + \" \" + occa::toString(definedValue);\n}\nvoid addSource(const std::string &content);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/json.hpp", "new_path": "include/occa/tools/json.hpp", "diff": "@@ -189,7 +189,7 @@ namespace occa {\n}\ntemplate <class TM>\n- TM get(const std::string &s, const TM &default_ = TM()) const {\n+ inline TM get(const std::string &s, const TM &default_ = TM()) const {\nreturn get<TM>(s.c_str(), default_);\n}\n@@ -258,6 +258,8 @@ namespace occa {\nreturn value.boolean == j.value.boolean;\ncase null_:\nreturn true;\n+ default:\n+ return false;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "scripts/occa.cpp", "new_path": "scripts/occa.cpp", "diff": "#include \"occa/parser/tools.hpp\"\n#include \"occa/tools/env.hpp\"\n#include \"occa/tools/io.hpp\"\n+#include \"occa/tools/misc.hpp\"\n#include \"occa/tools/sys.hpp\"\nvoid printHelp();\n@@ -208,7 +209,7 @@ void runClearOn(const std::string &path) {\nif (input == \"y\") {\nstd::string command = \"rm -rf \" + path + \"*\";\n- system(command.c_str());\n+ occa::ignoreResult( system(command.c_str()) );\n}\nelse if (input != \"n\") {\nstd::cout << \" Input must be [y] or [n], ignoring clear command\\n\";\n" }, { "change_type": "MODIFY", "old_path": "src/base.cpp", "new_path": "src/base.cpp", "diff": "namespace occa {\n//---[ Globals & Flags ]--------------\n- properties settings;\n+ properties& settings() {\n+ static properties settings_;\n+ return settings_;\n+ }\n//====================================\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -224,7 +224,7 @@ namespace occa {\nif (k->metadata.nestedKernels) {\nstd::stringstream ss;\n- const bool vc_f = settings.get(\"verboseCompilation\", true);\n+ const bool vc_f = settings().get(\"verboseCompilation\", true);\nfor (int ki = 0; ki < k->metadata.nestedKernels; ++ki) {\nss << ki;\n@@ -243,10 +243,10 @@ namespace occa {\n// Only show compilation the first time\nif (ki == 0) {\n- settings[\"verboseCompilation\"] = false;\n+ settings()[\"verboseCompilation\"] = false;\n}\n}\n- settings[\"verboseCompilation\"] = vc_f;\n+ settings()[\"verboseCompilation\"] = vc_f;\n}\n} else {\nk = dHandle->buildKernel(realFilename,\n" }, { "change_type": "MODIFY", "old_path": "src/lang/c/c_wrapper.cpp", "new_path": "src/lang/c/c_wrapper.cpp", "diff": "@@ -104,7 +104,7 @@ const occaUDim_t occaAllBytes = -1;\nconst void *occaEmptyProperties = (void*) new occa::properties();\nvoid OCCA_RFUNC occaSetVerboseCompilation(const int value) {\n- occa::settings[\"verboseCompilation\"] = (bool) value;\n+ occa::settings()[\"verboseCompilation\"] = (bool) value;\n}\n//======================================\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -50,19 +50,19 @@ namespace occa {\np2pEnabled = false;\n- std::string compiler, compilerFlags;\n+ std::string compiler = properties[\"compiler\"].getString();\n+ std::string compilerFlags = properties[\"compilerFlags\"].getString();\n- if (properties.has(\"compiler\")) {\n- compiler = properties[\"compiler\"];\n- } else if (env::var(\"OCCA_CUDA_COMPILER\").size()) {\n+ if (!compiler.size()) {\n+ if (env::var(\"OCCA_CUDA_COMPILER\").size()) {\ncompiler = env::var(\"OCCA_CUDA_COMPILER\");\n} else {\ncompiler = \"nvcc\";\n}\n+ }\n- if (properties.has(\"compilerFlags\")) {\n- compilerFlags = properties[\"compilerFlags\"];\n- } else if (env::var(\"OCCA_CUDA_COMPILER_FLAGS\").size()) {\n+ if (!compilerFlags.size()) {\n+ if (env::var(\"OCCA_CUDA_COMPILER_FLAGS\").size()) {\ncompilerFlags = env::var(\"OCCA_CUDA_COMPILER_FLAGS\");\n} else {\n#if OCCA_DEBUG_ENABLED\n@@ -71,6 +71,7 @@ namespace occa {\ncompilerFlags = \"\";\n#endif\n}\n+ }\nproperties[\"compiler\"] = compiler;\nproperties[\"compilerFlags\"] = compilerFlags;\n@@ -89,7 +90,7 @@ namespace occa {\n}\nvoid* device::getHandle(const occa::properties &props) {\n- if (props.get(\"type\") == \"context\") {\n+ if (props.get<std::string>(\"type\", \"\") == \"context\") {\nreturn (void*) context;\n}\nreturn (void*) (uintptr_t) handle;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/kernel.cpp", "new_path": "src/modes/cuda/kernel.cpp", "diff": "@@ -59,12 +59,12 @@ namespace occa {\nocca::properties allProps = properties + props;\nname = functionName;\n- if (allProps[\"compilerFlags\"].find(\"-arch=sm_\") == std::string::npos) {\n+ if (allProps.get<std::string>(\"compilerFlags\").find(\"-arch=sm_\") == std::string::npos) {\nconst int major = ((cuda::device*) dHandle)->archMajorVersion;\nconst int minor = ((cuda::device*) dHandle)->archMinorVersion;\nstd::stringstream ss;\nss << \" -arch=sm_\" << major << minor << ' ';\n- allProps[\"compilerFlags\"] += ss.str();\n+ allProps[\"compilerFlags\"].getString() += ss.str();\n}\nhash_t hash = occa::hashFile(filename);\n@@ -85,7 +85,7 @@ namespace occa {\n}\nif (foundBinary) {\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nstd::cout << \"Found cached binary of [\" << io::shortname(filename)\n<< \"] in [\" << io::shortname(binaryFile) << \"]\\n\";\n}\n@@ -110,7 +110,7 @@ namespace occa {\nss.str(),\nallProps[\"footer\"]);\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nstd::cout << \"Compiling [\" << functionName << \"]\\n\";\n}\n@@ -132,7 +132,7 @@ namespace occa {\n<< \" -o \" << ptxBinaryFile;\nconst std::string &ptxCommand = command.str();\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nstd::cout << \"Compiling [\" << functionName << \"]\\n\" << ptxCommand << \"\\n\";\n}\n@@ -156,7 +156,7 @@ namespace occa {\n<< \" -o \" << binaryFile;\nconst std::string &sCommand = command.str();\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nstd::cout << sCommand << '\\n';\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/kernel.cpp", "new_path": "src/modes/opencl/kernel.cpp", "diff": "@@ -84,7 +84,7 @@ namespace occa {\n}\nif (foundBinary) {\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nstd::cout << \"Found cached binary of [\" << io::shortname(filename)\n<< \"] in [\" << io::shortname(binaryFile) << \"]\\n\";\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/utils.cpp", "new_path": "src/modes/opencl/utils.cpp", "diff": "@@ -273,7 +273,7 @@ namespace occa {\nif (error && hash.initialized) {\nio::releaseHash(hash, hashTag);\n}\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nif (hash.initialized) {\nstd::cout << \"OpenCL compiling \" << functionName\n<< \" from [\" << sourceFile << \"]\";\n@@ -327,7 +327,7 @@ namespace occa {\n}\nOCCA_OPENCL_ERROR(\"Kernel (\" + functionName + \"): Creating Kernel\", error);\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nif (sourceFile.size()) {\nstd::cout << \"OpenCL compiled \" << functionName << \" from [\" << sourceFile << \"]\";\n" }, { "change_type": "MODIFY", "old_path": "src/modes/openmp/device.cpp", "new_path": "src/modes/openmp/device.cpp", "diff": "@@ -42,11 +42,11 @@ namespace occa {\nproperties[\"compiler\"]);\nif (openmpFlag != openmp::notSupported) {\n- std::string &compilerFlags = properties[\"compilerFlags\"];\n+ std::string &compilerFlags = properties[\"compilerFlags\"].getString();\ncompilerFlags += ' ';\ncompilerFlags += openmpFlag;\n} else {\n- std::cout << \"Compiler [\" << properties[\"compiler\"]\n+ std::cout << \"Compiler [\" << properties[\"compiler\"].getString()\n<< \"] does not support OpenMP, defaulting to [Serial] mode\\n\";\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/device.cpp", "new_path": "src/modes/serial/device.cpp", "diff": "@@ -36,7 +36,7 @@ namespace occa {\nint vendor;\nstd::string compiler, compilerFlags, compilerEnvScript;\n- if (properties.has(\"compiler\")) {\n+ if (properties.get<std::string>(\"compiler\").size()) {\ncompiler = properties[\"compiler\"].getString();\n} else if (env::var(\"OCCA_CXX\").size()) {\ncompiler = env::var(\"OCCA_CXX\");\n@@ -52,7 +52,7 @@ namespace occa {\nvendor = sys::compilerVendor(compiler);\n- if (properties.has(\"compilerFlags\")) {\n+ if (properties.get<std::string>(\"compilerFlags\").size()) {\ncompilerFlags = properties[\"compilerFlags\"].getString();\n} else if (env::var(\"OCCA_CXXFLAGS\").size()) {\ncompilerFlags = env::var(\"OCCA_CXXFLAGS\");\n@@ -70,7 +70,7 @@ namespace occa {\n#endif\n}\n- if (properties.has(\"compilerEnvScript\")) {\n+ if (properties.get<std::string>(\"compilerEnvScript\").size()) {\ncompilerEnvScript = properties[\"compilerEnvScript\"].getString();\n} else {\n#if (OCCA_OS == OCCA_WINDOWS_OS)\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/kernel.cpp", "new_path": "src/modes/serial/kernel.cpp", "diff": "@@ -71,7 +71,7 @@ namespace occa {\n}\nif (foundBinary) {\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nstd::cout << \"Found cached binary of [\" << io::shortname(filename) << \"] in [\" << io::shortname(binaryFile) << \"]\\n\";\n}\nreturn buildFromBinary(binaryFile, functionName, props);\n@@ -138,7 +138,7 @@ namespace occa {\nconst std::string &sCommand = command.str();\n- if (settings.get(\"verboseCompilation\", true)) {\n+ if (settings().get(\"verboseCompilation\", true)) {\nstd::cout << \"Compiling [\" << functionName << \"]\\n\" << sCommand << \"\\n\";\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/env.cpp", "new_path": "src/tools/env.cpp", "diff": "@@ -52,10 +52,10 @@ namespace occa {\n}\nvoid initSettings() {\n- settings = occa::properties();\n- settings[\"version\"] = \"1.0\";\n- settings[\"parser-version\"] = \"0.1\";\n- settings[\"verboseCompilation\"] = true;\n+ properties &settings_ = settings();\n+ settings_[\"version\"] = \"1.0\";\n+ settings_[\"parser-version\"] = \"0.1\";\n+ settings_[\"verboseCompilation\"] = true;\n}\nvoid initSignalHandling() {\n@@ -85,11 +85,7 @@ namespace occa {\nOCCA_DIR = env::var(\"OCCA_DIR\");\n#ifdef OCCA_COMPILED_DIR\nif (OCCA_DIR.size() == 0) {\n-# if (OCCA_OS & (OCCA_LINUX_OS | OCCA_OSX_OS))\n- OCCA_DIR = OCCA_STRINGIFY(OCCA_COMPILED_DIR);\n-# else\nOCCA_DIR = OCCA_COMPILED_DIR;\n-# endif\n}\n#endif\nOCCA_ERROR(\"Environment variable [OCCA_DIR] is not set\",\n" } ]
C++
MIT License
libocca/occa
[JSON] Updated Cuda and OpenMP
378,349
10.01.2017 11:03:06
21,600
3d0c60f405fef9c223b2d963acdf23621d51e8c5
[Parser] Fixed some segfault issues
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.hpp", "new_path": "parser_sandbox/include/trie.hpp", "diff": "@@ -66,6 +66,7 @@ namespace occa {\n//==================================\ntrieNode_t root;\n+ TM defaultValue;\nstd::vector<TM> values;\nbool isFrozen, autoFreeze;\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/trie.tpp", "new_path": "parser_sandbox/include/trie.tpp", "diff": "@@ -26,7 +26,7 @@ namespace occa {\ntemplate <class TM>\nconst TM& trie_t<TM>::result_t::value() const {\n- return trie->values[valueIdx];\n+ return (0 <= valueIdx) ? trie->values[valueIdx] : trie->defaultValue;\n}\n// ==================================\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/preprocessor.cpp", "new_path": "parser_sandbox/src/preprocessor.cpp", "diff": "@@ -400,9 +400,17 @@ namespace occa {\nreturn;\n}\n}\n- line[cEndLine - line.c_str()] = '\\0';\n+ const int cEndLineIdx = (int) (cEndLine - line.c_str());\n+ const int lineSize = (int) line.size();\n+ if (cEndLineIdx < lineSize) {\n+ line[cEndLineIdx] = '\\0';\n+ }\nlineNumber = (int) primitive(cStartLine);\n+ if (lineSize <= cEndLineIdx) {\n+ return;\n+ }\n+\n// Get filename (if exists)\nchar *cStartFilename = cEndLine + 1;\nchar *cEndFilename = cEnd;\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/specialMacros.cpp", "new_path": "parser_sandbox/src/specialMacros.cpp", "diff": "@@ -88,7 +88,8 @@ namespace occa {\n// __COUNTER__\ncounterMacro_t::counterMacro_t(const preprocessor_t *preprocessor_) :\n- macro_t(preprocessor_) {\n+ macro_t(preprocessor_),\n+ counter(0) {\nname = \"__COUNTER__\";\n}\n" } ]
C++
MIT License
libocca/occa
[Parser] Fixed some segfault issues
378,349
10.01.2017 13:07:56
21,600
e3c01a66b174b4e07f259e4d760f9edd95e5dbbf
[JSON] Removed setupAide to use JSON
[ { "change_type": "DELETE", "old_path": "examples/fd2d/include/setupAide.hpp", "new_path": null, "diff": "-#ifndef OCCA_SETUPAIDE_HEADER\n-#define OCCA_SETUPAIDE_HEADER\n-\n-#include <sys/stat.h>\n-#include <fcntl.h>\n-#include <cstdio>\n-#include <cstdlib>\n-\n-#include <iostream>\n-#include <sstream>\n-#include <vector>\n-#include <map>\n-\n-#include \"occa.hpp\"\n-\n-using std::stringstream;\n-using std::string;\n-using std::vector;\n-using std::map;\n-\n-class setupAide {\n-private:\n- map<string,string> data;\n-\n-public:\n- setupAide();\n- /// Setup from given file\n- setupAide(string fileName);\n-\n- setupAide(const setupAide&);\n- setupAide& operator=(const setupAide&);\n-\n- /// Parse through the read file\n- void read(string setupFile);\n-\n- /// Get arguments for given string\n- string getArgs(string key);\n-\n- template <class T>\n- void getArgs(string key, T &arg);\n-\n- template <class T>\n- void getArgs(string key, vector<T>& args);\n-\n- void getArgs(string key, vector<string>& args, string delimeter);\n-};\n-\n-template <>\n-void setupAide::getArgs(string key, string &t);\n-\n-#include \"setupAide.tpp\"\n-\n-#endif\n" }, { "change_type": "DELETE", "old_path": "examples/fd2d/include/setupAide.tpp", "new_path": null, "diff": "-template <class T>\n-void setupAide::getArgs(string key, T &t) {\n- vector<T> argv;\n-\n- getArgs(key, argv);\n-\n- if (argv.size())\n- t = argv[0];\n-\n- return;\n-}\n-\n-template <class T>\n-void setupAide::getArgs(string key, vector<T> &argv) {\n- stringstream args;\n- T input;\n-\n- args.str( getArgs(key) );\n-\n- while(args >> input)\n- argv.push_back(input);\n-\n- return;\n-}\n" }, { "change_type": "MODIFY", "old_path": "examples/fd2d/main.cpp", "new_path": "examples/fd2d/main.cpp", "diff": "#include <vector>\n#include \"math.h\"\n-#include \"visualizer.hpp\"\n-#include \"setupAide.hpp\"\n#include \"occa.hpp\"\n+#include \"occa/tools/json.hpp\"\n+\n+#include \"visualizer.hpp\"\n#if OCCA_GL_ENABLED\nvisualizer vis;\nint click;\n#endif\n-setupAide setup;\n-\nstd::string deviceInfo;\nint width, height;\n@@ -33,8 +32,8 @@ int mX, mY;\ntFloat freq;\ntFloat minU, maxU;\n-vector<tFloat> u1, u2;\n-vector<tFloat> xyz;\n+std::vector<tFloat> u1, u2;\n+std::vector<tFloat> xyz;\nvoid run();\nvoid setupMesh();\n@@ -103,39 +102,31 @@ void run() {\n}\nvoid setupMesh() {\n- setup.read(\"setuprc\");\n+ occa::json settings = occa::json::loads(\"settings.json\");\n- setup.getArgs(\"DEVICE INFO\", deviceInfo);\n+ deviceInfo = (std::string) settings[\"device\"];\n- setup.getArgs(\"STENCIL RADIUS\" , stencilRadius);\n+ stencilRadius = (int) settings[\"radius\"];\n- setup.getArgs(\"WIDTH\" , width);\n- setup.getArgs(\"HEIGHT\", height);\n+ width = (int) settings[\"width\"];\n+ height = (int) settings[\"height\"];\n- setup.getArgs(\"BX\", Bx);\n- setup.getArgs(\"BY\", By);\n+ Bx = (int) settings[\"bx\"];\n+ By = (int) settings[\"by\"];\n- setup.getArgs(\"DX\", dx);\n- setup.getArgs(\"DT\", dt);\n+ dx = (double) settings[\"dx\"];\n+ dt = (double) settings[\"dt\"];\n- setup.getArgs(\"MIN U\", minU);\n- setup.getArgs(\"MAX U\", maxU);\n+ minU = (double) settings[\"minU\"];\n+ maxU = (double) settings[\"maxU\"];\n- setup.getArgs(\"FREQUENCY\", freq);\n+ freq = (int) settings[\"frequency\"];\nheightScale = 20000.0;\ncurrentTime = 0;\n- std::cout << \"DEVICE INFO = \" << deviceInfo << '\\n'\n- << \"STENCIL RADIUS = \" << stencilRadius << '\\n'\n- << \"WIDTH = \" << width << '\\n'\n- << \"HEIGHT = \" << height << '\\n'\n- << \"DX = \" << dx << '\\n'\n- << \"DT = \" << dt << '\\n'\n- << \"MIN U = \" << minU << '\\n'\n- << \"MAX U = \" << maxU << '\\n'\n- << \"FREQUENCY = \" << freq << '\\n';\n+ std::cout << settings << '\\n';\nu1.resize(width*height, 0);\nu2.resize(width*height, 0);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/fd2d/settings.json", "diff": "+{\n+ device: \"mode: 'Serial'\",\n+\n+ radius: 7,\n+ width : 256,\n+ length: 256,\n+ height: 256,\n+\n+ bx: 16,\n+ by: 16,\n+\n+ dx: 0.01,\n+ dt: 0.001,\n+\n+ frequency: 3,\n+\n+ minU: 0.0,\n+ maxU: 0.0005,\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "examples/fd2d/setuprc", "new_path": null, "diff": "-[DEVICE INFO] \"mode: 'Serial'\"\n-#[DEVICE INFO] \"mode: 'OpenCL', platformID: 0, deviceID: 1\"\n-\n-[STENCIL RADIUS]\n-7\n-\n-[WIDTH] 256\n-[LENGTH] 256\n-[HEIGHT] 256\n-\n-[BX] 16\n-[BY] 16\n-\n-[DX] 0.01\n-[DT] 0.001\n-\n-[FREQUENCY] 3\n-\n-[MIN U] 0.0\n-[MAX U] 0.00005\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "examples/fd2d/src/setupAide.cpp", "new_path": null, "diff": "-#include \"setupAide.hpp\"\n-#include \"occa/tools/io.hpp\"\n-\n-setupAide::setupAide() {}\n-\n-setupAide::setupAide(string setupFile) {\n- read(setupFile);\n-}\n-\n-setupAide::setupAide(const setupAide& sa) {\n- *this = sa;\n-}\n-\n-setupAide& setupAide::operator = (const setupAide& sa) {\n- data = sa.data;\n- return *this;\n-}\n-\n-void setupAide::read(string setupFile) {\n- vector<string> data2;\n- vector<string> keyword2;\n-\n- string args = occa::io::read(setupFile);\n-\n- int size = args.length();\n- string current = \"\";\n- stringstream ss;\n- char c;\n-\n- for (int i=0; i<size; i++) {\n- c = args[i];\n-\n- // Batch strings together\n- if (c == '\\'' || c == '\"') {\n- i++;\n-\n- while(i < size && args[i] != c)\n- current += args[i++];\n-\n- if (i >= size)\n- break;\n-\n- ++i;\n- }\n-\n- // Batch comments\n- else if (c == '/' && i < size && args[i+1] == '*') {\n- i += 2;\n-\n- while( args[i] != '*' || (i < size && args[i+1] != '/') )\n- i++;\n-\n- if (i >= size)\n- break;\n-\n- i++;\n- }\n-\n- // Removing # comments\n- else if (c == '#') {\n- i++;\n-\n- while(i < size && args[i] != '\\n')\n- i++;\n- }\n-\n- // Change \\[\\] to []\n- else if (c == '\\\\' && i < size && (args[i+1] == '[' || args[i+1] == ']')) {\n- current += args[i+1];\n- i += 2;\n- }\n-\n- // Split keywords []\n- else if (c == '[') {\n- if (current != \"\") {\n- data2.push_back(current);\n- current = \"\";\n- }\n-\n- i++;\n-\n- while(i < size && args[i] != ']')\n- current += args[i++];\n-\n- keyword2.push_back(current);\n- current = \"\";\n- }\n-\n- // Else add the character\n- else\n- current += c;\n-\n- if (i >= (size-1) && current.length()) {\n- data2.push_back(current);\n- current = \"\";\n- }\n- }\n-\n- if (current.length())\n- data2.push_back(current);\n-\n- int argc = keyword2.size();\n-\n- for (int i=0; i<argc; i++)\n- data[ keyword2[i] ] = data2[i];\n-}\n-\n-string setupAide::getArgs(string key) {\n- return data[key];\n-}\n-\n-template <>\n-void setupAide::getArgs(string key, string &t) {\n- t = data[key];\n-}\n-\n-void setupAide::getArgs(string key, vector<string> &argv, string delimeter) {\n- string args, current;\n- int size;\n-\n- args = getArgs(key);\n-\n- size = args.length();\n-\n- current = \"\";\n-\n- for (int i=0; i<size; i++) {\n- while( i < size && delimeter.find(args[i]) == string::npos )\n- current += args[i++];\n-\n- if (current.length())\n- argv.push_back(current);\n-\n- current = \"\";\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "examples/mandelbulb/Makefile", "new_path": "examples/mandelbulb/Makefile", "diff": "@@ -21,6 +21,8 @@ else\nendif\nendif\n+flags += -I$(PROJ_DIR)/include\n+\nifeq ($(DOUBLE), 1)\nflags += -D tFloat=double -D tFloat3=occa::double3\nelse\n" }, { "change_type": "DELETE", "old_path": "examples/mandelbulb/include/setupAide.hpp", "new_path": null, "diff": "-#ifndef OCCA_SETUPAIDE_HEADER\n-#define OCCA_SETUPAIDE_HEADER\n-\n-#include <sys/stat.h>\n-#include <fcntl.h>\n-#include <cstdio>\n-#include <cstdlib>\n-\n-#include <iostream>\n-#include <sstream>\n-#include <vector>\n-#include <map>\n-\n-#include \"occa.hpp\"\n-\n-using std::stringstream;\n-using std::string;\n-using std::vector;\n-using std::map;\n-\n-class setupAide {\n-private:\n- map<string,string> data;\n-\n-public:\n- setupAide();\n- /// Setup from given file\n- setupAide(string fileName);\n-\n- setupAide(const setupAide&);\n- setupAide& operator=(const setupAide&);\n-\n- /// Parse through the read file\n- void read(string setupFile);\n-\n- /// Get arguments for given string\n- string getArgs(string key);\n-\n- template <class T>\n- void getArgs(string key, T &arg);\n-\n- template <class T>\n- void getArgs(string key, vector<T>& args);\n-\n- void getArgs(string key, vector<string>& args, string delimeter);\n-};\n-\n-template <>\n-void setupAide::getArgs(string key, string &t);\n-\n-static inline std::string strip(const std::string &str) {\n- const int chars = str.size();\n- const char *c = str.c_str();\n- int start, end;\n-\n- for (start = 0; start < chars; ++start)\n- if ((c[start] != ' ') &&\n- (c[start] != '\\t') &&\n- (c[start] != '\\n') &&\n- (c[start] != '\\r'))\n- break;\n-\n- for (end = (chars - 1); 0 <= end; --end)\n- if ((c[end] != ' ') &&\n- (c[end] != '\\t') &&\n- (c[end] != '\\n') &&\n- (c[end] != '\\r'))\n- break;\n-\n- return str.substr(start, end - start + 1);\n-}\n-\n-#include \"setupAide.tpp\"\n-\n-#endif\n" }, { "change_type": "DELETE", "old_path": "examples/mandelbulb/include/setupAide.tpp", "new_path": null, "diff": "-template <class T>\n-void setupAide::getArgs(string key, T &t) {\n- vector<T> argv;\n-\n- getArgs(key, argv);\n-\n- if (argv.size())\n- t = argv[0];\n-\n- return;\n-}\n-\n-template <class T>\n-void setupAide::getArgs(string key, vector<T> &argv) {\n- stringstream args;\n- T input;\n-\n- args.str( getArgs(key) );\n-\n- while(args >> input)\n- argv.push_back(input);\n-\n- return;\n-}\n" }, { "change_type": "MODIFY", "old_path": "examples/mandelbulb/main.cpp", "new_path": "examples/mandelbulb/main.cpp", "diff": "#include \"math.h\"\n#include \"visualizer.hpp\"\n-#include \"setupAide.hpp\"\n#include \"occa.hpp\"\n#include \"occa/array.hpp\"\n@@ -15,8 +14,6 @@ visualizer vis;\nGLuint screenTexID;\n#endif\n-setupAide setup;\n-\nconst tFloat DEPTH_OF_FIELD = 2.5;\nconst tFloat EYE_DISTANCE_FROM_NEAR_FIELD = 2.2;\nconst tFloat DEG_TO_RAD = (M_PI / 180.0);\n@@ -113,20 +110,18 @@ void glRun() {\n#endif\nvoid readSetupFile() {\n- setup.read(\"setuprc\");\n+ occa::json settings = occa::json::loads(\"settings.json\");\n+\n+ deviceInfo = (std::string) settings[\"device\"];\n- setup.getArgs(\"DEVICE INFO\", deviceInfo);\n+ shapeFunction = (std::string) settings[\"shapeFunction\"];\n- setup.getArgs(\"SHAPE FUNCTION\", shapeFunction);\n+ width = (int) settings[\"width\"];\n+ height = (int) settings[\"height\"];\n- setup.getArgs(\"WIDTH\" , width);\n- setup.getArgs(\"HEIGHT\", height);\n- setup.getArgs(\"BATCH_SIZE\", batchSize);\n+ batchSize = (int) settings[\"batchSize\"];\n- std::cout << \"DEVICE INFO = \" << deviceInfo << '\\n'\n- << \"SHAPE FUNCTION = \" << shapeFunction << '\\n'\n- << \"WIDTH = \" << width << '\\n'\n- << \"HEIGHT = \" << height << '\\n';\n+ std::cout << settings << '\\n';\n}\nvoid updateScene() {\n@@ -199,7 +194,7 @@ void setupRenderer() {\nvoid render() {\nvis.placeViewport(0,0);\n- const double startTime = occa::currentTime();\n+ const double startTime = occa::sys::currentTime();\nrayMarcher(rgba,\nlightDirection,\n@@ -208,7 +203,7 @@ void render() {\nocca::finish();\n- const double endTime = occa::currentTime();\n+ const double endTime = occa::sys::currentTime();\nstd::cout << \"Render Time Taken: \" << (endTime - startTime) << '\\n';\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/mandelbulb/settings.json", "diff": "+{\n+ device: \"mode: 'Serial'\",\n+\n+ shapeFunction: \"mandelbulb\",\n+\n+ width: 1000,\n+ height: 800,\n+\n+ batchSize: 128,\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "examples/mandelbulb/setuprc", "new_path": null, "diff": "-#[DEVICE INFO] \"mode: 'Serial', uva: true\"\n-#[DEVICE INFO] \"mode: 'OpenMP', uva: true\"\n-[DEVICE INFO] \"mode: 'OpenCL', platformID: 0, deviceID: 1, uva: true\"\n-#[DEVICE INFO] \"mode: 'CUDA', deviceID: 0, uva: true\"\n-\n-[SHAPE FUNCTION] mandelbulb\n-#[SHAPE FUNCTION] sphere\n-\n-[WIDTH] 1000\n-[HEIGHT] 800\n-\n-[BATCH_SIZE] 128\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "examples/mandelbulb/src/setupAide.cpp", "new_path": null, "diff": "-#include \"setupAide.hpp\"\n-\n-setupAide::setupAide() {}\n-\n-setupAide::setupAide(string setupFile) {\n- read(setupFile);\n-}\n-\n-setupAide::setupAide(const setupAide& sa) {\n- *this = sa;\n-}\n-\n-setupAide& setupAide::operator = (const setupAide& sa) {\n- data = sa.data;\n- return *this;\n-}\n-\n-void setupAide::read(string setupFile) {\n- vector<string> data2;\n- vector<string> keyword2;\n-\n- string args = occa::readFile(setupFile);\n-\n- int size = args.length();\n- string current = \"\";\n- stringstream ss;\n- char c;\n-\n- for (int i=0; i<size; i++) {\n- c = args[i];\n-\n- // Batch strings together\n- if (c == '\\'' || c == '\"') {\n- i++;\n-\n- while(i < size && args[i] != c)\n- current += args[i++];\n-\n- if (i >= size)\n- break;\n-\n- ++i;\n- }\n-\n- // Batch comments\n- else if (c == '/' && i < size && args[i+1] == '*') {\n- i += 2;\n-\n- while( args[i] != '*' || (i < size && args[i+1] != '/') )\n- i++;\n-\n- if (i >= size)\n- break;\n-\n- i++;\n- }\n-\n- // Removing # comments\n- else if (c == '#') {\n- i++;\n-\n- while(i < size && args[i] != '\\n')\n- i++;\n- }\n-\n- // Change \\[\\] to []\n- else if (c == '\\\\' && i < size && (args[i+1] == '[' || args[i+1] == ']')) {\n- current += args[i+1];\n- i += 2;\n- }\n-\n- // Split keywords []\n- else if (c == '[') {\n- if (current != \"\") {\n- data2.push_back(current);\n- current = \"\";\n- }\n-\n- i++;\n-\n- while(i < size && args[i] != ']')\n- current += args[i++];\n-\n- keyword2.push_back(current);\n- current = \"\";\n- }\n-\n- // Else add the character\n- else\n- current += c;\n-\n- if (i >= (size-1) && current.length()) {\n- data2.push_back(current);\n- current = \"\";\n- }\n- }\n-\n- if (current.length())\n- data2.push_back(current);\n-\n- int argc = keyword2.size();\n-\n- for (int i=0; i<argc; i++)\n- data[ keyword2[i] ] = strip(data2[i]);\n-}\n-\n-string setupAide::getArgs(string key) {\n- return data[key];\n-}\n-\n-template <>\n-void setupAide::getArgs(string key, string &t) {\n- t = data[key];\n-}\n-\n-void setupAide::getArgs(string key, vector<string> &argv, string delimeter) {\n- string args, current;\n- int size;\n-\n- args = getArgs(key);\n-\n- size = args.length();\n-\n- current = \"\";\n-\n- for (int i=0; i<size; i++) {\n- while( i < size && delimeter.find(args[i]) == string::npos )\n- current += args[i++];\n-\n- if (current.length())\n- argv.push_back(current);\n-\n- current = \"\";\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/json.hpp", "new_path": "include/occa/tools/json.hpp", "diff": "@@ -102,6 +102,9 @@ namespace occa {\nvoid load(const char *&c);\nvoid load(const std::string &s);\n+ static json loads(const std::string &filename);\n+ void dumps(const std::string &filename);\n+\nvoid loadString(const char *&c);\nvoid loadNumber(const char *&c);\nvoid loadObject(const char *&c);\n" }, { "change_type": "MODIFY", "old_path": "src/tools/json.cpp", "new_path": "src/tools/json.cpp", "diff": "#include <cstring>\n#include \"occa/defines.hpp\"\n+#include \"occa/tools/io.hpp\"\n#include \"occa/tools/json.hpp\"\nnamespace occa {\nconst char json::objectKeyEndChars[] = \" \\t\\r\\n\\v\\f:\";\n- json::json() :\n- type(none_) {}\n+ json::json() {\n+ clear();\n+ }\nvoid json::clear() {\ntype = none_;\n@@ -72,6 +74,14 @@ namespace occa {\nload(c);\n}\n+ json json::loads(const std::string &filename) {\n+ return json(io::read(filename));\n+ }\n+\n+ void json::dumps(const std::string &filename) {\n+ io::write(filename, toString());\n+ }\n+\nvoid json::loadString(const char *&c) {\n// Skip quote\nconst char quote = *c;\n@@ -415,6 +425,7 @@ namespace occa {\nstd::string newIndent = indent + \" \";\nout += '\\n';\nwhile (it != value.object.end()) {\n+ out += newIndent;\nout += '\"';\nout += it->first;\nout += \"\\\": \";\n" } ]
C++
MIT License
libocca/occa
[JSON] Removed setupAide to use JSON
378,349
10.01.2017 16:50:09
21,600
4debef7b2f610485ad1f1903cdc82565a631ebac
[Parser] Cleaned up frames
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/preprocessor.hpp", "new_path": "parser_sandbox/include/preprocessor.hpp", "diff": "@@ -24,27 +24,41 @@ namespace occa {\nstatic const std::string macroEndDelimiters;\n+ //---[ Stack Information ]----------\nclass status_t {\npublic:\nint status, lineNumber;\nstatus_t();\nstatus_t(const int status_, const int lineNumber_);\n+ void clear();\n};\n- //---[ Stack Information ]----------\n- trie_t<char> allFilenames;\n+ class frame_t {\n+ public:\n+ const preprocessor_t *preprocessor;\n+\nint filenameIdx;\n+ char *fileStart;\n+ int fileLineNumber;\n+ int lineNumber;\n- std::vector<std::string> filenames;\n- std::string filename;\n+ frame_t(const preprocessor_t *preprocessor_);\n+ void clear();\n- std::vector<char*> filePointers;\n+ std::string filename() const;\n- std::vector<int> lineNumbers;\n- int lineNumber;\n+ std::string getLineMessage() const;\n+ std::string getLineMessage(const int lineNumber_) const;\n+ };\n+\n+ trie_t<std::string> allFilenames;\n+\n+ std::vector<frame_t> frames;\n+ frame_t currentFrame;\nstd::vector<status_t> statusStack;\n+ status_t currentStatus;\n//==================================\n//---[ Macros and Directives ]------\n@@ -65,8 +79,6 @@ namespace occa {\nstatic directiveTrie_t& getDirectiveTrie();\n- int& getStatus();\n- int& getStatusLineNumber();\nvoid pushStatus(const int status);\nvoid setFilename(const std::string &filename_, const bool add = true);\n@@ -105,17 +117,25 @@ namespace occa {\n//---[ Messages ]-------------------\nvoid printMessage(const std::string &message,\n- const int lineNumber_, const int position,\n+ const int fileLineNumber,\n+ const int errorLineNumber,\n+ const int position,\nconst bool isError) const;\nvoid printError(const std::string &message,\n- const int lineNumber_ = -1, const int position = -1) const;\n+ const int fileLineNumber = -1,\n+ const int errorLineNumber = -1,\n+ const int position = -1) const;\nvoid printFatalError(const std::string &message,\n- const int lineNumber_ = -1, const int position = -1) const;\n+ const int fileLineNumber = -1,\n+ const int errorLineNumber = -1,\n+ const int position = -1) const;\nvoid printWarning(const std::string &message,\n- const int lineNumber_ = -1, const int position = -1) const;\n+ const int fileLineNumber = -1,\n+ const int errorLineNumber = -1,\n+ const int position = -1) const;\n//==================================\n//---[ Overriding Lex Methods ]-----\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/preprocessor.cpp", "new_path": "parser_sandbox/src/preprocessor.cpp", "diff": "#include \"specialMacros.hpp\"\nnamespace occa {\n- //---[ Status ]---------------------\n+ //---[ Stack Information ]------------\n+ //|-----[ Status ]--------------------\nstatic const int reading = (1 << 0);\nstatic const int ignoring = (1 << 1);\nstatic const int finishedIf = (1 << 2);\n+ //|===================================\npreprocessor_t::status_t::status_t() {}\npreprocessor_t::status_t::status_t(const int status_, const int lineNumber_) :\nstatus(status_),\nlineNumber(lineNumber_) {}\n- //==================================\n+\n+ void preprocessor_t::status_t::clear() {\n+ status = reading;\n+ lineNumber = 0;\n+ }\n+\n+ preprocessor_t::frame_t::frame_t(const preprocessor_t *preprocessor_) :\n+ preprocessor(preprocessor_) {\n+ clear();\n+ }\n+\n+ void preprocessor_t::frame_t::clear() {\n+ filenameIdx = 0;\n+ fileStart = NULL;\n+ fileLineNumber = 0;\n+ lineNumber = 0;\n+ }\n+\n+ std::string preprocessor_t::frame_t::filename() const {\n+ const strVector_t &filenames = preprocessor->allFilenames.values;\n+ if (filenameIdx < (int) filenames.size()) {\n+ return filenames[filenameIdx];\n+ }\n+ return \"(source)\";\n+ }\n+\n+ std::string preprocessor_t::frame_t::getLineMessage() const {\n+ return getLineMessage(lineNumber);\n+ }\n+\n+ std::string preprocessor_t::frame_t::getLineMessage(const int lineNumber_) const {\n+ std::string ret;\n+ ret += filename();\n+ ret += ':';\n+ ret += occa::toString(lineNumber_);\n+ ret += '\\n';\n+ return ret;\n+ }\n+ //====================================\npreprocessor_t& getPreprocessor(hash_t &compilerHash) {\nstatic std::map<hash_t, preprocessor_t> preprocessors;\n@@ -34,12 +74,9 @@ namespace occa {\nconst std::string preprocessor_t::macroEndDelimiters = std::string(lex::whitespaceChars) + '(';\npreprocessor_t::preprocessor_t() :\n+ currentFrame(this),\ndirectives(getDirectiveTrie()) {\n- filenameIdx = 0;\n- filename =\"\";\n- lineNumber = 0;\n-\ncompilerMacros.autoFreeze = false;\nmacro_t *specialMacros[5] = {\nnew fileMacro_t(this), // __FILE__\n@@ -60,18 +97,14 @@ namespace occa {\nvoid preprocessor_t::clear() {\nallFilenames.clear();\n- filenameIdx = 0;\n-\n- filenames.clear();\n- filename =\"\";\n- filePointers.clear();\n+ frames.clear();\n+ currentFrame.clear();\n- lineNumbers.clear();\n- lineNumber = 0;\n+ statusStack.clear();\n+ currentStatus.clear();\nsourceMacros.clear();\n- statusStack.clear();\n}\nvoid preprocessor_t::setOutputStream(std::ostream &outputStream_) {\n@@ -103,47 +136,34 @@ namespace occa {\nreturn trie;\n}\n- int& preprocessor_t::getStatus() {\n- return statusStack[statusStack.size() - 1].status;\n- }\n-\n- int& preprocessor_t::getStatusLineNumber() {\n- return statusStack[statusStack.size() - 1].lineNumber;\n- }\n-\nvoid preprocessor_t::pushStatus(const int status) {\n- statusStack.push_back(status_t(status, lineNumber));\n+ statusStack.push_back(currentStatus);\n+ currentStatus.status = status;\n+ currentStatus.lineNumber = currentFrame.lineNumber;\n}\nvoid preprocessor_t::setFilename(const std::string &filename_, const bool add) {\nif (add) {\n- allFilenames.add(filename_, 'u');\n+ allFilenames.add(filename_, filename_);\n}\n- filename = filename_;\n- filenameIdx = allFilenames.get(filename).valueIdx;\n+ currentFrame.filenameIdx = allFilenames.get(filename_).valueIdx;\n}\nvoid preprocessor_t::processFile(const std::string &filename_) {\n- setFilename(filename_);\n- lineNumber = 0;\n-\n- char *c = io::c_read(filename);\n+ char *c = io::c_read(filename_);\n- filenames.push_back(filename);\n- filePointers.push_back(c);\n- lineNumbers.push_back(lineNumber);\n+ frames.push_back(currentFrame);\n+ currentFrame.clear();\n+ setFilename(filename_);\n+ currentFrame.fileStart = c;\nprocess(c);\n::free((void*) c);\n- setFilename(filenames[filenames.size() - 1], false);\n- lineNumber = lineNumbers[lineNumbers.size() - 1];\n-\n- filenames.pop_back();\n- filePointers.pop_back();\n- lineNumbers.pop_back();\n+ currentFrame = frames[frames.size() - 1];\n+ frames.pop_back();\n- if ((filenames.size() == 0) &&\n+ if ((frames.size() == 0) &&\n(0 < statusStack.size())) {\nprintError(\"#if without a closing #endif\");\n}\n@@ -171,7 +191,7 @@ namespace occa {\nif (result.success()) {\nmacro_t * const macro = result.value();\nif ((macro->undefinedLine < 0) ||\n- (lineNumber < macro->undefinedLine)) {\n+ (currentFrame.lineNumber < macro->undefinedLine)) {\nreturn macro;\n}\n}\n@@ -234,7 +254,7 @@ namespace occa {\n// Parse #if[,def], #el[se,if], #endif even when ignored\n// For some reason the preprocessor honors ignored #if/#el/#endif stacks\n- const int status = getStatus();\n+ const int status = currentStatus.status;\nif (!(status & ignoring) ||\n(strncmp(cStart, \"if\" , 2) &&\nstrncmp(cStart, \"el\" , 2) &&\n@@ -249,7 +269,7 @@ namespace occa {\nchar *cStart = c;\nupdatingSkipTo(c, '\\n');\n- int &status = getStatus();\n+ int &status = currentStatus.status;\nif (status & ignoring) {\npushStatus(ignoring | finishedIf);\nreturn;\n@@ -265,7 +285,7 @@ namespace occa {\nchar *cStart = c;\nupdatingSkipTo(c, '\\n');\n- int &status = getStatus();\n+ int &status = currentStatus.status;\nif (status & ignoring) {\npushStatus(ignoring | finishedIf);\nreturn;\n@@ -280,7 +300,7 @@ namespace occa {\nvoid preprocessor_t::processIfndef(char *&c) {\nprocessIfdef(c);\n- int &status = getStatus();\n+ int &status = currentStatus.status;\n// Ifdef already set finishedIf so we can return\nif (status & ignoring) {\nreturn;\n@@ -294,7 +314,7 @@ namespace occa {\n}\nvoid preprocessor_t::processElse(char *&c) {\n- int &status = getStatus();\n+ int &status = currentStatus.status;\nif (status & finishedIf) {\nupdatingSkipTo(c, '\\n');\nreturn;\n@@ -306,7 +326,7 @@ namespace occa {\nupdatingSkipTo(c, '\\n');\nif ((statusStack.size() == 0) ||\n- (getStatus() & ignoring)) {\n+ (currentStatus.status & ignoring)) {\nprintError(\"#endif without #if\");\n}\n@@ -314,7 +334,7 @@ namespace occa {\n}\nvoid preprocessor_t::processDefine(char *&c) {\n- const int thisLineNumber = lineNumber;\n+ const int thisLineNumber = currentFrame.lineNumber;\nchar *cStart = c;\nupdatingSkipTo(c, '\\n');\n@@ -328,7 +348,7 @@ namespace occa {\n}\nvoid preprocessor_t::processUndef(char *&c) {\n- const int thisLineNumber = lineNumber;\n+ const int thisLineNumber = currentFrame.lineNumber;\nchar *cStart = c;\nupdatingSkipToWhitespace(c);\nchar *cEnd = c;\n@@ -405,7 +425,8 @@ namespace occa {\nif (cEndLineIdx < lineSize) {\nline[cEndLineIdx] = '\\0';\n}\n- lineNumber = (int) primitive(cStartLine);\n+ // We subtract one since the NEXT line has the line number given in #line\n+ currentFrame.lineNumber = ((int) primitive(cStartLine)) - 1;\nif (lineSize <= cEndLineIdx) {\nreturn;\n@@ -424,24 +445,19 @@ namespace occa {\n//---[ Messages ]---------------------\nvoid preprocessor_t::printMessage(const std::string &message,\n- const int lineNumber_, const int position,\n+ const int fileLineNumber,\n+ const int errorLineNumber,\n+ const int position,\nconst bool isError) const {\nstd::stringstream ss;\n// /path/to/file:line:pos:\n- const int filenameCount = (int) filenames.size();\n- for (int i = 0; i < (filenameCount - 1); ++i) {\n- ss << filenames[i] << ':' << lineNumbers[i] << '\\n';\n- }\n- if (filenameCount == 0) {\n- ss << \"(source)\" << ':' << lineNumber_;\n- if (0 <= position) {\n- ss << ':' << position;\n- }\n+ const int frameCount = frames.size();\n+ for (int i = 0; i < frameCount; ++i) {\n+ if (i < (frameCount - 1)) {\n+ ss << frames[i].getLineMessage() << '\\n';\n} else {\n- ss << filename << ':' << lineNumber_;\n- if (0 <= position) {\n- ss << ':' << position;\n+ ss << frames[i].getLineMessage(errorLineNumber);\n}\n}\n@@ -451,17 +467,17 @@ namespace occa {\n<< ' ' << message << '\\n';\n// <line>\n- if (filePointers.size()) {\n- const char *c = filePointers[filePointers.size() - 1];\n+ if (currentFrame.fileStart) {\n+ const char *c = currentFrame.fileStart;\nint ln = 0;\nwhile ((*c != '\\0') &&\n- (ln != lineNumber_)) {\n+ (ln != fileLineNumber)) {\nlex::skipTo(c, '\\n');\n++c;\n++ln;\n}\n- if (ln == lineNumber_) {\n+ if (ln == fileLineNumber) {\nconst char *cStart = c;\nlex::skipTo(c, '\\n');\nss << std::string(cStart, c - cStart);\n@@ -477,23 +493,31 @@ namespace occa {\n}\nvoid preprocessor_t::printError(const std::string &message,\n- const int lineNumber_, const int position) const {\n+ const int fileLineNumber,\n+ const int errorLineNumber,\n+ const int position) const {\nprintMessage(message,\n- 0 <= lineNumber_ ? lineNumber_ : lineNumber,\n+ 0 <= fileLineNumber ? fileLineNumber : currentFrame.fileLineNumber,\n+ 0 <= errorLineNumber ? errorLineNumber : currentFrame.lineNumber,\nposition,\ntrue);\n}\nvoid preprocessor_t::printFatalError(const std::string &message,\n- const int lineNumber_, const int position) const {\n- printError(message, lineNumber_, position);\n+ const int fileLineNumber,\n+ const int errorLineNumber,\n+ const int position) const {\n+ printError(message, fileLineNumber, errorLineNumber, position);\n::exit(1);\n}\nvoid preprocessor_t::printWarning(const std::string &message,\n- const int lineNumber_, const int position) const {\n+ const int fileLineNumber,\n+ const int errorLineNumber,\n+ const int position) const {\nprintMessage(message,\n- 0 <= lineNumber_ ? lineNumber_ : lineNumber,\n+ 0 <= fileLineNumber ? fileLineNumber : currentFrame.fileLineNumber,\n+ 0 <= errorLineNumber ? errorLineNumber : currentFrame.lineNumber,\nposition,\nfalse);\n}\n@@ -503,7 +527,8 @@ namespace occa {\nvoid preprocessor_t::updateLines(const char *c, const int chars) {\nfor (int i = 0; i < chars; ++i) {\nif (c[i] == '\\n') {\n- ++lineNumber;\n+ ++currentFrame.fileLineNumber;\n+ ++currentFrame.lineNumber;\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/specialMacros.cpp", "new_path": "parser_sandbox/src/specialMacros.cpp", "diff": "@@ -14,7 +14,7 @@ namespace occa {\n}\nstd::string fileMacro_t::expand(char *&c) const {\n- return preprocessor->filename;\n+ return preprocessor->currentFrame.filename();\n}\n// __LINE__\n@@ -24,7 +24,7 @@ namespace occa {\n}\nstd::string lineMacro_t::expand(char *&c) const {\n- return toString(preprocessor->lineNumber);\n+ return toString(preprocessor->currentFrame.lineNumber);\n}\n// __DATE__\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testMacro.cpp", "new_path": "parser_sandbox/tests/testMacro.cpp", "diff": "#include <sstream>\n+#include \"occa/tools/env.hpp\"\n#include \"occa/tools/string.hpp\"\n#include \"occa/tools/testing.hpp\"\n@@ -75,8 +76,7 @@ void testFunctionMacros() {\nvoid testSpecialMacros() {\nocca::preprocessor_t preprocessor;\n- preprocessor.filename = \"foo\";\n- preprocessor.lineNumber = 10;\n+ preprocessor.process(\"#line 10 foo\");\nchar *c = new char[1];\n@@ -84,10 +84,10 @@ void testSpecialMacros() {\nocca::lineMacro_t lineMacro(&preprocessor); // __LINE__\nocca::counterMacro_t counterMacro(&preprocessor); // __COUNTER__\n- OCCA_TEST_COMPARE(occa::toString(preprocessor.filename),\n+ OCCA_TEST_COMPARE(occa::env::PWD + \"foo\",\nfileMacro.expand(c));\n- OCCA_TEST_COMPARE(occa::toString(preprocessor.lineNumber),\n+ OCCA_TEST_COMPARE(\"9\",\nlineMacro.expand(c));\nOCCA_TEST_COMPARE(\"0\",\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testPreprocessor.cpp", "new_path": "parser_sandbox/tests/testPreprocessor.cpp", "diff": "@@ -164,14 +164,14 @@ void testErrorDefines() {\nvoid testLineDefine() {\nocca::preprocessor_t preprocessor;\npreprocessor.process(\"#line 10\\n\");\n- OCCA_TEST_COMPARE(11,\n- preprocessor.lineNumber);\n+ OCCA_TEST_COMPARE(10,\n+ preprocessor.currentFrame.lineNumber);\npreprocessor.process(\"#line 20 \\\"foo\\\"\\n\");\n- OCCA_TEST_COMPARE(21,\n- preprocessor.lineNumber);\n+ OCCA_TEST_COMPARE(20,\n+ preprocessor.currentFrame.lineNumber);\nOCCA_TEST_COMPARE(occa::env::PWD + \"foo\",\n- preprocessor.filename);\n+ preprocessor.currentFrame.filename());\n}\n#if 0\n" } ]
C++
MIT License
libocca/occa
[Parser] Cleaned up frames
378,349
10.01.2017 17:28:13
21,600
2da54ef66ac15b8daf0e046507c278a03b5c0dc8
[Preprocessor] Added source errors
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/preprocessor.hpp", "new_path": "parser_sandbox/include/preprocessor.hpp", "diff": "@@ -81,8 +81,13 @@ namespace occa {\nvoid pushStatus(const int status);\n- void setFilename(const std::string &filename_, const bool add = true);\n- void processFile(const std::string &filename_);\n+ void setFilename(const std::string &filename, const bool add = true);\n+\n+ void processFile(const std::string &filename);\n+ void processFile(const std::string &filename, char *content);\n+\n+ void processSource(char *c);\n+ void processSource(const char *c);\nvoid process(char *c);\ninline void process(const char *c) {\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/preprocessor.cpp", "new_path": "parser_sandbox/src/preprocessor.cpp", "diff": "@@ -37,16 +37,12 @@ namespace occa {\nvoid preprocessor_t::frame_t::clear() {\nfilenameIdx = 0;\nfileStart = NULL;\n- fileLineNumber = 0;\n- lineNumber = 0;\n+ fileLineNumber = 1;\n+ lineNumber = 1;\n}\nstd::string preprocessor_t::frame_t::filename() const {\n- const strVector_t &filenames = preprocessor->allFilenames.values;\n- if (filenameIdx < (int) filenames.size()) {\n- return filenames[filenameIdx];\n- }\n- return \"(source)\";\n+ return preprocessor->allFilenames.values[filenameIdx];\n}\nstd::string preprocessor_t::frame_t::getLineMessage() const {\n@@ -58,7 +54,6 @@ namespace occa {\nret += filename();\nret += ':';\nret += occa::toString(lineNumber_);\n- ret += '\\n';\nreturn ret;\n}\n//====================================\n@@ -142,24 +137,30 @@ namespace occa {\ncurrentStatus.lineNumber = currentFrame.lineNumber;\n}\n- void preprocessor_t::setFilename(const std::string &filename_, const bool add) {\n+ void preprocessor_t::setFilename(const std::string &filename, const bool add) {\nif (add) {\n- allFilenames.add(filename_, filename_);\n+ allFilenames.add(filename, filename);\n}\n- currentFrame.filenameIdx = allFilenames.get(filename_).valueIdx;\n+ currentFrame.filenameIdx = allFilenames.get(filename).valueIdx;\n}\n- void preprocessor_t::processFile(const std::string &filename_) {\n- char *c = io::c_read(filename_);\n+ void preprocessor_t::processFile(const std::string &filename) {\n+ char *c = io::c_read(filename);\n+ processFile(filename, c);\n+ ::free((void*) c);\n+ }\n+ void preprocessor_t::processFile(const std::string &filename, char *content) {\n+ if (currentFrame.fileStart) {\nframes.push_back(currentFrame);\n+ }\ncurrentFrame.clear();\n- setFilename(filename_);\n- currentFrame.fileStart = c;\n+ setFilename(filename);\n+ currentFrame.fileStart = content;\n- process(c);\n- ::free((void*) c);\n+ process(content);\n+ if (frames.size()) {\ncurrentFrame = frames[frames.size() - 1];\nframes.pop_back();\n@@ -168,6 +169,16 @@ namespace occa {\nprintError(\"#if without a closing #endif\");\n}\n}\n+ }\n+\n+ void preprocessor_t::processSource(char *c) {\n+ processFile(\"(source)\", c);\n+ }\n+\n+ void preprocessor_t::processSource(const char *c) {\n+ std::string s(c);\n+ processFile(\"(source)\", &(s[0]));\n+ }\nvoid preprocessor_t::process(char *c) {\nwhile (*c != '\\0') {\n@@ -454,12 +465,9 @@ namespace occa {\n// /path/to/file:line:pos:\nconst int frameCount = frames.size();\nfor (int i = 0; i < frameCount; ++i) {\n- if (i < (frameCount - 1)) {\nss << frames[i].getLineMessage() << '\\n';\n- } else {\n- ss << frames[i].getLineMessage(errorLineNumber);\n- }\n}\n+ ss << currentFrame.getLineMessage(errorLineNumber);\n// Error/Warning: <message>\\n\nss << \": \"\n@@ -480,7 +488,7 @@ namespace occa {\nif (ln == fileLineNumber) {\nconst char *cStart = c;\nlex::skipTo(c, '\\n');\n- ss << std::string(cStart, c - cStart);\n+ ss << std::string(cStart, c - cStart) << '\\n';\n}\n// ... ^\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testMacro.cpp", "new_path": "parser_sandbox/tests/testMacro.cpp", "diff": "@@ -22,6 +22,7 @@ int main(const int argc, const char **argv) {\nvoid testPlainMacros() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.processSource(\"\");\nocca::macro_t macro(&preprocessor, \"A\");\nOCCA_TEST_COMPARE(macro.name, \"A\");\n@@ -34,6 +35,7 @@ void testPlainMacros() {\nvoid testFunctionMacros() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.processSource(\"\");\nocca::macro_t macro(&preprocessor, \"FOO(A) A\");\nOCCA_TEST_COMPARE(\"\",\n@@ -76,7 +78,7 @@ void testFunctionMacros() {\nvoid testSpecialMacros() {\nocca::preprocessor_t preprocessor;\n- preprocessor.process(\"#line 10 foo\");\n+ preprocessor.processSource(\"#line 10 foo\");\nchar *c = new char[1];\n@@ -103,6 +105,7 @@ void testSpecialMacros() {\nvoid testErrors() {\nocca::preprocessor_t preprocessor;\nstd::stringstream ss;\n+ preprocessor.processSource(\"\");\npreprocessor.setOutputStream(ss);\nocca::macro_t macro(&preprocessor, \"FOO(A) A\");\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testPreprocessor.cpp", "new_path": "parser_sandbox/tests/testPreprocessor.cpp", "diff": "@@ -22,6 +22,8 @@ int main(const int argc, const char **argv) {\nvoid testMacroDefines() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.setFilename(\"(source)\");\n+\npreprocessor.process(\"#define A\\n\");\nOCCA_TEST_COMPARE(\"\",\npreprocessor.applyMacros(\"A\"));\n@@ -72,6 +74,8 @@ void testMacroDefines() {\n#if 0\nvoid testIfElseDefines() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.setFilename(\"(source)\");\n+\nOCCA_TEST_COMPARE(\"\",\npreprocessor.process(\"#ifdef FOO\\n\"\n\"1\\n\"\n@@ -151,6 +155,7 @@ void testIfElseDefines() {\nvoid testErrorDefines() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.setFilename(\"(source)\");\npreprocessor.props[\"exitOnError\"] = false;\npreprocessor.process(\"#error \\\"Error\\\"\\n\");\n@@ -163,6 +168,8 @@ void testErrorDefines() {\nvoid testLineDefine() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.setFilename(\"(source)\");\n+\npreprocessor.process(\"#line 10\\n\");\nOCCA_TEST_COMPARE(10,\npreprocessor.currentFrame.lineNumber);\n@@ -177,6 +184,7 @@ void testLineDefine() {\n#if 0\nvoid testEval() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.setFilename(\"(source)\");\npreprocessor.props[\"exitOnError\"] = false;\n// Types\n" } ]
C++
MIT License
libocca/occa
[Preprocessor] Added source errors
378,349
10.01.2017 23:17:16
21,600
b2e0bda16c456996ae6a5b57d79996a475ff2865
[Parser] Added more warning/error updates
[ { "change_type": "MODIFY", "old_path": "parser_sandbox/include/macro.hpp", "new_path": "parser_sandbox/include/macro.hpp", "diff": "@@ -37,13 +37,16 @@ namespace occa {\nclass macro_t {\npublic:\n+ static const std::string VA_ARGS;\n+\nconst preprocessor_t *preprocessor;\n+ const char *macroStart;\n+ const char *localMacroStart;\n- static const std::string VA_ARGS;\nstd::string name;\nint argc;\n- bool hasVarArgs;\n+ mutable bool hasVarArgs;\nmacroPartVector_t parts;\nint definedLine, undefinedLine;\n@@ -56,7 +59,7 @@ namespace occa {\nvoid load(const char *c);\nvoid loadName(char *&c);\n- void loadArgs(char *&c, macroPartVector_t &argNames, const bool keepWhitespace = false) const;\n+ void loadArgs(char *&c, macroPartVector_t &argNames, const bool loadingArgNames = true) const;\nvoid setParts(char *&c, macroPartVector_t &argNames);\nvoid clear();\n@@ -64,9 +67,9 @@ namespace occa {\nvirtual std::string expand(char *&c) const;\n//---[ Messages ]-------------------\n- void printError(const std::string &message) const;\n- void printFatalError(const std::string &message) const;\n- void printWarning(const std::string &message) const;\n+ void printError(const char *c, const std::string &message) const;\n+ void printFatalError(const char *c, const std::string &message) const;\n+ void printWarning(const char *c, const std::string &message) const;\n//==================================\n};\n//====================================\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/include/preprocessor.hpp", "new_path": "parser_sandbox/include/preprocessor.hpp", "diff": "@@ -27,10 +27,11 @@ namespace occa {\n//---[ Stack Information ]----------\nclass status_t {\npublic:\n- int status, lineNumber;\n+ int status;\n+ const char *filePosition;\nstatus_t();\n- status_t(const int status_, const int lineNumber_);\n+ status_t(const int status_, const char *filePosition_);\nvoid clear();\n};\n@@ -39,8 +40,8 @@ namespace occa {\nconst preprocessor_t *preprocessor;\nint filenameIdx;\n- char *fileStart;\n- int fileLineNumber;\n+ char *fileStart, *fileEnd;\n+ char *filePosition;\nint lineNumber;\nframe_t(const preprocessor_t *preprocessor_);\n@@ -50,6 +51,7 @@ namespace occa {\nstd::string getLineMessage() const;\nstd::string getLineMessage(const int lineNumber_) const;\n+ std::string getLineMessage(const char *c) const;\n};\ntrie_t<std::string> allFilenames;\n@@ -69,6 +71,9 @@ namespace occa {\n//==================================\n//---[ Misc ]-----------------------\n+ bool exitOnFatalError;\n+ mutable int errorCount, warningCount;\n+\nstd::ostream *outputStream;\n//==================================\n@@ -89,10 +94,11 @@ namespace occa {\nvoid processSource(char *c);\nvoid processSource(const char *c);\n- void process(char *c);\n+ void process(char *&c);\ninline void process(const char *c) {\nstd::string s(c);\n- process(&(s[0]));\n+ char *c_ = &(s[0]);\n+ process(c_);\n}\nconst macro_t* getMacro(char *c, const size_t chars);\n@@ -122,25 +128,19 @@ namespace occa {\n//---[ Messages ]-------------------\nvoid printMessage(const std::string &message,\n- const int fileLineNumber,\n- const int errorLineNumber,\n- const int position,\n+ const char *errorPosition,\nconst bool isError) const;\nvoid printError(const std::string &message,\n- const int fileLineNumber = -1,\n- const int errorLineNumber = -1,\n- const int position = -1) const;\n+ const char *errorPosition) const;\nvoid printFatalError(const std::string &message,\n- const int fileLineNumber = -1,\n- const int errorLineNumber = -1,\n- const int position = -1) const;\n+ const char *errorPosition) const;\nvoid printWarning(const std::string &message,\n- const int fileLineNumber = -1,\n- const int errorLineNumber = -1,\n- const int position = -1) const;\n+ const char *errorPosition) const;\n+\n+ void printErrorAndWarningCounts() const;\n//==================================\n//---[ Overriding Lex Methods ]-----\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/macro.cpp", "new_path": "parser_sandbox/src/macro.cpp", "diff": "@@ -28,6 +28,7 @@ namespace occa {\nmacro_t::macro_t(const preprocessor_t *preprocessor_) :\npreprocessor(preprocessor_),\n+ macroStart(NULL),\ndefinedLine(-1),\nundefinedLine(-1) {}\n@@ -36,6 +37,7 @@ namespace occa {\ndefinedLine(-1),\nundefinedLine(-1) {\n+ macroStart = c;\nload(c);\n}\n@@ -44,17 +46,20 @@ namespace occa {\ndefinedLine(-1),\nundefinedLine(-1) {\n+ macroStart = c;\nstd::string s(c);\nload(&(s[0]));\n}\nvoid macro_t::load(const char *c) {\n+ macroStart = c;\nstd::string s(c);\nload(&(s[0]));\n}\nvoid macro_t::load(char *c) {\nclear();\n+ localMacroStart = c;\nloadName(c);\n@@ -66,20 +71,6 @@ namespace occa {\nloadArgs(c, argNames);\nargc = (int) argNames.size();\n- // Check and remove ... from arguments\n- for (int i = 0; i < argc; ++i) {\n- if (argNames[i].str == \"...\") {\n- hasVarArgs = true;\n- if (i != (argc - 1)) {\n- printError(\"Variable arguments (...) must be the last argument\");\n- argNames.resize(i + 1);\n- } else {\n- argNames.pop_back();\n- }\n- argc = i;\n- }\n- }\n-\nsetParts(c, argNames);\n}\n@@ -87,11 +78,11 @@ namespace occa {\nlex::skipWhitespace(c);\nif (*c == '\\0') {\n- printError(\"Macro name missing\");\n+ printError(c, \"Macro name missing\");\nreturn;\n}\nif (!lex::charIsIn(*c, lex::identifierStartChar)) {\n- printError(\"Macro name must be an identifier: [a-zA-Z_]([a-zA-Z0-9_]*)\");\n+ printError(c, \"Macro name must be an identifier: [a-zA-Z_]([a-zA-Z0-9_]*)\");\nreturn;\n}\n@@ -100,13 +91,13 @@ namespace occa {\nname = std::string(nameStart, c - nameStart);\nif (!lex::isWhitespace(*c) && (*c != '(') && (*c != '\\0')) {\n- printWarning(\"Whitespace recommended after macro name\");\n+ printWarning(c, \"Whitespace recommended after macro name\");\n} else {\nlex::skipWhitespace(c);\n}\n}\n- void macro_t::loadArgs(char *&c, macroPartVector_t &argNames, const bool keepWhitespace) const {\n+ void macro_t::loadArgs(char *&c, macroPartVector_t &argNames, const bool loadingArgNames) const {\nstatic std::string startDelimiters = std::string(lex::whitespaceChars) + \"(\";\nstatic std::string endDelimiters(\",)\");\n@@ -122,7 +113,7 @@ namespace occa {\nlex::skipTo(c, ')');\nchar *argsEnd = c;\nif (*argsEnd != ')') {\n- printError(\"Missing closing \\\")\\\"\");\n+ printError(c, \"Missing closing \\\")\\\"\");\n}\nc = argsStart;\n@@ -136,7 +127,7 @@ namespace occa {\nmacroPart_t arg;\narg.str = std::string(argStart, argEnd - argStart);\n- if (keepWhitespace) {\n+ if (loadingArgNames) {\nif (lex::isWhitespace(*start)) {\narg.info |= macroInfo::hasLeftSpace;\n}\n@@ -144,8 +135,17 @@ namespace occa {\narg.info |= macroInfo::hasRightSpace;\n}\n}\n+\n+ if (loadingArgNames && hasVarArgs) {\n+ printFatalError(argStart, \"Variable arguments (...) must be the last argument\");\n+ }\n+\n+ if (loadingArgNames && arg.str == \"...\") {\n+ hasVarArgs = true;\n+ } else {\nargNames.push_back(arg);\n}\n+ }\nc = argsEnd + (*argsEnd == ')');\n}\n@@ -232,6 +232,7 @@ namespace occa {\nname = \"\";\nargc = 0;\n+ hasVarArgs = false;\nparts.clear();\ndefinedLine = -1;\n@@ -254,7 +255,7 @@ namespace occa {\n}\nmacroPartVector_t args;\n- loadArgs(c, args, true);\n+ loadArgs(c, args, false);\nconst int inputArgc = (int) args.size();\nstd::string ret;\n@@ -322,16 +323,19 @@ namespace occa {\n}\n// ---[ Messages ]-------------------\n- void macro_t::printError(const std::string &message) const {\n- preprocessor->printError(message);\n+ void macro_t::printError(const char *c,\n+ const std::string &message) const {\n+ preprocessor->printError(message, macroStart + (c - localMacroStart));\n}\n- void macro_t::printFatalError(const std::string &message) const {\n- preprocessor->printFatalError(message);\n+ void macro_t::printFatalError(const char *c,\n+ const std::string &message) const {\n+ preprocessor->printFatalError(message, macroStart + (c - localMacroStart));\n}\n- void macro_t::printWarning(const std::string &message) const {\n- preprocessor->printWarning(message);\n+ void macro_t::printWarning(const char *c,\n+ const std::string &message) const {\n+ preprocessor->printWarning(message, macroStart + (c - localMacroStart));\n}\n// ==================================\n//====================================\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/src/preprocessor.cpp", "new_path": "parser_sandbox/src/preprocessor.cpp", "diff": "@@ -20,13 +20,13 @@ namespace occa {\npreprocessor_t::status_t::status_t() {}\n- preprocessor_t::status_t::status_t(const int status_, const int lineNumber_) :\n+ preprocessor_t::status_t::status_t(const int status_, const char *filePosition_) :\nstatus(status_),\n- lineNumber(lineNumber_) {}\n+ filePosition(filePosition_) {}\nvoid preprocessor_t::status_t::clear() {\nstatus = reading;\n- lineNumber = 0;\n+ filePosition = NULL;\n}\npreprocessor_t::frame_t::frame_t(const preprocessor_t *preprocessor_) :\n@@ -37,7 +37,8 @@ namespace occa {\nvoid preprocessor_t::frame_t::clear() {\nfilenameIdx = 0;\nfileStart = NULL;\n- fileLineNumber = 1;\n+ fileEnd = NULL;\n+ filePosition = NULL;\nlineNumber = 1;\n}\n@@ -85,6 +86,10 @@ namespace occa {\n}\n// [-] Add actual compiler macros as well\n+ exitOnFatalError = true;\n+ errorCount = 0;\n+ warningCount = 0;\n+\noutputStream = &std::cerr;\npushStatus(reading);\n@@ -134,7 +139,7 @@ namespace occa {\nvoid preprocessor_t::pushStatus(const int status) {\nstatusStack.push_back(currentStatus);\ncurrentStatus.status = status;\n- currentStatus.lineNumber = currentFrame.lineNumber;\n+ currentStatus.filePosition = currentFrame.filePosition;\n}\nvoid preprocessor_t::setFilename(const std::string &filename, const bool add) {\n@@ -157,8 +162,10 @@ namespace occa {\ncurrentFrame.clear();\nsetFilename(filename);\ncurrentFrame.fileStart = content;\n+ currentFrame.fileEnd = content + strlen(content);\n+ currentFrame.filePosition = content;\n- process(content);\n+ process(currentFrame.filePosition);\nif (frames.size()) {\ncurrentFrame = frames[frames.size() - 1];\n@@ -166,7 +173,8 @@ namespace occa {\nif ((frames.size() == 0) &&\n(0 < statusStack.size())) {\n- printError(\"#if without a closing #endif\");\n+ printError(\"#if without a closing #endif\",\n+ currentStatus.filePosition);\n}\n}\n}\n@@ -180,7 +188,7 @@ namespace occa {\nprocessFile(\"(source)\", &(s[0]));\n}\n- void preprocessor_t::process(char *c) {\n+ void preprocessor_t::process(char *&c) {\nwhile (*c != '\\0') {\nupdatingSkipWhitespace(c);\nif (*c == '#') {\n@@ -258,7 +266,7 @@ namespace occa {\nstd::string message = \"Directive \\\"\";\nmessage += std::string(cStart, cEnd - cStart);\nmessage += \"\\\" is not defined\";\n- printError(message);\n+ printError(message, cStart);\nupdatingSkipTo(c, '\\n');\nreturn;\n}\n@@ -334,11 +342,12 @@ namespace occa {\n}\nvoid preprocessor_t::processEndif(char *&c) {\n+ const char *cStart = c;\nupdatingSkipTo(c, '\\n');\nif ((statusStack.size() == 0) ||\n(currentStatus.status & ignoring)) {\n- printError(\"#endif without #if\");\n+ printError(\"#endif without #if\", cStart);\n}\nstatusStack.pop_back();\n@@ -381,9 +390,9 @@ namespace occa {\nline = strip(line);\nif (isError) {\n- printError(line);\n+ printError(line, cStart);\n} else {\n- printWarning(line);\n+ printWarning(line, cStart);\n}\n}\n@@ -427,7 +436,7 @@ namespace occa {\nlex::skipToWhitespace(cEndLine);\nfor (char *c_ = cStartLine; c_ < cEndLine; ++c_) {\nif (!lex::isDigit(*c_)) {\n- printError(\"#line line number must be a simple number\");\n+ printError(\"#line line number must be a simple number\", c_);\nreturn;\n}\n}\n@@ -456,44 +465,58 @@ namespace occa {\n//---[ Messages ]---------------------\nvoid preprocessor_t::printMessage(const std::string &message,\n- const int fileLineNumber,\n- const int errorLineNumber,\n- const int position,\n+ const char *errorPosition,\nconst bool isError) const {\nstd::stringstream ss;\n+ const char *fileStart = currentFrame.fileStart;\n+ const char *fileEnd = currentFrame.fileEnd;\n+\n+ const bool useErrorPosition = (fileStart &&\n+ (fileStart <= errorPosition) &&\n+ (errorPosition < fileEnd));\n- // /path/to/file:line:pos:\n+ // Print filename stack\nconst int frameCount = frames.size();\nfor (int i = 0; i < frameCount; ++i) {\nss << frames[i].getLineMessage() << '\\n';\n}\n- ss << currentFrame.getLineMessage(errorLineNumber);\n+\n+ // Get line number based on errorPosition\n+ int lineNumber = currentFrame.lineNumber;\n+ const char *lineStart = fileStart;\n+\n+ if (useErrorPosition) {\n+ lineNumber = 1;\n+ for (const char *c = fileStart; c < errorPosition; ++c) {\n+ if (*c == '\\n') {\n+ lineStart = c + 1;\n+ ++lineNumber;\n+ }\n+ }\n+ } else {\n+ for (int i = 0; i < lineNumber; ++i) {\n+ lex::skipTo(lineStart, '\\n');\n+ lineStart += (lineStart != '\\0');\n+ }\n+ }\n+ // Print current file with found line number\n+ ss << currentFrame.getLineMessage(lineNumber);\n// Error/Warning: <message>\\n\nss << \": \"\n<< (isError ? red(\"Error:\") : yellow(\"Warning:\"))\n<< ' ' << message << '\\n';\n- // <line>\n- if (currentFrame.fileStart) {\n- const char *c = currentFrame.fileStart;\n- int ln = 0;\n- while ((*c != '\\0') &&\n- (ln != fileLineNumber)) {\n- lex::skipTo(c, '\\n');\n- ++c;\n- ++ln;\n- }\n+ // Print found line\n+ const char *lineEnd = lineStart;\n+ lex::skipTo(lineEnd, '\\n');\n- if (ln == fileLineNumber) {\n- const char *cStart = c;\n- lex::skipTo(c, '\\n');\n- ss << std::string(cStart, c - cStart) << '\\n';\n- }\n+ if (lineStart < lineEnd) {\n+ ss << std::string(lineStart, lineEnd - lineStart) << '\\n';\n// ... ^\n- if (0 <= position) {\n- ss << std::string(position, ' ') << green(\"^\") << '\\n';\n+ if (useErrorPosition) {\n+ ss << std::string(errorPosition - lineStart, ' ') << green(\"^\") << '\\n';\n}\n}\n@@ -501,33 +524,46 @@ namespace occa {\n}\nvoid preprocessor_t::printError(const std::string &message,\n- const int fileLineNumber,\n- const int errorLineNumber,\n- const int position) const {\n- printMessage(message,\n- 0 <= fileLineNumber ? fileLineNumber : currentFrame.fileLineNumber,\n- 0 <= errorLineNumber ? errorLineNumber : currentFrame.lineNumber,\n- position,\n- true);\n+ const char *errorPosition) const {\n+ printMessage(message, errorPosition, true);\n+ ++errorCount;\n}\nvoid preprocessor_t::printFatalError(const std::string &message,\n- const int fileLineNumber,\n- const int errorLineNumber,\n- const int position) const {\n- printError(message, fileLineNumber, errorLineNumber, position);\n- ::exit(1);\n+ const char *errorPosition) const {\n+ printMessage(message, errorPosition, true);\n+ ++errorCount;\n+ if (exitOnFatalError) {\n+ printErrorAndWarningCounts();\n+ throw 1;\n+ }\n}\nvoid preprocessor_t::printWarning(const std::string &message,\n- const int fileLineNumber,\n- const int errorLineNumber,\n- const int position) const {\n- printMessage(message,\n- 0 <= fileLineNumber ? fileLineNumber : currentFrame.fileLineNumber,\n- 0 <= errorLineNumber ? errorLineNumber : currentFrame.lineNumber,\n- position,\n- false);\n+ const char *errorPosition) const {\n+ printMessage(message, errorPosition, false);\n+ ++warningCount;\n+ }\n+\n+ void preprocessor_t::printErrorAndWarningCounts() const {\n+ if (warningCount) {\n+ *outputStream << warningCount << \" warning\";\n+ if (1 < warningCount) {\n+ *outputStream << 's';\n+ }\n+ }\n+ if (errorCount) {\n+ if (warningCount) {\n+ *outputStream << \" and \";\n+ }\n+ *outputStream << errorCount << \" error\";\n+ if (1 < errorCount) {\n+ *outputStream << 's';\n+ }\n+ }\n+ if (warningCount || errorCount) {\n+ *outputStream << \" generated.\\n\";\n+ }\n}\n//====================================\n@@ -535,7 +571,6 @@ namespace occa {\nvoid preprocessor_t::updateLines(const char *c, const int chars) {\nfor (int i = 0; i < chars; ++i) {\nif (c[i] == '\\n') {\n- ++currentFrame.fileLineNumber;\n++currentFrame.lineNumber;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "parser_sandbox/tests/testMacro.cpp", "new_path": "parser_sandbox/tests/testMacro.cpp", "diff": "@@ -22,6 +22,7 @@ int main(const int argc, const char **argv) {\nvoid testPlainMacros() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.exitOnFatalError = false;\npreprocessor.processSource(\"\");\nocca::macro_t macro(&preprocessor, \"A\");\n@@ -35,6 +36,7 @@ void testPlainMacros() {\nvoid testFunctionMacros() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.exitOnFatalError = false;\npreprocessor.processSource(\"\");\nocca::macro_t macro(&preprocessor, \"FOO(A) A\");\n@@ -78,6 +80,7 @@ void testFunctionMacros() {\nvoid testSpecialMacros() {\nocca::preprocessor_t preprocessor;\n+ preprocessor.exitOnFatalError = false;\npreprocessor.processSource(\"#line 10 foo\");\nchar *c = new char[1];\n@@ -105,9 +108,11 @@ void testSpecialMacros() {\nvoid testErrors() {\nocca::preprocessor_t preprocessor;\nstd::stringstream ss;\n- preprocessor.processSource(\"\");\n+ preprocessor.exitOnFatalError = false;\npreprocessor.setOutputStream(ss);\n+ preprocessor.processSource(\"\");\n+ // Missing closing )\nocca::macro_t macro(&preprocessor, \"FOO(A) A\");\nmacro.expand(\"(1\");\n" } ]
C++
MIT License
libocca/occa
[Parser] Added more warning/error updates
378,349
22.01.2017 14:01:26
21,600
c99db2d8c7174d703725803ab6617dda46668183
[Device] Added device hashing, [Kernel] Added kernelBuilder to be a device-dependent kernel builder
[ { "change_type": "MODIFY", "old_path": "include/occa/device.hpp", "new_path": "include/occa/device.hpp", "diff": "@@ -70,6 +70,8 @@ namespace occa {\nvirtual bool hasSeparateMemorySpace() = 0;\n+ virtual hash_t hash() = 0;\n+\n// |---[ Stream ]------------------\nvirtual stream_t createStream() = 0;\nvirtual void freeStream(stream_t s) = 0;\n@@ -120,11 +122,13 @@ namespace occa {\ndevice(const occa::device &d);\ndevice& operator = (const occa::device &d);\n+ bool isInitialized();\n+\nconst std::string& mode();\nocca::properties& properties();\nvoid* getHandle(const occa::properties &props = occa::properties());\n- device_v* getDHandle();\n+ device_v* getDHandle() const;\nvoid setup(const occa::properties &props);\n@@ -180,6 +184,9 @@ namespace occa {\nvoid free();\n};\n+\n+ template <>\n+ hash_t hash(const occa::device &device);\n//====================================\n//---[ stream ]-----------------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/kernel.hpp", "new_path": "include/occa/kernel.hpp", "diff": "@@ -216,13 +216,13 @@ namespace occa {\nvoid* getHandle(const occa::properties &props = occa::properties());\nkernel_v* getKHandle();\n+ occa::device getDevice();\n+\nconst std::string& mode();\nconst std::string& name();\nconst std::string& sourceFilename();\nconst std::string& binaryFilename();\n- occa::device getDevice();\n-\nint maxDims();\ndim maxOuterDims();\ndim maxInnerDims();\n@@ -238,6 +238,40 @@ namespace occa {\nvoid free();\n};\n//====================================\n+\n+ //---[ kernel builder ]---------------\n+ typedef std::map<hash_t,occa::kernel> hashedKernelMap_t;\n+ typedef hashedKernelMap_t::iterator hashedKernelMapIterator;\n+ typedef hashedKernelMap_t::const_iterator cHashedKernelMapIterator;\n+\n+ class kernelBuilder {\n+ private:\n+ std::string filename_;\n+ std::string function_;\n+ occa::properties props_;\n+\n+ hashedKernelMap_t kernelMap;\n+\n+ public:\n+ kernelBuilder();\n+ kernelBuilder(const std::string &filename,\n+ const std::string &function,\n+ const occa::properties &props = occa::properties());\n+\n+ kernelBuilder(const kernelBuilder &k);\n+ kernelBuilder& operator = (const kernelBuilder &k);\n+\n+ bool isInitialized();\n+\n+ void use(const std::string &filename,\n+ const std::string &function,\n+ const occa::properties &props = occa::properties());\n+\n+ occa::kernel operator [] (occa::device device);\n+\n+ void free();\n+ };\n+ //====================================\n}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "include/occa/memory.hpp", "new_path": "include/occa/memory.hpp", "diff": "@@ -125,11 +125,15 @@ namespace occa {\nmemory(const memory &m);\nmemory& operator = (const memory &m);\n+ bool isInitialized();\n+\nmemory& swap(memory &m);\nmemory_v* getMHandle();\ndevice_v* getDHandle();\n+ occa::device getDevice();\n+\noperator kernelArg() const;\nconst std::string& mode();\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/device.hpp", "new_path": "include/occa/modes/cuda/device.hpp", "diff": "namespace occa {\nnamespace cuda {\nclass device : public occa::device_v {\n+ hash_t hash_;\n+\npublic:\nint archMajorVersion, archMinorVersion;\nbool p2pEnabled;\n@@ -49,6 +51,8 @@ namespace occa {\nbool hasSeparateMemorySpace();\n+ hash_t hash();\n+\n// |---[ Stream ]----------------\nstream_t createStream();\nvoid freeStream(stream_t s);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/opencl/device.hpp", "new_path": "include/occa/modes/opencl/device.hpp", "diff": "namespace occa {\nnamespace opencl {\nclass device : public occa::device_v {\n+ hash_t hash_;\n+\npublic:\nint platformID, deviceID;\n@@ -49,6 +51,8 @@ namespace occa {\nbool hasSeparateMemorySpace();\n+ hash_t hash();\n+\n// |---[ Stream ]----------------\nstream_t createStream();\nvoid freeStream(stream_t s);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/serial/device.hpp", "new_path": "include/occa/modes/serial/device.hpp", "diff": "namespace occa {\nnamespace serial {\nclass device : public occa::device_v {\n+ hash_t hash_;\n+\npublic:\ndevice(const occa::properties &properties_ = occa::properties());\n~device();\n@@ -40,6 +42,8 @@ namespace occa {\nbool hasSeparateMemorySpace();\n+ hash_t hash();\n+\n// |---[ Stream ]----------------\nstream_t createStream();\nvoid freeStream(stream_t s);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/json.hpp", "new_path": "include/occa/tools/json.hpp", "diff": "@@ -221,6 +221,8 @@ namespace occa {\nreturn *this;\n}\n+ bool isInitialized();\n+\njson& load(const char *&c);\njson& load(const std::string &s);\n@@ -451,6 +453,9 @@ namespace occa {\nvoid toString(std::string &out, const std::string &indent = \"\") const;\n};\n+ template <>\n+ hash_t hash(const occa::json &json);\n+\nstd::ostream& operator << (std::ostream &out, const json &j);\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/properties.hpp", "new_path": "include/occa/tools/properties.hpp", "diff": "@@ -32,6 +32,8 @@ namespace occa {\nproperties(const char *c);\nproperties(const std::string &s);\n+ bool isInitialized();\n+\nvoid load(const char *&c);\nvoid load(const std::string &s);\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -81,11 +81,15 @@ namespace occa {\nreturn *this;\n}\n+ bool device::isInitialized() {\n+ return (dHandle != NULL);\n+ }\n+\nvoid* device::getHandle(const occa::properties &props) {\nreturn dHandle->getHandle(props);\n}\n- device_v* device::getDHandle() {\n+ device_v* device::getDHandle() const {\nreturn dHandle;\n}\n@@ -361,6 +365,9 @@ namespace occa {\n// |=================================\nvoid device::free() {\n+ if (dHandle == NULL) {\n+ return;\n+ }\nconst int streamCount = dHandle->streams.size();\nfor (int i = 0; i < streamCount; ++i)\n@@ -371,6 +378,11 @@ namespace occa {\ndelete dHandle;\ndHandle = NULL;\n}\n+\n+ template <>\n+ hash_t hash(const occa::device &device) {\n+ return device.getDHandle()->hash();\n+ }\n//====================================\n//---[ stream ]-----------------------\n" }, { "change_type": "MODIFY", "old_path": "src/kernel.cpp", "new_path": "src/kernel.cpp", "diff": "@@ -302,6 +302,10 @@ namespace occa {\nreturn kHandle;\n}\n+ occa::device kernel::getDevice() {\n+ return occa::device(kHandle->dHandle);\n+ }\n+\nconst std::string& kernel::mode() {\nreturn device(kHandle->dHandle).mode();\n}\n@@ -318,10 +322,6 @@ namespace occa {\nreturn kHandle->binaryFilename;\n}\n- occa::device kernel::getDevice() {\n- return occa::device(kHandle->dHandle);\n- }\n-\nvoid kernel::setWorkingDims(int dims, occa::dim inner, occa::dim outer) {\nfor (int i = 0; i < dims; ++i) {\ninner[i] += (inner[i] ? 0 : 1);\n@@ -395,6 +395,9 @@ namespace occa {\n#include \"operators/definitions.cpp\"\nvoid kernel::free() {\n+ if (kHandle == NULL) {\n+ return;\n+ }\nif (kHandle->nestedKernelCount()) {\nfor (int k = 0; k < kHandle->nestedKernelCount(); ++k)\nkHandle->nestedKernels[k].free();\n@@ -406,4 +409,59 @@ namespace occa {\nkHandle = NULL;\n}\n//====================================\n+\n+ //---[ kernel builder ]---------------\n+ kernelBuilder::kernelBuilder() {}\n+\n+ kernelBuilder::kernelBuilder(const std::string &filename,\n+ const std::string &function,\n+ const occa::properties &props) :\n+ filename_(filename),\n+ function_(function),\n+ props_(props) {}\n+\n+ kernelBuilder::kernelBuilder(const kernelBuilder &k) :\n+ filename_(k.filename_),\n+ function_(k.function_),\n+ props_(k.props_),\n+ kernelMap(k.kernelMap) {}\n+\n+ kernelBuilder& kernelBuilder::operator = (const kernelBuilder &k) {\n+ filename_ = k.filename_;\n+ function_ = k.function_;\n+ props_ = k.props_;\n+ kernelMap = k.kernelMap;\n+ return *this;\n+ }\n+\n+ bool kernelBuilder::isInitialized() {\n+ return (0 < filename_.size());\n+ }\n+\n+ void kernelBuilder::use(const std::string &filename,\n+ const std::string &function,\n+ const occa::properties &props) {\n+ free();\n+ filename_ = filename;\n+ function_ = function;\n+ props_ = props;\n+ }\n+\n+ occa::kernel kernelBuilder::operator [] (occa::device device) {\n+ occa::kernel &k = kernelMap[occa::hash(device)];\n+ if (!k.isInitialized()) {\n+ k = device.buildKernel(filename_, function_, props_);\n+ }\n+ return k;\n+ }\n+\n+ void kernelBuilder::free() {\n+ hashedKernelMapIterator it = kernelMap.begin();\n+ while (it != kernelMap.end()) {\n+ it->second.free();\n+ ++it;\n+ }\n+ }\n+\n+ //====================================\n}\n" }, { "change_type": "MODIFY", "old_path": "src/memory.cpp", "new_path": "src/memory.cpp", "diff": "@@ -104,6 +104,10 @@ namespace occa {\nreturn *this;\n}\n+ bool memory::isInitialized() {\n+ return (mHandle != NULL);\n+ }\n+\nmemory_v* memory::getMHandle() {\nreturn mHandle;\n}\n@@ -112,6 +116,10 @@ namespace occa {\nreturn mHandle->dHandle;\n}\n+ occa::device memory::getDevice() {\n+ return occa::device(mHandle->dHandle);\n+ }\n+\nmemory::operator kernelArg() const {\nkernelArg kArg = mHandle->makeKernelArg();\nkArg.arg.mHandle = mHandle;\n@@ -325,6 +333,9 @@ namespace occa {\n}\nvoid memory::deleteRefs(const bool freeMemory) {\n+ if (mHandle == NULL) {\n+ return;\n+ }\nmHandle->dHandle->bytesAllocated -= (mHandle->size);\nif (mHandle->uvaPtr) {\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -105,6 +105,15 @@ namespace occa {\nreturn true;\n}\n+ hash_t device::hash() {\n+ if (!hash_.initialized) {\n+ hash_ ^= occa::hash(properties);\n+ hash_ ^= occa::hash(archMajorVersion);\n+ hash_ ^= occa::hash(archMinorVersion);\n+ }\n+ return hash_;\n+ }\n+\n// |---[ Stream ]----------------\nstream_t device::createStream() {\nCUstream *retStream = new CUstream;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/device.cpp", "new_path": "src/modes/opencl/device.cpp", "diff": "@@ -94,6 +94,13 @@ namespace occa {\nreturn true;\n}\n+ hash_t device::hash() {\n+ if (!hash_.initialized) {\n+ hash_ = occa::hash(properties);\n+ }\n+ return hash_;\n+ }\n+\n// |---[ Stream ]----------------\nstream_t device::createStream() {\ncl_int error;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/device.cpp", "new_path": "src/modes/serial/device.cpp", "diff": "@@ -123,6 +123,13 @@ namespace occa {\nreturn false;\n}\n+ hash_t device::hash() {\n+ if (!hash_.initialized) {\n+ hash_ = occa::hash(properties);\n+ }\n+ return hash_;\n+ }\n+\nvoid device::waitFor(streamTag tag) {}\nstream_t device::createStream() {\n" }, { "change_type": "MODIFY", "old_path": "src/tools/json.cpp", "new_path": "src/tools/json.cpp", "diff": "@@ -61,6 +61,10 @@ namespace occa {\nreturn *this;\n}\n+ bool json::isInitialized() {\n+ return (type != none_);\n+ }\n+\njson& json::load(const char *&c) {\nclear();\nlex::skipWhitespace(c);\n@@ -460,6 +464,7 @@ namespace occa {\n++it;\n}\n}\n+ out += indent;\nout += '}';\nbreak;\n}\n@@ -474,6 +479,7 @@ namespace occa {\nout += '\\n';\n}\n}\n+ out += indent;\nout += ']';\nbreak;\n}\n@@ -485,6 +491,11 @@ namespace occa {\n}}\n}\n+ template <>\n+ hash_t hash(const occa::json &json) {\n+ return json.hash();\n+ }\n+\nstd::ostream& operator << (std::ostream &out, const json &j) {\nout << j.toString() << '\\n';\nreturn out;\n" }, { "change_type": "MODIFY", "old_path": "src/tools/properties.cpp", "new_path": "src/tools/properties.cpp", "diff": "@@ -37,6 +37,10 @@ namespace occa {\nload(s);\n}\n+ bool properties::isInitialized() {\n+ return (0 < value.object.size());\n+ }\n+\nvoid properties::load(const char *&c) {\nloadObject(c);\n}\n" } ]
C++
MIT License
libocca/occa
[Device] Added device hashing, [Kernel] Added kernelBuilder to be a device-dependent kernel builder
378,349
27.01.2017 15:33:59
18,000
05f5f0688578b69f59d252a4d58ed27edb152719
[Memory] Adding const to functions
[ { "change_type": "MODIFY", "old_path": "include/occa/memory.hpp", "new_path": "include/occa/memory.hpp", "diff": "@@ -125,18 +125,18 @@ namespace occa {\nmemory(const memory &m);\nmemory& operator = (const memory &m);\n- bool isInitialized();\n+ bool isInitialized() const;\nmemory& swap(memory &m);\nmemory_v* getMHandle();\ndevice_v* getDHandle();\n- occa::device getDevice();\n+ occa::device getDevice() const;\noperator kernelArg() const;\n- const std::string& mode();\n+ const std::string& mode() const;\nudim_t size() const;\n" }, { "change_type": "MODIFY", "old_path": "src/memory.cpp", "new_path": "src/memory.cpp", "diff": "@@ -104,7 +104,7 @@ namespace occa {\nreturn *this;\n}\n- bool memory::isInitialized() {\n+ bool memory::isInitialized() const {\nreturn (mHandle != NULL);\n}\n@@ -116,7 +116,7 @@ namespace occa {\nreturn mHandle->dHandle;\n}\n- occa::device memory::getDevice() {\n+ occa::device memory::getDevice() const {\nreturn occa::device(mHandle->dHandle);\n}\n@@ -127,7 +127,7 @@ namespace occa {\nreturn kArg;\n}\n- const std::string& memory::mode() {\n+ const std::string& memory::mode() const {\nreturn device(mHandle->dHandle).mode();\n}\n" } ]
C++
MIT License
libocca/occa
[Memory] Adding const to functions
378,349
29.01.2017 14:48:36
21,600
7dd5b26c0c872fc7db81e9709b7791c255a8bdf8
[Device] Fixed LAUNCH_KERNEL define property
[ { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -221,7 +221,8 @@ namespace occa {\nfunctionName,\nprops);\n- occa::properties launchKernelProps(\"OCCA_LAUNCH_KERNEL: 1\");\n+ occa::properties launchKernelProps;\n+ launchKernelProps[\"kernel/defines/OCCA_LAUNCH_KERNEL\"] = 1;\nk->build(parsedFile,\nfunctionName,\n" } ]
C++
MIT License
libocca/occa
[Device] Fixed LAUNCH_KERNEL define property
378,349
29.01.2017 21:21:22
21,600
5a3c801010d8dd34519433ef3b19fa86e0d5bcef
[Vector] Removed type3 (type3's are typedefed to type4)
[ { "change_type": "MODIFY", "old_path": "include/occa/array/array.hpp", "new_path": "include/occa/array/array.hpp", "diff": "@@ -238,7 +238,8 @@ namespace occa {\nconst udim_t i3, const udim_t i4, const udim_t i5);\n//==================================\n- //---[ Operators ]------------------\n+ //---[ Arithmetic Operators ]-------\n+\n//==================================\n//---[ Syncs ]----------------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/vector.hpp", "new_path": "include/occa/vector.hpp", "diff": "@@ -217,197 +217,6 @@ namespace occa {\n}\n//====================================\n- //---[ type3 ]------------------------\n- template <class TM>\n- class type3 {\n- public:\n- union { TM s0, x; };\n- union { TM s1, y; };\n- union { TM s2, z; };\n-\n- inline type3() :\n- x(0),\n- y(0),\n- z(0) {}\n-\n- inline type3(const TM &x_) :\n- x(x_),\n- y(0),\n- z(0) {}\n-\n- inline type3(const TM &x_,\n- const TM &y_) :\n- x(x_),\n- y(y_),\n- z(0) {}\n-\n- inline type3(const TM &x_,\n- const TM &y_,\n- const TM &z_) :\n- x(x_),\n- y(y_),\n- z(z_) {}\n- };\n-\n- template <class TM>\n- inline type3<TM> operator + (const type3<TM> &a, const type3<TM> &b) {\n- return type3<TM>(a.x + b.x,\n- a.y + b.y,\n- a.z + b.z);\n- }\n-\n- template <class TM>\n- inline type3<TM> operator + (const TM a, const type3<TM> &b) {\n- return type3<TM>(a + b.x,\n- a + b.y,\n- a + b.z);\n- }\n-\n- template <class TM>\n- inline type3<TM> operator + (const type3<TM> &a, const TM b) {\n- return type3<TM>(a.x + b,\n- a.y + b,\n- a.z + b);\n- }\n-\n- template <class TM>\n- inline type3<TM>& operator += ( type3<TM> &a, const type3<TM> &b) {\n- a.x += b.x;\n- a.y += b.y;\n- a.z += b.z;\n- return a;\n- }\n-\n- template <class TM>\n- inline type3<TM>& operator += ( type3<TM> &a, const TM b) {\n- a.x += b;\n- a.y += b;\n- a.z += b;\n- return a;\n- }\n-\n- template <class TM>\n- inline type3<TM> operator - (const type3<TM> &a, const type3<TM> &b) {\n- return type3<TM>(a.x - b.x,\n- a.y - b.y,\n- a.z - b.z);\n- }\n-\n- template <class TM>\n- inline type3<TM> operator - (const TM a, const type3<TM> &b) {\n- return type3<TM>(a - b.x,\n- a - b.y,\n- a - b.z);\n- }\n-\n- template <class TM>\n- inline type3<TM> operator - (const type3<TM> &a, const TM b) {\n- return type3<TM>(a.x - b,\n- a.y - b,\n- a.z - b);\n- }\n-\n- template <class TM>\n- inline type3<TM>& operator -= ( type3<TM> &a, const type3<TM> &b) {\n- a.x -= b.x;\n- a.y -= b.y;\n- a.z -= b.z;\n- return a;\n- }\n-\n- template <class TM>\n- inline type3<TM>& operator -= ( type3<TM> &a, const TM b) {\n- a.x -= b;\n- a.y -= b;\n- a.z -= b;\n- return a;\n- }\n-\n- template <class TM>\n- inline type3<TM> operator * (const type3<TM> &a, const type3<TM> &b) {\n- return type3<TM>(a.x * b.x,\n- a.y * b.y,\n- a.z * b.z);\n- }\n-\n- template <class TM>\n- inline type3<TM> operator * (const TM a, const type3<TM> &b) {\n- return type3<TM>(a * b.x,\n- a * b.y,\n- a * b.z);\n- }\n-\n- template <class TM>\n- inline type3<TM> operator * (const type3<TM> &a, const TM b) {\n- return type3<TM>(a.x * b,\n- a.y * b,\n- a.z * b);\n- }\n-\n- template <class TM>\n- inline type3<TM>& operator *= ( type3<TM> &a, const type3<TM> &b) {\n- a.x *= b.x;\n- a.y *= b.y;\n- a.z *= b.z;\n- return a;\n- }\n-\n- template <class TM>\n- inline type3<TM>& operator *= ( type3<TM> &a, const TM b) {\n- a.x *= b;\n- a.y *= b;\n- a.z *= b;\n- return a;\n- }\n-\n- template <class TM>\n- inline type3<TM> operator / (const type3<TM> &a, const type3<TM> &b) {\n- return type3<TM>(a.x / b.x,\n- a.y / b.y,\n- a.z / b.z);\n- }\n-\n- template <class TM>\n- inline type3<TM> operator / (const TM a, const type3<TM> &b) {\n- return type3<TM>(a / b.x,\n- a / b.y,\n- a / b.z);\n- }\n-\n- template <class TM>\n- inline type3<TM> operator / (const type3<TM> &a, const TM b) {\n- return type3<TM>(a.x / b,\n- a.y / b,\n- a.z / b);\n- }\n-\n- template <class TM>\n- inline type3<TM>& operator /= ( type3<TM> &a, const type3<TM> &b) {\n- a.x /= b.x;\n- a.y /= b.y;\n- a.z /= b.z;\n- return a;\n- }\n-\n- template <class TM>\n- inline type3<TM>& operator /= ( type3<TM> &a, const TM b) {\n- a.x /= b;\n- a.y /= b;\n- a.z /= b;\n- return a;\n- }\n-\n- template <class TM>\n- inline std::ostream& operator << (std::ostream &out, const type3<TM>& a) {\n- out << \"[\"\n- << a.x << \", \"\n- << a.y << \", \"\n- << a.z\n- << \"]\\n\";\n- return out;\n- }\n- //====================================\n-\n//---[ type4 ]------------------------\ntemplate <class TM>\nclass type4 {\n@@ -636,43 +445,43 @@ namespace occa {\n//---[ Typedefs ]---------------------\ntypedef type2<unsigned char> uchar2;\n- typedef type3<unsigned char> uchar3;\n+ typedef type4<unsigned char> uchar3;\ntypedef type4<unsigned char> uchar4;\ntypedef type2<char> char2;\n- typedef type3<char> char3;\n+ typedef type4<char> char3;\ntypedef type4<char> char4;\ntypedef type2<unsigned short> ushort2;\n- typedef type3<unsigned short> ushort3;\n+ typedef type4<unsigned short> ushort3;\ntypedef type4<unsigned short> ushort4;\ntypedef type2<short> short2;\n- typedef type3<short> short3;\n+ typedef type4<short> short3;\ntypedef type4<short> short4;\ntypedef type2<unsigned int> uint2;\n- typedef type3<unsigned int> uint3;\n+ typedef type4<unsigned int> uint3;\ntypedef type4<unsigned int> uint4;\ntypedef type2<int> int2;\n- typedef type3<int> int3;\n+ typedef type4<int> int3;\ntypedef type4<int> int4;\ntypedef type2<unsigned long> ulong2;\n- typedef type3<unsigned long> ulong3;\n+ typedef type4<unsigned long> ulong3;\ntypedef type4<unsigned long> ulong4;\ntypedef type2<long> long2;\n- typedef type3<long> long3;\n+ typedef type4<long> long3;\ntypedef type4<long> long4;\ntypedef type2<float> float2;\n- typedef type3<float> float3;\n+ typedef type4<float> float3;\ntypedef type4<float> float4;\ntypedef type2<double> double2;\n- typedef type3<double> double3;\n+ typedef type4<double> double3;\ntypedef type4<double> double4;\n//====================================\n@@ -683,13 +492,6 @@ namespace occa {\n(v.y * v.y));\n}\n- template <class TM>\n- inline double length(const type3<TM> &v) {\n- return sqrt((v.x * v.x) +\n- (v.y * v.y) +\n- (v.z * v.z));\n- }\n-\ntemplate <class TM>\ninline double length(const type4<TM> &v) {\nreturn sqrt((v.x * v.x) +\n@@ -705,14 +507,6 @@ namespace occa {\ninvNorm * v.y);\n}\n- template <class TM>\n- inline type3<TM> normalize(const type3<TM> &v) {\n- const double invNorm = (1.0 / length(v));\n- return type2<TM>(invNorm * v.x,\n- invNorm * v.y,\n- invNorm * v.z);\n- }\n-\ntemplate <class TM>\ninline type4<TM> normalize(const type4<TM> &v) {\nconst double invNorm = (1.0 / length(v));\n@@ -728,13 +522,6 @@ namespace occa {\n(a.y * b.y));\n}\n- template <class TM>\n- inline double dot(const type3<TM> &a, const type3<TM> &b) {\n- return ((a.x * b.x) +\n- (a.y * b.y) +\n- (a.z * b.z));\n- }\n-\ntemplate <class TM>\ninline double dot(const type4<TM> &a, const type4<TM> &b) {\nreturn ((a.x * b.x) +\n@@ -754,13 +541,6 @@ namespace occa {\nclamp(v.y, min, max));\n}\n- template <class TM>\n- inline type3<TM> clamp(const type3<TM> &v, const TM min, const TM max) {\n- return type3<TM>(clamp(v.x, min, max),\n- clamp(v.y, min, max),\n- clamp(v.z, min, max));\n- }\n-\ntemplate <class TM>\ninline type4<TM> clamp(const type4<TM> &v, const TM min, const TM max) {\nreturn type4<TM>(clamp(v.x, min, max),\n@@ -769,13 +549,13 @@ namespace occa {\nclamp(v.w, min, max));\n}\n- inline float3 cross(const float3 &a, const float3 &b) {\n- return float3((a.z * b.y) - (b.z * a.y),\n+ inline float4 cross(const float4 &a, const float4 &b) {\n+ return float4((a.z * b.y) - (b.z * a.y),\n(a.x * b.z) - (b.x * a.z),\n(a.y * b.x) - (b.y * a.x));\n}\n- inline double3 cross(const double3 &a, const double3 &b) {\n+ inline double4 cross(const double4 &a, const double4 &b) {\nreturn double3((a.z * b.y) - (b.z * a.y),\n(a.x * b.z) - (b.x * a.z),\n(a.y * b.x) - (b.y * a.x));\n" } ]
C++
MIT License
libocca/occa
[Vector] Removed type3 (type3's are typedefed to type4)
378,349
05.02.2017 17:26:38
21,600
bd034697f0c3310a464c9e7003366ec6f98a42aa
[README] Added readthedocs badge
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "<a name=\"OCCA\"></a>\n-## OCCA\n+# OCCA\n[![Build Status](https://travis-ci.org/libocca/occa.svg?branch=master)](https://travis-ci.org/libocca/occa)\n+[![Documentation](https://readthedocs.org/projects/occa/badge/?version=latest)](https://occa.readthedocs.io/en/latest/?badge=latest)\n[![Join the chat at https://gitter.im/libocca/occa](https://badges.gitter.im/libocca/occa.svg)](https://gitter.im/libocca/occa?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\nOCCA is an open-source (MIT license) library used to program current multi-core/many-core architectures.\nDevices (such as CPUs, GPUs, Intel's Xeon Phi, FPGAs, etc) are abstracted using an offload-model for application development and programming for the devices is done through a C-based (OKL) or Fortran-based kernel language (OFL).\nOCCA gives developers the ability to target devices at run-time by using run-time compilation for device kernels.\n-<a name=\"Taiga\"></a>\n-## Taiga\n-\n-We are using <a href=\"https://tree.taiga.io/project/dsm5-occa/kanban\">Taiga</a> to schedule and manage our tasks.\n-\n-To submit an issue, please follow <a href=\"https://tree.taiga.io/project/dsm5-occa/issues?page=1\">this link</a>\n-\n-<a name=\"README\"></a>\n-## README\n-\n-### Installing\n+## Installing\nUsing a terminal, go to your OCCA directory\nYou should see:\n@@ -29,25 +20,27 @@ You should see:\nTo compile `libocca.so`, type:\n-```\n-make\n+```bash\n+git clone https://github.com/libocca/occa.git\n+cd occa\n+make -j 4\n```\nTo compile the Fortran library, setup the `OCCA_FORTRAN_ENABLED` environment variable before compiling\n-```\n+```bash\nexport OCCA_FORTRAN_ENABLED=\"1\"\n```\n-Python 2 and 3 bindings are available with OCCA.\n-If you wish to setup the occa Python module, rather than using `make`, compile both `libocca.so` and the module with\n+Python 2 and 3 bindings are also available.\n+If you wish to setup the occa Python module\n-```\n-python make.py\n+```bash\n+python scripts/make.py\n```\n-### Examples\n+## Examples\nWe have a few examples to show different features of OCCA. The addVectors example contains examples for each current supported language\n@@ -57,28 +50,31 @@ We have a few examples to show different features of OCCA. The addVectors exampl\n* Fortran\n* Julia\n-#### Compile\n+### Compile\nTo compile addVectors (Hello World! style example) in C++\n-```\n+```bash\ncd examples/addVectors/cpp\nmake\n```\n-#### Environment\n-Setup your `LD_LIBRARY_PATH` to point to libocca.so\n+### Environment\n+Setup your library path to point to libocca.so\n-```\n+```bash\n+# Linux\nexport LD_LIBRARY_PATH+=':<occa>/lib'\n+# Mac\n+export DYLD_LIBRARY_PATH+=':<occa>/lib'\n```\nwhere `<occa>` is the OCCA directory\n-### Run\n-```\n+## Run\n+```bash\n./main\n```\n-### Status\n+## Status\n* Linux and OSX are fully supported\n* Windows is partially supported\n* Code is up-to-date for windows\n@@ -86,31 +82,24 @@ where `<occa>` is the OCCA directory\n* Visual Studio project is out of date\n* OKL Status:\n- * Supports most of C (send bugs =))\n- * Preprocessor is missing variadic functions\n-\n-* OFL Status:\n- * Obsolete for now\n- * Version 0.1 supports a subset of Fortran:\n- * integer, real, character, logical, double precision\n- * function, subroutine\n- * DO, WHILE, IF, IF ELSE, ELSE\n+ * Supports most of C\n-### Useful environment variables:\n+## Useful environment variables:\n| Environment Variable | Description |\n|----------------------------|-----------------------------------------------------|\n+| OCCA_DIR | Sets directory where OCCA was installed |\n| OCCA_CACHE_DIR | Sets directory where kernels are cached (Default: ${HOME}/._occa |\n| OCCA_INCLUDE_PATH | Adds directories to find headers |\n| OCCA_LIBRARY_PATH | Adds directories to find libraries |\n| OCCA_CXX | C++ compiler used for libocca.so and run-time compilation |\n| OCCA_CXXFLAGS | C++ compiler flags used for libocca.so and run-time compilation |\n-#### OpenCL\n+### OpenCL\n| Environment Variable | Description |\n|----------------------------|-----------------------------------------------------|\n| OCCA_OPENCL_COMPILER_FLAGS | Adds additional OpenCL flags when compiling kernels |\n-#### CUDA\n+### CUDA\n| Environment Variable | Description |\n|----------------------------|-----------------------------------------------------|\n| OCCA_CUDA_COMPILER | Can be used to specify the CUDA compiler |\n" } ]
C++
MIT License
libocca/occa
[README] Added readthedocs badge
378,349
06.02.2017 20:57:05
21,600
a2a1e72542f653a8770dd5fb828129497d084f3b
[Vector] Removed ids for type3 (since they are type4s)
[ { "change_type": "MODIFY", "old_path": "scripts/occa.cpp", "new_path": "scripts/occa.cpp", "diff": "@@ -200,6 +200,12 @@ std::string envEcho(const std::string &arg) {\nreturn (ret.size() ? ret : \"[NOT SET]\");\n}\n+template <class TM>\n+std::string envEcho(const std::string &arg, const TM &defaultValue) {\n+ std::string ret = occa::env::var(arg);\n+ return (ret.size() ? ret : occa::toString(defaultValue));\n+}\n+\nvoid runClearOn(const std::string &path) {\nstd::string input;\n@@ -270,10 +276,9 @@ void runEnv() {\n<< \" - LDFLAGS : \" << envEcho(\"LDFLAGS\") << \"\\n\"\n<< \" Backend Support:\\n\"\n- << \" - OCCA_OPENMP_ENABLED : \" << envEcho(\"OCCA_OPENMP_ENABLED\") << \"\\n\"\n- << \" - OCCA_OPENCL_ENABLED : \" << envEcho(\"OCCA_OPENCL_ENABLED\") << \"\\n\"\n- << \" - OCCA_CUDA_ENABLED : \" << envEcho(\"OCCA_CUDA_ENABLED\") << \"\\n\"\n- << \" - OCCA_COI_ENABLED : \" << envEcho(\"OCCA_COI_ENABLED\") << \"\\n\"\n+ << \" - OCCA_OPENMP_ENABLED : \" << envEcho(\"OCCA_OPENMP_ENABLED\", OCCA_OPENMP_ENABLED) << \"\\n\"\n+ << \" - OCCA_OPENCL_ENABLED : \" << envEcho(\"OCCA_OPENCL_ENABLED\", OCCA_OPENCL_ENABLED) << \"\\n\"\n+ << \" - OCCA_CUDA_ENABLED : \" << envEcho(\"OCCA_CUDA_ENABLED\", OCCA_CUDA_ENABLED) << \"\\n\"\n<< \" Run-Time Options:\\n\"\n<< \" - OCCA_CXX : \" << envEcho(\"OCCA_CXX\") << \"\\n\"\n" }, { "change_type": "MODIFY", "old_path": "src/types.cpp", "new_path": "src/types.cpp", "diff": "@@ -182,13 +182,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<uchar2>::isUnsigned = true;\n- template <>\n- const std::string typeinfo<uchar3>::id = \"vuc3\";\n- template <>\n- const std::string typeinfo<uchar3>::name = \"uchar3\";\n- template <>\n- const bool typeinfo<uchar3>::isUnsigned = true;\n-\ntemplate <>\nconst std::string typeinfo<uchar4>::id = \"vuc4\";\ntemplate <>\n@@ -203,13 +196,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<char2>::isUnsigned = false;\n- template <>\n- const std::string typeinfo<char3>::id = \"vc3\";\n- template <>\n- const std::string typeinfo<char3>::name = \"char3\";\n- template <>\n- const bool typeinfo<char3>::isUnsigned = false;\n-\ntemplate <>\nconst std::string typeinfo<char4>::id = \"vc4\";\ntemplate <>\n@@ -224,13 +210,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<ushort2>::isUnsigned = true;\n- template <>\n- const std::string typeinfo<ushort3>::id = \"vus3\";\n- template <>\n- const std::string typeinfo<ushort3>::name = \"ushort3\";\n- template <>\n- const bool typeinfo<ushort3>::isUnsigned = true;\n-\ntemplate <>\nconst std::string typeinfo<ushort4>::id = \"vus4\";\ntemplate <>\n@@ -245,13 +224,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<short2>::isUnsigned = false;\n- template <>\n- const std::string typeinfo<short3>::id = \"vs3\";\n- template <>\n- const std::string typeinfo<short3>::name = \"short3\";\n- template <>\n- const bool typeinfo<short3>::isUnsigned = false;\n-\ntemplate <>\nconst std::string typeinfo<short4>::id = \"vs4\";\ntemplate <>\n@@ -266,13 +238,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<uint2>::isUnsigned = true;\n- template <>\n- const std::string typeinfo<uint3>::id = \"vui3\";\n- template <>\n- const std::string typeinfo<uint3>::name = \"uint3\";\n- template <>\n- const bool typeinfo<uint3>::isUnsigned = true;\n-\ntemplate <>\nconst std::string typeinfo<uint4>::id = \"vui4\";\ntemplate <>\n@@ -287,13 +252,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<int2>::isUnsigned = false;\n- template <>\n- const std::string typeinfo<int3>::id = \"vi3\";\n- template <>\n- const std::string typeinfo<int3>::name = \"int3\";\n- template <>\n- const bool typeinfo<int3>::isUnsigned = false;\n-\ntemplate <>\nconst std::string typeinfo<int4>::id = \"vi4\";\ntemplate <>\n@@ -308,13 +266,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<ulong2>::isUnsigned = true;\n- template <>\n- const std::string typeinfo<ulong3>::id = \"vul3\";\n- template <>\n- const std::string typeinfo<ulong3>::name = \"ulong3\";\n- template <>\n- const bool typeinfo<ulong3>::isUnsigned = true;\n-\ntemplate <>\nconst std::string typeinfo<ulong4>::id = \"vul4\";\ntemplate <>\n@@ -329,13 +280,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<long2>::isUnsigned = false;\n- template <>\n- const std::string typeinfo<long3>::id = \"vl3\";\n- template <>\n- const std::string typeinfo<long3>::name = \"long3\";\n- template <>\n- const bool typeinfo<long3>::isUnsigned = false;\n-\ntemplate <>\nconst std::string typeinfo<long4>::id = \"vl4\";\ntemplate <>\n@@ -350,13 +294,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<float2>::isUnsigned = false;\n- template <>\n- const std::string typeinfo<float3>::id = \"vf3\";\n- template <>\n- const std::string typeinfo<float3>::name = \"float3\";\n- template <>\n- const bool typeinfo<float3>::isUnsigned = false;\n-\ntemplate <>\nconst std::string typeinfo<float4>::id = \"vf4\";\ntemplate <>\n@@ -371,13 +308,6 @@ namespace occa {\ntemplate <>\nconst bool typeinfo<double2>::isUnsigned = false;\n- template <>\n- const std::string typeinfo<double3>::id = \"vd3\";\n- template <>\n- const std::string typeinfo<double3>::name = \"double3\";\n- template <>\n- const bool typeinfo<double3>::isUnsigned = false;\n-\ntemplate <>\nconst std::string typeinfo<double4>::id = \"vd4\";\ntemplate <>\n" } ]
C++
MIT License
libocca/occa
[Vector] Removed ids for type3 (since they are type4s)
378,349
07.02.2017 01:11:06
21,600
dc2900fb4ae947fa4321df074d9641906f42d1bb
[Kernel] Properties kernel/defines and kernel/headers -> defines and headers
[ { "change_type": "MODIFY", "old_path": "examples/fd2d/main.cpp", "new_path": "examples/fd2d/main.cpp", "diff": "@@ -269,21 +269,21 @@ void setupSolver() {\no_u3 = dev.malloc(u2.size()*sizeof(tFloat), &(u2[0]));\nocca::properties kernelProps;\n- kernelProps[\"kernel/defines/sr\"] = stencilRadius;\n- kernelProps[\"kernel/defines/w\"] = width;\n- kernelProps[\"kernel/defines/h\"] = height;\n- kernelProps[\"kernel/defines/dx\"] = dx;\n- kernelProps[\"kernel/defines/dt\"] = dt;\n- kernelProps[\"kernel/defines/freq\"] = freq;\n- kernelProps[\"kernel/defines/mX\"] = mX;\n- kernelProps[\"kernel/defines/mY\"] = mY;\n- kernelProps[\"kernel/defines/Bx\"] = Bx;\n- kernelProps[\"kernel/defines/By\"] = By;\n+ kernelProps[\"defines/sr\"] = stencilRadius;\n+ kernelProps[\"defines/w\"] = width;\n+ kernelProps[\"defines/h\"] = height;\n+ kernelProps[\"defines/dx\"] = dx;\n+ kernelProps[\"defines/dt\"] = dt;\n+ kernelProps[\"defines/freq\"] = freq;\n+ kernelProps[\"defines/mX\"] = mX;\n+ kernelProps[\"defines/mY\"] = mY;\n+ kernelProps[\"defines/Bx\"] = Bx;\n+ kernelProps[\"defines/By\"] = By;\nif (sizeof(tFloat) == sizeof(float)) {\n- kernelProps[\"kernel/defines/tFloat\"] = \"float\";\n+ kernelProps[\"defines/tFloat\"] = \"float\";\n} else {\n- kernelProps[\"kernel/defines/tFloat\"] = \"double\";\n+ kernelProps[\"defines/tFloat\"] = \"double\";\n}\nfd2d = dev.buildKernel(\"fd2d.okl\", \"fd2d\", kernelProps);\n" }, { "change_type": "MODIFY", "old_path": "examples/mandelbulb/main.cpp", "new_path": "examples/mandelbulb/main.cpp", "diff": "@@ -160,19 +160,19 @@ void setupOCCA() {\nocca::properties kernelProps;\n- kernelProps[\"kernel/defines/WIDTH\"] = width;\n- kernelProps[\"kernel/defines/HEIGHT\"] = height;\n- kernelProps[\"kernel/defines/BATCH_SIZE\"] = batchSize;\n- kernelProps[\"kernel/defines/SHAPE_FUNCTION\"]= shapeFunction;\n- kernelProps[\"kernel/defines/PIXEL\"] = pixel;\n- kernelProps[\"kernel/defines/HALF_PIXEL\"] = halfPixel;\n+ kernelProps[\"defines/WIDTH\"] = width;\n+ kernelProps[\"defines/HEIGHT\"] = height;\n+ kernelProps[\"defines/BATCH_SIZE\"] = batchSize;\n+ kernelProps[\"defines/SHAPE_FUNCTION\"]= shapeFunction;\n+ kernelProps[\"defines/PIXEL\"] = pixel;\n+ kernelProps[\"defines/HALF_PIXEL\"] = halfPixel;\nif (sizeof(tFloat) == sizeof(float)) {\n- kernelProps[\"kernel/defines/tFloat\"] = \"float\";\n- kernelProps[\"kernel/defines/tFloat3\"] = \"float3\";\n+ kernelProps[\"defines/tFloat\"] = \"float\";\n+ kernelProps[\"defines/tFloat3\"] = \"float3\";\n} else {\n- kernelProps[\"kernel/defines/tFloat\"] = \"double\";\n- kernelProps[\"kernel/defines/tFloat3\"] = \"double3\";\n+ kernelProps[\"defines/tFloat\"] = \"double\";\n+ kernelProps[\"defines/tFloat3\"] = \"double3\";\n}\nrayMarcher = occa::buildKernel(\"rayMarcher.okl\",\n" }, { "change_type": "MODIFY", "old_path": "examples/reduction/main.cpp", "new_path": "examples/reduction/main.cpp", "diff": "@@ -30,7 +30,7 @@ int main(int argc, char **argv) {\no_aRed = device.malloc(reducedEntries*sizeof(float));\nocca::properties kernelProps;\n- kernelProps[\"kernel/defines/p_Nred\"] = p_Nred;\n+ kernelProps[\"defines/p_Nred\"] = p_Nred;\n#if 1\nreduction = device.buildKernel(\"reduction.okl\",\n" }, { "change_type": "MODIFY", "old_path": "include/occa/defines/cpuMode.hpp", "new_path": "include/occa/defines/cpuMode.hpp", "diff": "@@ -357,50 +357,18 @@ public:\nreturn data[index()][0];\n}\n- friend inline TM operator + (const TM &a, const occaPrivate_t &b) {\n- return (a + b.data[b.index()][0]);\n- }\n-\n- friend inline TM operator + (const occaPrivate_t &a, const TM &b) {\n- return (a.data[a.index()][0] + b);\n- }\n-\nfriend inline TM operator + (const occaPrivate_t &a, const occaPrivate_t &b) {\nreturn (a.data[a.index()][0] + b.data[b.index()][0]);\n}\n- friend inline TM operator - (const TM &a, const occaPrivate_t &b) {\n- return (a - b.data[b.index()][0]);\n- }\n-\n- friend inline TM operator - (const occaPrivate_t &a, const TM &b) {\n- return (a.data[a.index()][0] - b);\n- }\n-\nfriend inline TM operator - (const occaPrivate_t &a, const occaPrivate_t &b) {\nreturn (a.data[a.index()][0] - b.data[b.index()][0]);\n}\n- friend inline TM operator * (const TM &a, const occaPrivate_t &b) {\n- return (a * b.data[b.index()][0]);\n- }\n-\n- friend inline TM operator * (const occaPrivate_t &a, const TM &b) {\n- return (a.data[a.index()][0] * b);\n- }\n-\nfriend inline TM operator * (const occaPrivate_t &a, const occaPrivate_t &b) {\nreturn (a.data[a.index()][0] * b.data[b.index()][0]);\n}\n- friend inline TM operator / (const TM &a, const occaPrivate_t &b) {\n- return (a / b.data[b.index()][0]);\n- }\n-\n- friend inline TM operator / (const occaPrivate_t &a, const TM &b) {\n- return (a.data[a.index()][0] / b);\n- }\n-\nfriend inline TM operator / (const occaPrivate_t &a, const occaPrivate_t &b) {\nreturn (a.data[a.index()][0] / b.data[b.index()][0]);\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/string.hpp", "new_path": "include/occa/tools/string.hpp", "diff": "@@ -152,6 +152,10 @@ namespace occa {\nstd::string stringifyBytes(udim_t bytes);\n+ //---[ Vector Methods ]---------------\n+ std::string join(const strVector_t &vec, const std::string &seq);\n+ //====================================\n+\n//---[ Color Strings ]----------------\nnamespace color {\nenum color_t {\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -222,7 +222,7 @@ namespace occa {\nprops);\nocca::properties launchKernelProps;\n- launchKernelProps[\"kernel/defines/OCCA_LAUNCH_KERNEL\"] = 1;\n+ launchKernelProps[\"defines/OCCA_LAUNCH_KERNEL\"] = 1;\nk->build(parsedFile,\nfunctionName,\n" }, { "change_type": "MODIFY", "old_path": "src/kernel.cpp", "new_path": "src/kernel.cpp", "diff": "@@ -192,10 +192,10 @@ namespace occa {\n//---[ Kernel Properties ]------------\nstd::string assembleHeader(const occa::properties &props) {\n- const jsonArray_t &lines = props[\"kernel/headers\"].getArray();\n+ const jsonArray_t &lines = props[\"headers\"].getArray();\nconst int lineCount = (int) lines.size();\n- const jsonObject_t &defines = props[\"kernel/defines\"].getObject();\n+ const jsonObject_t &defines = props[\"defines\"].getObject();\ncJsonObjectIterator it = defines.begin();\nstd::string header;\n" }, { "change_type": "MODIFY", "old_path": "src/tools/json.cpp", "new_path": "src/tools/json.cpp", "diff": "@@ -262,8 +262,38 @@ namespace occa {\n}\njson& json::operator += (const json &j) {\n- value.object.insert(value.object.begin(),\n- value.object.end());\n+ OCCA_ERROR(\"Cannot apply operator + with different JSON types\",\n+ (type == array_) ||\n+ (type == j.type));\n+\n+ switch(type) {\n+ case none_: {\n+ break;\n+ }\n+ case string_: {\n+ value.string += j.value.string;\n+ break;\n+ }\n+ case number_: {\n+ value.number += j.value.number;\n+ break;\n+ }\n+ case object_: {\n+ value.object.insert(j.value.object.begin(),\n+ j.value.object.end());\n+ break;\n+ }\n+ case array_: {\n+ value.array.push_back(j);\n+ break;\n+ }\n+ case boolean_: {\n+ value.boolean += j.value.boolean;\n+ break;\n+ }\n+ case null_: {\n+ break;\n+ }}\nreturn *this;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/string.cpp", "new_path": "src/tools/string.cpp", "diff": "@@ -274,6 +274,21 @@ namespace occa {\nreturn \"\";\n}\n+ //---[ Vector Methods ]---------------\n+ std::string join(const strVector_t &vec, const std::string &seq) {\n+ const int entries = (int) vec.size();\n+ if (entries == 0) {\n+ return \"\";\n+ }\n+ std::string ret = vec[0];\n+ for (int i = 1; i < entries; ++i) {\n+ ret += seq;\n+ ret += vec[1];\n+ }\n+ return ret;\n+ }\n+ //====================================\n+\n//---[ Color Strings ]----------------\nnamespace color {\nconst char fgMap[9][7] = {\n" } ]
C++
MIT License
libocca/occa
[Kernel] Properties kernel/defines and kernel/headers -> defines and headers
378,349
12.02.2017 23:11:04
21,600
a60f4643dd82eff5476d7c0aeef401b297a7f0df
[Device] Removed manual uva enabling
[ { "change_type": "MODIFY", "old_path": "include/occa/base.hpp", "new_path": "include/occa/base.hpp", "diff": "@@ -51,7 +51,7 @@ namespace occa {\nvoid setDevice(device d);\nvoid setDevice(const properties &props);\n- properties& deviceProperties();\n+ const properties& deviceProperties();\nvoid finish();\n" }, { "change_type": "MODIFY", "old_path": "include/occa/device.hpp", "new_path": "include/occa/device.hpp", "diff": "@@ -46,7 +46,6 @@ namespace occa {\npublic:\nstd::string mode;\n- bool uvaEnabled_;\nptrRangeMap_t uvaMap;\nmemoryVector_t uvaStaleMemory;\n@@ -58,7 +57,6 @@ namespace occa {\ndevice_v(const occa::properties &properties_);\nvoid initFrom(const device_v &m);\n- bool hasUvaEnabled();\n//---[ Virtual Methods ]------------\nvirtual ~device_v() = 0;\n@@ -116,16 +114,17 @@ namespace occa {\npublic:\ndevice();\ndevice(device_v *dHandle_);\n-\ndevice(const occa::properties &props);\ndevice(const occa::device &d);\ndevice& operator = (const occa::device &d);\n+ void free();\n+\nbool isInitialized();\nconst std::string& mode();\n- occa::properties& properties();\n+ const occa::properties& properties();\nvoid* getHandle(const occa::properties &props = occa::properties());\ndevice_v* getDHandle() const;\n@@ -135,8 +134,6 @@ namespace occa {\nudim_t memorySize() const;\nudim_t memoryAllocated() const;\n- bool hasUvaEnabled();\n-\nvoid finish();\nbool hasSeparateMemorySpace();\n@@ -181,8 +178,6 @@ namespace occa {\nconst dim_t bytes,\nconst occa::properties &props = occa::properties());\n// |===============================\n-\n- void free();\n};\ntemplate <>\n" }, { "change_type": "MODIFY", "old_path": "src/base.cpp", "new_path": "src/base.cpp", "diff": "@@ -62,7 +62,7 @@ namespace occa {\ncurrentDevice() = device(props);\n}\n- properties& deviceProperties() {\n+ const properties& deviceProperties() {\nreturn currentDevice().properties();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -35,7 +35,6 @@ namespace occa {\nmode = properties_[\"mode\"].getString();\nproperties = properties_;\n- uvaEnabled_ = this->properties.get<bool>(\"uva\", false);\ncurrentStream = NULL;\nbytesAllocated = 0;\n}\n@@ -45,7 +44,6 @@ namespace occa {\nvoid device_v::initFrom(const device_v &m) {\nproperties = m.properties;\n- uvaEnabled_ = m.uvaEnabled_;\nuvaMap = m.uvaMap;\nuvaStaleMemory = m.uvaStaleMemory;\n@@ -54,10 +52,6 @@ namespace occa {\nbytesAllocated = m.bytesAllocated;\n}\n-\n- bool device_v::hasUvaEnabled() {\n- return uvaEnabled_;\n- }\n//====================================\n//---[ device ]-----------------------\n@@ -81,6 +75,21 @@ namespace occa {\nreturn *this;\n}\n+ void device::free() {\n+ if (dHandle == NULL) {\n+ return;\n+ }\n+ const int streamCount = dHandle->streams.size();\n+\n+ for (int i = 0; i < streamCount; ++i)\n+ dHandle->freeStream(dHandle->streams[i]);\n+\n+ dHandle->free();\n+\n+ delete dHandle;\n+ dHandle = NULL;\n+ }\n+\nbool device::isInitialized() {\nreturn (dHandle != NULL);\n}\n@@ -95,13 +104,16 @@ namespace occa {\nvoid device::setup(const occa::properties &props) {\ndHandle = occa::newModeDevice(props);\n- dHandle->uvaEnabled_ = dHandle->properties.get<bool>(\"uva\", false);\nstream newStream = createStream();\ndHandle->currentStream = newStream.handle;\n}\n- occa::properties& device::properties() {\n+ const std::string& device::mode() {\n+ return dHandle->mode;\n+ }\n+\n+ const occa::properties& device::properties() {\nreturn dHandle->properties;\n}\n@@ -113,14 +125,6 @@ namespace occa {\nreturn dHandle->bytesAllocated;\n}\n- bool device::hasUvaEnabled() {\n- return dHandle->hasUvaEnabled();\n- }\n-\n- const std::string& device::mode() {\n- return dHandle->mode;\n- }\n-\nvoid device::finish() {\nif (dHandle->hasSeparateMemorySpace()) {\nconst size_t staleEntries = uvaStaleMemory.size();\n@@ -365,21 +369,6 @@ namespace occa {\n}\n// |=================================\n- void device::free() {\n- if (dHandle == NULL) {\n- return;\n- }\n- const int streamCount = dHandle->streams.size();\n-\n- for (int i = 0; i < streamCount; ++i)\n- dHandle->freeStream(dHandle->streams[i]);\n-\n- dHandle->free();\n-\n- delete dHandle;\n- dHandle = NULL;\n- }\n-\ntemplate <>\nhash_t hash(const occa::device &device) {\nreturn device.getDHandle()->hash();\n" }, { "change_type": "MODIFY", "old_path": "src/kernel.cpp", "new_path": "src/kernel.cpp", "diff": "@@ -166,8 +166,7 @@ namespace occa {\nif (mHandle &&\nmHandle->isManaged() &&\n- mHandle->dHandle->hasSeparateMemorySpace() &&\n- mHandle->dHandle->hasUvaEnabled()) {\n+ mHandle->dHandle->hasSeparateMemorySpace()) {\nif (!mHandle->inDevice()) {\nmHandle->copyFrom(mHandle->uvaPtr, mHandle->size);\n" } ]
C++
MIT License
libocca/occa
[Device] Removed manual uva enabling
378,349
12.02.2017 23:13:45
21,600
f09db57522494353db4e7314bed6b5471ad22c1b
[License] Updated license
[ { "change_type": "MODIFY", "old_path": "LICENSE", "new_path": "LICENSE", "diff": "The MIT License (MIT)\n-Copyright (c) 2014-2016 David Medina and Tim Warburton\n+Copyright (c) 2014-2017 David Medina and Tim Warburton\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\n" } ]
C++
MIT License
libocca/occa
[License] Updated license
378,349
13.02.2017 22:10:41
21,600
0cf50dfe400a638b95551b18da0243afbf1e18e6
[Interop] Added props to wrapStream
[ { "change_type": "MODIFY", "old_path": "include/occa/base.hpp", "new_path": "include/occa/base.hpp", "diff": "@@ -49,9 +49,9 @@ namespace occa {\ndevice& currentDevice();\nvoid setDevice(device d);\n- void setDevice(const properties &props);\n+ void setDevice(const occa::properties &props);\n- const properties& deviceProperties();\n+ const occa::properties& deviceProperties();\nvoid finish();\n@@ -60,7 +60,8 @@ namespace occa {\nstream createStream();\nstream getStream();\nvoid setStream(stream s);\n- stream wrapStream(void *handle_);\n+ stream wrapStream(void *handle_,\n+ const occa::properties &props = occa::properties());\nstreamTag tagStream();\n//====================================\n@@ -68,25 +69,25 @@ namespace occa {\n//---[ Kernel Functions ]-------------\nkernel buildKernel(const std::string &filename,\nconst std::string &kernelName,\n- const properties &props = occa::properties());\n+ const occa::properties &props = occa::properties());\nkernel buildKernelFromString(const std::string &content,\nconst std::string &kernelName,\n- const properties &props = occa::properties());\n+ const occa::properties &props = occa::properties());\nkernel buildKernelFromBinary(const std::string &filename,\nconst std::string &kernelName,\n- const properties &props = occa::properties());\n+ const occa::properties &props = occa::properties());\n//====================================\n//---[ Memory Functions ]-------------\nocca::memory malloc(const dim_t bytes,\nvoid *src = NULL,\n- const properties &props = occa::properties());\n+ const occa::properties &props = occa::properties());\nvoid* uvaAlloc(const dim_t bytes,\nvoid *src = NULL,\n- const properties &props = occa::properties());\n+ const occa::properties &props = occa::properties());\nocca::memory wrapMemory(void *handle_,\nconst dim_t bytes,\n@@ -94,23 +95,23 @@ namespace occa {\nvoid memcpy(void *dest, const void *src,\nconst dim_t bytes,\n- const properties &props = properties());\n+ const occa::properties &props = properties());\nvoid memcpy(memory dest, const void *src,\nconst dim_t bytes = -1,\nconst dim_t offset = 0,\n- const properties &props = properties());\n+ const occa::properties &props = properties());\nvoid memcpy(void *dest, memory src,\nconst dim_t bytes = -1,\nconst dim_t offset = 0,\n- const properties &props = properties());\n+ const occa::properties &props = properties());\nvoid memcpy(memory dest, memory src,\nconst dim_t bytes = -1,\nconst dim_t destOffset = 0,\nconst dim_t srcOffset = 0,\n- const properties &props = properties());\n+ const occa::properties &props = properties());\n//====================================\n//---[ Free Functions ]---------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/device.hpp", "new_path": "include/occa/device.hpp", "diff": "@@ -78,7 +78,8 @@ namespace occa {\nvirtual void waitFor(streamTag tag) = 0;\nvirtual double timeBetween(const streamTag &startTag, const streamTag &endTag) = 0;\n- virtual stream_t wrapStream(void *handle_) = 0;\n+ virtual stream_t wrapStream(void *handle_,\n+ const occa::properties &props) = 0;\n// |===============================\n// |---[ Kernel ]------------------\n@@ -144,7 +145,8 @@ namespace occa {\nstream getStream();\nvoid setStream(stream s);\n- stream wrapStream(void *handle_);\n+ stream wrapStream(void *handle_,\n+ const occa::properties &props = occa::properties());\nstreamTag tagStream();\nvoid waitFor(streamTag tag);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/c/c_wrapper.hpp", "new_path": "include/occa/lang/c/c_wrapper.hpp", "diff": "@@ -143,7 +143,8 @@ OCCA_LFUNC void OCCA_RFUNC occaWaitFor(occaStreamTag tag);\nOCCA_LFUNC occaStream OCCA_RFUNC occaCreateStream();\nOCCA_LFUNC occaStream OCCA_RFUNC occaGetStream();\nOCCA_LFUNC void OCCA_RFUNC occaSetStream(occaStream stream);\n-OCCA_LFUNC occaStream OCCA_RFUNC occaWrapStream(void *handle_);\n+OCCA_LFUNC occaStream OCCA_RFUNC occaWrapStream(void *handle_,\n+ const occaProperties props);\nOCCA_LFUNC occaStreamTag OCCA_RFUNC occaTagStream();\n// |===================================\n@@ -224,7 +225,9 @@ OCCA_LFUNC void OCCA_RFUNC occaDeviceFinish(occaDevice device);\nOCCA_LFUNC occaStream OCCA_RFUNC occaDeviceCreateStream(occaDevice device);\nOCCA_LFUNC occaStream OCCA_RFUNC occaDeviceGetStream(occaDevice device);\nOCCA_LFUNC void OCCA_RFUNC occaDeviceSetStream(occaDevice device, occaStream stream);\n-OCCA_LFUNC occaStream OCCA_RFUNC occaDeviceWrapStream(occaDevice device, void *handle_);\n+OCCA_LFUNC occaStream OCCA_RFUNC occaDeviceWrapStream(occaDevice device,\n+ void *handle_,\n+ const occaProperties props);\nOCCA_LFUNC occaStreamTag OCCA_RFUNC occaDeviceTagStream(occaDevice device);\nOCCA_LFUNC void OCCA_RFUNC occaDeviceWaitForTag(occaDevice device,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/device.hpp", "new_path": "include/occa/modes/cuda/device.hpp", "diff": "@@ -61,7 +61,7 @@ namespace occa {\nvoid waitFor(streamTag tag);\ndouble timeBetween(const streamTag &startTag, const streamTag &endTag);\n- stream_t wrapStream(void *handle_);\n+ stream_t wrapStream(void *handle_, const occa::properties &props);\n// |=============================\n// |---[ Kernel ]----------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/opencl/device.hpp", "new_path": "include/occa/modes/opencl/device.hpp", "diff": "@@ -61,7 +61,7 @@ namespace occa {\nvoid waitFor(streamTag tag);\ndouble timeBetween(const streamTag &startTag, const streamTag &endTag);\n- stream_t wrapStream(void *handle_);\n+ stream_t wrapStream(void *handle_, const occa::properties &props);\n// |=============================\n// |---[ Kernel ]----------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/serial/device.hpp", "new_path": "include/occa/modes/serial/device.hpp", "diff": "@@ -52,7 +52,7 @@ namespace occa {\nvoid waitFor(streamTag tag);\ndouble timeBetween(const streamTag &startTag, const streamTag &endTag);\n- stream_t wrapStream(void *handle_);\n+ stream_t wrapStream(void *handle_, const occa::properties &props);\n// |=============================\n// |---[ Kernel ]----------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/io.hpp", "new_path": "include/occa/tools/io.hpp", "diff": "@@ -137,7 +137,7 @@ namespace occa {\nconst std::string &filename,\nconst std::string &cachedBinary,\nconst std::string &functionName,\n- const properties &props);\n+ const occa::properties &props);\nstd::string removeSlashes(const std::string &str);\n" }, { "change_type": "MODIFY", "old_path": "src/base.cpp", "new_path": "src/base.cpp", "diff": "@@ -58,11 +58,11 @@ namespace occa {\ncurrentDevice() = d;\n}\n- void setDevice(const properties &props) {\n+ void setDevice(const occa::properties &props) {\ncurrentDevice() = device(props);\n}\n- const properties& deviceProperties() {\n+ const occa::properties& deviceProperties() {\nreturn currentDevice().properties();\n}\n@@ -86,8 +86,8 @@ namespace occa {\ncurrentDevice().setStream(s);\n}\n- stream wrapStream(void *handle_) {\n- return currentDevice().wrapStream(handle_);\n+ stream wrapStream(void *handle_, const occa::properties &props) {\n+ return currentDevice().wrapStream(handle_, props);\n}\nstreamTag tagStream() {\n@@ -97,7 +97,7 @@ namespace occa {\n//---[ Kernel Functions ]-------------\nkernel buildKernel(const std::string &filename,\nconst std::string &kernelName,\n- const properties &props) {\n+ const occa::properties &props) {\nreturn currentDevice().buildKernel(filename,\nkernelName,\n@@ -121,14 +121,14 @@ namespace occa {\n//---[ Memory Functions ]-------------\nocca::memory malloc(const dim_t bytes,\nvoid *src,\n- const properties &props) {\n+ const occa::properties &props) {\nreturn currentDevice().malloc(bytes, src, props);\n}\nvoid* uvaAlloc(const dim_t bytes,\nvoid *src,\n- const properties &props) {\n+ const occa::properties &props) {\nreturn currentDevice().uvaAlloc(bytes, src, props);\n}\n@@ -142,7 +142,7 @@ namespace occa {\nvoid memcpy(void *dest, const void *src,\nconst dim_t bytes,\n- const properties &props) {\n+ const occa::properties &props) {\nptrRangeMap_t::iterator srcIt = uvaMap.find(const_cast<void*>(src));\nptrRangeMap_t::iterator destIt = uvaMap.find(dest);\n@@ -173,7 +173,7 @@ namespace occa {\nvoid memcpy(memory dest, const void *src,\nconst dim_t bytes,\nconst dim_t offset,\n- const properties &props) {\n+ const occa::properties &props) {\ndest.copyFrom(src, bytes, offset, props);\n}\n@@ -181,7 +181,7 @@ namespace occa {\nvoid memcpy(void *dest, memory src,\nconst dim_t bytes,\nconst dim_t offset,\n- const properties &props) {\n+ const occa::properties &props) {\nsrc.copyTo(dest, bytes, offset, props);\n}\n@@ -190,7 +190,7 @@ namespace occa {\nconst dim_t bytes,\nconst dim_t destOffset,\nconst dim_t srcOffset,\n- const properties &props) {\n+ const occa::properties &props) {\ndest.copyFrom(src, bytes, destOffset, srcOffset, props);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -180,8 +180,8 @@ namespace occa {\ndHandle->currentStream = s.handle;\n}\n- stream device::wrapStream(void *handle_) {\n- return stream(dHandle, dHandle->wrapStream(handle_));\n+ stream device::wrapStream(void *handle_, const occa::properties &props) {\n+ return stream(dHandle, dHandle->wrapStream(handle_, props));\n}\nstreamTag device::tagStream() {\n" }, { "change_type": "MODIFY", "old_path": "src/lang/c/c_wrapper.cpp", "new_path": "src/lang/c/c_wrapper.cpp", "diff": "@@ -479,8 +479,9 @@ void OCCA_RFUNC occaSetStream(occaStream stream) {\nocca::setStream(occa::c::from<occa::stream>(stream));\n}\n-occaStream OCCA_RFUNC occaWrapStream(void *handle_) {\n- occa::stream &newStream = *(new occa::stream(occa::wrapStream(handle_)));\n+occaStream OCCA_RFUNC occaWrapStream(void *handle_, const occaProperties props) {\n+ occa::properties &props_ = occa::c::from<occa::properties>(props);\n+ occa::stream &newStream = *(new occa::stream(occa::wrapStream(handle_, props_)));\nreturn newObject(&newStream, occa::c::stream_);\n}\n@@ -708,9 +709,12 @@ void OCCA_RFUNC occaDeviceSetStream(occaDevice device, occaStream stream) {\ndevice_.setStream(*((occa::stream*) stream.ptr->obj));\n}\n-occaStream OCCA_RFUNC occaDeviceWrapStream(occaDevice device, void *handle_) {\n+occaStream OCCA_RFUNC occaDeviceWrapStream(occaDevice device,\n+ void *handle_,\n+ const occaProperties props) {\nocca::device device_ = occa::c::getDevice(device);\n- occa::stream &newStream = *(new occa::stream(device_.wrapStream(handle_)));\n+ occa::properties &props_ = occa::c::from<occa::properties>(props);\n+ occa::stream &newStream = *(new occa::stream(device_.wrapStream(handle_, props_)));\nreturn newObject(&newStream, occa::c::stream_);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -161,7 +161,7 @@ namespace occa {\nreturn (double) (1.0e-3 * (double) msTimeTaken);\n}\n- stream_t device::wrapStream(void *handle_) {\n+ stream_t device::wrapStream(void *handle_, const occa::properties &props) {\nreturn handle_;\n}\n// |===============================\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/device.cpp", "new_path": "src/modes/opencl/device.cpp", "diff": "@@ -167,7 +167,7 @@ namespace occa {\nreturn (double) (1.0e-9 * (double)(end - start));\n}\n- stream_t device::wrapStream(void *handle_) {\n+ stream_t device::wrapStream(void *handle_, const occa::properties &props) {\nreturn handle_;\n}\n// |===============================\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/device.cpp", "new_path": "src/modes/serial/device.cpp", "diff": "@@ -138,7 +138,7 @@ namespace occa {\nvoid device::freeStream(stream_t s) {}\n- stream_t device::wrapStream(void *handle_) {\n+ stream_t device::wrapStream(void *handle_, const occa::properties &props) {\nreturn NULL;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/io.cpp", "new_path": "src/tools/io.cpp", "diff": "@@ -399,7 +399,7 @@ namespace occa {\nconst std::string &filename,\nconst std::string &parsedFile,\nconst std::string &functionName,\n- const properties &props) {\n+ const occa::properties &props) {\nconst std::string ext = extension(filename);\nocca::properties properties = props;\n" } ]
C++
MIT License
libocca/occa
[Interop] Added props to wrapStream
378,349
13.02.2017 22:26:29
21,600
2579de8d965b2020b6382a7d85076d2733701488
[CUDA] Updated device::getHandle()
[ { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -93,7 +93,7 @@ namespace occa {\nif (props.get<std::string>(\"type\", \"\") == \"context\") {\nreturn (void*) context;\n}\n- return (void*) (uintptr_t) handle;\n+ return &handle;\n}\nvoid device::finish() {\n" } ]
C++
MIT License
libocca/occa
[CUDA] Updated device::getHandle()
378,349
19.02.2017 10:13:50
21,600
0103f0d5c338f0c24cf9e65a178b7592f03f5445
[CLI] Fixed missing slash in removeDir
[ { "change_type": "MODIFY", "old_path": "include/occa/tools/env.hpp", "new_path": "include/occa/tools/env.hpp", "diff": "@@ -47,8 +47,6 @@ namespace occa {\nvoid signalExit(int sig);\n- void endDirWithSlash(std::string &dir);\n-\nclass envInitializer_t {\npublic: envInitializer_t();\n};\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/io.hpp", "new_path": "include/occa/tools/io.hpp", "diff": "@@ -107,6 +107,9 @@ namespace occa {\nconst std::string& cachePath();\nconst std::string& libraryPath();\n+ void endWithSlash(std::string &dir);\n+ std::string endWithSlash(const std::string &dir);\n+\nbool isAbsolutePath(const std::string &filename);\nstd::string convertSlashes(const std::string &filename);\nstd::string filename(const std::string &filename, bool makeAbsolute = true);\n" }, { "change_type": "MODIFY", "old_path": "scripts/occa.cpp", "new_path": "scripts/occa.cpp", "diff": "@@ -104,18 +104,21 @@ std::string envEcho(const std::string &arg, const TM &defaultValue) {\nreturn (ret.size() ? ret : occa::toString(defaultValue));\n}\n-bool removePath(const std::string &path) {\n- if (!occa::sys::fileExists(path)) {\n+bool removeDir(const std::string &dir) {\n+ const std::string fulldir = occa::io::endWithSlash(dir);\n+\n+ if (!occa::sys::fileExists(fulldir)) {\nreturn false;\n}\n+\nstd::string input;\n- std::cout << \" Removing [\" << path << \"*], are you sure? [y/n]: \";\n+ std::cout << \" Removing [\" << fulldir << \"*], are you sure? [y/n]: \";\nstd::cin >> input;\nocca::strip(input);\nif (input == \"y\") {\n- std::string command = \"rm -rf \" + path + \"*\";\n+ std::string command = \"rm -rf \" + fulldir + \"*\";\nocca::ignoreResult( system(command.c_str()) );\n} else if (input != \"n\") {\nstd::cout << \" Input must be [y] or [n], ignoring clear command\\n\";\n@@ -135,18 +138,20 @@ bool runClear(const occa::args::command &command,\nbool removedSomething = false;\nwhile (it != options.end()) {\nif (it->first == \"all\") {\n- removedSomething |= removePath(occa::env::OCCA_CACHE_DIR);\n+ removedSomething |= removeDir(occa::env::OCCA_CACHE_DIR);\n} else if (it->first == \"lib\") {\nconst occa::jsonArray_t &libraries = it->second.array();\nfor (int i = 0; i < (int) libraries.size(); ++i) {\n- removedSomething |= removePath(occa::io::libraryPath() +\n+ removedSomething |= removeDir(occa::io::libraryPath() +\nlibraries[i].array()[0].string());\n}\n+ } else if (it->first == \"libraries\") {\n+ removedSomething |= removeDir(occa::io::libraryPath());\n} else if (it->first == \"kernels\") {\n- removedSomething |= removePath(occa::io::cachePath());\n+ removedSomething |= removeDir(occa::io::cachePath());\n} else if (it->first == \"locks\") {\nconst std::string lockPath = occa::env::OCCA_CACHE_DIR + \"locks/\";\n- removedSomething |= removePath(lockPath);\n+ removedSomething |= removeDir(lockPath);\n}\n++it;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/env.cpp", "new_path": "src/tools/env.cpp", "diff": "@@ -76,9 +76,9 @@ namespace occa {\nPATH = env::var(\"PATH\");\nLD_LIBRARY_PATH = env::var(\"LD_LIBRARY_PATH\");\n- endDirWithSlash(HOME);\n- endDirWithSlash(PWD);\n- endDirWithSlash(PATH);\n+ io::endWithSlash(HOME);\n+ io::endWithSlash(PWD);\n+ io::endWithSlash(PATH);\n#endif\n// OCCA environment variables\n@@ -94,8 +94,8 @@ namespace occa {\ninitCachePath();\ninitIncludePath();\n- endDirWithSlash(OCCA_DIR);\n- endDirWithSlash(OCCA_CACHE_DIR);\n+ io::endWithSlash(OCCA_DIR);\n+ io::endWithSlash(OCCA_CACHE_DIR);\nOCCA_MEM_BYTE_ALIGN = OCCA_DEFAULT_MEM_BYTE_ALIGN;\nif (env::var(\"OCCA_MEM_BYTE_ALIGN\").size() > 0) {\n@@ -164,7 +164,7 @@ namespace occa {\nif (0 < (cEnd - cStart)) {\nstd::string newPath(cStart, cEnd - cStart);\nnewPath = io::filename(newPath);\n- endDirWithSlash(newPath);\n+ io::endWithSlash(newPath);\ntmpOIP.push_back(newPath);\n}\n@@ -194,13 +194,6 @@ namespace occa {\n::exit(sig);\n}\n- void endDirWithSlash(std::string &dir) {\n- if ((0 < dir.size()) &&\n- (dir[dir.size() - 1] != '/')) {\n- dir += '/';\n- }\n- }\n-\nenvInitializer_t::envInitializer_t() {\nenv::initialize();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/io.cpp", "new_path": "src/tools/io.cpp", "diff": "@@ -153,6 +153,19 @@ namespace occa {\nreturn path;\n}\n+ void endWithSlash(std::string &dir) {\n+ if ((0 < dir.size()) &&\n+ (dir[dir.size() - 1] != '/')) {\n+ dir += '/';\n+ }\n+ }\n+\n+ std::string endWithSlash(const std::string &dir) {\n+ std::string ret = dir;\n+ endWithSlash(ret);\n+ return ret;\n+ }\n+\nbool isAbsolutePath(const std::string &filename) {\n#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_OSX_OS))\nreturn ((0 < filename.size()) &&\n" } ]
C++
MIT License
libocca/occa
[CLI] Fixed missing slash in removeDir
378,349
19.02.2017 19:24:05
21,600
c6ccb362b396eddc0abfb8ddb897dda8551cf46d
[Linalg] Updated dot product
[ { "change_type": "MODIFY", "old_path": "examples/usingArrays/main.cpp", "new_path": "examples/usingArrays/main.cpp", "diff": "@@ -39,7 +39,7 @@ int main(int argc, char **argv) {\n<< \"a.l2Norm() = \" << a.l2Norm<double>() << '\\n'\n<< \"a.lpNorm(2) = \" << a.lpNorm<double>(2) << '\\n'\n<< \"a.lInfNorm() = \" << a.lInfNorm<double>() << '\\n'\n- << \"a.dot() = \" << a.dot<double>() << '\\n'\n+ << \"a.dot() = \" << a.dot<double>(b) << '\\n'\n<< \"a.max() = \" << a.max<double>() << '\\n'\n<< \"a.min() = \" << a.min<double>() << '\\n';\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.hpp", "new_path": "include/occa/array/array.hpp", "diff": "/* The MIT License (MIT)\n*\n- * Copyright (c) 2014-2017 David Medina and Tim Warburton\n+ * Copyright (c) 2014-2017 David Median and Tim Warburton\n*\n* Permission is hereby granted, free of charge, to any person obtaining a copy\n* of this software and associated documentation files (the \"Software\"), to deal\n@@ -272,22 +272,22 @@ namespace occa {\n//==================================\n//---[ Linear Algebra ]-------------\n- template <class TM2>\n- TM2 l1Norm();\n- template <class TM2>\n- TM2 l2Norm();\n- template <class TM2>\n- TM2 lpNorm(const float p);\n- template <class TM2>\n- TM2 lInfNorm();\n-\n- template <class TM2>\n- TM2 max();\n- template <class TM2>\n- TM2 min();\n-\n- template <class TM2>\n- TM2 dot();\n+ template <class RETTYPE>\n+ RETTYPE l1Norm();\n+ template <class RETTYPE>\n+ RETTYPE l2Norm();\n+ template <class RETTYPE>\n+ RETTYPE lpNorm(const float p);\n+ template <class RETTYPE>\n+ RETTYPE lInfNorm();\n+\n+ template <class RETTYPE>\n+ RETTYPE max();\n+ template <class RETTYPE>\n+ RETTYPE min();\n+\n+ template <class RETTYPE, class TM2, const int idxType2>\n+ RETTYPE dot(const array<TM2, idxType2> &vec);\n//==================================\n//---[ Syncs ]----------------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.tpp", "new_path": "include/occa/array/array.tpp", "diff": "@@ -731,45 +731,45 @@ namespace occa {\n//---[ Linear Algebra ]---------------\ntemplate <class TM, const int idxType>\n- template <class TM2>\n- TM2 array<TM,idxType>::l1Norm() {\n- return linalg::l1Norm<TM,TM2>(memory);\n+ template <class RETTYPE>\n+ RETTYPE array<TM,idxType>::l1Norm() {\n+ return linalg::l1Norm<TM,RETTYPE>(memory);\n}\ntemplate <class TM, const int idxType>\n- template <class TM2>\n- TM2 array<TM,idxType>::l2Norm() {\n- return linalg::l2Norm<TM,TM2>(memory);\n+ template <class RETTYPE>\n+ RETTYPE array<TM,idxType>::l2Norm() {\n+ return linalg::l2Norm<TM,RETTYPE>(memory);\n}\ntemplate <class TM, const int idxType>\n- template <class TM2>\n- TM2 array<TM,idxType>::lpNorm(const float p) {\n- return linalg::lpNorm<TM,TM2>(p, memory);\n+ template <class RETTYPE>\n+ RETTYPE array<TM,idxType>::lpNorm(const float p) {\n+ return linalg::lpNorm<TM,RETTYPE>(p, memory);\n}\ntemplate <class TM, const int idxType>\n- template <class TM2>\n- TM2 array<TM,idxType>::lInfNorm() {\n- return linalg::lInfNorm<TM,TM2>(memory);\n+ template <class RETTYPE>\n+ RETTYPE array<TM,idxType>::lInfNorm() {\n+ return linalg::lInfNorm<TM,RETTYPE>(memory);\n}\ntemplate <class TM, const int idxType>\n- template <class TM2>\n- TM2 array<TM,idxType>::max() {\n- return linalg::max<TM,TM2>(memory);\n+ template <class RETTYPE>\n+ RETTYPE array<TM,idxType>::max() {\n+ return linalg::max<TM,RETTYPE>(memory);\n}\ntemplate <class TM, const int idxType>\n- template <class TM2>\n- TM2 array<TM,idxType>::min() {\n- return linalg::min<TM,TM2>(memory);\n+ template <class RETTYPE>\n+ RETTYPE array<TM,idxType>::min() {\n+ return linalg::min<TM,RETTYPE>(memory);\n}\ntemplate <class TM, const int idxType>\n- template <class TM2>\n- TM2 array<TM,idxType>::dot() {\n- return linalg::dot<TM,TM2>(memory);\n+ template <class RETTYPE, class TM2, const int idxType2>\n+ RETTYPE array<TM,idxType>::dot(const array<TM2, idxType2> &vec) {\n+ return linalg::dot<TM,TM2,RETTYPE>(memory, vec.memory);\n}\n//==================================\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/kernels/linalg.okl", "new_path": "include/occa/array/kernels/linalg.okl", "diff": "+#ifndef VTYPE1\n+# define VTYPE1 VTYPE\n+# define VTYPE2 VTYPE\n+#endif\n+#ifndef VTYPE\n+# define VTYPE VTYPE1\n+#endif\n+\n#define CPU_CHUNK ((entries + CPU_DOT_OUTER - 1)/ CPU_DOT_OUTER)\n-#define CPU_REDUCTION_BODY(OPERATION) \\\n+#define CPU_REDUCTION_BODY(OPERATION, RED_OPERATION) \\\nfor (int oi = 0; oi < CPU_DOT_OUTER; ++oi; outer) { \\\nVTYPE r_red = 0; \\\nfor (int i = 0; i < CPU_CHUNK; ++i; inner) { \\\nif ((oi * CPU_CHUNK + i) < entries) { \\\n- VTYPE vec_i = vec[oi * CPU_CHUNK + i]; \\\n- OPERATION(r_red, vec_i); \\\n+ OPERATION(r_red, oi * CPU_CHUNK + i); \\\n} \\\n} \\\nvecReduction[oi] = r_red; \\\n#define GPU_DOT_BLOCK (GPU_DOT_OUTER * GPU_DOT_INNER)\n-#define GPU_UNROLLED_DOT_ITER(N, OPERATION) \\\n+#define GPU_UNROLLED_DOT_ITER(N, RED_OPERATION) \\\nfor (int i = 0; i < GPU_DOT_INNER; ++i; inner) { \\\nif (GPU_DOT_BLOCK >= (2*N)) { \\\nif (i < N) { \\\n- OPERATION(s_red[i], s_red[i + N])); \\\n+ RED_OPERATION(s_red[i], s_red[i + N]); \\\n+ } \\\n} \\\n}\n-#define GPU_REDUCTION_BODY(OPERATION) \\\n+#define GPU_REDUCTION_BODY(OPERATION, RED_OPERATION) \\\nfor (int oi = 0; oi < (entries + GPU_DOT_OUTER - 1)/GPU_DOT_OUTER; ++oi; outer) { \\\nshared VTYPE s_red[GPU_DOT_INNER]; \\\n\\\nVTYPE r_red = 0; \\\nfor (int j = 0; j < GPU_DOT_BLOCK; ++j) { \\\nif ((oi*GPU_DOT_OUTER + i*GPU_DOT_BLOCK + j) < entries) { \\\n- VTYPE vec_i = vec[oi*GPU_DOT_OUTER + i*GPU_DOT_BLOCK + j]; \\\n- OPERATION(r_red, vec_i); \\\n+ OPERATION(r_red, oi*GPU_DOT_OUTER + i*GPU_DOT_BLOCK + j); \\\n} \\\n} \\\ns_red[i] = r_red; \\\n} \\\n\\\n- GPU_UNROLLED_DOT_ITER(256, OPERATION); \\\n- GPU_UNROLLED_DOT_ITER(128, OPERATION); \\\n- GPU_UNROLLED_DOT_ITER(64 , OPERATION); \\\n- GPU_UNROLLED_DOT_ITER(32 , OPERATION); \\\n- GPU_UNROLLED_DOT_ITER(16 , OPERATION); \\\n- GPU_UNROLLED_DOT_ITER(8 , OPERATION); \\\n- GPU_UNROLLED_DOT_ITER(2 , OPERATION); \\\n- GPU_UNROLLED_DOT_ITER(1 , OPERATION); \\\n+ GPU_UNROLLED_DOT_ITER(256, RED_OPERATION); \\\n+ GPU_UNROLLED_DOT_ITER(128, RED_OPERATION); \\\n+ GPU_UNROLLED_DOT_ITER(64 , RED_OPERATION); \\\n+ GPU_UNROLLED_DOT_ITER(32 , RED_OPERATION); \\\n+ GPU_UNROLLED_DOT_ITER(16 , RED_OPERATION); \\\n+ GPU_UNROLLED_DOT_ITER(8 , RED_OPERATION); \\\n+ GPU_UNROLLED_DOT_ITER(2 , RED_OPERATION); \\\n+ GPU_UNROLLED_DOT_ITER(1 , RED_OPERATION); \\\n\\\nfor (int i = 0; i < GPU_DOT_INNER; ++i; inner) { \\\nif (i == 0) { \\\n# define REDUCTION_BODY GPU_REDUCTION_BODY\n#endif\n+#define SUM_RED_OPERATION(red, part) \\\n+ red += part\n+\n+#define ABS_MAX_RED_OPERATION(red, part) \\\n+ red = abs(red*red > part*part ? red : part)\n+\n+#define MAX_RED_OPERATION(red, part) \\\n+ red = red > part ? red : part\n+\n+#define MIN_RED_OPERATION(red, part) \\\n+ red = red < part ? red : part\n+\nkernel void l1Norm(const int entries,\nconst VTYPE * vec,\nRETTYPE * vecReduction) {\n-#define L1_NORM_BODY(out, in) \\\n- out += abs(in)\n- REDUCTION_BODY(L1_NORM_BODY);\n+#define L1_NORM_OPERATION(out, idx) \\\n+ out += abs(vec[idx])\n+ REDUCTION_BODY(L1_NORM_OPERATION, SUM_RED_OPERATION);\n}\nkernel void l2Norm(const int entries,\nconst VTYPE * vec,\nRETTYPE * vecReduction) {\n-#define L2_NORM_BODY(out, in) \\\n- out += in * in;\n- REDUCTION_BODY(L2_NORM_BODY);\n+#define L2_NORM_OPERATION(out, idx) \\\n+ const VTYPE vec_i = vec[idx]; \\\n+ out += vec_i * vec_i;\n+ REDUCTION_BODY(L2_NORM_OPERATION, SUM_RED_OPERATION);\n}\nkernel void lpNorm(const int entries,\nconst float p,\nconst VTYPE * vec,\nRETTYPE * vecReduction) {\n-#define LP_NORM_BODY(out, in) \\\n- out += pow(in, p)\n- REDUCTION_BODY(LP_NORM_BODY);\n+#define LP_NORM_OPERATION(out, idx) \\\n+ const VTYPE vec_i = vec[idx]; \\\n+ out += pow(vec_i, p)\n+ REDUCTION_BODY(LP_NORM_OPERATION, SUM_RED_OPERATION);\n}\nkernel void lInfNorm(const int entries,\nconst VTYPE * vec,\nRETTYPE * vecReduction) {\n-#define LINF_NORM_BODY(out, in) \\\n- out = abs(out*out > in*in ? out : in)\n- REDUCTION_BODY(LINF_NORM_BODY);\n+#define LINF_NORM_OPERATION(out, idx) \\\n+ const VTYPE vec_i = vec[idx]; \\\n+ out = abs(out*out > vec_i*vec_i ? out : vec_i)\n+ REDUCTION_BODY(LINF_NORM_OPERATION, ABS_MAX_RED_OPERATION);\n}\nkernel void vecMax(const int entries,\nconst VTYPE * vec,\nRETTYPE * vecReduction) {\n-#define MAX_BODY(out, in) \\\n- out = out > in ? out : in\n- REDUCTION_BODY(MAX_BODY);\n+#define MAX_OPERATION(out, idx) \\\n+ const VTYPE vec_i = vec[idx]; \\\n+ out = out > vec_i ? out : vec_i\n+ REDUCTION_BODY(MAX_OPERATION, MAX_RED_OPERATION);\n}\nkernel void vecMin(const int entries,\nconst VTYPE * vec,\nRETTYPE * vecReduction) {\n-#define MIN_BODY(out, in) \\\n- out = out < in ? out : in\n- REDUCTION_BODY(MIN_BODY);\n+#define MIN_OPERATION(out, idx) \\\n+ const VTYPE vec_i = vec[idx]; \\\n+ out = out < vec_i ? out : vec_i\n+ REDUCTION_BODY(MIN_OPERATION, MIN_RED_OPERATION);\n}\nkernel void dot(const int entries,\n- const VTYPE * vec,\n+ const VTYPE1 * vec1,\n+ const VTYPE2 * vec2,\nRETTYPE * vecReduction) {\n-#define DOT_BODY(out, in) \\\n- out += in * in\n- REDUCTION_BODY(DOT_BODY);\n+#define DOT_OPERATION(out, idx) \\\n+ out += vec1[idx] * vec2[idx]\n+ REDUCTION_BODY(DOT_OPERATION, SUM_RED_OPERATION);\n}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.hpp", "new_path": "include/occa/array/linalg.hpp", "diff": "@@ -73,7 +73,7 @@ namespace occa {\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE min(occa::memory vec);\n- template <class VTYPE, class RETTYPE>\n+ template <class VTYPE1, class VTYPE2, class RETTYPE>\nRETTYPE dot(occa::memory vec);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.tpp", "new_path": "include/occa/array/linalg.tpp", "diff": "@@ -194,21 +194,36 @@ namespace occa {\nreturn ret;\n}\n- template <class VTYPE, class RETTYPE>\n- RETTYPE dot(occa::memory vec) {\n+ template <class VTYPE1, class VTYPE2, class RETTYPE>\n+ RETTYPE dot(occa::memory vec1, occa::memory vec2) {\nstatic kernelBuilder builder(getKernelFile(),\n\"dot\",\n\"defines: {\"\n- \" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n+ \" VTYPE1: '\" + primitiveinfo<VTYPE1>::name + \"',\"\n+ \" VTYPE2: '\" + primitiveinfo<VTYPE2>::name + \"',\"\n\" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n\" CPU_DOT_OUTER: 1024,\"\n\" GPU_DOT_OUTER: 1024,\"\n\" GPU_DOT_INNER: 128,\"\n\"}\");\n- RETTYPE *partialReduction = reduce<VTYPE,RETTYPE>(vec, builder, 1024);\n+\n+ OCCA_ERROR(\"Vectors must be in the same device\",\n+ vec1.getDevice() == vec2.getDevice());\n+\n+ device dev = vec1.getDevice();\n+ const int bufferSize = 1024;\n+ RETTYPE *hostBuffer = hostReductionBuffer<RETTYPE>(bufferSize);\n+ memory deviceBuffer = deviceReductionBuffer<RETTYPE>(dev, bufferSize);\n+ const int entries = vec1.size() / sizeof(VTYPE1);\n+ builder.build(dev)(entries,\n+ vec1,\n+ vec2,\n+ deviceBuffer);\n+ dev.finish();\n+ deviceBuffer.copyTo(hostBuffer);\nRETTYPE ret = 0;\nfor (int i = 0; i < 1024; ++i) {\n- ret += partialReduction[i];\n+ ret += hostBuffer[i];\n}\nreturn ret;\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/device.hpp", "new_path": "include/occa/device.hpp", "diff": "@@ -120,6 +120,8 @@ namespace occa {\ndevice(const occa::device &d);\ndevice& operator = (const occa::device &d);\n+ bool operator == (const occa::device &d) const;\n+\nvoid free();\nbool isInitialized();\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -71,10 +71,13 @@ namespace occa {\ndevice& device::operator = (const device &d) {\ndHandle = d.dHandle;\n-\nreturn *this;\n}\n+ bool device::operator == (const occa::device &d) const {\n+ return (dHandle == d.dHandle);\n+ }\n+\nvoid device::free() {\nif (dHandle == NULL) {\nreturn;\n" } ]
C++
MIT License
libocca/occa
[Linalg] Updated dot product
378,349
19.02.2017 21:07:27
21,600
aaf0c7c467e82cffec8d8b4a8332d82a6f83df1c
[Linalg] Added vector assigment operators
[ { "change_type": "MODIFY", "old_path": "examples/usingArrays/main.cpp", "new_path": "examples/usingArrays/main.cpp", "diff": "@@ -18,6 +18,47 @@ int main(int argc, char **argv) {\n//---[ Testing API ]------------------\nstd::cout << \"Testing API:\\n\";\n+ occa::array<float> vec1(10), vec2(10);\n+ for (int i = 0; i < 10; ++i) {\n+ vec1[i] = vec2[i] = i + 1;\n+ }\n+\n+ printVector(vec1);\n+ vec1 += 100;\n+ std::cout << \"vec1 += 100\\n\";\n+ printVector(vec1);\n+ vec1 -= 100;\n+ std::cout << \"vec1 -= 100\\n\";\n+ printVector(vec1);\n+ vec1 *= 10;\n+ std::cout << \"vec1 *= 10\\n\";\n+ printVector(vec1);\n+ vec1 /= 10;\n+ std::cout << \"vec1 /= 10\\n\";\n+ printVector(vec1);\n+\n+ vec1 += vec2;\n+ std::cout << \"vec1 += vec2\\n\";\n+ printVector(vec1);\n+ vec1 -= vec2;\n+ std::cout << \"vec1 -= vec2\\n\";\n+ printVector(vec1);\n+ vec1 *= vec2;\n+ std::cout << \"vec1 *= vec2\\n\";\n+ printVector(vec1);\n+ vec1 /= vec2;\n+ std::cout << \"vec1 /= vec2\\n\";\n+ printVector(vec1);\n+\n+ // Basic linear algebra routines\n+ std::cout << \"vec1.l1Norm() = \" << vec1.l1Norm<double>() << '\\n'\n+ << \"vec1.l2Norm() = \" << vec1.l2Norm<double>() << '\\n'\n+ << \"vec1.lpNorm(2) = \" << vec1.lpNorm<double>(2) << '\\n'\n+ << \"vec1.lInfNorm() = \" << vec1.lInfNorm<double>() << '\\n'\n+ << \"vec1.dot() = \" << vec1.dot<double>(vec2) << '\\n'\n+ << \"vec1.max() = \" << vec1.max<double>() << '\\n'\n+ << \"vec1.min() = \" << vec1.min<double>() << '\\n';\n+\nocca::array<int> a(3,3);\nocca::array<int, occa::useIdxOrder> b(3,3);\n@@ -34,15 +75,6 @@ int main(int argc, char **argv) {\n// Can pass @idxOrder to the kernel\nstd::cout << \"b.idxOrderStr() = \" << b.idxOrderStr() << '\\n';\n- // Basic linear algebra routines\n- std::cout << \"a.l1Norm() = \" << a.l1Norm<double>() << '\\n'\n- << \"a.l2Norm() = \" << a.l2Norm<double>() << '\\n'\n- << \"a.lpNorm(2) = \" << a.lpNorm<double>(2) << '\\n'\n- << \"a.lInfNorm() = \" << a.lInfNorm<double>() << '\\n'\n- << \"a.dot() = \" << a.dot<double>(b) << '\\n'\n- << \"a.max() = \" << a.max<double>() << '\\n'\n- << \"a.min() = \" << a.min<double>() << '\\n';\n-\n// Arrays a and b print out differently\n// due to b.setIdxOrder()\nprintVector(a);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.hpp", "new_path": "include/occa/array/array.hpp", "diff": "@@ -240,35 +240,27 @@ namespace occa {\n//==================================\n//---[ Assignment Operators ]-------\n- template <class TM2>\n- array& operator = (const TM2 value);\n+ array& operator = (const TM value);\n- template <class TM2>\n- array& operator = (const array<TM2> &value);\n+ array& operator += (const TM value);\n- template <class TM2>\n- array& operator += (const TM2 value);\n-\n- template <class TM2>\n- array& operator += (const array<TM2> &value);\n+ template <class TM2, const int idxType2>\n+ array& operator += (const array<TM2,idxType2> &vec);\n- template <class TM2>\n- array& operator -= (const TM2 value);\n+ array& operator -= (const TM value);\n- template <class TM2>\n- array& operator -= (const array<TM2> &value);\n+ template <class TM2, const int idxType2>\n+ array& operator -= (const array<TM2,idxType2> &vec);\n- template <class TM2>\n- array& operator *= (const TM2 value);\n+ array& operator *= (const TM value);\n- template <class TM2>\n- array& operator *= (const array<TM2> &value);\n+ template <class TM2, const int idxType2>\n+ array& operator *= (const array<TM2,idxType2> &vec);\n- template <class TM2>\n- array& operator /= (const TM2 value);\n+ array& operator /= (const TM value);\n- template <class TM2>\n- array& operator /= (const array<TM2> &value);\n+ template <class TM2, const int idxType2>\n+ array& operator /= (const array<TM2,idxType2> &vec);\n//==================================\n//---[ Linear Algebra ]-------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.tpp", "new_path": "include/occa/array/array.tpp", "diff": "@@ -728,6 +728,67 @@ namespace occa {\n}\nreturn data_[fs_[0]*i0 + fs_[1]*i1 + fs_[2]*i2 + fs_[3]*i3 + fs_[4]*i4 + fs_[5]*i5];\n}\n+ //====================================\n+\n+ //---[ Assignment Operators ]-------\n+ template <class TM, const int idxType>\n+ array<TM,idxType>& array<TM,idxType>::operator = (const TM value) {\n+ linalg::operator_eq<TM>(memory, value);\n+ return *this;\n+ }\n+\n+ template <class TM, const int idxType>\n+ array<TM,idxType>& array<TM,idxType>::operator += (const TM value) {\n+ linalg::operator_plus_eq<TM>(memory, value);\n+ return *this;\n+ }\n+\n+ template <class TM, const int idxType>\n+ template <class TM2, const int idxType2>\n+ array<TM,idxType>& array<TM,idxType>::operator += (const array<TM2,idxType2> &vec) {\n+ linalg::operator_plus_eq<TM2,TM>(vec.memory, memory);\n+ return *this;\n+ }\n+\n+ template <class TM, const int idxType>\n+ array<TM,idxType>& array<TM,idxType>::operator -= (const TM value) {\n+ linalg::operator_sub_eq<TM>(memory, value);\n+ return *this;\n+ }\n+\n+ template <class TM, const int idxType>\n+ template <class TM2, const int idxType2>\n+ array<TM,idxType>& array<TM,idxType>::operator -= (const array<TM2,idxType2> &vec) {\n+ linalg::operator_sub_eq<TM2,TM>(vec.memory, memory);\n+ return *this;\n+ }\n+\n+ template <class TM, const int idxType>\n+ array<TM,idxType>& array<TM,idxType>::operator *= (const TM value) {\n+ linalg::operator_mult_eq<TM>(memory, value);\n+ return *this;\n+ }\n+\n+ template <class TM, const int idxType>\n+ template <class TM2, const int idxType2>\n+ array<TM,idxType>& array<TM,idxType>::operator *= (const array<TM2,idxType2> &vec) {\n+ linalg::operator_mult_eq<TM2,TM>(vec.memory, memory);\n+ return *this;\n+ }\n+\n+ template <class TM, const int idxType>\n+ array<TM,idxType>& array<TM,idxType>::operator /= (const TM value) {\n+ linalg::operator_div_eq<TM>(memory, value);\n+ return *this;\n+ }\n+\n+ template <class TM, const int idxType>\n+ template <class TM2, const int idxType2>\n+ array<TM,idxType>& array<TM,idxType>::operator /= (const array<TM2,idxType2> &vec) {\n+ linalg::operator_div_eq<TM2,TM>(vec.memory, memory);\n+ return *this;\n+ }\n+ //====================================\n//---[ Linear Algebra ]---------------\ntemplate <class TM, const int idxType>\n" }, { "change_type": "ADD", "old_path": null, "new_path": "include/occa/array/kernels/assignment.okl", "diff": "+//---[ Compile-time Defines ]-----------\n+// VTYPE_IN : Type of input vectors\n+// VTYPE_OUT : Type of output vectors\n+// TILESIZE : Tiling size\n+//======================================\n+\n+kernel void eq_const(const int entries,\n+ const VTYPE_OUT value,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] = value;\n+ }\n+ }\n+}\n+\n+kernel void plus_eq(const int entries,\n+ const VTYPE_IN * in,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] += in[i];\n+ }\n+ }\n+}\n+\n+kernel void plus_eq_const(const int entries,\n+ const VTYPE_OUT value,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] += value;\n+ }\n+ }\n+}\n+\n+kernel void sub_eq(const int entries,\n+ const VTYPE_IN * in,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] -= in[i];\n+ }\n+ }\n+}\n+\n+kernel void sub_eq_const(const int entries,\n+ const VTYPE_OUT value,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] -= value;\n+ }\n+ }\n+}\n+\n+kernel void mult_eq(const int entries,\n+ const VTYPE_IN * in,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] *= in[i];\n+ }\n+ }\n+}\n+\n+kernel void mult_eq_const(const int entries,\n+ const VTYPE_OUT value,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] *= value;\n+ }\n+ }\n+}\n+\n+kernel void div_eq(const int entries,\n+ const VTYPE_IN * in,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] /= in[i];\n+ }\n+ }\n+}\n+\n+kernel void div_eq_const(const int entries,\n+ const VTYPE_OUT value,\n+ VTYPE_OUT * out) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ out[i] /= value;\n+ }\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/kernels/linalg.okl", "new_path": "include/occa/array/kernels/linalg.okl", "diff": "-#ifndef VTYPE1\n-# define VTYPE1 VTYPE\n-# define VTYPE2 VTYPE\n-#endif\n-#ifndef VTYPE\n-# define VTYPE VTYPE1\n-#endif\n-\n#define CPU_CHUNK ((entries + CPU_DOT_OUTER - 1)/ CPU_DOT_OUTER)\n#define CPU_REDUCTION_BODY(OPERATION, RED_OPERATION) \\\nfor (int oi = 0; oi < CPU_DOT_OUTER; ++oi; outer) { \\\n@@ -133,7 +125,7 @@ kernel void vecMin(const int entries,\n}\nkernel void dot(const int entries,\n- const VTYPE1 * vec1,\n+ const VTYPE * vec1,\nconst VTYPE2 * vec2,\nRETTYPE * vecReduction) {\n#define DOT_OPERATION(out, idx) \\\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.hpp", "new_path": "include/occa/array/linalg.hpp", "diff": "#include \"occa/defines.hpp\"\n#include \"occa/base.hpp\"\n+#include \"occa/tools/env.hpp\"\nnamespace occa {\nnamespace linalg {\n- std::string getKernelFile();\n+ static const int assigmentTileSizeCount = 5;\n+ static const int assigmentTileSizes[5] = {32, 64, 128, 256, 512};\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ kernelBuilder makeAssignmentBuilder(const std::string &kernelName,\n+ const int tileSize);\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ kernelBuilder* makeAssignmentBuilders(const std::string &kernelName);\n+\n+ inline occa::kernel getAssignmentKernel(kernelBuilder *builders,\n+ occa::device dev,\n+ const int tileSize) {\n+ for (int i = 0; i < assigmentTileSizeCount; ++i) {\n+ if (assigmentTileSizes[i] <= tileSize) {\n+ return builders[i].build(dev);\n+ }\n+ }\n+ return builders[assigmentTileSizeCount - 1].build(dev);\n+ }\n+ template <class VTYPE, class RETTYPE>\n+ kernelBuilder makeLinalgBuilder(const std::string &kernelName);\n+\n+ template <class VTYPE1, class VTYPE2, class RETTYPE>\n+ kernelBuilder makeLinalgBuilder(const std::string &kernelName);\n+\n+ //---[ Assignment ]-----------------\n+ template <class VTYPE_OUT>\n+ void operator_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize = 128);\n+\n+ template <class VTYPE_OUT>\n+ void operator_plus_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize = 128);\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ void operator_plus_eq(occa::memory in,\n+ occa::memory out,\n+ const int tileSize = 128);\n+\n+ template <class VTYPE_OUT>\n+ void operator_sub_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize = 128);\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ void operator_sub_eq(occa::memory in,\n+ occa::memory out,\n+ const int tileSize = 128);\n+\n+ template <class VTYPE_OUT>\n+ void operator_mult_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize = 128);\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ void operator_mult_eq(occa::memory in,\n+ occa::memory out,\n+ const int tileSize = 128);\n+\n+ template <class VTYPE_OUT>\n+ void operator_div_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize = 128);\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ void operator_div_eq(occa::memory in,\n+ occa::memory out,\n+ const int tileSize = 128);\n+ //==================================\n+\n+ //---[ Linear Algebra ]-------------\ntemplate <class TM>\ninline std::map<int, TM*>& hostBufferMap() {\nstatic std::map<int, TM*> bufferMap;\n@@ -75,6 +149,7 @@ namespace occa {\ntemplate <class VTYPE1, class VTYPE2, class RETTYPE>\nRETTYPE dot(occa::memory vec);\n+ //==================================\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.tpp", "new_path": "include/occa/array/linalg.tpp", "diff": "namespace occa {\nnamespace linalg {\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ kernelBuilder makeAssignmentBuilder(const std::string &kernelName,\n+ const int tileSize) {\n+ return kernelBuilder(env::OCCA_DIR + \"include/occa/array/kernels/assignment.okl\",\n+ kernelName,\n+ \"defines: {\"\n+ \" VTYPE_IN: '\" + primitiveinfo<VTYPE_IN>::name + \"',\"\n+ \" VTYPE_OUT: '\" + primitiveinfo<VTYPE_OUT>::name + \"',\"\n+ \" TILESIZE: '\" + toString(tileSize) + \"',\"\n+ \"}\");\n+ }\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ kernelBuilder* makeAssignmentBuilders(const std::string &kernelName) {\n+ kernelBuilder *builders = new kernelBuilder[assigmentTileSizeCount];\n+ for (int i = 0; i < assigmentTileSizeCount; ++i) {\n+ builders[i] = makeAssignmentBuilder<VTYPE_IN,VTYPE_OUT>(kernelName,\n+ assigmentTileSizes[i]);\n+ }\n+ return builders;\n+ }\n+\n+ template <class VTYPE, class RETTYPE>\n+ kernelBuilder makeLinalgBuilder(const std::string &kernelName) {\n+ return kernelBuilder(env::OCCA_DIR + \"include/occa/array/kernels/linalg.okl\",\n+ kernelName,\n+ \"defines: {\"\n+ \" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n+ \" VTYPE2: '\" + primitiveinfo<VTYPE>::name + \"',\"\n+ \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n+ \" CPU_DOT_OUTER: 1024,\"\n+ \" GPU_DOT_OUTER: 1024,\"\n+ \" GPU_DOT_INNER: 128,\"\n+ \"}\");\n+ }\n+\n+ template <class VTYPE1, class VTYPE2, class RETTYPE>\n+ kernelBuilder makeLinalgBuilder(const std::string &kernelName) {\n+ return kernelBuilder(env::OCCA_DIR + \"include/occa/array/kernels/linalg.okl\",\n+ kernelName,\n+ \"defines: {\"\n+ \" VTYPE: '\" + primitiveinfo<VTYPE1>::name + \"',\"\n+ \" VTYPE2: '\" + primitiveinfo<VTYPE2>::name + \"',\"\n+ \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n+ \" CPU_DOT_OUTER: 1024,\"\n+ \" GPU_DOT_OUTER: 1024,\"\n+ \" GPU_DOT_INNER: 128,\"\n+ \"}\");\n+ }\n+\n+ //---[ Assignment ]-----------------\n+ template <class VTYPE_OUT>\n+ void operator_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"eq_const\");\n+\n+ const int entries = vec.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ vec.getDevice(),\n+ tileSize)(entries, value, vec);\n+ }\n+\n+ template <class VTYPE_OUT>\n+ void operator_plus_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"plus_eq_const\");\n+\n+ const int entries = vec.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ vec.getDevice(),\n+ tileSize)(entries, value, vec);\n+ }\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ void operator_plus_eq(occa::memory in,\n+ occa::memory out,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_IN,VTYPE_OUT>(\"plus_eq\");\n+\n+ const int entries = in.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ in.getDevice(),\n+ tileSize)(entries, in, out);\n+ }\n+\n+ template <class VTYPE_OUT>\n+ void operator_sub_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"sub_eq_const\");\n+\n+ const int entries = vec.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ vec.getDevice(),\n+ tileSize)(entries, value, vec);\n+ }\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ void operator_sub_eq(occa::memory in,\n+ occa::memory out,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_IN,VTYPE_OUT>(\"sub_eq\");\n+\n+ const int entries = in.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ in.getDevice(),\n+ tileSize)(entries, in, out);\n+ }\n+\n+ template <class VTYPE_OUT>\n+ void operator_mult_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"mult_eq_const\");\n+\n+ const int entries = vec.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ vec.getDevice(),\n+ tileSize)(entries, value, vec);\n+ }\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ void operator_mult_eq(occa::memory in,\n+ occa::memory out,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_IN,VTYPE_OUT>(\"mult_eq\");\n+\n+ const int entries = in.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ in.getDevice(),\n+ tileSize)(entries, in, out);\n+ }\n+\n+ template <class VTYPE_OUT>\n+ void operator_div_eq(occa::memory vec,\n+ const VTYPE_OUT value,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"div_eq_const\");\n+\n+ const int entries = vec.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ vec.getDevice(),\n+ tileSize)(entries, value, vec);\n+ }\n+\n+ template <class VTYPE_IN, class VTYPE_OUT>\n+ void operator_div_eq(occa::memory in,\n+ occa::memory out,\n+ const int tileSize) {\n+ static kernelBuilder *builders =\n+ makeAssignmentBuilders<VTYPE_IN,VTYPE_OUT>(\"div_eq\");\n+\n+ const int entries = in.size() / sizeof(VTYPE_OUT);\n+ getAssignmentKernel(builders,\n+ in.getDevice(),\n+ tileSize)(entries, in, out);\n+ }\n+ //==================================\n+\n+ //---[ Linear Algebra ]-------------\ntemplate <class TM>\nTM *hostReductionBuffer(const int size) {\nstd::map<int, TM*> &bufferMap = hostBufferMap<TM>();\n@@ -63,15 +233,9 @@ namespace occa {\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE l1Norm(occa::memory vec) {\n- static kernelBuilder builder(getKernelFile(),\n- \"l1Norm\",\n- \"defines: {\"\n- \" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n- \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n- \" CPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_INNER: 128,\"\n- \"}\");\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE, RETTYPE>(\"l1Norm\");\n+\nRETTYPE *partialReduction = reduce<VTYPE,RETTYPE>(vec, builder, 1024);\nRETTYPE ret = 0;\nfor (int i = 0; i < 1024; ++i) {\n@@ -82,15 +246,9 @@ namespace occa {\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE l2Norm(occa::memory vec) {\n- static kernelBuilder builder(getKernelFile(),\n- \"l2Norm\",\n- \"defines: {\"\n- \" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n- \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n- \" CPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_INNER: 128,\"\n- \"}\");\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE, RETTYPE>(\"l2Norm\");\n+\nRETTYPE *partialReduction = reduce<VTYPE,RETTYPE>(vec, builder, 1024);\nRETTYPE ret = 0;\nfor (int i = 0; i < 1024; ++i) {\n@@ -102,15 +260,9 @@ namespace occa {\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE lpNorm(const float p,\nocca::memory vec) {\n- static kernelBuilder builder(getKernelFile(),\n- \"lpNorm\",\n- \"defines: {\"\n- \" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n- \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n- \" CPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_INNER: 128,\"\n- \"}\");\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE, RETTYPE>(\"lpNorm\");\n+\ndevice dev = vec.getDevice();\nconst int bufferSize = 1024;\n@@ -132,15 +284,9 @@ namespace occa {\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE lInfNorm(occa::memory vec) {\n- static kernelBuilder builder(getKernelFile(),\n- \"lInfNorm\",\n- \"defines: {\"\n- \" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n- \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n- \" CPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_INNER: 128,\"\n- \"}\");\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE, RETTYPE>(\"lInfNorm\");\n+\nRETTYPE *partialReduction = reduce<VTYPE,RETTYPE>(vec, builder, 1024);\nRETTYPE ret = std::abs(partialReduction[0]);\nfor (int i = 1; i < 1024; ++i) {\n@@ -154,15 +300,9 @@ namespace occa {\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE max(occa::memory vec) {\n- static kernelBuilder builder(getKernelFile(),\n- \"vecMax\",\n- \"defines: {\"\n- \" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n- \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n- \" CPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_INNER: 128,\"\n- \"}\");\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE, RETTYPE>(\"vecMax\");\n+\nRETTYPE *partialReduction = reduce<VTYPE,RETTYPE>(vec, builder, 1024);\nRETTYPE ret = partialReduction[0];\nfor (int i = 1; i < 1024; ++i) {\n@@ -175,15 +315,9 @@ namespace occa {\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE min(occa::memory vec) {\n- static kernelBuilder builder(getKernelFile(),\n- \"vecMin\",\n- \"defines: {\"\n- \" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n- \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n- \" CPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_INNER: 128,\"\n- \"}\");\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE, RETTYPE>(\"vecMin\");\n+\nRETTYPE *partialReduction = reduce<VTYPE,RETTYPE>(vec, builder, 1024);\nRETTYPE ret = partialReduction[0];\nfor (int i = 1; i < 1024; ++i) {\n@@ -196,16 +330,8 @@ namespace occa {\ntemplate <class VTYPE1, class VTYPE2, class RETTYPE>\nRETTYPE dot(occa::memory vec1, occa::memory vec2) {\n- static kernelBuilder builder(getKernelFile(),\n- \"dot\",\n- \"defines: {\"\n- \" VTYPE1: '\" + primitiveinfo<VTYPE1>::name + \"',\"\n- \" VTYPE2: '\" + primitiveinfo<VTYPE2>::name + \"',\"\n- \" RETTYPE: '\" + primitiveinfo<RETTYPE>::name + \"',\"\n- \" CPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_OUTER: 1024,\"\n- \" GPU_DOT_INNER: 128,\"\n- \"}\");\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE1, VTYPE2, RETTYPE>(\"dot\");\nOCCA_ERROR(\"Vectors must be in the same device\",\nvec1.getDevice() == vec2.getDevice());\n@@ -227,5 +353,6 @@ namespace occa {\n}\nreturn ret;\n}\n+ //==================================\n}\n}\n" } ]
C++
MIT License
libocca/occa
[Linalg] Added vector assigment operators
378,349
19.02.2017 21:31:28
21,600
d028f83784e51840729f0aeb9eea0029041cd3ff
[Linalg] Added axpy
[ { "change_type": "MODIFY", "old_path": "examples/usingArrays/main.cpp", "new_path": "examples/usingArrays/main.cpp", "diff": "@@ -50,6 +50,14 @@ int main(int argc, char **argv) {\nstd::cout << \"vec1 /= vec2\\n\";\nprintVector(vec1);\n+ std::cout << \"vec1 += -1*vec2 (axpy)\\n\";\n+ vec1.sum(-1, vec2);\n+ printVector(vec1);\n+\n+ std::cout << \"vec1 += 10*vec2 (axpy)\\n\";\n+ vec1.sum(10, vec2);\n+ printVector(vec1);\n+\n// Basic linear algebra routines\nstd::cout << \"vec1.l1Norm() = \" << vec1.l1Norm<double>() << '\\n'\n<< \"vec1.l2Norm() = \" << vec1.l2Norm<double>() << '\\n'\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.hpp", "new_path": "include/occa/array/array.hpp", "diff": "@@ -280,6 +280,10 @@ namespace occa {\ntemplate <class RETTYPE, class TM2, const int idxType2>\nRETTYPE dot(const array<TM2, idxType2> &vec);\n+\n+ template <class TYPE_A, class TM2, const int idxType2>\n+ array& sum(const TYPE_A alpha,\n+ const array<TM2, idxType2> &vec);\n//==================================\n//---[ Syncs ]----------------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.tpp", "new_path": "include/occa/array/array.tpp", "diff": "@@ -832,6 +832,14 @@ namespace occa {\nRETTYPE array<TM,idxType>::dot(const array<TM2, idxType2> &vec) {\nreturn linalg::dot<TM,TM2,RETTYPE>(memory, vec.memory);\n}\n+\n+ template <class TM, const int idxType>\n+ template <class TYPE_A, class TM2, const int idxType2>\n+ array<TM,idxType>& array<TM,idxType>::sum(const TYPE_A alpha,\n+ const array<TM2, idxType2> &vec) {\n+ linalg::axpy<TYPE_A,TM2,TM>(alpha, vec.memory, memory);\n+ return *this;\n+ }\n//==================================\n//---[ Syncs ]------------------------\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/kernels/linalg.okl", "new_path": "include/occa/array/kernels/linalg.okl", "diff": "+// Make sure the compiler doesn't complain if we don't define some things\n+// We define what is needed on a kernel-by-kernel basis\n+#ifndef RETTYPE\n+# define RETTYPE float\n+#endif\n+#ifndef VTYPE\n+# define VTYPE float\n+#endif\n+#ifndef VTYPE2\n+# define VTYPE2 float\n+#endif\n+#ifndef CPU_DOT_OUTER\n+# define CPU_DOT_OUTER 1\n+#endif\n+#ifndef GPU_DOT_OUTER\n+# define GPU_DOT_OUTER 1\n+#endif\n+#ifndef GPU_DOT_INNER\n+# define GPU_DOT_INNER 1\n+#endif\n+\n+#ifndef TILESIZE\n+# define TILESIZE 128\n+#endif\n+#ifndef TYPE_A\n+# define TYPE_A float\n+#endif\n+#ifndef VTYPE_X\n+# define VTYPE_X float\n+#endif\n+#ifndef VTYPE_Y\n+# define VTYPE_Y float\n+#endif\n+\n#define CPU_CHUNK ((entries + CPU_DOT_OUTER - 1)/ CPU_DOT_OUTER)\n#define CPU_REDUCTION_BODY(OPERATION, RED_OPERATION) \\\nfor (int oi = 0; oi < CPU_DOT_OUTER; ++oi; outer) { \\\n@@ -132,3 +166,14 @@ kernel void dot(const int entries,\nout += vec1[idx] * vec2[idx]\nREDUCTION_BODY(DOT_OPERATION, SUM_RED_OPERATION);\n}\n+\n+kernel void axpy(const int entries,\n+ const TYPE_A alpha,\n+ const VTYPE_X * x,\n+ VTYPE_Y * y) {\n+ for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\n+ if (i < entries) {\n+ y[i] += alpha * x[i];\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.hpp", "new_path": "include/occa/array/linalg.hpp", "diff": "namespace occa {\nnamespace linalg {\n- static const int assigmentTileSizeCount = 5;\n- static const int assigmentTileSizes[5] = {32, 64, 128, 256, 512};\n+ static const int usedTileSizeCount = 5;\n+ static const int usedTileSizes[5] = {32, 64, 128, 256, 512};\ntemplate <class VTYPE_IN, class VTYPE_OUT>\nkernelBuilder makeAssignmentBuilder(const std::string &kernelName,\n@@ -41,15 +41,15 @@ namespace occa {\ntemplate <class VTYPE_IN, class VTYPE_OUT>\nkernelBuilder* makeAssignmentBuilders(const std::string &kernelName);\n- inline occa::kernel getAssignmentKernel(kernelBuilder *builders,\n+ inline occa::kernel getTiledKernel(kernelBuilder *builders,\nocca::device dev,\nconst int tileSize) {\n- for (int i = 0; i < assigmentTileSizeCount; ++i) {\n- if (assigmentTileSizes[i] <= tileSize) {\n+ for (int i = 0; i < usedTileSizeCount; ++i) {\n+ if (usedTileSizes[i] <= tileSize) {\nreturn builders[i].build(dev);\n}\n}\n- return builders[assigmentTileSizeCount - 1].build(dev);\n+ return builders[usedTileSizeCount - 1].build(dev);\n}\ntemplate <class VTYPE, class RETTYPE>\n@@ -149,6 +149,12 @@ namespace occa {\ntemplate <class VTYPE1, class VTYPE2, class RETTYPE>\nRETTYPE dot(occa::memory vec);\n+\n+ template <class TYPE_A, class VTYPE_X, class VTYPE_Y>\n+ void axpy(const TYPE_A &alpha,\n+ occa::memory x,\n+ occa::memory y,\n+ const int tileSize = 128);\n//==================================\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.tpp", "new_path": "include/occa/array/linalg.tpp", "diff": "@@ -36,10 +36,10 @@ namespace occa {\ntemplate <class VTYPE_IN, class VTYPE_OUT>\nkernelBuilder* makeAssignmentBuilders(const std::string &kernelName) {\n- kernelBuilder *builders = new kernelBuilder[assigmentTileSizeCount];\n- for (int i = 0; i < assigmentTileSizeCount; ++i) {\n+ kernelBuilder *builders = new kernelBuilder[usedTileSizeCount];\n+ for (int i = 0; i < usedTileSizeCount; ++i) {\nbuilders[i] = makeAssignmentBuilder<VTYPE_IN,VTYPE_OUT>(kernelName,\n- assigmentTileSizes[i]);\n+ usedTileSizes[i]);\n}\nreturn builders;\n}\n@@ -81,7 +81,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"eq_const\");\nconst int entries = vec.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nvec.getDevice(),\ntileSize)(entries, value, vec);\n}\n@@ -94,7 +94,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"plus_eq_const\");\nconst int entries = vec.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nvec.getDevice(),\ntileSize)(entries, value, vec);\n}\n@@ -107,7 +107,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_IN,VTYPE_OUT>(\"plus_eq\");\nconst int entries = in.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nin.getDevice(),\ntileSize)(entries, in, out);\n}\n@@ -120,7 +120,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"sub_eq_const\");\nconst int entries = vec.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nvec.getDevice(),\ntileSize)(entries, value, vec);\n}\n@@ -133,7 +133,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_IN,VTYPE_OUT>(\"sub_eq\");\nconst int entries = in.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nin.getDevice(),\ntileSize)(entries, in, out);\n}\n@@ -146,7 +146,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"mult_eq_const\");\nconst int entries = vec.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nvec.getDevice(),\ntileSize)(entries, value, vec);\n}\n@@ -159,7 +159,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_IN,VTYPE_OUT>(\"mult_eq\");\nconst int entries = in.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nin.getDevice(),\ntileSize)(entries, in, out);\n}\n@@ -172,7 +172,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_OUT,VTYPE_OUT>(\"div_eq_const\");\nconst int entries = vec.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nvec.getDevice(),\ntileSize)(entries, value, vec);\n}\n@@ -185,7 +185,7 @@ namespace occa {\nmakeAssignmentBuilders<VTYPE_IN,VTYPE_OUT>(\"div_eq\");\nconst int entries = in.size() / sizeof(VTYPE_OUT);\n- getAssignmentKernel(builders,\n+ getTiledKernel(builders,\nin.getDevice(),\ntileSize)(entries, in, out);\n}\n@@ -353,6 +353,34 @@ namespace occa {\n}\nreturn ret;\n}\n+\n+ template <class TYPE_A, class VTYPE_X, class VTYPE_Y>\n+ void axpy(const TYPE_A &alpha,\n+ occa::memory x,\n+ occa::memory y,\n+ const int tileSize) {\n+\n+ static kernelBuilder *builders;\n+ if (!builders) {\n+ builders = new kernelBuilder[usedTileSizeCount];\n+ for (int i = 0; i < usedTileSizeCount; ++i) {\n+ builders[i] = kernelBuilder(env::OCCA_DIR +\n+ \"include/occa/array/kernels/linalg.okl\",\n+ \"axpy\",\n+ \"defines: {\"\n+ \" TYPE_A: '\" + primitiveinfo<TYPE_A>::name + \"',\"\n+ \" VTYPE_X: '\" + primitiveinfo<VTYPE_X>::name + \"',\"\n+ \" VTYPE_Y: '\" + primitiveinfo<VTYPE_Y>::name + \"',\"\n+ \" TILESIZE: '\" + toString(usedTileSizes[i]) + \"',\"\n+ \"}\");\n+ }\n+ }\n+\n+ const int entries = y.size() / sizeof(VTYPE_Y);\n+ getTiledKernel(builders,\n+ y.getDevice(),\n+ tileSize)(entries, alpha, x, y);\n+ }\n//==================================\n}\n}\n" } ]
C++
MIT License
libocca/occa
[Linalg] Added axpy
378,349
19.02.2017 22:57:15
21,600
1ac15e6fd280fd838c913e1edeb327e8e0ef6a37
[Linalg] Added custom linear kernel builders
[ { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.hpp", "new_path": "include/occa/array/linalg.hpp", "diff": "@@ -148,13 +148,17 @@ namespace occa {\nRETTYPE min(occa::memory vec);\ntemplate <class VTYPE1, class VTYPE2, class RETTYPE>\n- RETTYPE dot(occa::memory vec);\n+ RETTYPE dot(occa::memory vec1, occa::memory vec2);\ntemplate <class TYPE_A, class VTYPE_X, class VTYPE_Y>\nvoid axpy(const TYPE_A &alpha,\nocca::memory x,\nocca::memory y,\nconst int tileSize = 128);\n+\n+ sourceKernelBuilder customLinearMethod(const std::string &kernelName,\n+ const std::string &formula,\n+ const occa::properties &props = occa::properties());\n//==================================\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.tpp", "new_path": "include/occa/array/linalg.tpp", "diff": "@@ -360,17 +360,17 @@ namespace occa {\nocca::memory y,\nconst int tileSize) {\n- static kernelBuilder *builders;\n+ static sourceKernelBuilder *builders;\nif (!builders) {\n- builders = new kernelBuilder[usedTileSizeCount];\n+ builders = new sourceKernelBuilder[usedTileSizeCount];\nfor (int i = 0; i < usedTileSizeCount; ++i) {\n- builders[i] = kernelBuilder(env::OCCA_DIR +\n- \"include/occa/array/kernels/linalg.okl\",\n- \"axpy\",\n+ builders[i] =\n+ customLinearMethod(\"axpy\",\n+ \"v0[i] += c0 * v1[i]\",\n\"defines: {\"\n- \" TYPE_A: '\" + primitiveinfo<TYPE_A>::name + \"',\"\n- \" VTYPE_X: '\" + primitiveinfo<VTYPE_X>::name + \"',\"\n- \" VTYPE_Y: '\" + primitiveinfo<VTYPE_Y>::name + \"',\"\n+ \" CTYPE0: '\" + primitiveinfo<TYPE_A>::name + \"',\"\n+ \" VTYPE0: '\" + primitiveinfo<VTYPE_Y>::name + \"',\"\n+ \" VTYPE1: '\" + primitiveinfo<VTYPE_X>::name + \"',\"\n\" TILESIZE: '\" + toString(usedTileSizes[i]) + \"',\"\n\"}\");\n}\n@@ -379,7 +379,7 @@ namespace occa {\nconst int entries = y.size() / sizeof(VTYPE_Y);\ngetTiledKernel(builders,\ny.getDevice(),\n- tileSize)(entries, alpha, x, y);\n+ tileSize)(entries, alpha, y, x);\n}\n//==================================\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/kernel.hpp", "new_path": "include/occa/kernel.hpp", "diff": "@@ -242,7 +242,7 @@ namespace occa {\n//---[ kernel builder ]---------------\nclass kernelBuilder {\n- private:\n+ protected:\nstd::string filename_;\nstd::string function_;\nocca::properties props_;\n@@ -264,7 +264,7 @@ namespace occa {\nconst std::string &function,\nconst occa::properties &props = occa::properties());\n- occa::kernel build(occa::device device,\n+ virtual occa::kernel build(occa::device device,\nconst hash_t &hash);\nocca::kernel build(occa::device device);\n@@ -280,6 +280,27 @@ namespace occa {\nvoid free();\n};\n+\n+ class sourceKernelBuilder : public kernelBuilder {\n+ private:\n+ std::string content_;\n+\n+ public:\n+ sourceKernelBuilder();\n+ sourceKernelBuilder(const std::string &content,\n+ const std::string &function,\n+ const occa::properties &props = occa::properties());\n+\n+ sourceKernelBuilder(const sourceKernelBuilder &k);\n+ sourceKernelBuilder& operator = (const sourceKernelBuilder &k);\n+\n+ void use(const std::string &content,\n+ const std::string &function,\n+ const occa::properties &props = occa::properties());\n+\n+ virtual occa::kernel build(occa::device device,\n+ const hash_t &hash);\n+ };\n//====================================\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/array/linalg.cpp", "diff": "+/* The MIT License (MIT)\n+ *\n+ * Copyright (c) 2014-2017 David Medina and Tim Warburton\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in all\n+ * copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+ */\n+\n+#include <algorithm>\n+#include <sstream>\n+\n+#include \"occa/types.hpp\"\n+#include \"occa/array/linalg.hpp\"\n+#include \"occa/tools/lex.hpp\"\n+\n+namespace occa {\n+ namespace linalg {\n+ // \"v0[i] = c1 * (v0[i] + v1[i])\"\n+ sourceKernelBuilder customLinearMethod(const std::string &kernelName,\n+ const std::string &formula,\n+ const occa::properties &props) {\n+\n+ sourceKernelBuilder builder;\n+\n+ // Extract input and constant counts\n+ intVector_t inputs, constants;\n+ int minInput = 0, maxInput = 0;\n+ int minConstant = 0, maxConstant = 0;\n+\n+ const char *c = formula.c_str();\n+ while (*c) {\n+ if ((*c == 'v') || (*c == 'c')) {\n+ intVector_t &vec = (*c == 'v') ? inputs : constants;\n+ int &minVal = (*c == 'v') ? minInput : minConstant;\n+ int &maxVal = (*c == 'v') ? maxInput : maxConstant;\n+\n+ const char *cStart = ++c;\n+ lex::skipFrom(c, lex::numChars);\n+ OCCA_ERROR(\"Digit must follow 'v' or 'c'\",\n+ cStart != c);\n+\n+ const int idx = occa::atoi(std::string(cStart, c - cStart));\n+ if (std::find(vec.begin(), vec.end(), idx) == vec.end()) {\n+ vec.push_back(idx);\n+ if (minVal > idx) {\n+ minVal = idx;\n+ }\n+ if (maxVal < idx) {\n+ maxVal = idx;\n+ }\n+ }\n+ }\n+ ++c;\n+ }\n+\n+ const int inputCount = (int) inputs.size();\n+ const int constantCount = (int) constants.size();\n+\n+ // Make sure vectors and constants are propertly labeled:\n+ // v0, v1, v2, ...\n+ // c0, c1, c2, ...\n+ OCCA_ERROR(\"Minimum vector index must be 0 (the output)\",\n+ minInput == 0);\n+ OCCA_ERROR(\"Cannot skip vector indices, found index \"\n+ << maxInput << \" but only \" << inputCount << \" vector inputs\",\n+ maxInput == (inputCount - 1));\n+\n+ OCCA_ERROR(\"Minimum constant index must be 0\",\n+ minConstant == 0);\n+ OCCA_ERROR(\"Cannot skip constant indices, found index \"\n+ << maxConstant << \" but only \" << constantCount << \" constants inputs\",\n+ maxConstant == (constantCount - 1));\n+\n+ // Make sure we have all the defines needed\n+ OCCA_ERROR(\"TILESIZE must be defined\",\n+ props.has(\"defines/TILESIZE\"));\n+ for (int i = 0; i < inputCount; ++i) {\n+ const std::string vtype = \"VTYPE\" + toString(i);\n+ OCCA_ERROR(\"Type \" << vtype << \" must be defined\",\n+ props.has(\"defines/\" + vtype));\n+ }\n+ for (int i = 0; i < constantCount; ++i) {\n+ const std::string ctype = \"CTYPE\" + toString(i);\n+ OCCA_ERROR(\"Type \" << ctype << \" must be defined\",\n+ props.has(\"defines/\" + ctype));\n+ }\n+\n+ std::stringstream ss;\n+\n+ // Setup arguments\n+ ss << \"kernel void \" << kernelName << \"(const int entries,\\n\";\n+ for (int i = 0; i < constantCount; ++i) {\n+ ss << \" const CTYPE\" << i << \" c\" << i;\n+ if ((i < (constantCount - 1)) || inputCount) {\n+ ss << \",\\n\";\n+ }\n+ }\n+ for (int i = 0; i < inputCount; ++i) {\n+ ss << \" \"\n+ << (i != 0 ? \"const \" : \" \")\n+ << \"VTYPE\" << i << \" *v\" << i;\n+ if (i < (inputCount - 1)) {\n+ ss << \",\\n\";\n+ }\n+ }\n+ // Setup body\n+ ss << \") {\\n\"\n+ \" for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\\n\"\n+ \" if (i < entries) {\\n\"\n+ \" \" << formula << \";\\n\"\n+ \" }\\n\"\n+ \" }\\n\"\n+ \"}\\n\";\n+\n+ return sourceKernelBuilder(ss.str(), kernelName, props);\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "src/kernel.cpp", "new_path": "src/kernel.cpp", "diff": "@@ -439,7 +439,7 @@ namespace occa {\n}\nbool kernelBuilder::isInitialized() {\n- return (0 < filename_.size());\n+ return (0 < function_.size());\n}\nvoid kernelBuilder::use(const std::string &filename,\n@@ -451,7 +451,7 @@ namespace occa {\nprops_ = props;\n}\n- inline occa::kernel kernelBuilder::build(occa::device device,\n+ occa::kernel kernelBuilder::build(occa::device device,\nconst hash_t &hash) {\nocca::kernel &k = kernelMap[hash];\nif (!k.isInitialized()) {\n@@ -492,5 +492,49 @@ namespace occa {\n}\n}\n+ sourceKernelBuilder::sourceKernelBuilder() {}\n+\n+ sourceKernelBuilder::sourceKernelBuilder(const std::string &content,\n+ const std::string &function,\n+ const occa::properties &props) :\n+ content_(content) {\n+\n+ function_ = function;\n+ props_ = props;\n+ }\n+\n+ sourceKernelBuilder::sourceKernelBuilder(const sourceKernelBuilder &k) :\n+ content_(k.content_) {\n+ function_ = k.function_;\n+ props_ = k.props_;\n+ kernelMap = k.kernelMap;\n+ }\n+\n+ sourceKernelBuilder& sourceKernelBuilder::operator = (const sourceKernelBuilder &k) {\n+ content_ = k.content_;\n+ function_ = k.function_;\n+ props_ = k.props_;\n+ kernelMap = k.kernelMap;\n+ return *this;\n+ }\n+\n+ void sourceKernelBuilder::use(const std::string &content,\n+ const std::string &function,\n+ const occa::properties &props) {\n+ free();\n+ content_ = content;\n+ function_ = function;\n+ props_ = props;\n+ }\n+\n+ occa::kernel sourceKernelBuilder::build(occa::device device,\n+ const hash_t &hash) {\n+ occa::kernel &k = kernelMap[hash];\n+ if (!k.isInitialized()) {\n+ k = device.buildKernelFromString(content_, function_, props_);\n+ }\n+ return k;\n+ }\n+\n//====================================\n}\n" } ]
C++
MIT License
libocca/occa
[Linalg] Added custom linear kernel builders
378,349
19.02.2017 23:37:14
21,600
f0b33094b62c55d7dfb1cff503dc66b59a1e6218
[Kernel] Merged kernelBuilder and sourceKernelBuilder
[ { "change_type": "MODIFY", "old_path": "include/occa/array/kernels/linalg.okl", "new_path": "include/occa/array/kernels/linalg.okl", "diff": "@@ -167,6 +167,14 @@ kernel void dot(const int entries,\nREDUCTION_BODY(DOT_OPERATION, SUM_RED_OPERATION);\n}\n+kernel void sum(const int entries,\n+ const VTYPE * vec,\n+ RETTYPE * vecReduction) {\n+#define SUM_OPERATION(out, idx) \\\n+ out += vec[idx]\n+ REDUCTION_BODY(SUM_OPERATION, SUM_RED_OPERATION);\n+}\n+\nkernel void axpy(const int entries,\nconst TYPE_A alpha,\nconst VTYPE_X * x,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.hpp", "new_path": "include/occa/array/linalg.hpp", "diff": "@@ -150,13 +150,16 @@ namespace occa {\ntemplate <class VTYPE1, class VTYPE2, class RETTYPE>\nRETTYPE dot(occa::memory vec1, occa::memory vec2);\n+ template <class VTYPE, class RETTYPE>\n+ RETTYPE sum(occa::memory vec);\n+\ntemplate <class TYPE_A, class VTYPE_X, class VTYPE_Y>\nvoid axpy(const TYPE_A &alpha,\nocca::memory x,\nocca::memory y,\nconst int tileSize = 128);\n- sourceKernelBuilder customLinearMethod(const std::string &kernelName,\n+ kernelBuilder customLinearMethod(const std::string &kernelName,\nconst std::string &formula,\nconst occa::properties &props = occa::properties());\n//==================================\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.tpp", "new_path": "include/occa/array/linalg.tpp", "diff": "@@ -25,7 +25,7 @@ namespace occa {\ntemplate <class VTYPE_IN, class VTYPE_OUT>\nkernelBuilder makeAssignmentBuilder(const std::string &kernelName,\nconst int tileSize) {\n- return kernelBuilder(env::OCCA_DIR + \"include/occa/array/kernels/assignment.okl\",\n+ return kernelBuilder::fromFile(env::OCCA_DIR + \"include/occa/array/kernels/assignment.okl\",\nkernelName,\n\"defines: {\"\n\" VTYPE_IN: '\" + primitiveinfo<VTYPE_IN>::name + \"',\"\n@@ -46,7 +46,7 @@ namespace occa {\ntemplate <class VTYPE, class RETTYPE>\nkernelBuilder makeLinalgBuilder(const std::string &kernelName) {\n- return kernelBuilder(env::OCCA_DIR + \"include/occa/array/kernels/linalg.okl\",\n+ return kernelBuilder::fromFile(env::OCCA_DIR + \"include/occa/array/kernels/linalg.okl\",\nkernelName,\n\"defines: {\"\n\" VTYPE: '\" + primitiveinfo<VTYPE>::name + \"',\"\n@@ -60,7 +60,7 @@ namespace occa {\ntemplate <class VTYPE1, class VTYPE2, class RETTYPE>\nkernelBuilder makeLinalgBuilder(const std::string &kernelName) {\n- return kernelBuilder(env::OCCA_DIR + \"include/occa/array/kernels/linalg.okl\",\n+ return kernelBuilder::fromFile(env::OCCA_DIR + \"include/occa/array/kernels/linalg.okl\",\nkernelName,\n\"defines: {\"\n\" VTYPE: '\" + primitiveinfo<VTYPE1>::name + \"',\"\n@@ -354,15 +354,28 @@ namespace occa {\nreturn ret;\n}\n+ template <class VTYPE, class RETTYPE>\n+ RETTYPE sum(occa::memory vec) {\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE, RETTYPE>(\"sum\");\n+\n+ RETTYPE *partialReduction = reduce<VTYPE,RETTYPE>(vec, builder, 1024);\n+ RETTYPE ret = 0;\n+ for (int i = 0; i < 1024; ++i) {\n+ ret += partialReduction[i];\n+ }\n+ return ret;\n+ }\n+\ntemplate <class TYPE_A, class VTYPE_X, class VTYPE_Y>\nvoid axpy(const TYPE_A &alpha,\nocca::memory x,\nocca::memory y,\nconst int tileSize) {\n- static sourceKernelBuilder *builders;\n+ static kernelBuilder *builders;\nif (!builders) {\n- builders = new sourceKernelBuilder[usedTileSizeCount];\n+ builders = new kernelBuilder[usedTileSizeCount];\nfor (int i = 0; i < usedTileSizeCount; ++i) {\nbuilders[i] =\ncustomLinearMethod(\"axpy\",\n" }, { "change_type": "MODIFY", "old_path": "include/occa/kernel.hpp", "new_path": "include/occa/kernel.hpp", "diff": "@@ -243,27 +243,30 @@ namespace occa {\n//---[ kernel builder ]---------------\nclass kernelBuilder {\nprotected:\n- std::string filename_;\n+ std::string source_;\nstd::string function_;\nocca::properties props_;\nhashedKernelMap_t kernelMap;\n+ bool buildingFromFile;\n+\npublic:\nkernelBuilder();\n- kernelBuilder(const std::string &filename,\n- const std::string &function,\n- const occa::properties &props = occa::properties());\nkernelBuilder(const kernelBuilder &k);\nkernelBuilder& operator = (const kernelBuilder &k);\n- bool isInitialized();\n+ static kernelBuilder fromFile(const std::string &filename,\n+ const std::string &function,\n+ const occa::properties &props = occa::properties());\n- void use(const std::string &filename,\n+ static kernelBuilder fromString(const std::string &content,\nconst std::string &function,\nconst occa::properties &props = occa::properties());\n+ bool isInitialized();\n+\nvirtual occa::kernel build(occa::device device,\nconst hash_t &hash);\n@@ -280,27 +283,6 @@ namespace occa {\nvoid free();\n};\n-\n- class sourceKernelBuilder : public kernelBuilder {\n- private:\n- std::string content_;\n-\n- public:\n- sourceKernelBuilder();\n- sourceKernelBuilder(const std::string &content,\n- const std::string &function,\n- const occa::properties &props = occa::properties());\n-\n- sourceKernelBuilder(const sourceKernelBuilder &k);\n- sourceKernelBuilder& operator = (const sourceKernelBuilder &k);\n-\n- void use(const std::string &content,\n- const std::string &function,\n- const occa::properties &props = occa::properties());\n-\n- virtual occa::kernel build(occa::device device,\n- const hash_t &hash);\n- };\n//====================================\n}\n" }, { "change_type": "MODIFY", "old_path": "src/array/linalg.cpp", "new_path": "src/array/linalg.cpp", "diff": "namespace occa {\nnamespace linalg {\n// \"v0[i] = c1 * (v0[i] + v1[i])\"\n- sourceKernelBuilder customLinearMethod(const std::string &kernelName,\n+ kernelBuilder customLinearMethod(const std::string &kernelName,\nconst std::string &formula,\nconst occa::properties &props) {\n- sourceKernelBuilder builder;\n+ kernelBuilder builder;\n// Extract input and constant counts\nintVector_t inputs, constants;\n@@ -126,7 +126,7 @@ namespace occa {\n\" }\\n\"\n\"}\\n\";\n- return sourceKernelBuilder(ss.str(), kernelName, props);\n+ return kernelBuilder::fromString(ss.str(), kernelName, props);\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/kernel.cpp", "new_path": "src/kernel.cpp", "diff": "@@ -417,45 +417,57 @@ namespace occa {\n//---[ kernel builder ]---------------\nkernelBuilder::kernelBuilder() {}\n- kernelBuilder::kernelBuilder(const std::string &filename,\n- const std::string &function,\n- const occa::properties &props) :\n- filename_(filename),\n- function_(function),\n- props_(props) {}\n-\nkernelBuilder::kernelBuilder(const kernelBuilder &k) :\n- filename_(k.filename_),\n+ source_(k.source_),\nfunction_(k.function_),\nprops_(k.props_),\n- kernelMap(k.kernelMap) {}\n+ kernelMap(k.kernelMap),\n+ buildingFromFile(k.buildingFromFile) {}\nkernelBuilder& kernelBuilder::operator = (const kernelBuilder &k) {\n- filename_ = k.filename_;\n+ source_ = k.source_;\nfunction_ = k.function_;\nprops_ = k.props_;\nkernelMap = k.kernelMap;\n+ buildingFromFile = k.buildingFromFile;\nreturn *this;\n}\n- bool kernelBuilder::isInitialized() {\n- return (0 < function_.size());\n+ kernelBuilder kernelBuilder::fromFile(const std::string &filename,\n+ const std::string &function,\n+ const occa::properties &props) {\n+ kernelBuilder builder;\n+ builder.source_ = filename;\n+ builder.function_ = function;\n+ builder.props_ = props;\n+ builder.buildingFromFile = true;\n+ return builder;\n}\n- void kernelBuilder::use(const std::string &filename,\n+ kernelBuilder kernelBuilder::fromString(const std::string &content,\nconst std::string &function,\nconst occa::properties &props) {\n- free();\n- filename_ = filename;\n- function_ = function;\n- props_ = props;\n+ kernelBuilder builder;\n+ builder.source_ = content;\n+ builder.function_ = function;\n+ builder.props_ = props;\n+ builder.buildingFromFile = false;\n+ return builder;\n+ }\n+\n+ bool kernelBuilder::isInitialized() {\n+ return (0 < function_.size());\n}\nocca::kernel kernelBuilder::build(occa::device device,\nconst hash_t &hash) {\nocca::kernel &k = kernelMap[hash];\nif (!k.isInitialized()) {\n- k = device.buildKernel(filename_, function_, props_);\n+ if (buildingFromFile) {\n+ k = device.buildKernel(source_, function_, props_);\n+ } else {\n+ k = device.buildKernelFromString(source_, function_, props_);\n+ }\n}\nreturn k;\n}\n@@ -491,50 +503,5 @@ namespace occa {\n++it;\n}\n}\n-\n- sourceKernelBuilder::sourceKernelBuilder() {}\n-\n- sourceKernelBuilder::sourceKernelBuilder(const std::string &content,\n- const std::string &function,\n- const occa::properties &props) :\n- content_(content) {\n-\n- function_ = function;\n- props_ = props;\n- }\n-\n- sourceKernelBuilder::sourceKernelBuilder(const sourceKernelBuilder &k) :\n- content_(k.content_) {\n- function_ = k.function_;\n- props_ = k.props_;\n- kernelMap = k.kernelMap;\n- }\n-\n- sourceKernelBuilder& sourceKernelBuilder::operator = (const sourceKernelBuilder &k) {\n- content_ = k.content_;\n- function_ = k.function_;\n- props_ = k.props_;\n- kernelMap = k.kernelMap;\n- return *this;\n- }\n-\n- void sourceKernelBuilder::use(const std::string &content,\n- const std::string &function,\n- const occa::properties &props) {\n- free();\n- content_ = content;\n- function_ = function;\n- props_ = props;\n- }\n-\n- occa::kernel sourceKernelBuilder::build(occa::device device,\n- const hash_t &hash) {\n- occa::kernel &k = kernelMap[hash];\n- if (!k.isInitialized()) {\n- k = device.buildKernelFromString(content_, function_, props_);\n- }\n- return k;\n- }\n-\n//====================================\n}\n" } ]
C++
MIT License
libocca/occa
[Kernel] Merged kernelBuilder and sourceKernelBuilder
378,349
19.02.2017 23:46:10
21,600
b07118af2017eafdd434cd19591ebca335e8ee8a
[Linalg] Added distance
[ { "change_type": "MODIFY", "old_path": "examples/usingArrays/main.cpp", "new_path": "examples/usingArrays/main.cpp", "diff": "@@ -63,7 +63,8 @@ int main(int argc, char **argv) {\n<< \"vec1.l2Norm() = \" << vec1.l2Norm<double>() << '\\n'\n<< \"vec1.lpNorm(2) = \" << vec1.lpNorm<double>(2) << '\\n'\n<< \"vec1.lInfNorm() = \" << vec1.lInfNorm<double>() << '\\n'\n- << \"vec1.dot() = \" << vec1.dot<double>(vec2) << '\\n'\n+ << \"vec1.dot(vec2) = \" << vec1.dot<double>(vec2) << '\\n'\n+ << \"vec1.distance(vec2) = \" << vec1.distance<double>(vec2) << '\\n'\n<< \"vec1.max() = \" << vec1.max<double>() << '\\n'\n<< \"vec1.min() = \" << vec1.min<double>() << '\\n';\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.hpp", "new_path": "include/occa/array/array.hpp", "diff": "@@ -281,6 +281,9 @@ namespace occa {\ntemplate <class RETTYPE, class TM2, const int idxType2>\nRETTYPE dot(const array<TM2, idxType2> &vec);\n+ template <class RETTYPE, class TM2, const int idxType2>\n+ RETTYPE distance(const array<TM2, idxType2> &vec);\n+\ntemplate <class TYPE_A, class TM2, const int idxType2>\narray& sum(const TYPE_A alpha,\nconst array<TM2, idxType2> &vec);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.tpp", "new_path": "include/occa/array/array.tpp", "diff": "@@ -833,6 +833,12 @@ namespace occa {\nreturn linalg::dot<TM,TM2,RETTYPE>(memory, vec.memory);\n}\n+ template <class TM, const int idxType>\n+ template <class RETTYPE, class TM2, const int idxType2>\n+ RETTYPE array<TM,idxType>::distance(const array<TM2, idxType2> &vec) {\n+ return linalg::distance<TM,TM2,RETTYPE>(memory, vec.memory);\n+ }\n+\ntemplate <class TM, const int idxType>\ntemplate <class TYPE_A, class TM2, const int idxType2>\narray<TM,idxType>& array<TM,idxType>::sum(const TYPE_A alpha,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/kernels/linalg.okl", "new_path": "include/occa/array/kernels/linalg.okl", "diff": "@@ -175,6 +175,16 @@ kernel void sum(const int entries,\nREDUCTION_BODY(SUM_OPERATION, SUM_RED_OPERATION);\n}\n+kernel void distance(const int entries,\n+ const VTYPE * vec1,\n+ const VTYPE2 * vec2,\n+ RETTYPE * vecReduction) {\n+#define DISTANCE_OPERATION(out, idx) \\\n+ const RETTYPE diff = (vec1[idx] - vec2[idx]); \\\n+ out += diff * diff\n+ REDUCTION_BODY(DISTANCE_OPERATION, SUM_RED_OPERATION);\n+}\n+\nkernel void axpy(const int entries,\nconst TYPE_A alpha,\nconst VTYPE_X * x,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.hpp", "new_path": "include/occa/array/linalg.hpp", "diff": "@@ -150,6 +150,9 @@ namespace occa {\ntemplate <class VTYPE1, class VTYPE2, class RETTYPE>\nRETTYPE dot(occa::memory vec1, occa::memory vec2);\n+ template <class VTYPE1, class VTYPE2, class RETTYPE>\n+ RETTYPE distance(occa::memory vec1, occa::memory vec2);\n+\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE sum(occa::memory vec);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.tpp", "new_path": "include/occa/array/linalg.tpp", "diff": "@@ -354,6 +354,32 @@ namespace occa {\nreturn ret;\n}\n+ template <class VTYPE1, class VTYPE2, class RETTYPE>\n+ RETTYPE distance(occa::memory vec1, occa::memory vec2) {\n+ static kernelBuilder builder =\n+ makeLinalgBuilder<VTYPE1, VTYPE2, RETTYPE>(\"distance\");\n+\n+ OCCA_ERROR(\"Vectors must be in the same device\",\n+ vec1.getDevice() == vec2.getDevice());\n+\n+ device dev = vec1.getDevice();\n+ const int bufferSize = 1024;\n+ RETTYPE *hostBuffer = hostReductionBuffer<RETTYPE>(bufferSize);\n+ memory deviceBuffer = deviceReductionBuffer<RETTYPE>(dev, bufferSize);\n+ const int entries = vec1.size() / sizeof(VTYPE1);\n+ builder.build(dev)(entries,\n+ vec1,\n+ vec2,\n+ deviceBuffer);\n+ dev.finish();\n+ deviceBuffer.copyTo(hostBuffer);\n+ RETTYPE ret = 0;\n+ for (int i = 0; i < 1024; ++i) {\n+ ret += hostBuffer[i];\n+ }\n+ return sqrt(ret);\n+ }\n+\ntemplate <class VTYPE, class RETTYPE>\nRETTYPE sum(occa::memory vec) {\nstatic kernelBuilder builder =\n" } ]
C++
MIT License
libocca/occa
[Linalg] Added distance
378,349
20.02.2017 18:14:06
21,600
52d4ec75c7c67f3db73d59bc4bc00830e37159c8
[Linalg] custom linear methods don't restrict the v and c characters
[ { "change_type": "MODIFY", "old_path": "src/array/linalg.cpp", "new_path": "src/array/linalg.cpp", "diff": "@@ -43,6 +43,7 @@ namespace occa {\nconst char *c = formula.c_str();\nwhile (*c) {\n+ // Input vectors/constants are of the format [cv][0-9]+\nif ((*c == 'v') || (*c == 'c')) {\nintVector_t &vec = (*c == 'v') ? inputs : constants;\nint &minVal = (*c == 'v') ? minInput : minConstant;\n@@ -50,8 +51,11 @@ namespace occa {\nconst char *cStart = ++c;\nlex::skipFrom(c, lex::numChars);\n- OCCA_ERROR(\"Digit must follow 'v' or 'c'\",\n- cStart != c);\n+ // This is not the 'v' or 'c' you're looking for\n+ if (cStart == c) {\n+ ++c;\n+ continue;\n+ }\nconst int idx = occa::atoi(std::string(cStart, c - cStart));\nif (std::find(vec.begin(), vec.end(), idx) == vec.end()) {\n" } ]
C++
MIT License
libocca/occa
[Linalg] custom linear methods don't restrict the v and c characters
378,349
20.02.2017 19:26:20
21,600
dd3ddb0c3a4a2e45d6eea45fd38258c431e4e923
[Base] const-ed src in memory copies
[ { "change_type": "MODIFY", "old_path": "include/occa/base.hpp", "new_path": "include/occa/base.hpp", "diff": "@@ -82,11 +82,11 @@ namespace occa {\n//---[ Memory Functions ]-------------\nocca::memory malloc(const dim_t bytes,\n- void *src = NULL,\n+ const void *src = NULL,\nconst occa::properties &props = occa::properties());\nvoid* uvaAlloc(const dim_t bytes,\n- void *src = NULL,\n+ const void *src = NULL,\nconst occa::properties &props = occa::properties());\nocca::memory wrapMemory(void *handle_,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/device.hpp", "new_path": "include/occa/device.hpp", "diff": "@@ -94,7 +94,7 @@ namespace occa {\n// |---[ Memory ]------------------\nvirtual memory_v* malloc(const udim_t bytes,\n- void* src,\n+ const void* src,\nconst occa::properties &props) = 0;\nvirtual memory_v* wrapMemory(void *handle_,\n@@ -171,11 +171,11 @@ namespace occa {\n// |---[ Memory ]------------------\nocca::memory malloc(const dim_t bytes,\n- void *src = NULL,\n+ const void *src = NULL,\nconst occa::properties &props = occa::properties());\nvoid* uvaAlloc(const dim_t bytes,\n- void *src = NULL,\n+ const void *src = NULL,\nconst occa::properties &props = occa::properties());\nocca::memory wrapMemory(void *handle_,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/c/c_wrapper.hpp", "new_path": "include/occa/lang/c/c_wrapper.hpp", "diff": "@@ -166,11 +166,11 @@ OCCA_LFUNC occaKernel OCCA_RFUNC occaBuildKernelFromBinary(const char *filename,\nOCCA_LFUNC void OCCA_RFUNC occaMemorySwap(occaMemory a, occaMemory b);\nOCCA_LFUNC occaMemory OCCA_RFUNC occaMalloc(const occaUDim_t bytes,\n- void *src,\n+ const void *src,\noccaProperties props);\nOCCA_LFUNC void* OCCA_RFUNC occaUvaAlloc(const occaUDim_t bytes,\n- void *src,\n+ const void *src,\noccaProperties props);\nOCCA_LFUNC occaMemory OCCA_RFUNC occaWrapMemory(void *handle_,\n@@ -207,12 +207,12 @@ OCCA_LFUNC occaKernel OCCA_RFUNC occaDeviceBuildKernelFromBinary(occaDevice devi\nOCCA_LFUNC occaMemory OCCA_RFUNC occaDeviceMalloc(occaDevice device,\nconst occaUDim_t bytes,\n- void *src,\n+ const void *src,\noccaProperties props);\nOCCA_LFUNC void* OCCA_RFUNC occaDeviceUvaAlloc(occaDevice device,\nconst occaUDim_t bytes,\n- void *src,\n+ const void *src,\noccaProperties props);\nOCCA_LFUNC occaMemory OCCA_RFUNC occaDeviceWrapMemory(occaDevice device,\n@@ -285,7 +285,7 @@ OCCA_LFUNC const char* OCCA_RFUNC occaMemoryMode(occaMemory memory);\nOCCA_LFUNC void* OCCA_RFUNC occaMemoryGetHandle(occaMemory mem,\noccaProperties props);\n-OCCA_LFUNC void OCCA_RFUNC occaMemcpy(void *dest, void *src,\n+OCCA_LFUNC void OCCA_RFUNC occaMemcpy(void *dest, const void *src,\nconst occaUDim_t bytes,\noccaProperties props);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/device.hpp", "new_path": "include/occa/modes/cuda/device.hpp", "diff": "@@ -76,11 +76,11 @@ namespace occa {\n// |---[ Memory ]----------------\nmemory_v* malloc(const udim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props);\nmemory_v* mappedAlloc(const udim_t bytes,\n- void *src);\n+ const void *src);\nmemory_v* wrapMemory(void *handle_,\nconst udim_t bytes,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/opencl/device.hpp", "new_path": "include/occa/modes/opencl/device.hpp", "diff": "@@ -76,11 +76,11 @@ namespace occa {\n// |---[ Memory ]----------------\nmemory_v* malloc(const udim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props);\nmemory_v* mappedAlloc(const udim_t bytes,\n- void *src);\n+ const void *src);\nmemory_v* wrapMemory(void *handle_,\nconst udim_t bytes,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/serial/device.hpp", "new_path": "include/occa/modes/serial/device.hpp", "diff": "@@ -67,7 +67,7 @@ namespace occa {\n// |---[ Kernel ]----------------\nmemory_v* malloc(const udim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props);\nmemory_v* wrapMemory(void *handle_,\n" }, { "change_type": "MODIFY", "old_path": "src/base.cpp", "new_path": "src/base.cpp", "diff": "@@ -120,14 +120,14 @@ namespace occa {\n//---[ Memory Functions ]-------------\nocca::memory malloc(const dim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props) {\nreturn currentDevice().malloc(bytes, src, props);\n}\nvoid* uvaAlloc(const dim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props) {\nreturn currentDevice().uvaAlloc(bytes, src, props);\n" }, { "change_type": "MODIFY", "old_path": "src/device.cpp", "new_path": "src/device.cpp", "diff": "@@ -326,7 +326,7 @@ namespace occa {\n// |---[ Memory ]--------------------\nmemory device::malloc(const dim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props) {\nOCCA_ERROR(\"Trying to allocate negative bytes (\" << bytes << \")\",\nbytes >= 0);\n@@ -341,7 +341,7 @@ namespace occa {\n}\nvoid* device::uvaAlloc(const dim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props) {\nOCCA_ERROR(\"Trying to allocate negative bytes (\" << bytes << \")\",\nbytes >= 0);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/c/c_wrapper.cpp", "new_path": "src/lang/c/c_wrapper.cpp", "diff": "@@ -543,7 +543,7 @@ void OCCA_RFUNC occaMemorySwap(occaMemory a, occaMemory b) {\n}\noccaMemory OCCA_RFUNC occaMalloc(const occaUDim_t bytes,\n- void *src,\n+ const void *src,\noccaProperties props) {\nocca::properties &props_ = occa::c::getProperties(props);\nocca::memory memory_ = occa::malloc(bytes, src, props_);\n@@ -554,7 +554,7 @@ occaMemory OCCA_RFUNC occaMalloc(const occaUDim_t bytes,\n}\nvoid* OCCA_RFUNC occaUvaAlloc(const occaUDim_t bytes,\n- void *src,\n+ const void *src,\noccaProperties props) {\nocca::properties &props_ = occa::c::getProperties(props);\n@@ -651,7 +651,7 @@ occaKernel OCCA_RFUNC occaDeviceBuildKernelFromBinary(occaDevice device,\noccaMemory OCCA_RFUNC occaDeviceMalloc(occaDevice device,\nconst occaUDim_t bytes,\n- void *src,\n+ const void *src,\noccaProperties props) {\nocca::device device_ = occa::c::getDevice(device);\n@@ -665,7 +665,7 @@ occaMemory OCCA_RFUNC occaDeviceMalloc(occaDevice device,\nvoid* OCCA_RFUNC occaDeviceUvaAlloc(occaDevice device,\nconst occaUDim_t bytes,\n- void *src,\n+ const void *src,\noccaProperties props) {\nocca::device device_ = occa::c::getDevice(device);\n@@ -892,7 +892,7 @@ void* OCCA_RFUNC occaMemoryGetHandle(occaMemory memory,\nreturn occa::c::getMemory(memory).getHandle(occa::c::getProperties(props));\n}\n-void OCCA_RFUNC occaMemcpy(void *dest, void *src,\n+void OCCA_RFUNC occaMemcpy(void *dest, const void *src,\nconst occaUDim_t bytes,\noccaProperties props) {\nif (!occa::c::isDefault(props)) {\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -196,7 +196,7 @@ namespace occa {\n// |---[ Memory ]------------------\nmemory_v* device::malloc(const udim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props) {\nif (props.get<bool>(\"mapped\")) {\n@@ -221,7 +221,7 @@ namespace occa {\n}\nmemory_v* device::mappedAlloc(const udim_t bytes,\n- void *src) {\n+ const void *src) {\ncuda::memory *mem = new cuda::memory();\nmem->dHandle = this;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/device.cpp", "new_path": "src/modes/opencl/device.cpp", "diff": "@@ -214,7 +214,7 @@ namespace occa {\n// |---[ Memory ]------------------\nmemory_v* device::malloc(const udim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props) {\nif (props.get<bool>(\"mapped\")) {\n@@ -235,7 +235,7 @@ namespace occa {\n} else {\n*((cl_mem*) mem->handle) = clCreateBuffer(clContext,\nCL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,\n- bytes, src, &error);\n+ bytes, const_cast<void*>(src), &error);\nfinish();\n}\n@@ -244,7 +244,7 @@ namespace occa {\n}\nmemory_v* device::mappedAlloc(const udim_t bytes,\n- void *src) {\n+ const void *src) {\ncl_int error;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/device.cpp", "new_path": "src/modes/serial/device.cpp", "diff": "@@ -171,7 +171,7 @@ namespace occa {\n}\nmemory_v* device::malloc(const udim_t bytes,\n- void *src,\n+ const void *src,\nconst occa::properties &props) {\nmemory *mem = new memory();\n" } ]
C++
MIT License
libocca/occa
[Base] const-ed src in memory copies
378,349
21.02.2017 23:23:47
21,600
dc2c4df75d23eec78010bf1cd78d3ca0cf5a0dad
[Fix] Fixed issue with merging json objects using + operator, custom linear kernels require ;
[ { "change_type": "MODIFY", "old_path": "include/occa/array/array.hpp", "new_path": "include/occa/array/array.hpp", "diff": "@@ -40,7 +40,7 @@ namespace occa {\nclass array {\npublic:\nocca::device device;\n- occa::memory memory;\n+ occa::memory memory_;\nTM *data_;\n@@ -68,15 +68,27 @@ namespace occa {\nreturn data_;\n}\n- inline udim_t entries() {\n+ inline const TM* data() const {\n+ return data_;\n+ }\n+\n+ inline occa::memory memory() {\n+ return memory_;\n+ }\n+\n+ inline const occa::memory memory() const {\n+ return memory_;\n+ }\n+\n+ inline udim_t entries() const {\nreturn s_[0] * s_[1] * s_[2] * s_[3] * s_[4] * s_[5];\n}\n- inline udim_t bytes() {\n+ inline udim_t bytes() const {\nreturn (entries() * sizeof(TM));\n}\n- inline udim_t dim(const int i) {\n+ inline udim_t dim(const int i) const {\nreturn s_[i];\n}\n@@ -84,10 +96,10 @@ namespace occa {\nocca::kernelArg ret;\nocca::kernelArg_t sizeArg;\n- ret.arg.mHandle = memory.getMHandle();\n- ret.arg.dHandle = memory.getDHandle();\n+ ret.arg.mHandle = memory_.getMHandle();\n+ ret.arg.dHandle = memory_.getDHandle();\n- ret.arg.data.void_ = memory.getHandle();\n+ ret.arg.data.void_ = memory_.getHandle();\nret.arg.size = sizeof(void*);\nret.arg.info = kArgInfo::usePointer;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/array.tpp", "new_path": "include/occa/array/array.tpp", "diff": "@@ -42,7 +42,7 @@ namespace occa {\ntemplate <class TM2, const int idxType2>\narray<TM,idxType>& array<TM,idxType>::operator = (const array<TM2,idxType2> &v) {\ndevice = v.device;\n- memory = v.memory;\n+ memory_ = v.memory_;\ndata_ = v.data_;\n@@ -278,7 +278,7 @@ namespace occa {\ntemplate <class TM, const int idxType>\nvoid array<TM,idxType>::allocate() {\ndata_ = (TM*) device.uvaAlloc(bytes());\n- memory = occa::memory(data_);\n+ memory_ = occa::memory(data_);\n}\ntemplate <class TM, const int idxType>\n@@ -733,59 +733,59 @@ namespace occa {\n//---[ Assignment Operators ]-------\ntemplate <class TM, const int idxType>\narray<TM,idxType>& array<TM,idxType>::operator = (const TM value) {\n- linalg::operator_eq<TM>(memory, value);\n+ linalg::operator_eq<TM>(memory_, value);\nreturn *this;\n}\ntemplate <class TM, const int idxType>\narray<TM,idxType>& array<TM,idxType>::operator += (const TM value) {\n- linalg::operator_plus_eq<TM>(memory, value);\n+ linalg::operator_plus_eq<TM>(memory_, value);\nreturn *this;\n}\ntemplate <class TM, const int idxType>\ntemplate <class TM2, const int idxType2>\narray<TM,idxType>& array<TM,idxType>::operator += (const array<TM2,idxType2> &vec) {\n- linalg::operator_plus_eq<TM2,TM>(vec.memory, memory);\n+ linalg::operator_plus_eq<TM2,TM>(vec.memory_, memory_);\nreturn *this;\n}\ntemplate <class TM, const int idxType>\narray<TM,idxType>& array<TM,idxType>::operator -= (const TM value) {\n- linalg::operator_sub_eq<TM>(memory, value);\n+ linalg::operator_sub_eq<TM>(memory_, value);\nreturn *this;\n}\ntemplate <class TM, const int idxType>\ntemplate <class TM2, const int idxType2>\narray<TM,idxType>& array<TM,idxType>::operator -= (const array<TM2,idxType2> &vec) {\n- linalg::operator_sub_eq<TM2,TM>(vec.memory, memory);\n+ linalg::operator_sub_eq<TM2,TM>(vec.memory_, memory_);\nreturn *this;\n}\ntemplate <class TM, const int idxType>\narray<TM,idxType>& array<TM,idxType>::operator *= (const TM value) {\n- linalg::operator_mult_eq<TM>(memory, value);\n+ linalg::operator_mult_eq<TM>(memory_, value);\nreturn *this;\n}\ntemplate <class TM, const int idxType>\ntemplate <class TM2, const int idxType2>\narray<TM,idxType>& array<TM,idxType>::operator *= (const array<TM2,idxType2> &vec) {\n- linalg::operator_mult_eq<TM2,TM>(vec.memory, memory);\n+ linalg::operator_mult_eq<TM2,TM>(vec.memory_, memory_);\nreturn *this;\n}\ntemplate <class TM, const int idxType>\narray<TM,idxType>& array<TM,idxType>::operator /= (const TM value) {\n- linalg::operator_div_eq<TM>(memory, value);\n+ linalg::operator_div_eq<TM>(memory_, value);\nreturn *this;\n}\ntemplate <class TM, const int idxType>\ntemplate <class TM2, const int idxType2>\narray<TM,idxType>& array<TM,idxType>::operator /= (const array<TM2,idxType2> &vec) {\n- linalg::operator_div_eq<TM2,TM>(vec.memory, memory);\n+ linalg::operator_div_eq<TM2,TM>(vec.memory_, memory_);\nreturn *this;\n}\n//====================================\n@@ -794,56 +794,56 @@ namespace occa {\ntemplate <class TM, const int idxType>\ntemplate <class RETTYPE>\nRETTYPE array<TM,idxType>::l1Norm() {\n- return linalg::l1Norm<TM,RETTYPE>(memory);\n+ return linalg::l1Norm<TM,RETTYPE>(memory_);\n}\ntemplate <class TM, const int idxType>\ntemplate <class RETTYPE>\nRETTYPE array<TM,idxType>::l2Norm() {\n- return linalg::l2Norm<TM,RETTYPE>(memory);\n+ return linalg::l2Norm<TM,RETTYPE>(memory_);\n}\ntemplate <class TM, const int idxType>\ntemplate <class RETTYPE>\nRETTYPE array<TM,idxType>::lpNorm(const float p) {\n- return linalg::lpNorm<TM,RETTYPE>(p, memory);\n+ return linalg::lpNorm<TM,RETTYPE>(p, memory_);\n}\ntemplate <class TM, const int idxType>\ntemplate <class RETTYPE>\nRETTYPE array<TM,idxType>::lInfNorm() {\n- return linalg::lInfNorm<TM,RETTYPE>(memory);\n+ return linalg::lInfNorm<TM,RETTYPE>(memory_);\n}\ntemplate <class TM, const int idxType>\ntemplate <class RETTYPE>\nRETTYPE array<TM,idxType>::max() {\n- return linalg::max<TM,RETTYPE>(memory);\n+ return linalg::max<TM,RETTYPE>(memory_);\n}\ntemplate <class TM, const int idxType>\ntemplate <class RETTYPE>\nRETTYPE array<TM,idxType>::min() {\n- return linalg::min<TM,RETTYPE>(memory);\n+ return linalg::min<TM,RETTYPE>(memory_);\n}\ntemplate <class TM, const int idxType>\ntemplate <class RETTYPE, class TM2, const int idxType2>\nRETTYPE array<TM,idxType>::dot(const array<TM2, idxType2> &vec) {\n- return linalg::dot<TM,TM2,RETTYPE>(memory, vec.memory);\n+ return linalg::dot<TM,TM2,RETTYPE>(memory_, vec.memory_);\n}\ntemplate <class TM, const int idxType>\ntemplate <class RETTYPE, class TM2, const int idxType2>\nRETTYPE array<TM,idxType>::distance(const array<TM2, idxType2> &vec) {\n- return linalg::distance<TM,TM2,RETTYPE>(memory, vec.memory);\n+ return linalg::distance<TM,TM2,RETTYPE>(memory_, vec.memory_);\n}\ntemplate <class TM, const int idxType>\ntemplate <class TYPE_A, class TM2, const int idxType2>\narray<TM,idxType>& array<TM,idxType>::sum(const TYPE_A alpha,\nconst array<TM2, idxType2> &vec) {\n- linalg::axpy<TYPE_A,TM2,TM>(alpha, vec.memory, memory);\n+ linalg::axpy<TYPE_A,TM2,TM>(alpha, vec.memory_, memory_);\nreturn *this;\n}\n//==================================\n" }, { "change_type": "MODIFY", "old_path": "include/occa/array/linalg.tpp", "new_path": "include/occa/array/linalg.tpp", "diff": "@@ -405,7 +405,7 @@ namespace occa {\nfor (int i = 0; i < usedTileSizeCount; ++i) {\nbuilders[i] =\ncustomLinearMethod(\"axpy\",\n- \"v0[i] += c0 * v1[i]\",\n+ \"v0[i] += c0 * v1[i];\",\n\"defines: {\"\n\" CTYPE0: '\" + primitiveinfo<TYPE_A>::name + \"',\"\n\" VTYPE0: '\" + primitiveinfo<VTYPE_Y>::name + \"',\"\n" }, { "change_type": "MODIFY", "old_path": "src/array/linalg.cpp", "new_path": "src/array/linalg.cpp", "diff": "namespace occa {\nnamespace linalg {\n- // \"v0[i] = c1 * (v0[i] + v1[i])\"\n+ // \"v0[i] = c1 * (v0[i] + v1[i]);\"\nkernelBuilder customLinearMethod(const std::string &kernelName,\nconst std::string &formula,\nconst occa::properties &props) {\n@@ -37,9 +37,12 @@ namespace occa {\nkernelBuilder builder;\n// Extract input and constant counts\n+ // If formula is correct\n+ // - minInput should go down to 0\n+ // - maxOutput should go up to at least 0\nintVector_t inputs, constants;\n- int minInput = 0, maxInput = 0;\n- int minConstant = 0, maxConstant = 0;\n+ int minInput = 1, maxInput = -1;\n+ int minConstant = 0, maxConstant = -1;\nconst char *c = formula.c_str();\nwhile (*c) {\n@@ -125,7 +128,7 @@ namespace occa {\nss << \") {\\n\"\n\" for (int i = 0; i < entries; ++i; tile(TILESIZE)) {\\n\"\n\" if (i < entries) {\\n\"\n- \" \" << formula << \";\\n\"\n+ \" \" << formula << \"\\n\"\n\" }\\n\"\n\" }\\n\"\n\"}\\n\";\n" }, { "change_type": "MODIFY", "old_path": "src/tools/env.cpp", "new_path": "src/tools/env.cpp", "diff": "@@ -54,7 +54,7 @@ namespace occa {\nvoid initSettings() {\nproperties &settings_ = settings();\nsettings_[\"version\"] = \"1.0\";\n- settings_[\"parser-version\"] = \"0.1\";\n+ settings_[\"parserVersion\"] = \"0.1\";\nsettings_[\"verboseCompilation\"] = false;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/json.cpp", "new_path": "src/tools/json.cpp", "diff": "@@ -272,8 +272,11 @@ namespace occa {\nbreak;\n}\ncase object_: {\n- value_.object.insert(j.value_.object.begin(),\n- j.value_.object.end());\n+ cJsonObjectIterator it = j.value_.object.begin();\n+ while (it != j.value_.object.end()) {\n+ value_.object[it->first] = it->second;\n+ ++it;\n+ }\nbreak;\n}\ncase array_: {\n" } ]
C++
MIT License
libocca/occa
[Fix] Fixed issue with merging json objects using + operator, custom linear kernels require ;
378,349
21.02.2017 23:41:54
21,600
1f56a4b6b9746c88ad37a02ba1d2ddd16924a3b4
[JSON] Added nested JSON merging for objects
[ { "change_type": "MODIFY", "old_path": "Makefile", "new_path": "Makefile", "diff": "@@ -160,22 +160,27 @@ $(libPath)/_C_occa.so: $(libPath)/libocca.so $(incPath)/occa/lang/python/_C_occa\n#---[ TEST ]--------------------------------------\ntest:\ncd $(OCCA_DIR)/examples/addVectors/cpp && \\\n+ rm -f main && \\\nmake -j 4 CXXFLAGS='-g' FCFLAGS='-g' && \\\n./main\ncd $(OCCA_DIR)/examples/addVectors/c && \\\n+ rm -f main && \\\nmake -j 4 CXXFLAGS='-g' FCFLAGS='-g' && \\\n./main\ncd $(OCCA_DIR)/examples/uvaAddVectors/ && \\\n+ rm -f main && \\\nmake -j 4 CXXFLAGS='-g' FCFLAGS='-g'; \\\n./main\ncd $(OCCA_DIR)/examples/backgroundDevices/ && \\\n+ rm -f main && \\\nmake -j 4 CXXFLAGS='-g' FCFLAGS='-g'; \\\n./main\ncd $(OCCA_DIR)/examples/usingArrays/ && \\\n+ rm -f main && \\\nmake -j 4 CXXFLAGS='-g' FCFLAGS='-g'; \\\n./main\n#=================================================\n" }, { "change_type": "MODIFY", "old_path": "src/tools/json.cpp", "new_path": "src/tools/json.cpp", "diff": "@@ -274,7 +274,20 @@ namespace occa {\ncase object_: {\ncJsonObjectIterator it = j.value_.object.begin();\nwhile (it != j.value_.object.end()) {\n- value_.object[it->first] = it->second;\n+ const std::string &key = it->first;\n+ const json &val = it->second;\n+ // If we're merging two json objects, recursively merge them\n+ if (val.isObject() && has(key)) {\n+ // Reuse prefetch\n+ json &oldVal = value_.object[key];\n+ if (oldVal.isObject()) {\n+ oldVal += val;\n+ } else {\n+ oldVal = val;\n+ }\n+ } else {\n+ value_.object[key] = val;\n+ }\n++it;\n}\nbreak;\n" } ]
C++
MIT License
libocca/occa
[JSON] Added nested JSON merging for objects