Unverified Commit d39e51ed authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Add flag to enable cpu backend (#680)

* Add flag to enable cpu backend

* Make buffers shared

* Enable optimizations

* Formatting

* Enable cpu backend for gcc builds
parent f71af72a
...@@ -43,6 +43,9 @@ else() ...@@ -43,6 +43,9 @@ else()
set(MIGRAPHX_ENABLE_GPU Off CACHE BOOL "") set(MIGRAPHX_ENABLE_GPU Off CACHE BOOL "")
endif() endif()
# Disable cpu backend by default
set(MIGRAPHX_ENABLE_CPU Off CACHE BOOL "")
set(CMAKE_CXX_STANDARD_DEFAULT "") set(CMAKE_CXX_STANDARD_DEFAULT "")
add_compile_options(-std=c++14) add_compile_options(-std=c++14)
......
...@@ -156,7 +156,7 @@ rocmtest tidy: rocmnode('rocmtest') { cmake_build -> ...@@ -156,7 +156,7 @@ rocmtest tidy: rocmnode('rocmtest') { cmake_build ->
// TODO: Add bounds-strict // TODO: Add bounds-strict
def sanitizers = "undefined,address" def sanitizers = "undefined,address"
def debug_flags = "-g -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer -fsanitize-address-use-after-scope -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}" def debug_flags = "-g -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer -fsanitize-address-use-after-scope -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build("g++-7", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off ${cmake_linker_flags} -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'") cmake_build("g++-7", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_CPU=On -DMIGRAPHX_ENABLE_PYTHON=Off ${cmake_linker_flags} -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
} }
stage('Codecov') { stage('Codecov') {
......
...@@ -177,6 +177,11 @@ add_subdirectory(tf) ...@@ -177,6 +177,11 @@ add_subdirectory(tf)
add_subdirectory(py) add_subdirectory(py)
add_subdirectory(targets/ref) add_subdirectory(targets/ref)
if(MIGRAPHX_ENABLE_CPU)
add_subdirectory(targets/cpu)
target_link_libraries(migraphx_all_targets INTERFACE migraphx_cpu)
target_compile_definitions(migraphx_all_targets INTERFACE -DHAVE_CPU)
endif()
if(MIGRAPHX_ENABLE_GPU) if(MIGRAPHX_ENABLE_GPU)
list(APPEND PACKAGE_DEPENDS PACKAGE MIOpen PACKAGE rocblas) list(APPEND PACKAGE_DEPENDS PACKAGE MIOpen PACKAGE rocblas)
add_subdirectory(targets/gpu) add_subdirectory(targets/gpu)
......
...@@ -23,9 +23,8 @@ struct argument : raw_data<argument> ...@@ -23,9 +23,8 @@ struct argument : raw_data<argument>
argument(const shape& s) : m_shape(s) argument(const shape& s) : m_shape(s)
{ {
std::vector<char> buffer(s.bytes()); auto buffer = std::make_shared<std::vector<char>>(s.bytes());
// TODO: Move vector data = [=]() mutable { return buffer->data(); };
data = [=]() mutable { return buffer.data(); };
} }
template <class F, MIGRAPHX_REQUIRES(std::is_pointer<decltype(std::declval<F>()())>{})> template <class F, MIGRAPHX_REQUIRES(std::is_pointer<decltype(std::declval<F>()())>{})>
......
...@@ -39,10 +39,10 @@ struct is_fast_gemm_type : std::false_type ...@@ -39,10 +39,10 @@ struct is_fast_gemm_type : std::false_type
{ {
}; };
template <> // template <>
struct is_fast_gemm_type<float> : std::true_type // struct is_fast_gemm_type<float> : std::true_type
{ // {
}; // };
template <class T, class F> template <class T, class F>
void migemm_impl( void migemm_impl(
......
#include <migraphx/auto_contiguous.hpp>
#include <migraphx/check_context.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/decompose.hpp>
#include <migraphx/eliminate_allocation.hpp>
#include <migraphx/eliminate_common_subexpression.hpp>
#include <migraphx/eliminate_concat.hpp>
#include <migraphx/eliminate_contiguous.hpp>
#include <migraphx/eliminate_identity.hpp>
#include <migraphx/eliminate_pad.hpp>
#include <migraphx/memory_coloring.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/remap.hpp>
#include <migraphx/rewrite_batchnorm.hpp>
#include <migraphx/rewrite_pooling.hpp>
#include <migraphx/rewrite_rnn.hpp>
#include <migraphx/schedule.hpp>
#include <migraphx/simplify_algebra.hpp>
#include <migraphx/simplify_reshapes.hpp>
#include <migraphx/cpu/target.hpp> #include <migraphx/cpu/target.hpp>
#include <migraphx/cpu/lowering.hpp> #include <migraphx/cpu/lowering.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/pass.hpp> #include <migraphx/pass.hpp>
#include <migraphx/auto_contiguous.hpp>
#include <migraphx/rewrite_rnn.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
namespace migraphx { namespace migraphx {
...@@ -16,9 +32,26 @@ std::string target::name() const { return "cpu"; } ...@@ -16,9 +32,26 @@ std::string target::name() const { return "cpu"; }
std::vector<pass> target::get_passes(migraphx::context&, const compile_options&) const std::vector<pass> target::get_passes(migraphx::context&, const compile_options&) const
{ {
return {rewrite_rnn{}, return {decompose{},
dead_code_elimination{},
simplify_reshapes{},
eliminate_identity{},
eliminate_pad{},
dead_code_elimination{},
rewrite_batchnorm{},
dead_code_elimination{},
rewrite_rnn{},
dead_code_elimination{},
rewrite_pooling{},
dead_code_elimination{},
eliminate_common_subexpression{},
dead_code_elimination{}, dead_code_elimination{},
simplify_algebra{},
simplify_reshapes{},
simplify_algebra{},
auto_contiguous{}, auto_contiguous{},
simplify_reshapes{},
propagate_constant{},
dead_code_elimination{}, dead_code_elimination{},
lowering{}, lowering{},
dead_code_elimination{}}; dead_code_elimination{}};
......
#include <migraphx/gpu/target.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/gpu/lowering.hpp>
#include <migraphx/memory_coloring.hpp>
#include <migraphx/gpu/write_literals.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/eliminate_workspace.hpp>
#include <migraphx/eliminate_allocation.hpp>
#include <migraphx/gpu/fuse_ops.hpp>
#include <migraphx/check_context.hpp>
#include <migraphx/auto_contiguous.hpp> #include <migraphx/auto_contiguous.hpp>
#include <migraphx/check_context.hpp>
#include <migraphx/dead_code_elimination.hpp> #include <migraphx/dead_code_elimination.hpp>
#include <migraphx/simplify_reshapes.hpp> #include <migraphx/decompose.hpp>
#include <migraphx/simplify_algebra.hpp> #include <migraphx/eliminate_allocation.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/eliminate_contiguous.hpp>
#include <migraphx/eliminate_common_subexpression.hpp> #include <migraphx/eliminate_common_subexpression.hpp>
#include <migraphx/rewrite_batchnorm.hpp>
#include <migraphx/rewrite_rnn.hpp>
#include <migraphx/rewrite_pooling.hpp>
#include <migraphx/eliminate_concat.hpp> #include <migraphx/eliminate_concat.hpp>
#include <migraphx/eliminate_contiguous.hpp>
#include <migraphx/eliminate_identity.hpp> #include <migraphx/eliminate_identity.hpp>
#include <migraphx/gpu/concat_gpu_opt.hpp>
#include <migraphx/gpu/schedule_model.hpp>
#include <migraphx/gpu/adjust_allocation.hpp>
#include <migraphx/gpu/preallocate_param.hpp>
#include <migraphx/gpu/pack_int8_args.hpp>
#include <migraphx/gpu/sync_device.hpp>
#include <migraphx/eliminate_pad.hpp> #include <migraphx/eliminate_pad.hpp>
#include <migraphx/decompose.hpp> #include <migraphx/memory_coloring.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/remap.hpp> #include <migraphx/remap.hpp>
#include <migraphx/rewrite_batchnorm.hpp>
#include <migraphx/rewrite_pooling.hpp>
#include <migraphx/rewrite_rnn.hpp>
#include <migraphx/schedule.hpp> #include <migraphx/schedule.hpp>
#include <migraphx/simplify_algebra.hpp>
#include <migraphx/simplify_reshapes.hpp>
#include <migraphx/gpu/adjust_allocation.hpp>
#include <migraphx/gpu/concat_gpu_opt.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/eliminate_workspace.hpp>
#include <migraphx/gpu/fuse_ops.hpp>
#include <migraphx/gpu/lowering.hpp>
#include <migraphx/gpu/pack_int8_args.hpp>
#include <migraphx/gpu/preallocate_param.hpp>
#include <migraphx/gpu/schedule_model.hpp>
#include <migraphx/gpu/sync_device.hpp>
#include <migraphx/gpu/target.hpp>
#include <migraphx/gpu/write_literals.hpp>
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
......
File mode changed from 100644 to 100755
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment