Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
faust group
faust
Commits
5e29b843
Commit
5e29b843
authored
5 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Update FaustGPU: cpu_gpu_map is only used when RefManager is enabled.
parent
403f3e97
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/faust_linear_operator/CPU/faust_gpu_mod.h
+1
-1
1 addition, 1 deletion
src/faust_linear_operator/CPU/faust_gpu_mod.h
src/faust_linear_operator/CPU/faust_gpu_mod_gen.hpp.in
+27
-26
27 additions, 26 deletions
src/faust_linear_operator/CPU/faust_gpu_mod_gen.hpp.in
with
28 additions
and
27 deletions
src/faust_linear_operator/CPU/faust_gpu_mod.h
+
1
−
1
View file @
5e29b843
...
...
@@ -24,7 +24,7 @@ namespace Faust
static
void
*
dsm_funcs
;
static
void
*
gp_funcs
;
gm_MatArray_t
gpu_mat_arr
;
std
::
vector
<
void
*>
cpu_mat_ptrs
;
// addresses stored in gpu_mat_arr
std
::
vector
<
void
*>
cpu_mat_ptrs
;
//
cpu mat
addresses
for which gpu copies are
stored in gpu_mat_arr
size_t
size
;
// this map is used to retrieve a cpu mat addr from a gpu mat addr
...
...
This diff is collapsed.
Click to expand it.
src/faust_linear_operator/CPU/faust_gpu_mod_gen.hpp.in
+
27
−
26
View file @
5e29b843
...
...
@@ -101,7 +101,10 @@ namespace Faust
{
// release all gpu mats
for(auto m: cpu_mat_ptrs)
ref_man.release(m);
{
if(ref_man.contains(m)) //TODO: remove when the bug of nonsense factor is corrected
ref_man.release(m);
}
}
marr_funcs->free(gpu_mat_arr, ! use_ref_man); // delete used mats only if it doesn't use ref_man
if(gm_users <= 0)
...
...
@@ -163,21 +166,22 @@ namespace Faust
for(auto m: factors)
{
if(cpu_gpu_map.find(m) != cpu_gpu_map.end())
if(
use_ref_man &&
cpu_gpu_map.find(m) != cpu_gpu_map.end())
{
// already known cpu, gpu mats
if(use_ref_man)
{
ref_man.acquire(m);
// add the gpu matrix to gpu mat list
if(dynamic_cast<MatDense<@FAUST_SCALAR_FOR_GM@,Cpu>*>(m))
marr_funcs->addgpu_dsm(gpu_mat_arr, cpu_gpu_map[m]);
else
// m is sparse
marr_funcs->addgpu_spm(gpu_mat_arr, cpu_gpu_map[m]);
cpu_mat_ptrs.push_back(m);
continue;
}
// add the gpu matrix to gpu mat list
if(dynamic_cast<MatDense<@FAUST_SCALAR_FOR_GM@,Cpu>*>(m))
marr_funcs->addgpu_dsm(gpu_mat_arr, cpu_gpu_map[m]);
else
// m is sparse
marr_funcs->addgpu_spm(gpu_mat_arr, cpu_gpu_map[m]);
cpu_mat_ptrs.push_back(m);
ref_man.acquire(m);
continue;
}
if(sp_mat = dynamic_cast<MatSparse<@FAUST_SCALAR_FOR_GM@,Cpu>*>(m))
...
...
@@ -194,44 +198,41 @@ namespace Faust
}
size++;
cpu_gpu_map[m] = gpu_ref;
cpu_mat_ptrs.push_back(m);
if(use_ref_man)
{
cpu_gpu_map[m] = gpu_ref;
ref_man.acquire(m);
}
}
}
// this def. must be located after called ctor and class dtor to avoid error of type "specialization after instantiation"
// template<>
// FaustGPU<@FAUST_SCALAR_FOR_GM@>::FaustGPU(const Transform<@FAUST_SCALAR_FOR_GM@,Cpu>* src_t) : FaustGPU<@FAUST_SCALAR_FOR_GM@>(src_t->data)
// {
// }
template <>
void FaustGPU<@FAUST_SCALAR_FOR_GM@>::update(const Faust::MatGeneric<@FAUST_SCALAR_FOR_GM@,Cpu>* M, int32_t id)
{
MatGeneric<@FAUST_SCALAR_FOR_GM@,Cpu>* M_ = const_cast<MatGeneric<@FAUST_SCALAR_FOR_GM@,Cpu>*>(M);
// I promise I won't touch M_ data!
if(
cpu_gpu_map.find(M_) == cpu_gpu_map.end()
)
throw std::runtime_error("It's not authorized to update from an
unknown host matrix
.");
if(
M != cpu_mat_ptrs[id]
)
throw std::runtime_error("It's not authorized to update from an
other cpu matrix than the original one
.");
gm_MatArrayFunc_@GM_SCALAR@* marr_funcs = (gm_MatArrayFunc_@GM_SCALAR@*) this->marr_funcs;
MatSparse<@FAUST_SCALAR_FOR_GM@, Cpu>* sp_mat;
MatDense<@FAUST_SCALAR_FOR_GM@, Cpu>* ds_mat;
void* gpu_ref;
// if the dims are not equal between M_ and the gpu mat, an exception will be raised by gpu_mod
if(sp_mat = dynamic_cast<MatSparse<@FAUST_SCALAR_FOR_GM@,Cpu>*>(M_))
{
// std::cout << "FaustGPU::update(): " << sp_mat->getNbRow() << " " << sp_mat->getNbCol()<< " " << sp_mat->getNonZeros()<< std::endl;
/*
gpu_ref =
*/
marr_funcs->cpu_set_spm_at(gpu_mat_arr, sp_mat->getNbRow(), sp_mat->getNbCol(), sp_mat->getNonZeros(), sp_mat->getOuterIndexPtr(), sp_mat->getInnerIndexPtr(), (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(sp_mat->getValuePtr()), id);
gpu_ref = marr_funcs->cpu_set_spm_at(gpu_mat_arr, sp_mat->getNbRow(), sp_mat->getNbCol(), sp_mat->getNonZeros(), sp_mat->getOuterIndexPtr(), sp_mat->getInnerIndexPtr(), (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(sp_mat->getValuePtr()), id);
}
else if(ds_mat = dynamic_cast<MatDense<@FAUST_SCALAR_FOR_GM@,Cpu>*>(M_))
{
// std::cout << "FaustGPU::update(): " << ds_mat->getNbRow() << " " << ds_mat->getNbCol()<< " " << ds_mat->getNonZeros()<< std::endl;
/*
gpu_ref =
*/
marr_funcs->cpu_set_dsm_at(gpu_mat_arr, ds_mat->getNbRow(), ds_mat->getNbCol(), (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(ds_mat->getData()), id);
gpu_ref = marr_funcs->cpu_set_dsm_at(gpu_mat_arr, ds_mat->getNbRow(), ds_mat->getNbCol(), (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(ds_mat->getData()), id);
}
// gpu_ref is not recorded because this is an assignment
, so
the pointers don't change
// gpu_ref is not recorded because this is an assignment
of data but
the pointers don't change
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment