Skip to content

Commit

Permalink
Merge branch 'main' into cpp17
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Dec 28, 2023
2 parents 553e326 + eedf851 commit 5eec22c
Show file tree
Hide file tree
Showing 13 changed files with 927 additions and 87 deletions.
6 changes: 6 additions & 0 deletions six.sln
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github-workflows", ".githu
.github\workflows\frequent_check.yml = .github\workflows\frequent_check.yml
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "8AMPI_PHSI", "six\modules\c++\samples\8AMPI_PHSI.dir\8AMPI_PHSI.dir.vcxproj", "{05C352A8-9F70-4006-B851-70A6904B58C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -114,6 +116,10 @@ Global
{9997E895-5161-4DDF-8F3F-099894CB2F21}.Debug|x64.Build.0 = Debug|x64
{9997E895-5161-4DDF-8F3F-099894CB2F21}.Release|x64.ActiveCfg = Release|x64
{9997E895-5161-4DDF-8F3F-099894CB2F21}.Release|x64.Build.0 = Release|x64
{05C352A8-9F70-4006-B851-70A6904B58C1}.Debug|x64.ActiveCfg = Debug|x64
{05C352A8-9F70-4006-B851-70A6904B58C1}.Debug|x64.Build.0 = Debug|x64
{05C352A8-9F70-4006-B851-70A6904B58C1}.Release|x64.ActiveCfg = Release|x64
{05C352A8-9F70-4006-B851-70A6904B58C1}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
205 changes: 205 additions & 0 deletions six/modules/c++/samples/8AMPI_PHSI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
// 8AMPI_PHSI.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <math.h>

#include <assert.h>

#include <iostream>
#include <span>
#include <algorithm>
#include <iterator>
#include <future>
#include <vector>
//#include <execution>
#include <chrono>

#include "six/AmplitudeTable.h"
#include "six/sicd/Utilities.h"

using namespace six;

static void toComplex(six::Amp8iPhs8iLookup_t values, std::span<const AMP8I_PHS8I_t> inputs, std::span<six::zfloat> results)
{
const auto toComplex_ = [&values](const auto& v)
{
return values(v.amplitude, v.phase);
};

std::transform(inputs.begin(), inputs.end(), results.begin(), toComplex_);
//std::transform(std::execution::par, inputs.begin(), inputs.end(), results.begin(), toComplex_);
}
void toComplex(std::span<const AMP8I_PHS8I_t> inputs, std::span<six::zfloat> results)
{
const auto values = six::sicd::ImageData::getLookup(nullptr);
toComplex(values, inputs, results);
}

auto make_inputs(size_t count)
{
std::vector<AMP8I_PHS8I_t> retval;
retval.reserve(count);
for (size_t i = 0; i < count; i++)
{
const auto amplitude = static_cast<uint8_t>(i * i);
const auto phase = static_cast<uint8_t>(~amplitude);
retval.push_back(AMP8I_PHS8I_t{ amplitude, phase });
}
return retval;
}

static std::vector<AMP8I_PHS8I_t> fromComplex_nearest_neighbors(std::span<const six::zfloat> inputs)
{
static const six::sicd::ImageData imageData;
assert(imageData.amplitudeTable.get() == nullptr);
return imageData.fromComplex(inputs);
}
//static std::vector<AMP8I_PHS8I_t> fromComplex_nearest_neighbors2(std::span<const six::zfloat> inputs)
//{
// return six::sicd::details::ComplexToAMP8IPHS8I::nearest_neighbors2(inputs, nullptr);
//}
//
//static std::vector<AMP8I_PHS8I_t> fromComplex_nearest_neighbors_par(std::span<const six::zfloat> inputs)
//{
// return six::sicd::details::ComplexToAMP8IPHS8I::nearest_neighbors(std::execution::par, inputs, nullptr);
//}
//static std::vector<AMP8I_PHS8I_t> fromComplex_nearest_neighbors_par2(std::span<const six::zfloat> inputs)
//{
// return six::sicd::details::ComplexToAMP8IPHS8I::nearest_neighbors_par2(inputs, nullptr);
//}

//static std::vector<AMP8I_PHS8I_t> fromComplex_nearest_neighbors_unseq(std::span<const six::zfloat> inputs)
//{
// return six::sicd::details::ComplexToAMP8IPHS8I::nearest_neighbors(std::execution::unseq, inputs, nullptr);
//}
//static std::vector<AMP8I_PHS8I_t> fromComplex_nearest_neighbors_par_unseq(std::span<const six::zfloat> inputs)
//{
// return six::sicd::details::ComplexToAMP8IPHS8I::nearest_neighbors(std::execution::par_unseq, inputs, nullptr);
//}

//static void fromComplex_nearest_neighbors_threaded(std::span<const six::zfloat> inputs, std::span<AMP8I_PHS8I_t> results)
//{
// // make a structure to quickly find the nearest neighbor
// auto& converter = six::sicd::details::ComplexToAMP8IPHS8I::make(nullptr);
// converter.nearest_neighbors_threaded(inputs, results);
//}
//static void fromComplex_nearest_neighbors_simd(std::span<const six::zfloat> inputs, std::span<AMP8I_PHS8I_t> results)
//{
// // make a structure to quickly find the nearest neighbor
// auto& converter = six::sicd::details::ComplexToAMP8IPHS8I::make(nullptr);
// converter.nearest_neighbors_simd(inputs, results);
//}

#ifdef NDEBUG
constexpr auto iterations = 10;
#else
constexpr auto iterations = 1;
#endif
template<typename TFunc>
static std::chrono::duration<double> test(TFunc f, const std::vector<six::zfloat>& inputs)
{
auto ap_results = f(inputs);
auto start = std::chrono::high_resolution_clock::now();
for (int i = 0; i < iterations; i++)
{
ap_results = f(inputs);
}
auto end = std::chrono::high_resolution_clock::now();
return end - start;
}

int main()
{
#ifdef NDEBUG
constexpr auto inputs_size = 25000000;
#else
constexpr auto inputs_size = 100;
#endif
const auto inputs = make_inputs(inputs_size * 4);
std::vector<six::zfloat> results(inputs.size());

toComplex(inputs, results);

/*********************************************************************************/
auto diff = test(fromComplex_nearest_neighbors, results);
std::cout << "Time (nearest_neighbors): " << std::setw(9) << diff.count() << "\n";

//diff = test(fromComplex_nearest_neighbors2, results);
//std::cout << "Time (nearest_neighbors2): " << std::setw(9) << diff.count() << "\n";

//diff = test(fromComplex_nearest_neighbors_par, results);
//std::cout << "Time (nearest_neighbors_par): " << std::setw(9) << diff.count() << "\n";

//diff = test(fromComplex_nearest_neighbors_par2, results);
//std::cout << "Time (nearest_neighbors_par2): " << std::setw(9) << diff.count() << "\n";

//diff = test(fromComplex_nearest_neighbors_unseq, results);
//std::cout << "Time (nearest_neighbors_unseq): " << std::setw(9) << diff.count() << "\n";

//diff = test(fromComplex_nearest_neighbors_par_unseq, results);
//std::cout << "Time (nearest_neighbors_par_unseq): " << std::setw(9) << diff.count() << "\n";

//fromComplex_transform(results, ap_results);
//start = std::chrono::high_resolution_clock::now();
//for (int i = 0; i < iterations; i++)
//{
// fromComplex_transform(results, ap_results);
//}
//end = std::chrono::high_resolution_clock::now();
//diff = end - start;
//std::cout << "Time (transform): " << std::setw(9) << diff.count() << "\n";
//const auto transform_results = ap_results;

///*********************************************************************************/

//fromComplex_nearest_neighbors_threaded(results, ap_results);
//start = std::chrono::high_resolution_clock::now();
//for (int i = 0; i < iterations; i++)
//{
// fromComplex_nearest_neighbors_threaded(results, ap_results);
//}
//end = std::chrono::high_resolution_clock::now();
//diff = end - start;
//std::cout << "Time (nearest_neighbors_threaded): " << std::setw(9) << diff.count() << "\n";
//const auto nearest_neighbors_threaded_results = ap_results;

//fromComplex_transform_par(results, ap_results);
//start = std::chrono::high_resolution_clock::now();
//for (int i = 0; i < iterations; i++)
//{
// fromComplex_transform_par(results, ap_results);
//}
//end = std::chrono::high_resolution_clock::now();
//diff = end - start;
//std::cout << "Time (transform_par): " << std::setw(9) << diff.count() << "\n";
//const auto transform_par_results = ap_results;

///*********************************************************************************/

//fromComplex_nearest_neighbors_simd(results, ap_results);
//start = std::chrono::high_resolution_clock::now();
//for (int i = 0; i < iterations; i++)
//{
// fromComplex_nearest_neighbors_simd(results, ap_results);
//}
//end = std::chrono::high_resolution_clock::now();
//diff = end - start;
//std::cout << "Time (nearest_neighbors_simd): " << std::setw(9) << diff.count() << "\n";
//const auto nearest_neighbors_threaded_simd = ap_results;

//fromComplex_transform_unseq(results, ap_results);
//start = std::chrono::high_resolution_clock::now();
//for (int i = 0; i < iterations; i++)
//{
// fromComplex_transform_unseq(results, ap_results);
//}
//end = std::chrono::high_resolution_clock::now();
//diff = end - start;
//std::cout << "Time (transform_unseq): " << std::setw(9) << diff.count() << "\n";
//const auto transform_unseq_results = ap_results;

}

146 changes: 146 additions & 0 deletions six/modules/c++/samples/8AMPI_PHSI.dir/8AMPI_PHSI.dir.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{05C352A8-9F70-4006-B851-70A6904B58C1}</ProjectGuid>
<RootNamespace>checkvalidsix</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>8AMPI_PHSI</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING; CODA_OSS_LIBRARY_SHARED</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)six\modules\c++\scene\include;$(SolutionDir)six\modules\c++\six\include;$(SolutionDir)six\modules\c++\six.sidd\include;$(SolutionDir)six\modules\c++\six.sicd\include;$(SolutionDir)six\modules\c++\cphd\include;$(SolutionDir)six\modules\c++\cphd03\include;$(SolutionDir)externals\nitro\modules\c\nrt\include;$(SolutionDir)externals\nitro\modules\c\nitf\include;$(SolutionDir)externals\nitro\modules\c++\nitf\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ControlFlowGuard>Guard</ControlFlowGuard>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib;$(SolutionDir)out\install\$(Platform)-$(Configuration)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING; CODA_OSS_LIBRARY_SHARED</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)six\modules\c++\scene\include;$(SolutionDir)six\modules\c++\six\include;$(SolutionDir)six\modules\c++\six.sidd\include;$(SolutionDir)six\modules\c++\six.sicd\include;$(SolutionDir)six\modules\c++\cphd\include;$(SolutionDir)six\modules\c++\cphd03\include;$(SolutionDir)externals\nitro\modules\c\nrt\include;$(SolutionDir)externals\nitro\modules\c\nitf\include;$(SolutionDir)externals\nitro\modules\c++\nitf\include;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<ControlFlowGuard>Guard</ControlFlowGuard>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\lib;$(SolutionDir)out\install\$(Platform)-$(Configuration)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\8AMPI_PHSI.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</ForcedIncludeFiles>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\externals\coda-oss\modules\c++\coda-oss.vcxproj">
<Project>{9997e895-5161-4ddf-8f3f-099894cb2f21}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\externals\nitro\modules\c++\nitf-c++.vcxproj">
<Project>{8f357a19-799e-4971-850e-3f28485c130b}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\externals\nitro\modules\c\nitf-c.vcxproj">
<Project>{f06550ad-cfc7-40b8-8727-6c82c69a8982}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\externals\nitro\modules\c\nitf\XML_DATA_CONTENT.vcxproj">
<Project>{78849481-d356-4cc7-b182-31c21f857ed1}</Project>
</ProjectReference>
<ProjectReference Include="..\..\scene\scene.vcxproj">
<Project>{1cfcde59-6410-4037-95eb-b37d31e10820}</Project>
</ProjectReference>
<ProjectReference Include="..\..\six.sicd\six.sicd.vcxproj">
<Project>{34ac2314-fbd1-42ad-aaf4-0cebc6bf737e}</Project>
</ProjectReference>
<ProjectReference Include="..\..\six.sidd\six.sidd.vcxproj">
<Project>{ddc587c2-53ba-44a9-94e7-07be52af3d0b}</Project>
</ProjectReference>
<ProjectReference Include="..\..\six\six.vcxproj">
<Project>{62aad4dd-35ba-41a0-8263-1f4dfd755689}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading

0 comments on commit 5eec22c

Please sign in to comment.