Skip to content

Commit 1ba4ead

Browse files
[arcane,accelerator] Déplace la classe 'RunCommandLaunchInfo' dans 'accelerator/core'.
1 parent 4cf87ed commit 1ba4ead

File tree

5 files changed

+134
-131
lines changed

5 files changed

+134
-131
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,2 @@
1-
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2-
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4-
// See the top-level COPYRIGHT file for details.
5-
// SPDX-License-Identifier: Apache-2.0
6-
//-----------------------------------------------------------------------------
7-
/*---------------------------------------------------------------------------*/
8-
/* RunCommandLaunchInfo.h (C) 2000-2024 */
9-
/* */
10-
/* Informations pour l'exécution d'une 'RunCommand'. */
11-
/*---------------------------------------------------------------------------*/
12-
#ifndef ARCANE_ACCELERATOR_RUNCOMMANDLAUNCHINFO_H
13-
#define ARCANE_ACCELERATOR_RUNCOMMANDLAUNCHINFO_H
14-
/*---------------------------------------------------------------------------*/
15-
/*---------------------------------------------------------------------------*/
16-
17-
#include "arcane/utils/CheckedConvert.h"
18-
#include "arcane/utils/ConcurrencyUtils.h"
19-
#include "arcane/utils/Profiling.h"
20-
21-
#include "arcane/accelerator/AcceleratorGlobal.h"
22-
23-
/*---------------------------------------------------------------------------*/
24-
/*---------------------------------------------------------------------------*/
25-
26-
namespace Arcane::Accelerator::impl
27-
{
28-
29-
/*---------------------------------------------------------------------------*/
30-
/*---------------------------------------------------------------------------*/
31-
/*!
32-
* \internal
33-
* \brief Object temporaire pour conserver les informations d'exécution d'une
34-
* commande et regrouper les tests.
35-
*/
36-
class ARCANE_ACCELERATOR_EXPORT RunCommandLaunchInfo
37-
{
38-
template <typename SyclKernel, typename Lambda, typename LambdaArgs, typename... ReducerArgs>
39-
friend void _applyKernelSYCL(impl::RunCommandLaunchInfo& launch_info, SyclKernel kernel, Lambda& func,
40-
const LambdaArgs& args, const ReducerArgs&... reducer_args);
41-
42-
public:
43-
44-
struct ThreadBlockInfo
45-
{
46-
int nb_block_per_grid = 0;
47-
int nb_thread_per_block = 0;
48-
};
49-
50-
public:
51-
52-
RunCommandLaunchInfo(RunCommand& command, Int64 total_loop_size);
53-
~RunCommandLaunchInfo();
54-
RunCommandLaunchInfo(const RunCommandLaunchInfo&) = delete;
55-
RunCommandLaunchInfo operator=(const RunCommandLaunchInfo&) = delete;
56-
57-
public:
58-
59-
eExecutionPolicy executionPolicy() const { return m_exec_policy; }
60-
61-
/*!
62-
* \brief Indique qu'on commence l'exécution de la commande.
63-
*
64-
* Doit toujours être appelé avant de lancer la commande pour être
65-
* sur que cette méthode est appelée en cas d'exception.
66-
*/
67-
void beginExecute();
68-
69-
/*!
70-
* \brief Signale la fin de l'exécution.
71-
*
72-
* Si la file associée à la commande est asynchrone, la commande
73-
* peut continuer à s'exécuter après cet appel.
74-
*/
75-
void endExecute();
76-
77-
//! Informations sur le nombre de block/thread/grille du noyau à lancer.
78-
ThreadBlockInfo threadBlockInfo() const { return m_thread_block_info; }
79-
80-
//! Calcul les informations pour les boucles multi-thread
81-
ParallelLoopOptions computeParallelLoopOptions() const;
82-
83-
//! Calcule la valeur de loopRunInfo()
84-
void computeLoopRunInfo();
85-
86-
//! Informations d'exécution de la boucle
87-
const ForLoopRunInfo& loopRunInfo() const { return m_loop_run_info; }
88-
89-
//! Taille totale de la boucle
90-
Int64 totalLoopSize() const { return m_total_loop_size; }
91-
92-
public:
93-
94-
void* _internalStreamImpl();
95-
96-
private:
97-
98-
RunCommand& m_command;
99-
bool m_has_exec_begun = false;
100-
bool m_is_notify_end_kernel_done = false;
101-
IRunnerRuntime* m_runtime = nullptr;
102-
IRunQueueStream* m_queue_stream = nullptr;
103-
eExecutionPolicy m_exec_policy = eExecutionPolicy::Sequential;
104-
ThreadBlockInfo m_thread_block_info;
105-
ForLoopRunInfo m_loop_run_info;
106-
Int64 m_total_loop_size = 0;
107-
108-
private:
109-
110-
void _begin();
111-
void _doEndKernelLaunch();
112-
ThreadBlockInfo _computeThreadBlockInfo() const;
113-
114-
private:
115-
116-
// Pour SYCL: enregistre l'évènement associé à la dernière commande de la file
117-
// \a sycl_event_ptr est de type 'sycl::event*'.
118-
void _addSyclEvent(void* sycl_event_ptr);
119-
};
120-
121-
/*---------------------------------------------------------------------------*/
122-
/*---------------------------------------------------------------------------*/
123-
124-
} // End namespace Arcane::Accelerator::impl
125-
126-
/*---------------------------------------------------------------------------*/
127-
/*---------------------------------------------------------------------------*/
128-
129-
#endif
1+
#include "arcane/accelerator/AcceleratorGlobal.h"
2+
#include "arcane/accelerator/core/RunCommandLaunchInfo.h"

arcane/src/arcane/accelerator/RunCommandLaunchInfo.cc renamed to arcane/src/arcane/accelerator/core/RunCommandLaunchInfo.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/*---------------------------------------------------------------------------*/
1212
/*---------------------------------------------------------------------------*/
1313

14-
#include "arcane/accelerator/RunCommandLaunchInfo.h"
14+
#include "arcane/accelerator/core/RunCommandLaunchInfo.h"
1515

1616
#include "arcane/utils/CheckedConvert.h"
1717
#include "arcane/utils/PlatformUtils.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2+
//-----------------------------------------------------------------------------
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4+
// See the top-level COPYRIGHT file for details.
5+
// SPDX-License-Identifier: Apache-2.0
6+
//-----------------------------------------------------------------------------
7+
/*---------------------------------------------------------------------------*/
8+
/* RunCommandLaunchInfo.h (C) 2000-2024 */
9+
/* */
10+
/* Informations pour l'exécution d'une 'RunCommand'. */
11+
/*---------------------------------------------------------------------------*/
12+
#ifndef ARCANE_ACCELERATOR_CORE_RUNCOMMANDLAUNCHINFO_H
13+
#define ARCANE_ACCELERATOR_CORE_RUNCOMMANDLAUNCHINFO_H
14+
/*---------------------------------------------------------------------------*/
15+
/*---------------------------------------------------------------------------*/
16+
17+
#include "arcane/utils/CheckedConvert.h"
18+
#include "arcane/utils/ConcurrencyUtils.h"
19+
#include "arcane/utils/Profiling.h"
20+
21+
#include "arcane/accelerator/core/AcceleratorCoreGlobal.h"
22+
23+
/*---------------------------------------------------------------------------*/
24+
/*---------------------------------------------------------------------------*/
25+
26+
namespace Arcane::Accelerator::impl
27+
{
28+
29+
/*---------------------------------------------------------------------------*/
30+
/*---------------------------------------------------------------------------*/
31+
/*!
32+
* \internal
33+
* \brief Object temporaire pour conserver les informations d'exécution d'une
34+
* commande et regrouper les tests.
35+
*/
36+
class ARCANE_ACCELERATOR_CORE_EXPORT RunCommandLaunchInfo
37+
{
38+
template <typename SyclKernel, typename Lambda, typename LambdaArgs, typename... ReducerArgs>
39+
friend void _applyKernelSYCL(impl::RunCommandLaunchInfo& launch_info, SyclKernel kernel, Lambda& func,
40+
const LambdaArgs& args, const ReducerArgs&... reducer_args);
41+
42+
public:
43+
44+
struct ThreadBlockInfo
45+
{
46+
int nb_block_per_grid = 0;
47+
int nb_thread_per_block = 0;
48+
};
49+
50+
public:
51+
52+
RunCommandLaunchInfo(RunCommand& command, Int64 total_loop_size);
53+
~RunCommandLaunchInfo();
54+
RunCommandLaunchInfo(const RunCommandLaunchInfo&) = delete;
55+
RunCommandLaunchInfo operator=(const RunCommandLaunchInfo&) = delete;
56+
57+
public:
58+
59+
eExecutionPolicy executionPolicy() const { return m_exec_policy; }
60+
61+
/*!
62+
* \brief Indique qu'on commence l'exécution de la commande.
63+
*
64+
* Doit toujours être appelé avant de lancer la commande pour être
65+
* sur que cette méthode est appelée en cas d'exception.
66+
*/
67+
void beginExecute();
68+
69+
/*!
70+
* \brief Signale la fin de l'exécution.
71+
*
72+
* Si la file associée à la commande est asynchrone, la commande
73+
* peut continuer à s'exécuter après cet appel.
74+
*/
75+
void endExecute();
76+
77+
//! Informations sur le nombre de block/thread/grille du noyau à lancer.
78+
ThreadBlockInfo threadBlockInfo() const { return m_thread_block_info; }
79+
80+
//! Calcul les informations pour les boucles multi-thread
81+
ParallelLoopOptions computeParallelLoopOptions() const;
82+
83+
//! Calcule la valeur de loopRunInfo()
84+
void computeLoopRunInfo();
85+
86+
//! Informations d'exécution de la boucle
87+
const ForLoopRunInfo& loopRunInfo() const { return m_loop_run_info; }
88+
89+
//! Taille totale de la boucle
90+
Int64 totalLoopSize() const { return m_total_loop_size; }
91+
92+
public:
93+
94+
void* _internalStreamImpl();
95+
96+
private:
97+
98+
RunCommand& m_command;
99+
bool m_has_exec_begun = false;
100+
bool m_is_notify_end_kernel_done = false;
101+
IRunnerRuntime* m_runtime = nullptr;
102+
IRunQueueStream* m_queue_stream = nullptr;
103+
eExecutionPolicy m_exec_policy = eExecutionPolicy::Sequential;
104+
ThreadBlockInfo m_thread_block_info;
105+
ForLoopRunInfo m_loop_run_info;
106+
Int64 m_total_loop_size = 0;
107+
108+
private:
109+
110+
void _begin();
111+
void _doEndKernelLaunch();
112+
ThreadBlockInfo _computeThreadBlockInfo() const;
113+
114+
private:
115+
116+
// Pour SYCL: enregistre l'évènement associé à la dernière commande de la file
117+
// \a sycl_event_ptr est de type 'sycl::event*'.
118+
void _addSyclEvent(void* sycl_event_ptr);
119+
};
120+
121+
/*---------------------------------------------------------------------------*/
122+
/*---------------------------------------------------------------------------*/
123+
124+
} // End namespace Arcane::Accelerator::impl
125+
126+
/*---------------------------------------------------------------------------*/
127+
/*---------------------------------------------------------------------------*/
128+
129+
#endif

arcane/src/arcane/accelerator/core/srcs.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ set( ARCANE_SOURCES
2323
RunCommandImpl.h
2424
RunCommand.cc
2525
RunCommandImpl.cc
26+
RunCommandLaunchInfo.cc
27+
RunCommandLaunchInfo.h
2628
RunQueue.h
2729
RunQueue.cc
2830
RunQueueBuildInfo.h

arcane/src/arcane/accelerator/srcs.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ set( ARCANE_SOURCES
2424
Reduce.h
2525
RunCommand.h
2626
RunCommandEnumerate.h
27-
RunCommandLaunchInfo.cc
2827
RunCommandLaunchInfo.h
2928
RunCommandLoop.h
3029
RunCommandMaterialEnumerate.cc

0 commit comments

Comments
 (0)